mirror of
https://github.com/devplayer0/docker-net-dhcp
synced 2024-10-30 09:20:28 +00:00
push script: Fix buildx mangled symlinks
This commit is contained in:
parent
e62d1b19e3
commit
743aa65fbb
@ -90,10 +90,19 @@ class DXF(dxf.DXF):
|
||||
self.set_manifest(ref, mf, mime=mime)
|
||||
return size, digest
|
||||
|
||||
def fix_slash(info: tarfile.TarInfo):
|
||||
if info.name == '':
|
||||
info.name = '.'
|
||||
return info
|
||||
def tar_filter(p: Platform):
|
||||
def f(info: tarfile.TarInfo):
|
||||
# Ensure there's no directory called '/'
|
||||
if info.name == '':
|
||||
info.name = '.'
|
||||
|
||||
# buildx messes up symlink targets...
|
||||
platform_prefix = f'/{p.dirname}'
|
||||
if info.issym() and info.linkname.startswith(platform_prefix):
|
||||
info.linkname = info.linkname[len(platform_prefix):]
|
||||
|
||||
return info
|
||||
return f
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Construct and push a multiarch Docker plugin')
|
||||
@ -127,7 +136,7 @@ def main():
|
||||
with tarfile.open(name=tar_name, mode='w', fileobj=gz) as tar:
|
||||
path = os.path.join(args.rootfs, p.dirname)
|
||||
print(f"tar'ing and gzip'ing {path}")
|
||||
tar.add(path, arcname='', filter=fix_slash)
|
||||
tar.add(path, arcname='', filter=tar_filter(p))
|
||||
f.seek(0, os.SEEK_SET)
|
||||
|
||||
sha256 = hashlib.sha256()
|
||||
|
Loading…
Reference in New Issue
Block a user