Spotter-VM/zz-extra/fix-apk
2018-09-12 16:12:23 +02:00

35 lines
1.1 KiB
Python

#!/usr/bin/python3
import os
import sys
def fix_installed(layers):
installed = []
for layer in layers[:-1]:
with open(os.path.join(layer, 'lib/apk/db/installed'), 'r') as fd:
buffer = []
for line in df:
if line.startswith('C:'):
buffer = ''.join(buffer)
if buffer not in installed:
installed.append(buffer)
buffer = []
buffer.append(line)
os.makedirs(os.path.join(layers[-1], 'lib/apk/db', 0o755, True))
with open(os.path.join(layers[-1], 'lib/apk/db/installed'), 'w') as fd:
fd.writelines(world_items)
def fix_world(layers):
world = []
for layer in layers[:-1]:
with open(os.path.join(layer, 'etc/apk/world'), 'r') as fd:
for line in fd:
if line in world:
world.append(world)
os.makedirs(os.path.join(layers[-1], 'etc/apk', 0o755, True))
with open(os.path.join(layers[-1], 'etc/apk/world'), 'w') as fd:
fd.writelines(world_items)
fix_installed(sys.argv)
fix_world(sys.argv)