Cleanups, packages/cmd_check: ignore comments, cmd_build: add --force

Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
This commit is contained in:
InsanePrawn 2021-09-26 17:17:53 +02:00
parent 23ff0d50e0
commit 3594952a13
3 changed files with 22 additions and 16 deletions

View file

@ -78,14 +78,14 @@ def create_chroot_user(
): ):
chroot_path = get_chroot_path(chroot_name, override_basepath=chroot_base_path) chroot_path = get_chroot_path(chroot_name, override_basepath=chroot_base_path)
install_script = '\n'.join([ install_script = f'''
f'if ! id -u "{user}" >/dev/null 2>&1; then', if ! id -u "{user}" >/dev/null 2>&1; then
f' useradd -m {user}', useradd -m {user}
f'fi', fi
f'usermod -a -G {",".join(groups)} {user}', usermod -a -G {",".join(groups)} {user}
f'echo "{user}:{password}" | chpasswd', echo "{user}:{password}" | chpasswd
f'chown {user}:{user} /home/{user} -R', chown {user}:{user} /home/{user} -R
]) '''
result = subprocess.run([ result = subprocess.run([
'arch-chroot', 'arch-chroot',
chroot_path, chroot_path,

View file

@ -62,6 +62,6 @@ BASE_DISTROS = {
'community': 'http://mirror.archlinuxarm.org/$arch/$repo', 'community': 'http://mirror.archlinuxarm.org/$arch/$repo',
'alarm': 'http://mirror.archlinuxarm.org/$arch/$repo', 'alarm': 'http://mirror.archlinuxarm.org/$arch/$repo',
'aur': 'http://mirror.archlinuxarm.org/$arch/$repo', 'aur': 'http://mirror.archlinuxarm.org/$arch/$repo',
} },
}, },
} }

View file

@ -116,7 +116,7 @@ def check_prebuilts(dir: str = None):
exit(1) 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'] dir = dir if dir else config.file['paths']['pkgbuilds']
packages = {} packages = {}
paths = [] paths = []
@ -502,8 +502,9 @@ def cmd_packages():
@click.command(name='build') @click.command(name='build')
@click.option('--force', is_flag=True, default=False)
@click.argument('paths', nargs=-1) @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() check_prebuilts()
paths = list(paths) paths = list(paths)
@ -519,7 +520,8 @@ def cmd_build(paths: list[str], arch='aarch64'):
for packages in package_levels: for packages in package_levels:
level = set[Package]() level = set[Package]()
for package in packages: 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) level.add(package)
build_names.update(package.names) build_names.update(package.names)
if level: if level:
@ -546,7 +548,7 @@ def cmd_clean():
'-dffX', '-dffX',
] + REPOSITORIES) ] + REPOSITORIES)
if result.returncode != 0: if result.returncode != 0:
logging.fatal(f'Failed to git clean') logging.fatal('Failed to git clean')
exit(1) exit(1)
@ -554,10 +556,10 @@ def cmd_clean():
@click.argument('paths', nargs=-1) @click.argument('paths', nargs=-1)
def cmd_check(paths): def cmd_check(paths):
paths = list(paths) paths = list(paths)
packages = discover_packages(paths) packages = filter_packages_by_paths(discover_packages(), paths)
for name in packages: for package in packages:
package = packages[name] name = package.name
is_git_package = False is_git_package = False
if name.endswith('-git'): if name.endswith('-git'):
@ -604,6 +606,10 @@ def cmd_check(paths):
while True: while True:
line = lines[line_index] 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): if line.startswith('_') and not line.startswith(mode_key) and not line.startswith(commit_key):
line_index += 1 line_index += 1
continue continue