POC fonctionnel
This commit is contained in:
34
package
34
package
@ -10,11 +10,13 @@ def configure_args_parser():
|
||||
|
||||
profile_names = tamarin.get_available_profile_names()
|
||||
|
||||
parser = argparse.ArgumentParser(description="Generate packages for various GNU/Linux distribution")
|
||||
parser = argparse.ArgumentParser(description="Generate packages for various GNU/Linux distributions")
|
||||
|
||||
# Define available/required arguments and flags
|
||||
parser.add_argument("project_path", help="The path to your project to package")
|
||||
parser.add_argument("project_directory", help="The path to your project to package")
|
||||
parser.add_argument("-o", "--output", help="The path to the generated packages destination directory", default=".")
|
||||
parser.add_argument("-p", "--profile", help="The profile to use to package this project (default: debian)", choices=profile_names, default='debian')
|
||||
parser.add_argument("-a", "--architecture", help="The target architecture for the package (default: amd64)", default='amd64')
|
||||
parser.add_argument("--rebuild", help="Ignore cache and rebuild container's image", action="store_true", default=False)
|
||||
|
||||
return parser
|
||||
@ -24,6 +26,10 @@ if __name__ == "__main__":
|
||||
parser = configure_args_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
# Verify project directory
|
||||
project_dir = os.path.abspath(args.project_directory)
|
||||
output_dir = os.path.abspath(args.output)
|
||||
|
||||
# Load build profile
|
||||
profile = tamarin.load_profile(args.profile)
|
||||
|
||||
@ -86,14 +92,18 @@ if __name__ == "__main__":
|
||||
|
||||
# Build image
|
||||
tamarin.run_acbuild(acbuild_flags+["set-name", "image_{:d}".format(pid)])
|
||||
tamarin.run_acbuild(acbuild_flags+["copy-to-dir", tamarin.get_hooks_dir(), '/tamarin'])
|
||||
tamarin.run_acbuild(acbuild_flags+["copy-to-dir", tamarin.get_lib_dir(), '/tamarin'])
|
||||
tamarin.run_acbuild(acbuild_flags+["mount", "add", "src", "/src", "--read-only"])
|
||||
tamarin.run_acbuild(acbuild_flags+["mount", "add", "dist", "/dist"])
|
||||
tamarin.run_acbuild(acbuild_flags+["mount", "add", "tamarin-hooks", "/tamarin/hooks", "--read-only"])
|
||||
tamarin.run_acbuild(acbuild_flags+["mount", "add", "tamarin-lib", "/tamarin/lib", "--read-only"])
|
||||
tamarin.run_acbuild(acbuild_flags+["mount", "add", "tamarin-profiles", "/tamarin/profiles", "--read-only"])
|
||||
|
||||
# Execute containerbuild hooks
|
||||
cpb_hooks_env = os.environ.copy()
|
||||
cpb_hooks_env["PATH"] = os.environ['PATH'] + ':' + local_acbuild_dir
|
||||
cpb_hooks_env["TAMARIN_ACBUILD"] = " ".join([system.which('acbuild', local_acbuild_dir)]+acbuild_flags)
|
||||
tamarin.run_profile_hooks(profile, 'containerbuild', cwd=build_workspace, env=cpb_hooks_env)
|
||||
cb_hooks_env = os.environ.copy()
|
||||
cb_hooks_env["PATH"] = os.environ['PATH'] + ':' + local_acbuild_dir
|
||||
cb_hooks_env["TAMARIN_ACBUILD"] = " ".join([system.which('acbuild', local_acbuild_dir)]+acbuild_flags)
|
||||
cb_hooks_env["TAMARIN_ACBUILD_ENGINE"] = "chroot" if system.which('systemd-nspawn') == "" else "systemd-nspawn"
|
||||
tamarin.run_profile_hooks(profile, 'containerbuild', cwd=build_workspace, env=cb_hooks_env)
|
||||
|
||||
# Cache image
|
||||
shutil.copyfile(aci_file, cached_image_file)
|
||||
@ -103,7 +113,13 @@ if __name__ == "__main__":
|
||||
"run",
|
||||
"--insecure-options=image",
|
||||
aci_file, "--net=host",
|
||||
"--exec", "/usr/bin/python3", "--", "/tamarin/lib/build.py"
|
||||
"--volume=src,kind=host,source={:s}".format(project_dir),
|
||||
"--volume=dist,kind=host,source={:s}".format(output_dir),
|
||||
"--volume=tamarin-hooks,kind=host,source={:s}".format(tamarin.get_hooks_dir()),
|
||||
"--volume=tamarin-lib,kind=host,source={:s}".format(tamarin.get_lib_dir()),
|
||||
"--volume=tamarin-profiles,kind=host,source={:s}".format(tamarin.get_profiles_dir()),
|
||||
"--interactive", "--exec", "/bin/bash"
|
||||
#"--exec", "/usr/bin/python3", "--", "/tamarin/lib/build.py", args.profile, args.architecture
|
||||
], as_root=True)
|
||||
|
||||
# Cleanup
|
||||
|
Reference in New Issue
Block a user