From d4ebc226a35b50ce1e6bd13414aeef00583aa059be267db256cb39f63a871e9f Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Fri, 9 Jul 2021 13:55:49 +0000 Subject: [PATCH] Accepting request 905232 from home:alarrosa:branches:openSUSE:Factory:Rings:1-MinimalX - Add patch from upstream to remove python2 compatibility so cloud-init builds fine in Tumbleweed with a recent Jinja2 version. This patch is only applied in TW. * 0001-templater-drop-Jinja-Python-2-compatibility-shim.patch OBS-URL: https://build.opensuse.org/request/show/905232 OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=187 --- ...op-Jinja-Python-2-compatibility-shim.patch | 49 +++++++++++++++++++ cloud-init.changes | 8 +++ cloud-init.spec | 5 ++ 3 files changed, 62 insertions(+) create mode 100644 0001-templater-drop-Jinja-Python-2-compatibility-shim.patch diff --git a/0001-templater-drop-Jinja-Python-2-compatibility-shim.patch b/0001-templater-drop-Jinja-Python-2-compatibility-shim.patch new file mode 100644 index 0000000..eaf9b48 --- /dev/null +++ b/0001-templater-drop-Jinja-Python-2-compatibility-shim.patch @@ -0,0 +1,49 @@ +From f23a4c4262ac11cd75c99fcbfbfe453f4e115f18 Mon Sep 17 00:00:00 2001 +From: Daniel Watkins +Date: Thu, 14 May 2020 23:22:27 -0400 +Subject: [PATCH] templater: drop Jinja Python 2 compatibility shim (#353) + +--- + cloudinit/helpers.py | 4 ---- + cloudinit/templater.py | 4 ---- + 2 files changed, 8 deletions(-) + +diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py +index 7d2a330582..9752ad2831 100644 +--- a/cloudinit/helpers.py ++++ b/cloudinit/helpers.py +@@ -451,8 +451,4 @@ def stringify(self, header=None): + contents = '\n'.join([header, contents, '']) + return contents + +- +-def identity(object): +- return object +- + # vi: ts=4 expandtab +diff --git a/cloudinit/templater.py b/cloudinit/templater.py +index e47cdedaf7..a00ade200c 100644 +--- a/cloudinit/templater.py ++++ b/cloudinit/templater.py +@@ -21,13 +21,10 @@ + CHEETAH_AVAILABLE = False + + try: +- from jinja2.runtime import implements_to_string + from jinja2 import Template as JTemplate + from jinja2 import DebugUndefined as JUndefined + JINJA_AVAILABLE = True + except (ImportError, AttributeError): +- from cloudinit.helpers import identity +- implements_to_string = identity + JINJA_AVAILABLE = False + JUndefined = object + +@@ -42,7 +39,6 @@ + MISSING_JINJA_PREFIX = u'CI_MISSING_JINJA_VAR/' + + +-@implements_to_string # Needed for python2.7. Otherwise cached super.__str__ + class UndefinedJinjaVariable(JUndefined): + """Class used to represent any undefined jinja template variable.""" + diff --git a/cloud-init.changes b/cloud-init.changes index cf0ff6e..ff72eb6 100644 --- a/cloud-init.changes +++ b/cloud-init.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Jul 9 10:45:23 UTC 2021 - Antonio Larrosa + +- Add patch from upstream to remove python2 compatibility so + cloud-init builds fine in Tumbleweed with a recent Jinja2 + version. This patch is only applied in TW. + * 0001-templater-drop-Jinja-Python-2-compatibility-shim.patch + ------------------------------------------------------------------- Wed Jun 2 12:13:54 UTC 2021 - Robert Schweikert diff --git a/cloud-init.spec b/cloud-init.spec index 3dad328..aed7b98 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -50,6 +50,8 @@ Patch72: cloud-init-log-file-mode.patch Patch73: cloud-init-no-pwd-in-log.patch # FIXME https://github.com/canonical/cloud-init/pull/857 Patch74: cloud-init-purge-cache-py-ver-change.patch +# PATCH-FIX-UPSTREAM https://github.com/canonical/cloud-init/commit/f23a4c4262ac11cd75c99fcbfbfe453f4e115f18 +Patch75: 0001-templater-drop-Jinja-Python-2-compatibility-shim.patch BuildRequires: fdupes BuildRequires: filesystem # pkg-config is needed to find correct systemd unit dir @@ -156,6 +158,9 @@ Documentation and examples for cloud-init tools %patch72 %patch73 %patch74 +%if 0%{?suse_version} >= 1550 +%patch75 -p1 +%endif # patch in the full version to version.py version_pys=$(find . -name version.py -type f) [ -n "$version_pys" ] ||