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