Revert order of layers for MERGE
This commit is contained in:
parent
56af4a0b66
commit
827991d7ac
@ -28,7 +28,7 @@ def makedirs(path, mode=0o755, uid=100000, gid=100000):
|
|||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def merge_apk_world():
|
def merge_apk_world(layers):
|
||||||
world = []
|
world = []
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
try:
|
try:
|
||||||
@ -43,7 +43,7 @@ def merge_apk_world():
|
|||||||
f.writelines(world)
|
f.writelines(world)
|
||||||
os.chown(os.path.join(layers[-1], APK_WORLD), 100000, 100000)
|
os.chown(os.path.join(layers[-1], APK_WORLD), 100000, 100000)
|
||||||
|
|
||||||
def merge_apk_installed():
|
def merge_apk_installed(layers):
|
||||||
installed = []
|
installed = []
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
try:
|
try:
|
||||||
@ -66,7 +66,7 @@ def merge_apk_installed():
|
|||||||
f.writelines(installed)
|
f.writelines(installed)
|
||||||
os.chown(os.path.join(layers[-1], APK_INSTALLED), 100000, 100000)
|
os.chown(os.path.join(layers[-1], APK_INSTALLED), 100000, 100000)
|
||||||
|
|
||||||
def merge_apk_scripts():
|
def merge_apk_scripts(layers):
|
||||||
tmp_tar_path = tempfile.mkstemp()[1]
|
tmp_tar_path = tempfile.mkstemp()[1]
|
||||||
files_in_tar = []
|
files_in_tar = []
|
||||||
with tarfile.open(tmp_tar_path, 'w:') as tmp_tar:
|
with tarfile.open(tmp_tar_path, 'w:') as tmp_tar:
|
||||||
@ -86,7 +86,7 @@ def merge_apk_scripts():
|
|||||||
else:
|
else:
|
||||||
os.unlink(tmp_tar_path)
|
os.unlink(tmp_tar_path)
|
||||||
|
|
||||||
def merge_apk_triggers():
|
def merge_apk_triggers(layers):
|
||||||
triggers = []
|
triggers = []
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
try:
|
try:
|
||||||
@ -101,7 +101,7 @@ def merge_apk_triggers():
|
|||||||
f.writelines(triggers)
|
f.writelines(triggers)
|
||||||
os.chown(os.path.join(layers[-1], APK_TRIGGERS), 100000, 100000)
|
os.chown(os.path.join(layers[-1], APK_TRIGGERS), 100000, 100000)
|
||||||
|
|
||||||
def merge_etc_passwd():
|
def merge_etc_passwd(layers):
|
||||||
passwd = {}
|
passwd = {}
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
try:
|
try:
|
||||||
@ -115,7 +115,7 @@ def merge_etc_passwd():
|
|||||||
f.writelines(passwd.values())
|
f.writelines(passwd.values())
|
||||||
os.chown(os.path.join(layers[-1], ETC_PASSWD), 100000, 100000)
|
os.chown(os.path.join(layers[-1], ETC_PASSWD), 100000, 100000)
|
||||||
|
|
||||||
def merge_etc_group():
|
def merge_etc_group(layers):
|
||||||
groups = {}
|
groups = {}
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
try:
|
try:
|
||||||
@ -141,7 +141,7 @@ def merge_etc_group():
|
|||||||
f.writelines([':'.join(group) for group in groups.values()])
|
f.writelines([':'.join(group) for group in groups.values()])
|
||||||
os.chown(os.path.join(layers[-1], ETC_GROUP), 100000, 100000)
|
os.chown(os.path.join(layers[-1], ETC_GROUP), 100000, 100000)
|
||||||
|
|
||||||
def merge_etc_shadow():
|
def merge_etc_shadow(layers):
|
||||||
shadow = {}
|
shadow = {}
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
try:
|
try:
|
||||||
@ -159,17 +159,16 @@ def merge_etc_shadow():
|
|||||||
parser = argparse.ArgumentParser(description='APK database merge script')
|
parser = argparse.ArgumentParser(description='APK database merge script')
|
||||||
parser.add_argument('layers', help='Path to LXC layers to be merged', nargs=argparse.REMAINDER)
|
parser.add_argument('layers', help='Path to LXC layers to be merged', nargs=argparse.REMAINDER)
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 3:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
layers = args.layers[::-1]
|
|
||||||
|
|
||||||
merge_apk_world()
|
merge_apk_world(args.layers)
|
||||||
merge_apk_installed()
|
merge_apk_installed(args.layers)
|
||||||
merge_apk_scripts()
|
merge_apk_scripts(args.layers)
|
||||||
merge_apk_triggers()
|
merge_apk_triggers(args.layers)
|
||||||
|
|
||||||
merge_etc_passwd()
|
merge_etc_passwd(args.layers)
|
||||||
merge_etc_group()
|
merge_etc_group(args.layers)
|
||||||
merge_etc_shadow()
|
merge_etc_shadow(args.layers)
|
||||||
|
@ -94,7 +94,7 @@ class ImageBuilder:
|
|||||||
|
|
||||||
def merge_layers(self, cmd):
|
def merge_layers(self, cmd):
|
||||||
layers = [self.get_layer_path(layer) for layer in self.image.conf['layers']]
|
layers = [self.get_layer_path(layer) for layer in self.image.conf['layers']]
|
||||||
subprocess.run(cmd + layers, check=True)
|
subprocess.run(cmd + layers[::-1], check=True)
|
||||||
|
|
||||||
def copy_files(self, src, dst):
|
def copy_files(self, src, dst):
|
||||||
dst = os.path.join(LXC_STORAGE_DIR, self.image.name, dst)
|
dst = os.path.join(LXC_STORAGE_DIR, self.image.name, dst)
|
||||||
|
Loading…
Reference in New Issue
Block a user