From b1d705487ad5a811e1a6281c4e84239f9886bbbb Mon Sep 17 00:00:00 2001 From: Disassembler Date: Mon, 23 Sep 2019 15:34:37 +0200 Subject: [PATCH] Fix packaging --- apk/vmmgr | 2 +- build/usr/bin/lxcbuild | 2 +- build/usr/lib/python3.6/lxcbuild/image.py | 6 +++--- build/usr/lib/python3.6/lxcbuild/packer.py | 16 ++++++++++------ 4 files changed, 15 insertions(+), 11 deletions(-) mode change 100644 => 100755 build/usr/bin/lxcbuild diff --git a/apk/vmmgr b/apk/vmmgr index 4c26168..7b045cf 160000 --- a/apk/vmmgr +++ b/apk/vmmgr @@ -1 +1 @@ -Subproject commit 4c2616887f52b1265aa5943d1b6bd0f7d5e9f008 +Subproject commit 7b045cf9c3e7f0de494a75e99a9f2a9d34d4772d diff --git a/build/usr/bin/lxcbuild b/build/usr/bin/lxcbuild old mode 100644 new mode 100755 index cd60d72..ae03087 --- a/build/usr/bin/lxcbuild +++ b/build/usr/bin/lxcbuild @@ -24,7 +24,7 @@ if os.path.isfile(buildpath): image.build_and_pack(args.force) elif basename == 'meta' or basename.endswith('.meta'): app = App(buildpath) - app.build_and_pack() + app.pack() else: print('Unknown file {} given, expected "lxcfile" or "meta"'.format(buildpath)) sys.exit(1) diff --git a/build/usr/lib/python3.6/lxcbuild/image.py b/build/usr/lib/python3.6/lxcbuild/image.py index d026843..f77bff8 100644 --- a/build/usr/lib/python3.6/lxcbuild/image.py +++ b/build/usr/lib/python3.6/lxcbuild/image.py @@ -14,12 +14,12 @@ class Image: self.lxcfile = lxcfile self.build_dir = os.path.dirname(lxcfile) - def build_and_pack(self, force=False): + def build_and_pack(self, force): self.conf['build'] = True try: builder = Builder() builder.build(self, force) - # In case of successful build, packaging needs to be forced to prevent outdated packages + # In case of successful build, packaging needs to happen in all cases to prevent outdated packages force = True except ImageExistsError as e: print('Image {} already exists, skipping build tasks'.format(e)) @@ -30,9 +30,9 @@ class Image: except: builder.clean() raise + del self.conf['build'] try: packer = Packer() packer.pack_image(self, force) except PackageExistsError as e: print('Package {} already exists, skipping packaging tasks'.format(e)) - del self.conf['build'] diff --git a/build/usr/lib/python3.6/lxcbuild/packer.py b/build/usr/lib/python3.6/lxcbuild/packer.py index 72c789d..ffbeb53 100644 --- a/build/usr/lib/python3.6/lxcbuild/packer.py +++ b/build/usr/lib/python3.6/lxcbuild/packer.py @@ -36,12 +36,14 @@ class Packer: # Prepare package file names self.tar_path = os.path.join(REPO_IMAGES_DIR, '{}.tar'.format(self.image.name)) self.xz_path = '{}.xz'.format(self.tar_path) - if os.path.exists(self.xz_path): - if force: - self.unregister_image() + if force: + self.unregister_image() + try: os.unlink(self.xz_path) - else: - raise PackageExistsError(self.xz_path) + except FileNotFoundError: + pass + elif os.path.exists(self.xz_path): + raise PackageExistsError(self.xz_path) self.create_image_archive() self.register_image() self.sign_packages() @@ -90,8 +92,10 @@ class Packer: # Prepare package file names self.tar_path = os.path.join(REPO_APPS_DIR, '{}.tar'.format(self.app.name)) self.xz_path = '{}.xz'.format(self.tar_path) - if os.path.exists(self.xz_path): + try: os.unlink(self.xz_path) + except FileNotFoundError: + pass self.create_app_archive() self.register_app() self.sign_packages()