Skip to content
Snippets Groups Projects
Unverified Commit f53eefa2 authored by Newbyte's avatar Newbyte :snowflake:
Browse files

pmb: Migrate pkgrel_bump to Command

Also remove args from functions that don't actually need it to
faciliate this.

This does not attempt to fix any of the bugs with pkgrel_bump.
parent f05be9c6
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ from .index import Index
from .repo_bootstrap import RepoBootstrap
from .shutdown import Shutdown
from .test import Test
from .pkgrel_bump import PkgrelBump
from .pull import Pull
from .kconfig_check import KConfigCheck
from .kconfig_edit import KConfigEdit
......@@ -32,7 +33,6 @@ unmigrated_commands = [
"flasher",
"initfs",
"qemu",
"pkgrel_bump",
"aportupgrade",
"newapkbuild",
"lint",
......@@ -74,6 +74,8 @@ def run_command(args: PmbArgs):
command = Shutdown()
elif args.action == "test":
command = Test(args.action_test)
elif args.action == "pkgrel_bump":
command = PkgrelBump(args.packages, args.dry, args.auto)
elif args.action == "pull":
command = Pull()
elif args.action == "kconfig" and args.action_kconfig == "check":
......
# Copyright 2024 Stefan Hansson
# SPDX-License-Identifier: GPL-3.0-or-later
import sys
from pmb import commands
from pmb.helpers import logging
import pmb.helpers.pkgrel_bump
class PkgrelBump(commands.Command):
def __init__(self, packages: list[str], dry_run: bool, auto: bool) -> None:
self.packages = packages
self.dry_run = dry_run
self.auto = auto
def run(self) -> None:
would_bump = True
if self.auto:
would_bump = bool(pmb.helpers.pkgrel_bump.auto(self.dry_run))
else:
# Each package must exist
for package in self.packages:
pmb.helpers.pmaports.find(package)
# Increase pkgrel
for package in self.packages:
pmb.helpers.pkgrel_bump.package(package, dry=self.dry_run)
if self.dry_run and would_bump:
logging.info("Pkgrels of package(s) would have been bumped!")
sys.exit(1)
......@@ -27,7 +27,6 @@ import pmb.helpers.devices
import pmb.helpers.git
import pmb.helpers.lint
import pmb.helpers.logging
import pmb.helpers.pkgrel_bump
import pmb.helpers.pmaports
import pmb.helpers.repo
import pmb.helpers.repo_missing
......@@ -501,24 +500,6 @@ def apkindex_parse(args: PmbArgs) -> None:
print(json.dumps(result, indent=4))
def pkgrel_bump(args: PmbArgs) -> None:
would_bump = True
if args.auto:
would_bump = bool(pmb.helpers.pkgrel_bump.auto(args, args.dry))
else:
# Each package must exist
for package in args.packages:
pmb.helpers.pmaports.find(package)
# Increase pkgrel
for package in args.packages:
pmb.helpers.pkgrel_bump.package(args, package, dry=args.dry)
if args.dry and would_bump:
logging.info("Pkgrels of package(s) would have been bumped!")
sys.exit(1)
def aportupgrade(args: PmbArgs) -> None:
if args.all or args.all_stable or args.all_git:
pmb.helpers.aportupgrade.upgrade_all(args)
......
......@@ -3,7 +3,6 @@
from pmb.core.arch import Arch
from pmb.helpers import logging
from pmb.types import PmbArgs
import pmb.helpers.file
import pmb.helpers.pmaports
import pmb.helpers.repo
......@@ -11,7 +10,7 @@ import pmb.parse
import pmb.parse.apkindex
def package(args: PmbArgs, pkgname: str, reason="", dry: bool = False) -> None:
def package(pkgname: str, reason="", dry: bool = False) -> None:
"""Increase the pkgrel in the APKBUILD of a specific package.
:param pkgname: name of the package
......@@ -54,7 +53,7 @@ def package(args: PmbArgs, pkgname: str, reason="", dry: bool = False) -> None:
)
def auto_apkindex_package(args: PmbArgs, arch, aport, apk, dry: bool = False) -> bool:
def auto_apkindex_package(arch, aport, apk, dry: bool = False) -> bool:
"""Bump the pkgrel of a specific package if it is outdated in the given APKINDEX.
:param arch: the architecture, e.g. "armhf"
......@@ -103,13 +102,13 @@ def auto_apkindex_package(args: PmbArgs, arch, aport, apk, dry: bool = False) ->
# Increase pkgrel
if len(missing):
package(args, pkgname, reason=", missing depend(s): " + ", ".join(missing), dry=dry)
package(pkgname, reason=", missing depend(s): " + ", ".join(missing), dry=dry)
return True
return False
def auto(args: PmbArgs, dry=False) -> list[str]:
def auto(dry=False) -> list[str]:
""":returns: list of aport names, where the pkgrel needed to be changed"""
ret = []
for arch in Arch.supported():
......@@ -128,6 +127,6 @@ def auto(args: PmbArgs, dry=False) -> list[str]:
logging.warning(f"{pkgname}: origin '{origin}' aport not found")
continue
aport = pmb.parse.apkbuild(aport_path)
if auto_apkindex_package(args, arch, aport, apk, dry):
if auto_apkindex_package(arch, aport, apk, dry):
ret.append(pkgname)
return ret
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment