Version in base suite: 1.0 Base version: distro-info_1.0 Target version: distro-info_1.0+deb11u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/d/distro-info/distro-info_1.0.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/d/distro-info/distro-info_1.0+deb11u1.dsc debian/changelog | 10 +++++ debian/control | 2 - python/distro_info_test/test_setup.py | 58 ++++++++++++++++++++++++++++++++++ python/setup.py | 14 +++++++- test-debian-distro-info | 8 ++-- 5 files changed, 86 insertions(+), 6 deletions(-) diff -Nru distro-info-1.0/debian/changelog distro-info-1.0+deb11u1/debian/changelog --- distro-info-1.0/debian/changelog 2021-01-29 20:35:30.000000000 +0000 +++ distro-info-1.0+deb11u1/debian/changelog 2023-10-29 12:48:16.000000000 +0000 @@ -1,3 +1,13 @@ +distro-info (1.0+deb11u1) bullseye; urgency=medium + + * python: + - Assert that Python version is PEP440 compliant + - Handle more Debian versions correctly in make_pep440_compliant + * Update tests for distro-info-data 0.51+deb11u5, which adjusted Debian 7's + EoL (Closes: #1054946) + + -- Stefano Rivera Sun, 29 Oct 2023 14:48:16 +0200 + distro-info (1.0) unstable; urgency=medium [ Debian Janitor ] diff -Nru distro-info-1.0/debian/control distro-info-1.0+deb11u1/debian/control --- distro-info-1.0/debian/control 2021-01-29 20:35:30.000000000 +0000 +++ distro-info-1.0+deb11u1/debian/control 2023-10-29 12:48:16.000000000 +0000 @@ -5,7 +5,7 @@ Uploaders: Stefano Rivera Build-Depends: debhelper-compat (= 13), dh-python, - distro-info-data (>= 0.46), + distro-info-data (>= 0.51+deb11u5~), pylint (>= 2.2.2-2~), python3-all, python3-flake8, diff -Nru distro-info-1.0/python/distro_info_test/test_setup.py distro-info-1.0+deb11u1/python/distro_info_test/test_setup.py --- distro-info-1.0/python/distro_info_test/test_setup.py 1970-01-01 00:00:00.000000000 +0000 +++ distro-info-1.0+deb11u1/python/distro_info_test/test_setup.py 2023-10-29 12:48:16.000000000 +0000 @@ -0,0 +1,58 @@ +# Copyright (C) 2022, Benjamin Drung +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +"""Test functions in setup.py.""" + +import unittest +import unittest.mock + +from setup import make_pep440_compliant + + +class SetupTestCase(unittest.TestCase): + """Test functions in setup.py.""" + + def test_make_pep440_compliant_unchanged(self) -> None: + """Test make_pep440_compliant() with already correct version.""" + self.assertEqual(make_pep440_compliant("1.2"), "1.2") + + def test_make_pep440_compliant_debian_backport(self) -> None: + """Test make_pep440_compliant() with Debian backport version.""" + self.assertEqual(make_pep440_compliant("0.21~bpo9+1"), "0.21+bpo9.1") + + def test_make_pep440_compliant_debian_stable(self) -> None: + """Test make_pep440_compliant() with Debian stable update.""" + self.assertEqual(make_pep440_compliant("2.21.3+deb11u1"), "2.21.3+deb11u1") + + def test_make_pep440_compliant_debian_stable_backport(self) -> None: + """Test make_pep440_compliant() with Debian stable backport.""" + self.assertEqual(make_pep440_compliant("2.21.3+deb11u1~bpo10+1"), "2.21.3+deb11u1.bpo10.1") + + def test_make_pep440_compliant_tilde(self) -> None: + """Test make_pep440_compliant() with tilde in Debian version.""" + self.assertEqual(make_pep440_compliant("0.175~18.04.3"), "0.175+18.04.3") + + def test_make_pep440_compliant_ubuntu(self) -> None: + """Test make_pep440_compliant() with Ubuntu version.""" + self.assertEqual(make_pep440_compliant("1.1ubuntu1"), "1.1+ubuntu1") + + def test_make_pep440_compliant_ubuntu_backport(self) -> None: + """Test make_pep440_compliant() with Ubuntu backport version.""" + self.assertEqual( + make_pep440_compliant("2.22.1ubuntu1~bpo20.04.1"), "2.22.1+ubuntu1.bpo20.04.1" + ) + + def test_make_pep440_compliant_ubuntu_security(self) -> None: + """Test make_pep440_compliant() with Ubuntu security update.""" + self.assertEqual(make_pep440_compliant("2.17.12ubuntu1.1"), "2.17.12+ubuntu1.1") diff -Nru distro-info-1.0/python/setup.py distro-info-1.0+deb11u1/python/setup.py --- distro-info-1.0/python/setup.py 2021-01-29 20:35:30.000000000 +0000 +++ distro-info-1.0+deb11u1/python/setup.py 2023-10-29 12:48:16.000000000 +0000 @@ -23,10 +23,22 @@ return version +def make_pep440_compliant(version: str) -> str: + """Convert the version into a PEP440 compliant version.""" + public_version_re = re.compile(r"^([0-9][0-9.]*(?:(?:a|b|rc|.post|.dev)[0-9]+)*)\+?") + _, public, local = public_version_re.split(version, maxsplit=1) + if not local: + return version + sanitized_local = re.sub("[+~]+", ".", local).strip(".") + pep440_version = f"{public}+{sanitized_local}" + assert re.match("^[a-zA-Z0-9.]+$", sanitized_local), f"'{pep440_version}' not PEP440 compliant" + return pep440_version + + if __name__ == "__main__": setup( name="distro-info", - version=get_debian_version(), + version=make_pep440_compliant(get_debian_version()), py_modules=PY_MODULES, packages=PACKAGES, test_suite="distro_info_test", diff -Nru distro-info-1.0/test-debian-distro-info distro-info-1.0+deb11u1/test-debian-distro-info --- distro-info-1.0/test-debian-distro-info 2021-01-29 20:35:30.000000000 +0000 +++ distro-info-1.0+deb11u1/test-debian-distro-info 2023-10-29 12:48:16.000000000 +0000 @@ -346,10 +346,10 @@ success "--testing --date=$date --days=release -f" "Debian 7 \"Wheezy\" 1" success "--testing --date=$date --days=release -r" "7 1" - success "--testing --date=$date --days=eol" "1089" - success "--testing --date=$date --days=eol -c" "wheezy 1089" - success "--testing --date=$date --days=eol -f" "Debian 7 \"Wheezy\" 1089" - success "--testing --date=$date --days=eol -r" "7 1089" + success "--testing --date=$date --days=eol" "1088" + success "--testing --date=$date --days=eol -c" "wheezy 1088" + success "--testing --date=$date --days=eol -f" "Debian 7 \"Wheezy\" 1088" + success "--testing --date=$date --days=eol -r" "7 1088" success "--testing --date=$date --days=eol-lts" "1854" success "--testing --date=$date --days=eol-lts -c" "wheezy 1854"