diff --git a/0001-Added-AlmaLinux-change-identifier-0.7.3.patch b/0001-Added-AlmaLinux-change-identifier-0.7.3.patch new file mode 100644 index 0000000..e6c3dd1 --- /dev/null +++ b/0001-Added-AlmaLinux-change-identifier-0.7.3.patch @@ -0,0 +1,217 @@ +From 887d32899f8528b4681895dd2f922a4f056e9f70 Mon Sep 17 00:00:00 2001 +From: eabdullin +Date: Fri, 6 Dec 2024 09:44:47 +0300 +Subject: [PATCH] Added AlmaLinux change identifier +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When modifying a package in AlmaLinux relative to upstream, we do not increment the package’s version/release number. Instead, we use almalinux.{almalinux_release_number}. +Therefore, the ability to identify AlmaLinux-specific changes was added, using the comment "AlmaLinux change: ". +If this comment is used, the base release number of the package remains unchanged, but the suffix almalinux.{almalinux_release_number} is appended. +The almalinux_release_number counter increments with each AlmaLinux-specific change to the package and resets upon version/release updates of the package. +--- + rpmautospec/changelog.py | 2 + + rpmautospec/magic_comments.py | 7 ++- + rpmautospec/pkg_history.py | 52 ++++++++++++++++++- + rpmautospec/subcommands/process_distgit.py | 9 +++- + .../subcommands/test_process_distgit.py | 3 +- + tests/rpmautospec/test_magic_comments.py | 1 + + 6 files changed, 69 insertions(+), 5 deletions(-) + +diff --git a/rpmautospec/changelog.py b/rpmautospec/changelog.py +index cb3e74f..599df6f 100644 +--- a/rpmautospec/changelog.py ++++ b/rpmautospec/changelog.py +@@ -106,6 +106,8 @@ class ChangelogEntry(dict): + changelog_evr = f" - {entry_info['epoch-version']}" + if entry_info["release-complete"]: + changelog_evr += f"-{entry_info['release-complete']}" ++ if "almalinux-release-complete" in entry_info and entry_info["almalinux-release-complete"]: ++ changelog_evr += f".{entry_info['almalinux-release-complete']}" + else: + changelog_evr = "" + changelog_header = f"* {changelog_date} {entry_info['authorblurb']}{changelog_evr}" +diff --git a/rpmautospec/magic_comments.py b/rpmautospec/magic_comments.py +index d56086e..4c1c06c 100644 +--- a/rpmautospec/magic_comments.py ++++ b/rpmautospec/magic_comments.py +@@ -3,19 +3,24 @@ from typing import NamedTuple + + magic_comment_re = re.compile(r"^\s*\[(?P.*)\]\s*$") + skip_changelog_re = re.compile(r"\s*skip\s+changelog\s*") ++is_almalinux_re = re.compile(r"almalinux\s+change", re.IGNORECASE) + bump_release_re = re.compile(r"\s*bump\s+release\s*(?::\s*)?(?P\d+)\s*") + + + class MagicCommentResult(NamedTuple): + skip_changelog: bool ++ is_almalinux: bool + bump_release: int + + + def parse_magic_comments(message: str) -> MagicCommentResult: + skip_changelog = False ++ is_almalinux = False + bump_release = 0 + + for line in message.split("\n"): ++ if is_almalinux_re.match(line): ++ is_almalinux = True + if l_match := magic_comment_re.match(line): + for part in l_match.group("magic").split(","): + if skip_changelog_re.match(part): +@@ -23,4 +28,4 @@ def parse_magic_comments(message: str) -> MagicCommentResult: + if br_match := bump_release_re.match(part): + bump_release = max(bump_release, int(br_match.group("bump_value"))) + +- return MagicCommentResult(skip_changelog=skip_changelog, bump_release=bump_release) ++ return MagicCommentResult(skip_changelog=skip_changelog, bump_release=bump_release, is_almalinux=is_almalinux) +diff --git a/rpmautospec/pkg_history.py b/rpmautospec/pkg_history.py +index 6527ffe..91bd080 100644 +--- a/rpmautospec/pkg_history.py ++++ b/rpmautospec/pkg_history.py +@@ -311,13 +311,55 @@ class PkgHistoryProcessor: + ) + release_number = max(parent_release_numbers, default=0) + +- if self.specfile.name in commit.tree: ++ if ( ++ self.specfile.name in commit.tree ++ and ( ++ not commit_result["magic-comment-result"].is_almalinux ++ ) ++ ): + release_number += 1 + + release_number = max(release_number, commit_result["magic-comment-result"].bump_release) + + commit_result["release-number"] = release_number + ++ is_almalinux_commit = ( ++ commit_result["magic-comment-result"].is_almalinux ++ ) ++ ++ if is_almalinux_commit: ++ log.debug("\tHas AlmaLinux changes") ++ ++ parent_almalinux_release_numbers = tuple( ++ ( ++ res.get("almalinux-release-number", 0) ++ if res and ( ++ epoch_version is None or res["epoch-version"] is None or epoch_version == res["epoch-version"] ++ ) ++ else 0 ++ ) ++ for res in parent_results ++ ) ++ almalinux_release_number = max(parent_almalinux_release_numbers, default=0) ++ ++ if commit_result["magic-comment-result"].is_almalinux: ++ almalinux_release_number += 1 ++ ++ if ( ++ release_number > max(parent_release_numbers, default=0) ++ ): ++ almalinux_release_number = 1 ++ elif epoch_version != commit_verflags.get("epoch-version"): ++ almalinux_release_number = 1 ++ ++ commit_result["almalinux-release-number"] = almalinux_release_number ++ almalinux_release_number_with_base = almalinux_release_number + base - 1 ++ commit_result["almalinux-release-complete"] = f"alma.{almalinux_release_number_with_base}" ++ log.debug("\talmalinux_release_number: %s", almalinux_release_number) ++ else: ++ commit_result["almalinux-release-number"] = 0 ++ commit_result["almalinux-release-complete"] = "" ++ + log.debug("\trelease_number: %s", release_number) + + prerel_str = "0." if prerelease else "" +@@ -382,6 +424,10 @@ class PkgHistoryProcessor: + # care. If it didn't change, we don't know how to continue and need to flag that. + merge_unresolvable = not changelog_changed + ++ if merge_unresolvable and commit.message.lower().startswith("almalinux changes:"): ++ merge_unresolvable = False ++ parent_to_follow = commit.parents[1] ++ + our_child_must_continue = ( + not (changelog_changed and changelog_blob or merge_unresolvable) and child_must_continue + ) +@@ -408,6 +454,7 @@ class PkgHistoryProcessor: + "commitlog": commit.message, + "epoch-version": commit_result["epoch-version"], + "release-complete": commit_result["release-complete"], ++ "almalinux-release-complete": commit_result["almalinux-release-complete"] + } + ) + +@@ -450,6 +497,9 @@ class PkgHistoryProcessor: + + log.debug("\tskip_for_changelog: %s", skip_for_changelog) + ++ if skip_for_changelog and commit.message.lower().startswith("almalinux changes:"): ++ skip_for_changelog = False ++ + changelog_entry["skip"] = skip_for_changelog + + if not skip_for_changelog: +diff --git a/rpmautospec/subcommands/process_distgit.py b/rpmautospec/subcommands/process_distgit.py +index ab8ca20..94c4e20 100644 +--- a/rpmautospec/subcommands/process_distgit.py ++++ b/rpmautospec/subcommands/process_distgit.py +@@ -26,7 +26,7 @@ AUTORELEASE_TEMPLATE = """ + release_number = {autorelease_number:d}; + base_release_number = tonumber(rpm.expand("%{{?-b*}}%{{!?-b:1}}")); + print(release_number + base_release_number - 1); +-}}%{{?-e:.%{{-e*}}}}%{{?-s:.%{{-s*}}}}%{{!?-n:%{{?dist}}}}""" # noqa: E501 ++}}%{{?-e:.%{{-e*}}}}%{{?-s:.%{{-s*}}}}%{{!?-n:%{{?dist}}}}{almalinux_suffix}""" # noqa: E501 + + + def do_process_distgit( +@@ -94,9 +94,14 @@ def do_process_distgit( + # Process the spec file into a temporary file... + used_features = [] + ++ almalinux_suffix = "" ++ if result.get("almalinux-release-complete", False): ++ almalinux_suffix = f'.{result["almalinux-release-complete"]}' ++ + if features.has_autorelease: + autorelease_blurb_if_needed = AUTORELEASE_TEMPLATE.format( +- autorelease_number=autorelease_number ++ autorelease_number=autorelease_number, ++ almalinux_suffix=almalinux_suffix + ) + used_features.append("autorelease") + else: +diff --git a/tests/rpmautospec/subcommands/test_process_distgit.py b/tests/rpmautospec/subcommands/test_process_distgit.py +index 9b049e8..11b8b48 100644 +--- a/tests/rpmautospec/subcommands/test_process_distgit.py ++++ b/tests/rpmautospec/subcommands/test_process_distgit.py +@@ -124,7 +124,8 @@ def fuzz_spec_file( + new_spec_file_path.open("w", encoding="utf-8") as new, + ): + if is_processed: +- autorelease_blurb = process_distgit.AUTORELEASE_TEMPLATE.format(autorelease_number=15) ++ almalinux_suffix = "" ++ autorelease_blurb = process_distgit.AUTORELEASE_TEMPLATE.format(autorelease_number=15, almalinux_suffix=almalinux_suffix) + print( + process_distgit.RPMAUTOSPEC_TEMPLATE.format( + version=__version__, +diff --git a/tests/rpmautospec/test_magic_comments.py b/tests/rpmautospec/test_magic_comments.py +index 2801cd7..7a8b7f5 100644 +--- a/tests/rpmautospec/test_magic_comments.py ++++ b/tests/rpmautospec/test_magic_comments.py +@@ -26,6 +26,7 @@ def _read_commitlog_magic_comments_testdata(): + MagicCommentResult( + skip_changelog=d.get("skip_changelog", False), + bump_release=d.get("bump_release", 0), ++ is_almalinux=False, + ), + id=f"commit-{variant}", + ) +-- +2.39.5 (Apple Git-154) + diff --git a/python-rpmautospec.spec b/python-rpmautospec.spec index 5bfb253..7c18f93 100644 --- a/python-rpmautospec.spec +++ b/python-rpmautospec.spec @@ -5,7 +5,7 @@ release_number = 1; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); -}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} +}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}.alma.1 ## END: Set by rpmautospec # Polyfill %%bcond() macro for platforms without it @@ -65,6 +65,8 @@ License: MIT URL: https://github.com/fedora-infra/%{srcname} Source0: https://github.com/fedora-infra/%{srcname}/releases/download/%{version}/%{srcname}-%{version}.tar.gz +Patch1: 0001-Added-AlmaLinux-change-identifier-0.7.3.patch + %if 0%{!?pyproject_files:1} %global pyproject_files %{_builddir}/%{name}-%{version}-%{release}.%{_arch}-pyproject-files %endif @@ -136,7 +138,7 @@ enabled packages locally. %endif %prep -%autosetup -n %{srcname}-%{version} +%autosetup -n %{srcname}-%{version} -p1 %if %{without poetry} sed -i -e 's/\[project\]/#\&/g' pyproject.toml %endif @@ -238,6 +240,9 @@ done %changelog ## START: Generated by rpmautospec +* Thu Apr 17 2025 Eduard Abdullin - 0.7.3-1 +- AlmaLinux change: Add AlmaLinux OS change identifier + * Fri Oct 11 2024 Nils Philippsen - 0.7.3-1 - Update to 0.7.3