Fix package building
This commit is contained in:
parent
52458bd314
commit
fe52671e06
3 changed files with 19 additions and 12 deletions
|
@ -30,4 +30,4 @@ COPY . .
|
||||||
|
|
||||||
RUN python -c "import constants; repos='\n'.join(['\n'.join(['', f'[{repo}]', f'Server = file:///prebuilts/\$arch/\$repo']) for repo in constants.REPOSITORIES]); print(repos)" | tee -a /etc/pacman.conf
|
RUN python -c "import constants; repos='\n'.join(['\n'.join(['', f'[{repo}]', f'Server = file:///prebuilts/\$arch/\$repo']) for repo in constants.REPOSITORIES]); print(repos)" | tee -a /etc/pacman.conf
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /
|
||||||
|
|
22
packages.py
22
packages.py
|
@ -160,7 +160,7 @@ def discover_packages(dir: str = None) -> dict[str, Package]:
|
||||||
init_pkgbuilds(interactive=False)
|
init_pkgbuilds(interactive=False)
|
||||||
for repo in REPOSITORIES:
|
for repo in REPOSITORIES:
|
||||||
for _dir in os.listdir(os.path.join(dir, repo)):
|
for _dir in os.listdir(os.path.join(dir, repo)):
|
||||||
paths.append(os.path.join(repo, _dir))
|
paths.append(os.path.join(dir, repo, _dir))
|
||||||
|
|
||||||
results = Parallel(n_jobs=multiprocessing.cpu_count() * 4)(delayed(Package)(path, dir) for path in paths)
|
results = Parallel(n_jobs=multiprocessing.cpu_count() * 4)(delayed(Package)(path, dir) for path in paths)
|
||||||
for package in results:
|
for package in results:
|
||||||
|
@ -191,7 +191,7 @@ def filter_packages_by_paths(repo: dict[str, Package], paths: list[str]) -> list
|
||||||
return repo.values()
|
return repo.values()
|
||||||
result = []
|
result = []
|
||||||
for pkg in repo.values():
|
for pkg in repo.values():
|
||||||
if pkg.path in paths:
|
if pkg.path.replace('/pkgbuilds/', '') in paths:
|
||||||
result += [pkg]
|
result += [pkg]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -498,17 +498,17 @@ def build_package(
|
||||||
env['PATH'] = f"/usr/lib/ccache:{env['PATH']}"
|
env['PATH'] = f"/usr/lib/ccache:{env['PATH']}"
|
||||||
logging.debug(('Building for native arch. ' if not foreign_arch else '') + 'Skipping crossdirect.')
|
logging.debug(('Building for native arch. ' if not foreign_arch else '') + 'Skipping crossdirect.')
|
||||||
|
|
||||||
src_dir = os.path.join(build_root, 'src')
|
src_dir = os.path.join(build_root, 'pkgbuilds')
|
||||||
os.makedirs(src_dir, exist_ok=True)
|
os.makedirs(src_dir, exist_ok=True)
|
||||||
#setup_sources(package, build_root, enable_crosscompile=enable_crosscompile)
|
#setup_sources(package, build_root, enable_crosscompile=enable_crosscompile)
|
||||||
|
|
||||||
result = mount(config.get_path('pkgbuilds'), src_dir)
|
result = mount(config.get_path('pkgbuilds'), src_dir)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise Exception(f'Failed to bind mount pkgbuilds to {build_root}/src')
|
raise Exception(f'Failed to bind mount pkgbuilds to {src_dir}')
|
||||||
umount_dirs += [src_dir]
|
umount_dirs += [src_dir]
|
||||||
|
|
||||||
makepkg_conf_absolute = os.path.join('/', makepkg_conf_path)
|
makepkg_conf_absolute = os.path.join('/', makepkg_conf_path)
|
||||||
build_cmd = f'cd /src/{package.path} && makepkg --config {makepkg_conf_absolute} --needed --noconfirm --ignorearch {" ".join(makepkg_compile_opts)}'
|
build_cmd = f'cd {package.path} && makepkg --config {makepkg_conf_absolute} --needed --noconfirm --ignorearch {" ".join(makepkg_compile_opts)}'
|
||||||
logging.debug(f'Building: Running {build_cmd}')
|
logging.debug(f'Building: Running {build_cmd}')
|
||||||
result = run_chroot_cmd(build_cmd, chroot_path=build_root, inner_env=env)
|
result = run_chroot_cmd(build_cmd, chroot_path=build_root, inner_env=env)
|
||||||
|
|
||||||
|
@ -571,6 +571,7 @@ def build_packages(
|
||||||
def build_packages_by_paths(
|
def build_packages_by_paths(
|
||||||
paths: list[str],
|
paths: list[str],
|
||||||
arch: str,
|
arch: str,
|
||||||
|
repo: dict[str, Package],
|
||||||
force=False,
|
force=False,
|
||||||
enable_crosscompile: bool = True,
|
enable_crosscompile: bool = True,
|
||||||
enable_crossdirect: bool = True,
|
enable_crossdirect: bool = True,
|
||||||
|
@ -581,7 +582,6 @@ def build_packages_by_paths(
|
||||||
|
|
||||||
for _arch in set([arch, config.runtime['arch']]):
|
for _arch in set([arch, config.runtime['arch']]):
|
||||||
init_prebuilts(_arch)
|
init_prebuilts(_arch)
|
||||||
repo: dict[str, Package] = discover_packages()
|
|
||||||
packages = filter_packages_by_paths(repo, paths)
|
packages = filter_packages_by_paths(repo, paths)
|
||||||
build_packages(
|
build_packages(
|
||||||
repo,
|
repo,
|
||||||
|
@ -618,12 +618,14 @@ def cmd_build(paths: list[str], force=False, arch=None):
|
||||||
if arch not in ARCHES:
|
if arch not in ARCHES:
|
||||||
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
raise Exception(f'Unknown architecture "{arch}". Choices: {", ".join(ARCHES)}')
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
|
repo: dict[str, Package] = discover_packages()
|
||||||
native = config.runtime['arch']
|
native = config.runtime['arch']
|
||||||
if arch != native:
|
if arch != native:
|
||||||
# build qemu-user, binfmt, crossdirect
|
# build qemu-user, binfmt, crossdirect
|
||||||
build_packages_by_paths(
|
build_packages_by_paths(
|
||||||
['cross/' + pkg for pkg in CROSSDIRECT_PKGS],
|
['cross/' + pkg for pkg in CROSSDIRECT_PKGS],
|
||||||
native,
|
native,
|
||||||
|
repo,
|
||||||
enable_crosscompile=False,
|
enable_crosscompile=False,
|
||||||
enable_crossdirect=False,
|
enable_crossdirect=False,
|
||||||
enable_ccache=False,
|
enable_ccache=False,
|
||||||
|
@ -635,6 +637,7 @@ def cmd_build(paths: list[str], force=False, arch=None):
|
||||||
build_packages_by_paths(
|
build_packages_by_paths(
|
||||||
paths,
|
paths,
|
||||||
arch,
|
arch,
|
||||||
|
repo,
|
||||||
force=force,
|
force=force,
|
||||||
enable_crosscompile=config.file['build']['crosscompile'],
|
enable_crosscompile=config.file['build']['crosscompile'],
|
||||||
enable_crossdirect=config.file['build']['crossdirect'],
|
enable_crossdirect=config.file['build']['crossdirect'],
|
||||||
|
@ -645,10 +648,13 @@ def cmd_build(paths: list[str], force=False, arch=None):
|
||||||
@cmd_packages.command(name='clean')
|
@cmd_packages.command(name='clean')
|
||||||
def cmd_clean():
|
def cmd_clean():
|
||||||
enforce_wrap()
|
enforce_wrap()
|
||||||
result = git([
|
result = git(
|
||||||
|
[
|
||||||
'clean',
|
'clean',
|
||||||
'-dffX',
|
'-dffX',
|
||||||
] + REPOSITORIES)
|
] + REPOSITORIES,
|
||||||
|
dir='/pkgbuilds',
|
||||||
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.fatal('Failed to git clean')
|
logging.fatal('Failed to git clean')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
|
@ -13,7 +13,7 @@ DOCKER_PATHS = {
|
||||||
'jumpdrive': '/var/cache/jumpdrive',
|
'jumpdrive': '/var/cache/jumpdrive',
|
||||||
'pacman': '/var/cache/pacman',
|
'pacman': '/var/cache/pacman',
|
||||||
'packages': '/prebuilts',
|
'packages': '/prebuilts',
|
||||||
'pkgbuilds': '/src',
|
'pkgbuilds': '/pkgbuilds',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ def wrap_docker():
|
||||||
dump_config_file(file_path=wrapped_config, config=(config.file | {'paths': DOCKER_PATHS}))
|
dump_config_file(file_path=wrapped_config, config=(config.file | {'paths': DOCKER_PATHS}))
|
||||||
volumes = {
|
volumes = {
|
||||||
'/dev': '/dev',
|
'/dev': '/dev',
|
||||||
|
os.getcwd(): '/src',
|
||||||
wrapped_config: '/root/.config/kupfer/kupferbootstrap.toml',
|
wrapped_config: '/root/.config/kupfer/kupferbootstrap.toml',
|
||||||
}
|
}
|
||||||
volumes |= dict({config.get_path(vol_name): vol_dest for vol_name, vol_dest in DOCKER_PATHS.items()})
|
volumes |= dict({config.get_path(vol_name): vol_dest for vol_name, vol_dest in DOCKER_PATHS.items()})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue