From 3594952a133e643346216e90bfeb4b15ceae85c6 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Sun, 26 Sep 2021 17:17:53 +0200 Subject: [PATCH] Cleanups, packages/cmd_check: ignore comments, cmd_build: add --force Signed-off-by: InsanePrawn --- chroot.py | 16 ++++++++-------- constants.py | 2 +- packages.py | 20 +++++++++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/chroot.py b/chroot.py index 4768c7d..9048bd2 100644 --- a/chroot.py +++ b/chroot.py @@ -78,14 +78,14 @@ def create_chroot_user( ): chroot_path = get_chroot_path(chroot_name, override_basepath=chroot_base_path) - install_script = '\n'.join([ - f'if ! id -u "{user}" >/dev/null 2>&1; then', - f' useradd -m {user}', - f'fi', - f'usermod -a -G {",".join(groups)} {user}', - f'echo "{user}:{password}" | chpasswd', - f'chown {user}:{user} /home/{user} -R', - ]) + install_script = f''' + if ! id -u "{user}" >/dev/null 2>&1; then + useradd -m {user} + fi + usermod -a -G {",".join(groups)} {user} + echo "{user}:{password}" | chpasswd + chown {user}:{user} /home/{user} -R + ''' result = subprocess.run([ 'arch-chroot', chroot_path, diff --git a/constants.py b/constants.py index 9a3c971..466c13b 100644 --- a/constants.py +++ b/constants.py @@ -62,6 +62,6 @@ BASE_DISTROS = { 'community': 'http://mirror.archlinuxarm.org/$arch/$repo', 'alarm': 'http://mirror.archlinuxarm.org/$arch/$repo', 'aur': 'http://mirror.archlinuxarm.org/$arch/$repo', - } + }, }, } diff --git a/packages.py b/packages.py index 4388e76..ef2f052 100644 --- a/packages.py +++ b/packages.py @@ -116,7 +116,7 @@ def check_prebuilts(dir: str = None): exit(1) -def discover_packages(package_paths: list[str] = ['all'], dir: str = None) -> dict[str, Package]: +def discover_packages(dir: str = None) -> dict[str, Package]: dir = dir if dir else config.file['paths']['pkgbuilds'] packages = {} paths = [] @@ -502,8 +502,9 @@ def cmd_packages(): @click.command(name='build') +@click.option('--force', is_flag=True, default=False) @click.argument('paths', nargs=-1) -def cmd_build(paths: list[str], arch='aarch64'): +def cmd_build(paths: list[str], force=False, arch='aarch64'): check_prebuilts() paths = list(paths) @@ -519,7 +520,8 @@ def cmd_build(paths: list[str], arch='aarch64'): for packages in package_levels: level = set[Package]() for package in packages: - if (not check_package_version_built(package)) or set.intersection(set(package.depends), set(build_names)): + if ((not check_package_version_built(package)) or set.intersection(set(package.depends), set(build_names)) or + (force and package.path in paths)): level.add(package) build_names.update(package.names) if level: @@ -546,7 +548,7 @@ def cmd_clean(): '-dffX', ] + REPOSITORIES) if result.returncode != 0: - logging.fatal(f'Failed to git clean') + logging.fatal('Failed to git clean') exit(1) @@ -554,10 +556,10 @@ def cmd_clean(): @click.argument('paths', nargs=-1) def cmd_check(paths): paths = list(paths) - packages = discover_packages(paths) + packages = filter_packages_by_paths(discover_packages(), paths) - for name in packages: - package = packages[name] + for package in packages: + name = package.name is_git_package = False if name.endswith('-git'): @@ -604,6 +606,10 @@ def cmd_check(paths): while True: line = lines[line_index] + if line.startswith('#'): + line_index += 1 + continue + if line.startswith('_') and not line.startswith(mode_key) and not line.startswith(commit_key): line_index += 1 continue