Skip to content

Commit bdbd593

Browse files
committed
Prepare scripts for aggregated signatures:
- fetch file signatures in contrib/add_cosigner. - detect cosigners in make_download. - format download page for aggregated signatures.
1 parent 195b470 commit bdbd593

File tree

2 files changed

+72
-27
lines changed

2 files changed

+72
-27
lines changed

contrib/add_cosigner

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/python3
2+
import re
3+
import os
4+
import sys
5+
import importlib
6+
7+
# load version.py; needlessly complicated alternative to "imp.load_source":
8+
version_spec = importlib.util.spec_from_file_location('version', 'electrum/version.py')
9+
version_module = importlib.util.module_from_spec(version_spec)
10+
version_spec.loader.exec_module(version_module)
11+
12+
ELECTRUM_VERSION = version_module.ELECTRUM_VERSION
13+
APK_VERSION = version_module.APK_VERSION
14+
print("version", ELECTRUM_VERSION)
15+
16+
# GPG names of cosigner
17+
cosigner = sys.argv[1]
18+
19+
version = version_win = version_mac = version_android = ELECTRUM_VERSION
20+
21+
files = {
22+
'tgz': "Electrum-%s.tar.gz" % version,
23+
'appimage': "electrum-%s-x86_64.AppImage" % version,
24+
'mac': "electrum-%s.dmg" % version_mac,
25+
'win': "electrum-%s.exe" % version_win,
26+
'win_setup': "electrum-%s-setup.exe" % version_win,
27+
'win_portable': "electrum-%s-portable.exe" % version_win,
28+
'apk_arm64': "Electrum-%s-arm64-v8a-release.apk" % APK_VERSION,
29+
'apk_armeabi': "Electrum-%s-armeabi-v7a-release.apk" % APK_VERSION,
30+
}
31+
32+
33+
for k, n in files.items():
34+
path = "dist/%s"%n
35+
link = "https://download.electrum.org/%s/%s"%(version,n)
36+
if not os.path.exists(path):
37+
os.system("wget -q %s -O %s" % (link, path))
38+
if not os.path.getsize(path):
39+
raise Exception(path)
40+
sig_name = n + '.'+cosigner+'.asc'
41+
sig_url = "https://raw.githubusercontent.com/spesmilo/electrum-signatures/master/%s/%s/%s"%(version, n, sig_name)
42+
sig_path = "dist/%s"% sig_name
43+
os.system("wget -nc %s -O %s"%(sig_url, sig_path))
44+
if os.system("gpg --verify %s %s"%(sig_path, path)) != 0:
45+
raise Exception(sig_name)

contrib/make_download

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import re
33
import os
44
import sys
55
import importlib
6+
from collections import defaultdict
67

78
# load version.py; needlessly complicated alternative to "imp.load_source":
89
version_spec = importlib.util.spec_from_file_location('version', 'electrum/version.py')
@@ -15,9 +16,6 @@ print("version", ELECTRUM_VERSION)
1516

1617
dirname = sys.argv[1]
1718

18-
# GPG names of extra signers
19-
extra_signers = sys.argv[2:]
20-
2119
print("directory", dirname)
2220

2321
download_page = os.path.join(dirname, "panel-download.html")
@@ -44,33 +42,35 @@ files = {
4442
'apk_armeabi': "Electrum-%s-armeabi-v7a-release.apk" % APK_VERSION,
4543
}
4644

45+
# default signers
46+
signers = ['ThomasV', 'SomberNight']
4747

48-
for k, n in files.items():
49-
path = "dist/%s"%n
50-
link = "https://download.electrum.org/%s/%s"%(version,n)
51-
if not os.path.exists(path):
52-
os.system("wget -q %s -O %s" % (link, path))
53-
if not os.path.getsize(path):
54-
raise Exception(path)
48+
# detect extra signers
49+
list_dir = os.listdir('dist')
50+
detected_sigs = defaultdict(set)
51+
for f in list_dir:
52+
if f.endswith('.asc'):
53+
parts = f.split('.')
54+
signer = parts[-2]
55+
filename = '.'.join(parts[0:-2])
56+
detected_sigs[signer].add(filename)
57+
for k, v in detected_sigs.items():
58+
if v == set(files.values()):
59+
if k not in signers:
60+
signers.append(k)
5561

56-
string = string.replace("##link_%s##"%k, link)
57-
sig_ThomasV = link + '.ThomasV.asc'
58-
sig_SomberNight = link + '.sombernight_releasekey.asc'
59-
sigs = [
60-
"<a href=\"%s\">%s</a>"%(sig_ThomasV, 'ThomasV'),
61-
"<a href=\"%s\">%s</a>"%(sig_SomberNight, 'SomberNight'),
62-
]
62+
print("signers:", signers)
6363

64-
for signer in extra_signers:
65-
sig_name = n + '.'+signer+'.asc'
66-
sig_url = "https://raw.githubusercontent.com/spesmilo/electrum-signatures/master/%s/%s/%s"%(version, n, sig_name)
67-
sig_path = "dist/%s"% sig_name
68-
os.system("wget %s -O %s"%(sig_url, sig_path))
69-
if os.system("gpg --verify %s %s"%(sig_path, path)) != 0:
70-
raise Exception(sig_name)
71-
sigs.append( "<a href=\"%s\">%s</a>"%(sig_url, signer) )
72-
sigs = '\n'+',\n'.join(sigs)+'\n'
73-
string = string.replace("##sigs_%s##"%k, sigs)
64+
gpg_name = lambda x: 'sombernight_releasekey' if x=='SomberNight' else x
65+
signers_list = ', '.join("<a href=\"https://raw.githubusercontent.com/spesmilo/electrum/master/pubkeys/%s.asc\">%s</a>"%(gpg_name(x), x) for x in signers)
66+
string = string.replace("##signers_list##", signers_list)
67+
68+
for k, filename in files.items():
69+
path = "dist/%s"%filename
70+
assert filename in list_dir
71+
link = "https://download.electrum.org/%s/%s"%(version, filename)
72+
string = string.replace("##link_%s##"%k, link)
73+
string = string.replace("##sigs_%s##"%k, link+'.asc')
7474

7575
with open(download_page,'w') as f:
7676
f.write(string)

0 commit comments

Comments
 (0)