feat: add support of atom builds
Signed-off-by: sisungo <[email protected]>
This commit is contained in:
@@ -7,7 +7,9 @@ import typing
|
||||
|
||||
import hooks
|
||||
import lib.arch
|
||||
import lib.atombuild
|
||||
import lib.make
|
||||
import lib.packie
|
||||
import lib.pkgcomposer
|
||||
import lib.sources
|
||||
|
||||
@@ -20,6 +22,7 @@ argparser = argparse.ArgumentParser(
|
||||
argparser.add_argument(
|
||||
"--target", type=str, help="Target architecture to build the package for"
|
||||
)
|
||||
argparser.add_argument("--atombuild", action="store_true", help="Enable Atom Build")
|
||||
subparsers = argparser.add_subparsers(dest="subcommand")
|
||||
parser_build = subparsers.add_parser("build")
|
||||
parser_build.add_argument("BUILD_PKGNAME")
|
||||
@@ -64,6 +67,9 @@ def run_build_package(package: str):
|
||||
print(f"Architecture {lib.arch.get_target()} is not supported for this package")
|
||||
exit(1)
|
||||
|
||||
if os.environ.get("SEMIOS_PKGBUILD_IN_ATOMIC", "0") == "1":
|
||||
lib.packie.install(lib.make._builddep)
|
||||
|
||||
# Run `pre_build` hooks
|
||||
run_hooks(hooks.pre_build)
|
||||
|
||||
@@ -151,8 +157,48 @@ def run_list(item):
|
||||
print(i)
|
||||
|
||||
|
||||
def run_build_atom(pkgname: str):
|
||||
# Declare necessary paths
|
||||
repo_root = os.getcwd()
|
||||
package_dir = f"{repo_root}/packages/{pkgname}"
|
||||
target_dir = f"{package_dir}/target"
|
||||
build_env_root = f"{target_dir}/atombuild_root"
|
||||
|
||||
# Read `pkgbuild.py` of that package
|
||||
lib.make._in_atombuild = True
|
||||
try:
|
||||
os.chdir(package_dir)
|
||||
os.makedirs(target_dir, exist_ok=True)
|
||||
except Exception:
|
||||
print(f"No such package {pkgname}")
|
||||
exit(1)
|
||||
importlib.import_module(f"packages.{pkgname}.pkgbuild")
|
||||
os.chdir(repo_root)
|
||||
|
||||
# Initialize build environment
|
||||
lib.atombuild.prepare_build_env(build_env_root, lib.make._builddep)
|
||||
lib.atombuild.copy_pkgbuild_tree(repo_root, pkgname, build_env_root)
|
||||
lib.atombuild.enter_build_env(
|
||||
build_env_root,
|
||||
["./x", "--target", lib.arch.get_target(), "build", pkgname],
|
||||
chdir="/Atom",
|
||||
)
|
||||
|
||||
# Copy artifacts
|
||||
atom_target_dir = f"{build_env_root}/Atom/packages/{pkgname}/target"
|
||||
try:
|
||||
for i in os.listdir(atom_target_dir):
|
||||
if i.endswith(".pkg"):
|
||||
shutil.copy2(f"{atom_target_dir}/{i}", f"{target_dir}/{i}")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
if args.subcommand == "build":
|
||||
run_build_package(args.BUILD_PKGNAME)
|
||||
if args.atombuild:
|
||||
run_build_atom(args.BUILD_PKGNAME)
|
||||
else:
|
||||
run_build_package(args.BUILD_PKGNAME)
|
||||
elif args.subcommand == "clean":
|
||||
run_clean_package(args.CLEAN_PKGNAME)
|
||||
elif args.subcommand == "list":
|
||||
|
||||
Reference in New Issue
Block a user