Backport jsonschema compatibility patch

This commit is contained in:
Lubomír Sedlář 2022-08-11 15:10:05 +02:00
parent d870fb3532
commit d0d84279be
2 changed files with 58 additions and 1 deletions

51
1621.patch Normal file
View File

@ -0,0 +1,51 @@
From 0abf937b0eeafa96e2cbdce0c47c350a88789d5f Mon Sep 17 00:00:00 2001
From: Lubomír Sedlář <lsedlar@redhat.com>
Date: Aug 10 2022 07:52:23 +0000
Subject: Fix compatibility with jsonschema >= 4.0.0
Fedora Rawhide (to be 37) packages jsonschema 4.9.0 at the moment, so we
can no longer get by with limiting the requirements. This patch makes
the validation work with both old and new version.
Fixes: rhbz#2113607
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
---
diff --git a/pungi/checks.py b/pungi/checks.py
index bc5d908..6d4465e 100644
--- a/pungi/checks.py
+++ b/pungi/checks.py
@@ -229,7 +229,6 @@ def validate(config, offline=False, schema=None):
)
validator = DefaultValidator(
schema,
- {"array": (tuple, list), "regex": six.string_types, "url": six.string_types},
)
errors = []
warnings = []
@@ -445,6 +444,16 @@ def _extend_with_default_and_alias(validator_class, offline=False):
context=all_errors,
)
+ def is_array(checker, instance):
+ return isinstance(instance, (tuple, list))
+
+ def is_string_type(checker, instance):
+ return isinstance(instance, six.string_types)
+
+ type_checker = validator_class.TYPE_CHECKER.redefine_many(
+ {"array": is_array, "regex": is_string_type, "url": is_string_type}
+ )
+
return jsonschema.validators.extend(
validator_class,
{
@@ -455,6 +464,7 @@ def _extend_with_default_and_alias(validator_class, offline=False):
"additionalProperties": _validate_additional_properties,
"anyOf": _validate_any_of,
},
+ type_checker=type_checker,
)

View File

@ -2,13 +2,16 @@
Name: pungi
Version: 4.3.5
Release: 7%{?dist}
Release: 8%{?dist}
Summary: Distribution compose tool
License: GPLv2
URL: https://pagure.io/pungi
Source0: https://pagure.io/releases/%{name}/%{name}-%{version}.tar.bz2
Patch0: https://pagure.io/pungi/pull-request/1613.patch
# Downloaded from https://pagure.io/pungi/pull-request/1621.patch and removed
# irrelevant hunk.
Patch1: 1621.patch
BuildRequires: make
BuildRequires: python3-pytest
@ -139,6 +142,9 @@ rm %{buildroot}%{_bindir}/pungi
%{_bindir}/%{name}-wait-for-signed-ostree-handler
%changelog
* Thu Aug 11 2022 Lubomír Sedlář <lsedlar@redhat.com> - 4.3.5-8
- Backport jsonschema compatibility patch (rhbz#2113607)
* Mon Jul 25 2022 Lubomír Sedlář <lsedlar@redhat.com> - 4.3.5-7
- Update xorriso patch