From 05f0f912abee41dbbbd5796b94d30243968b412b Mon Sep 17 00:00:00 2001 From: Athos Ribeiro Date: Apr 12 2019 10:01:38 +0000 Subject: New upstream release 0.0.13 * Make new version buildable in EPEL 6 and 7 * Drop python2 package for Fedora >= 30 Signed-off-by: Athos Ribeiro --- diff --git a/.gitignore b/.gitignore index d6dffcd..dee977e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /dockerfile-parse-0.0.7.tar.gz /dockerfile-parse-0.0.10.tar.gz /dockerfile-parse-0.0.11.tar.gz +/dockerfile-parse-0.0.13.tar.gz diff --git a/dockerfile-parse-0.0.5-parent_env.patch b/dockerfile-parse-0.0.5-parent_env.patch deleted file mode 100644 index 37e48cc..0000000 --- a/dockerfile-parse-0.0.5-parent_env.patch +++ /dev/null @@ -1,128 +0,0 @@ -diff --git a/dockerfile_parse/parser.py b/dockerfile_parse/parser.py -index 615d7a8..25b6536 100644 ---- a/dockerfile_parse/parser.py -+++ b/dockerfile_parse/parser.py -@@ -66,11 +66,12 @@ class Envs(dict): - - - class DockerfileParser(object): -- def __init__(self, path=None, cache_content=False, env_replace=True): -+ def __init__(self, path=None, cache_content=False, env_replace=True, parent_env=None): - """ - Initialize path to Dockerfile - :param path: path to (directory with) Dockerfile - :param cache_content: cache Dockerfile content inside DockerfileParser -+ :param parent_env: python dict of inherited env vars from parent image - """ - path = path or '.' - if path.endswith(DOCKERFILE_FILENAME): -@@ -91,6 +92,14 @@ class DockerfileParser(object): - - self.env_replace = env_replace - -+ if isinstance(parent_env, dict): -+ logger.debug("Setting inherited parent image ENV vars: %s", parent_env) -+ self.parent_env = parent_env -+ elif parent_env != None: -+ assert isinstance(parent_env, dict) -+ else: -+ self.parent_env = {} -+ - @property - def lines(self): - """ -@@ -106,7 +115,7 @@ class DockerfileParser(object): - self.cached_content = ''.join(lines) - return lines - except (IOError, OSError) as ex: -- logger.error("Couldn't retrieve lines from dockerfile: %s" % repr(ex)) -+ logger.error("Couldn't retrieve lines from dockerfile: %r", ex) - raise - - @lines.setter -@@ -122,7 +131,7 @@ class DockerfileParser(object): - with open(self.dockerfile_path, 'w') as dockerfile: - dockerfile.writelines([u2b(l) for l in lines]) - except (IOError, OSError) as ex: -- logger.error("Couldn't write lines to dockerfile: %s" % repr(ex)) -+ logger.error("Couldn't write lines to dockerfile: %r", ex) - raise - - @property -@@ -140,7 +149,7 @@ class DockerfileParser(object): - self.cached_content = content - return content - except (IOError, OSError) as ex: -- logger.error("Couldn't retrieve content of dockerfile: %s" % repr(ex)) -+ logger.error("Couldn't retrieve content of dockerfile: %r", ex) - raise - - @content.setter -@@ -156,7 +165,7 @@ class DockerfileParser(object): - with open(self.dockerfile_path, 'w') as dockerfile: - dockerfile.write(u2b(content)) - except (IOError, OSError) as ex: -- logger.error("Couldn't write content to dockerfile: %s" % repr(ex)) -+ logger.error("Couldn't write content to dockerfile: %r", ex) - raise - - @property -@@ -290,7 +299,7 @@ class DockerfileParser(object): - if name != 'LABEL' and name != 'ENV': - raise ValueError("Unsupported instruction '%s'", name) - instructions = {} -- envs = {} -+ envs = self.parent_env.copy() - for insndesc in self.structure: - this_insn = insndesc['instruction'] - if this_insn in (name, 'ENV'): -@@ -354,7 +363,7 @@ class DockerfileParser(object): - elif name == 'ENV': - existing = self.envs - -- logger.debug("setting %s instructions: %r" % (name, instructions)) -+ logger.debug("setting %s instructions: %r", name, instructions) - - to_delete = [k for k in existing if k not in instructions] - for key in to_delete: - -diff --git a/tests/test_parser.py b/tests/test_parser.py -index 8f63a04..e47fefe 100644 ---- a/tests/test_parser.py -+++ b/tests/test_parser.py -@@ -86,6 +86,35 @@ USER {0}""".format(NON_ASCII) - base_img = dfparser.baseimage - assert base_img.startswith('fedora') - -+ def test_get_parent_env(self, tmpdir): -+ tmpdir_path = str(tmpdir.realpath()) -+ p_env = {"bar": "baz"} -+ df1 = DockerfileParser(tmpdir_path, env_replace=True, parent_env=p_env) -+ df1.lines = [ -+ "FROM parent\n", -+ "ENV foo=\"$bar\"\n", -+ "LABEL label=\"$foo $bar\"\n" -+ ] -+ -+ # Even though we inherit an ENV, this .envs count should only be for the -+ # ENVs defined in *this* Dockerfile as we're parsing the Dockerfile and -+ # the parent_env is only to satisfy use of inhereted ENVs. -+ assert len(df1.envs) == 1 -+ assert df1.envs.get('foo') == 'baz' -+ assert len(df1.labels) == 1 -+ assert df1.labels.get('label') == 'baz baz' -+ -+ def test_get_parent_env_from_scratch(self, tmpdir): -+ tmpdir_path = str(tmpdir.realpath()) -+ p_env = {"bar": "baz"} -+ df1 = DockerfileParser(tmpdir_path, env_replace=True, parent_env=p_env) -+ df1.lines = [ -+ "FROM scratch\n", -+ ] -+ -+ assert not df1.envs -+ -+ - def test_get_instructions_from_df(self, dfparser, instruction): - dfparser.content = "" - lines = [] diff --git a/python-dockerfile-parse.spec b/python-dockerfile-parse.spec index 6952d0b..ba02847 100644 --- a/python-dockerfile-parse.spec +++ b/python-dockerfile-parse.spec @@ -8,14 +8,20 @@ %bcond_without python3 %endif +%if 0%{?fedora} && 0%{?fedora} >= 30 +%bcond_with python2 +%else +%bcond_without python2 +%endif + %bcond_without tests %global srcname dockerfile-parse %global modname %(n=%{srcname}; echo ${n//-/_}) Name: python-%{srcname} -Version: 0.0.11 -Release: 4%{?dist} +Version: 0.0.13 +Release: 1%{?dist} Summary: Python library for Dockerfile manipulation License: BSD @@ -27,17 +33,18 @@ BuildArch: noarch %description %{summary}. +%if %{with python2} %package -n python2-%{srcname} Summary: %{summary} %{?python_provide:%python_provide python2-%{srcname}} BuildRequires: python2-devel +BuildRequires: python2-six %if 0%{?rhel} && 0%{?rhel} <= 7 BuildRequires: python-setuptools BuildRequires: pytest %else BuildRequires: python2-setuptools BuildRequires: python2-pytest -BuildRequires: python2-six %endif Requires: python2-six @@ -45,6 +52,7 @@ Requires: python2-six %{summary}. Python 2 version. +%endif # python2 pkg %if %{with python3} %package -n python3-%{srcname} @@ -62,20 +70,24 @@ Requires: python3-six %{summary}. Python 3 version. -%endif +%endif #python3 pkg %prep -%setup -n %{srcname}-%{version} +%setup -q -n %{srcname}-%{version} %build +%if %{with python2} %py2_build +%endif # python2 %if %{with python3} %py3_build %endif %install +%if %{with python2} %py2_install +%endif #python2 %if %{with python3} %py3_install %endif @@ -83,17 +95,21 @@ Python 3 version. %if %{with tests} %check export LANG=C.UTF-8 +%if %{with python2} py.test-%{python2_version} -v tests +%endif # python2 %if %{with python3} py.test-%{python3_version} -v tests -%endif +%endif # python3 %endif +%if %{with python2} %files -n python2-%{srcname} %license LICENSE %doc README.md %{python2_sitelib}/%{modname}-*.egg-info/ %{python2_sitelib}/%{modname}/ +%endif %if %{with python3} %files -n python3-%{srcname} @@ -104,6 +120,11 @@ py.test-%{python3_version} -v tests %endif %changelog +* Fri Apr 12 2019 Athos Ribeiro - 0.0.13-1 +- New upstream release 0.0.13 +- Require six for RHEL builds +- Do not build python2 packages for Fedora >= 30 + * Sat Feb 02 2019 Fedora Release Engineering - 0.0.11-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild diff --git a/sources b/sources index 42a07d7..85ff388 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (dockerfile-parse-0.0.11.tar.gz) = 0e14c1f964f736a50e96d5a235390f93691fc43514d833a886d75fe166b2fdb3424bf1eac25ec1271c73239114f877d35d998033e554c13b1a8bd96bef31941e +SHA512 (dockerfile-parse-0.0.13.tar.gz) = d3039e8f57829e8f3488b2f51bd3a21afd9684b5a6063ffce781226541c98a585bbaa6cb574ae9b9925b1fe332b47e26d27dfab0f6aa3472630a9bd183e8c31d