commit: 35f3015c8331414d5e298c9031b9fbdd2320aad7
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 1 08:37:37 2020 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 1 08:37:37 2020 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=35f3015c
scripts/auto-bootstraps/update_distfiles: try to populate mirror structure
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
scripts/auto-bootstraps/update_distfiles.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/scripts/auto-bootstraps/update_distfiles.py
b/scripts/auto-bootstraps/update_distfiles.py
index c8c54b7aa7..9287afa83e 100755
--- a/scripts/auto-bootstraps/update_distfiles.py
+++ b/scripts/auto-bootstraps/update_distfiles.py
@@ -7,7 +7,7 @@ import sys
distfilessrc='./distfiles'
def hash_file(f):
- hsh = hashlib.new('sha1')
+ hsh = hashlib.sha1()
with open(f, 'rb') as fle:
hsh.update(fle.read())
return hsh.hexdigest()
@@ -20,6 +20,7 @@ with os.scandir(path=sys.argv[1]) as it:
h = hash_file(srcfile)
distname = os.path.join(distfilessrc,
f.name + "@" + h).lower()
+ isnew = False
if os.path.exists(distname):
print("DUP %s" % distname.split('/')[-1])
os.remove(srcfile)
@@ -27,3 +28,16 @@ with os.scandir(path=sys.argv[1]) as it:
else:
print("NEW %s" % distname.split('/')[-1])
os.link(srcfile, distname)
+ isnew = True
+
+ # generate a name match for distfiles serving along the
+ # specification from gentoo-dev ML 18 Oct 2019 15:41:32 +0200
+ # [email protected]
+ blh = hashlib.blake2b(bytes(f.name.encode('us-ascii'))).hexdigest()
+ trgpth = os.path.join(distfilessrc, 'public', blh[:2], f.name);
+ if isnew or !os.path.exists(trgpth):
+ if os.path.exists(trgpth):
+ os.remove(trgpth)
+ os.makedirs(os.path.join(distfilessrc, 'public', blh[:2]),
+ exist_ok=True)
+ os.link(distname, trgpth);