Allow scratch builds with dir as argument
This commit is contained in:
parent
93cc9f435b
commit
466a83e407
@ -20,7 +20,7 @@ if len(sys.argv) < 2:
|
||||
sys.exit(1)
|
||||
args = parser.parse_args()
|
||||
|
||||
def build_and_pack_image(args, path):
|
||||
def build_and_pack_image(path, args):
|
||||
image = Image()
|
||||
image.force_build = args.force or args.scratch
|
||||
image.scratch_build = args.scratch
|
||||
@ -44,7 +44,7 @@ else:
|
||||
if os.path.isfile(buildpath):
|
||||
basename = os.path.basename(buildpath)
|
||||
if basename == 'lxcfile' or basename.endswith('.lxcfile'):
|
||||
build_and_pack_image(args, buildpath)
|
||||
build_and_pack_image(buildpath, args)
|
||||
# Compose files needs to be ignored when performing scratch builds
|
||||
elif not args.scratch and basename == 'meta':
|
||||
pack_app(buildpath)
|
||||
@ -54,13 +54,18 @@ else:
|
||||
# If the buildpath is a directory, build as much as possible, unless scratch build was requested, in which case don't build anything
|
||||
else:
|
||||
if args.scratch:
|
||||
lxcfile = os.path.join(buildpath, 'lxcfile')
|
||||
if os.path.exists(lxcfile):
|
||||
build_and_pack_image(lxcfile, args)
|
||||
else:
|
||||
print('Please specify an lxcfile for scratch build')
|
||||
sys.exit(1)
|
||||
else:
|
||||
valid_dir = False
|
||||
for entry in os.scandir(buildpath):
|
||||
if entry.is_file() and (entry.name == 'lxcfile' or entry.name.endswith('.lxcfile')):
|
||||
valid_dir = True
|
||||
build_and_pack_image(args, entry.path)
|
||||
build_and_pack_image(entry.path, args)
|
||||
meta = os.path.join(buildpath, 'meta')
|
||||
if os.path.exists(meta):
|
||||
valid_dir = True
|
||||
|
@ -47,7 +47,7 @@ class AppPacker(Packer):
|
||||
|
||||
def register(self):
|
||||
# Register package in global repository metadata file
|
||||
print('Registering package', self.app.name)
|
||||
print('Registering application package', self.app.name)
|
||||
self.packages['apps'][self.app.name] = self.app.conf.copy()
|
||||
self.packages['apps'][self.app.name]['size'] = self.tar_size
|
||||
self.packages['apps'][self.app.name]['pkgsize'] = self.xz_size
|
||||
|
@ -40,13 +40,13 @@ class ImagePacker(Packer):
|
||||
|
||||
def create_archive(self):
|
||||
# Create archive
|
||||
print('Archiving', self.image.name)
|
||||
print('Archiving image', self.image.name)
|
||||
subprocess.run(['tar', '--xattrs', '-cpf', self.tar_path, self.image.name], cwd=LXC_STORAGE_DIR)
|
||||
self.compress_archive()
|
||||
|
||||
def register(self):
|
||||
# Register image in global repository metadata file
|
||||
print('Registering package', self.image.name)
|
||||
print('Registering image package', self.image.name)
|
||||
self.packages['images'][self.image.name] = self.image.conf.copy()
|
||||
self.packages['images'][self.image.name]['size'] = self.tar_size
|
||||
self.packages['images'][self.image.name]['pkgsize'] = self.xz_size
|
||||
|
Loading…
Reference in New Issue
Block a user