From 913900dfa2f9c55273a5390d300e1a44d1d44a3b Mon Sep 17 00:00:00 2001 From: mkosiarc Date: Oct 25 2022 14:14:52 +0000 Subject: Allow arch override for FlatpakBuilder Signed-off-by: mkosiarc --- diff --git a/flatpak_module_tools/flatpak_builder.py b/flatpak_module_tools/flatpak_builder.py index 516c203..6a6b5c6 100644 --- a/flatpak_module_tools/flatpak_builder.py +++ b/flatpak_module_tools/flatpak_builder.py @@ -78,7 +78,7 @@ def get_rpm_arch(): # since our build step is just unpacking the filesystem we've already # created. This is a stub implementation of 'flatpak build-init' that # doesn't check for the SDK or use it to set up the build filesystem. -def build_init(directory, appname, sdk, runtime, runtime_branch, tags=[]): +def build_init(directory, appname, sdk, runtime, runtime_branch, tags=[], arch=None): if not os.path.isdir(directory): os.mkdir(directory) with open(os.path.join(directory, "metadata"), "w") as f: @@ -91,7 +91,7 @@ def build_init(directory, appname, sdk, runtime, runtime_branch, tags=[]): sdk=sdk, runtime=runtime, runtime_branch=runtime_branch, - arch=get_flatpak_arch()))) + arch=arch or get_flatpak_arch()))) if tags: f.write("tags=" + ";".join(tags) + "\n") os.mkdir(os.path.join(directory, "files")) @@ -389,11 +389,12 @@ class FlatpakSourceInfo(object): class FlatpakBuilder(object): def __init__(self, source, workdir, root, parse_manifest=None, - flatpak_metadata=FLATPAK_METADATA_ANNOTATIONS): + flatpak_metadata=FLATPAK_METADATA_ANNOTATIONS, arch=None): self.source = source self.workdir = workdir self.root = root self.parse_manifest = parse_manifest + self.arch = arch or get_flatpak_arch() if flatpak_metadata not in (FLATPAK_METADATA_ANNOTATIONS, FLATPAK_METADATA_LABELS, @@ -714,7 +715,7 @@ class FlatpakBuilder(object): 'id': id_, 'runtime_id': runtime_id, 'sdk_id': sdk_id, - 'arch': get_flatpak_arch(), + 'arch': self.arch, 'branch': branch } @@ -786,7 +787,7 @@ class FlatpakBuilder(object): # See comment for build_init() for why we can't use 'flatpak build-init' # subprocess.check_call(['flatpak', 'build-init', # builddir, app_id, runtime_id, runtime_id, runtime_version]) - build_init(builddir, app_id, sdk_id, runtime_id, runtime_version, tags=info.get('tags', [])) + build_init(builddir, app_id, sdk_id, runtime_id, runtime_version, tags=info.get('tags', []), arch=self.arch) # with gzip'ed tarball, tar is several seconds faster than tarfile.extractall subprocess.check_call(['tar', 'xCfz', builddir, tarred_filesystem]) @@ -840,7 +841,7 @@ class FlatpakBuilder(object): outfile, app_id, app_branch]) app_ref = 'app/{app_id}/{arch}/{branch}'.format(app_id=app_id, - arch=get_flatpak_arch(), + arch=self.arch, branch=app_branch) return app_ref