Skip to content

Commit

Permalink
Prepare scripts for aggregated signatures:
Browse files Browse the repository at this point in the history
 - fetch file signatures in contrib/add_cosigner.
 - detect cosigners in make_download.
 - format download page for aggregated signatures.
  • Loading branch information
ecdsa committed Dec 19, 2021
1 parent 195b470 commit bdbd593
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 27 deletions.
45 changes: 45 additions & 0 deletions contrib/add_cosigner
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/python3
import re
import os
import sys
import importlib

# load version.py; needlessly complicated alternative to "imp.load_source":
version_spec = importlib.util.spec_from_file_location('version', 'electrum/version.py')
version_module = importlib.util.module_from_spec(version_spec)
version_spec.loader.exec_module(version_module)

ELECTRUM_VERSION = version_module.ELECTRUM_VERSION
APK_VERSION = version_module.APK_VERSION
print("version", ELECTRUM_VERSION)

# GPG names of cosigner
cosigner = sys.argv[1]

version = version_win = version_mac = version_android = ELECTRUM_VERSION

files = {
'tgz': "Electrum-%s.tar.gz" % version,
'appimage': "electrum-%s-x86_64.AppImage" % version,
'mac': "electrum-%s.dmg" % version_mac,
'win': "electrum-%s.exe" % version_win,
'win_setup': "electrum-%s-setup.exe" % version_win,
'win_portable': "electrum-%s-portable.exe" % version_win,
'apk_arm64': "Electrum-%s-arm64-v8a-release.apk" % APK_VERSION,
'apk_armeabi': "Electrum-%s-armeabi-v7a-release.apk" % APK_VERSION,
}


for k, n in files.items():
path = "dist/%s"%n
link = "https://download.electrum.org/%s/%s"%(version,n)
if not os.path.exists(path):
os.system("wget -q %s -O %s" % (link, path))
if not os.path.getsize(path):
raise Exception(path)
sig_name = n + '.'+cosigner+'.asc'
sig_url = "https://raw.githubusercontent.com/spesmilo/electrum-signatures/master/%s/%s/%s"%(version, n, sig_name)
sig_path = "dist/%s"% sig_name
os.system("wget -nc %s -O %s"%(sig_url, sig_path))
if os.system("gpg --verify %s %s"%(sig_path, path)) != 0:
raise Exception(sig_name)
54 changes: 27 additions & 27 deletions contrib/make_download
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import re
import os
import sys
import importlib
from collections import defaultdict

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

dirname = sys.argv[1]

# GPG names of extra signers
extra_signers = sys.argv[2:]

print("directory", dirname)

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

# default signers
signers = ['ThomasV', 'SomberNight']

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

string = string.replace("##link_%s##"%k, link)
sig_ThomasV = link + '.ThomasV.asc'
sig_SomberNight = link + '.sombernight_releasekey.asc'
sigs = [
"<a href=\"%s\">%s</a>"%(sig_ThomasV, 'ThomasV'),
"<a href=\"%s\">%s</a>"%(sig_SomberNight, 'SomberNight'),
]
print("signers:", signers)

for signer in extra_signers:
sig_name = n + '.'+signer+'.asc'
sig_url = "https://raw.githubusercontent.com/spesmilo/electrum-signatures/master/%s/%s/%s"%(version, n, sig_name)
sig_path = "dist/%s"% sig_name
os.system("wget %s -O %s"%(sig_url, sig_path))
if os.system("gpg --verify %s %s"%(sig_path, path)) != 0:
raise Exception(sig_name)
sigs.append( "<a href=\"%s\">%s</a>"%(sig_url, signer) )
sigs = '\n'+',\n'.join(sigs)+'\n'
string = string.replace("##sigs_%s##"%k, sigs)
gpg_name = lambda x: 'sombernight_releasekey' if x=='SomberNight' else x
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)
string = string.replace("##signers_list##", signers_list)

for k, filename in files.items():
path = "dist/%s"%filename
assert filename in list_dir
link = "https://download.electrum.org/%s/%s"%(version, filename)
string = string.replace("##link_%s##"%k, link)
string = string.replace("##sigs_%s##"%k, link+'.asc')

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

0 comments on commit bdbd593

Please sign in to comment.