Fix packaging

This commit is contained in:
Disassembler 2019-09-23 15:34:37 +02:00
parent bbfe11f557
commit b1d705487a
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
4 changed files with 15 additions and 11 deletions

@ -1 +1 @@
Subproject commit 4c2616887f52b1265aa5943d1b6bd0f7d5e9f008
Subproject commit 7b045cf9c3e7f0de494a75e99a9f2a9d34d4772d

2
build/usr/bin/lxcbuild Normal file → Executable file
View File

@ -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)

View File

@ -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']

View File

@ -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()