Add unpacked sizes

This commit is contained in:
Disassembler 2019-09-24 10:04:13 +02:00
parent 69f67649f3
commit 7f0d9572e3
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
2 changed files with 11 additions and 5 deletions

@ -1 +1 @@
Subproject commit 7b045cf9c3e7f0de494a75e99a9f2a9d34d4772d
Subproject commit d14fba7ec1759bb9a9a45369d155a9937dbdbecd

View File

@ -20,7 +20,9 @@ class Packer:
self.app = None
self.image = None
self.tar_path = None
self.tar_size = 0
self.xz_path = None
self.xz_size = 0
if os.path.exists(REPO_META_FILE):
with open(REPO_META_FILE, 'r') as f:
self.packages = json.load(f)
@ -56,15 +58,18 @@ class Packer:
def compress_archive(self):
# Compress the tarball with xz (LZMA2)
print('Compressing', self.tar_path, '({:.2f} MB)'.format(os.path.getsize(self.tar_path)/1048576))
self.tar_size = os.path.getsize(self.tar_path)
print('Compressing', self.tar_path, '({:.2f} MB)'.format(self.tar_size/1048576))
subprocess.run(['xz', '-9', self.tar_path])
print('Compressed ', self.xz_path, '({:.2f} MB)'.format(os.path.getsize(self.xz_path)/1048576))
self.xz_size = os.path.getsize(self.xz_path)
print('Compressed ', self.xz_path, '({:.2f} MB)'.format(self.xz_size/1048576))
def register_image(self):
# Register image in global repository metadata file
print('Registering package {}'.format(self.image.name))
self.packages['images'][self.image.name] = self.image.conf.copy()
self.packages['images'][self.image.name]['size'] = os.path.getsize(self.xz_path)
self.packages['images'][self.image.name]['size'] = self.tar_size
self.packages['images'][self.image.name]['pkgsize'] = self.xz_size
self.packages['images'][self.image.name]['sha512'] = crypto.hash_file(self.xz_path)
self.save_repo_meta()
# Register the image also to locally installed images for package manager
@ -112,6 +117,7 @@ class Packer:
# Register package in global repository metadata file
print('Registering package {}'.format(self.app.name))
self.packages['apps'][self.app.name] = self.app.conf.copy()
self.packages['apps'][self.app.name]['size'] = os.path.getsize(self.xz_path)
self.packages['apps'][self.app.name]['size'] = self.tar_size
self.packages['apps'][self.app.name]['pkgsize'] = self.xz_size
self.packages['apps'][self.app.name]['sha512'] = crypto.hash_file(self.xz_path)
self.save_repo_meta()