diff --git a/pmb/aportgen/__init__.py b/pmb/aportgen/__init__.py index 778fefcda7c6a3f7b00231402e220c78d34955cb..75060e3f16f872c785d0f6f0d19063be12eb72b4 100644 --- a/pmb/aportgen/__init__.py +++ b/pmb/aportgen/__init__.py @@ -64,7 +64,7 @@ def properties(pkgname): raise ValueError("No generator available for " + pkgname + "!") -def generate(pkgname: str, fork_alpine: bool): +def generate(pkgname: str, fork_alpine: bool, fork_alpine_retain_branch: bool = False) -> None: if fork_alpine: prefix, folder, options = (pkgname, "temp", {"confirm_overwrite": True}) else: @@ -83,7 +83,9 @@ def generate(pkgname: str, fork_alpine: bool): if os.path.exists(aportgen): pmb.helpers.run.user(["rm", "-r", aportgen]) if fork_alpine: - upstream = pmb.aportgen.core.get_upstream_aport(pkgname) + upstream = pmb.aportgen.core.get_upstream_aport( + pkgname, retain_branch=fork_alpine_retain_branch + ) pmb.helpers.run.user(["cp", "-r", upstream, aportgen]) pmb.aportgen.core.rewrite( pkgname, replace_simple={"# Contributor:*": None, "# Maintainer:*": None} diff --git a/pmb/aportgen/core.py b/pmb/aportgen/core.py index ab7a5f1078479b61a0dd5040c2bfc853ff464c2f..3bb7e6ac08a6b8977361fa4db7e75850bc4bdf52 100644 --- a/pmb/aportgen/core.py +++ b/pmb/aportgen/core.py @@ -6,7 +6,6 @@ from pathlib import Path import re import pmb.helpers.git import pmb.helpers.run -import pmb.helpers.args from pmb.core.arch import Arch from pmb.core.context import get_context @@ -162,7 +161,7 @@ def rewrite( handle.truncate() -def get_upstream_aport(pkgname: str, arch: Arch | None = None): +def get_upstream_aport(pkgname: str, arch: Arch | None = None, retain_branch: bool = False): """ Perform a git checkout of Alpine's aports and get the path to the aport. @@ -175,9 +174,7 @@ def get_upstream_aport(pkgname: str, arch: Arch | None = None): pmb.helpers.git.clone("aports_upstream") aports_upstream_path = get_context().config.work / "cache_git/aports_upstream" - args = pmb.helpers.args.please_i_really_need_args() - - if getattr(args, "fork_alpine_retain_branch", False): + if retain_branch: logging.info("Not changing aports branch as --fork-alpine-retain-branch was " "used.") else: # Checkout branch diff --git a/pmb/commands/__init__.py b/pmb/commands/__init__.py index 78f37d47ce29625bebd3bbaa6890f28a62ba821b..506db1735ca62accf57f36ffac8778e5c3a6eda2 100644 --- a/pmb/commands/__init__.py +++ b/pmb/commands/__init__.py @@ -65,7 +65,7 @@ def run_command(args: PmbArgs): command: Command match args.action: case "aportgen": - command = Aportgen(args.packages, args.fork_alpine) + command = Aportgen(args.packages, args.fork_alpine, args.fork_alpine_retain_branch) case "log": command = Log(args.clear_log, args.lines) case "index": diff --git a/pmb/commands/aportgen.py b/pmb/commands/aportgen.py index 4bfe1373733473a53576cd383f53354674f1bc3d..f4a64e8f627227769414508fc4df1da2c30c6ddc 100644 --- a/pmb/commands/aportgen.py +++ b/pmb/commands/aportgen.py @@ -8,11 +8,14 @@ from pmb.helpers import logging class Aportgen(commands.Command): - def __init__(self, package_list: list[str], fork_alpine: bool) -> None: + def __init__( + self, package_list: list[str], fork_alpine: bool, fork_alpine_retain_branch: bool + ) -> None: self.package_list = package_list self.fork_alpine = fork_alpine + self.fork_alpine_retain_branch = fork_alpine_retain_branch def run(self) -> None: for package in self.package_list: logging.info(f"Generate aport: {package}") - pmb.aportgen.generate(package, self.fork_alpine) + pmb.aportgen.generate(package, self.fork_alpine, self.fork_alpine_retain_branch)