Skip to content

Commit

Permalink
Rename /ios/apk to /ish/apk, add /ish/version
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Nov 29, 2020
1 parent 5a209d8 commit 31251b2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM --platform=linux/386 alpine:3.12.0 AS ish-alpine
RUN touch /etc/ish-version

FROM ish-alpine
LABEL ish.export=appstore.tar.gz
Expand All @@ -8,5 +7,6 @@ RUN : > /etc/motd

FROM ish-alpine
LABEL ish.export=appstore-apk.tar.gz
RUN mkdir /ish && touch /ish/version
COPY apk-motd /etc/motd
COPY odr-repositories /etc/apk/repositories
23 changes: 20 additions & 3 deletions flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,48 @@
import tarfile

WHITEOUT = '.wh.'
WHITEOUT_OPAQUE = '.wh..wh..opq'

def flatten(image, output):
manifest = json.load(image.extractfile('manifest.json'))
assert len(manifest) == 1
manifest = manifest[0]

entries = {}
layers = [tarfile.open(fileobj=image.extractfile(layer)) for layer in manifest['Layers']]
for layer in layers:
real_members = []
# process whiteout files
for info in layer.getmembers():
info.name = './' + info.name
dirname, sep, basename = info.name.rpartition('/')
if basename.startswith(WHITEOUT):

if basename == WHITEOUT_OPAQUE:
for key in entries.keys():
if key.startswith(dirname+sep):
del entries[key]
elif basename.startswith(WHITEOUT):
del entries[dirname+sep+basename[len(WHITEOUT):]]
else:
entries[info.name] = layer, info
real_members.append(info)
continue

# real files
for info in real_members:
entries[info.name] = layer, info

# need a root entry
if './' not in entries:
info = tarfile.TarInfo('./')
info.type = tarfile.DIRTYPE
info.mode = 0o755
entries[info.name] = None, info

for layer, info in entries.values():
fileobj = layer.extractfile(info) if info.isfile() else None
info.mtime = 0
info.mtime = 0 # make reproducible
output.addfile(info, fileobj)

for layer in layers:
layer.close()

Expand Down
2 changes: 1 addition & 1 deletion odr-repositories
Original file line number Diff line number Diff line change
@@ -1 +1 @@
file:///ios/apk/main
file:///ish/apk/main

0 comments on commit 31251b2

Please sign in to comment.