Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/auto-bootstraps/
Date: Mon, 01 Jun 2020 08:37:52
Message-Id: 1591000657.35f3015c8331414d5e298c9031b9fbdd2320aad7.grobian@gentoo
1 commit: 35f3015c8331414d5e298c9031b9fbdd2320aad7
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jun 1 08:37:37 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon Jun 1 08:37:37 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=35f3015c
7
8 scripts/auto-bootstraps/update_distfiles: try to populate mirror structure
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 scripts/auto-bootstraps/update_distfiles.py | 16 +++++++++++++++-
13 1 file changed, 15 insertions(+), 1 deletion(-)
14
15 diff --git a/scripts/auto-bootstraps/update_distfiles.py b/scripts/auto-bootstraps/update_distfiles.py
16 index c8c54b7aa7..9287afa83e 100755
17 --- a/scripts/auto-bootstraps/update_distfiles.py
18 +++ b/scripts/auto-bootstraps/update_distfiles.py
19 @@ -7,7 +7,7 @@ import sys
20 distfilessrc='./distfiles'
21
22 def hash_file(f):
23 - hsh = hashlib.new('sha1')
24 + hsh = hashlib.sha1()
25 with open(f, 'rb') as fle:
26 hsh.update(fle.read())
27 return hsh.hexdigest()
28 @@ -20,6 +20,7 @@ with os.scandir(path=sys.argv[1]) as it:
29 h = hash_file(srcfile)
30 distname = os.path.join(distfilessrc,
31 f.name + "@" + h).lower()
32 + isnew = False
33 if os.path.exists(distname):
34 print("DUP %s" % distname.split('/')[-1])
35 os.remove(srcfile)
36 @@ -27,3 +28,16 @@ with os.scandir(path=sys.argv[1]) as it:
37 else:
38 print("NEW %s" % distname.split('/')[-1])
39 os.link(srcfile, distname)
40 + isnew = True
41 +
42 + # generate a name match for distfiles serving along the
43 + # specification from gentoo-dev ML 18 Oct 2019 15:41:32 +0200
44 + # 4c7465824f1fb69924c826f6bbe3ee73afa08ec8.camel@g.o
45 + blh = hashlib.blake2b(bytes(f.name.encode('us-ascii'))).hexdigest()
46 + trgpth = os.path.join(distfilessrc, 'public', blh[:2], f.name);
47 + if isnew or !os.path.exists(trgpth):
48 + if os.path.exists(trgpth):
49 + os.remove(trgpth)
50 + os.makedirs(os.path.join(distfilessrc, 'public', blh[:2]),
51 + exist_ok=True)
52 + os.link(distname, trgpth);