From 2d23f6d493b15bfc4e7d575c9383fbcccd58503e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 5 Sep 2012 10:05:55 +0530 Subject: [PATCH] Update published signatures when re-uploading an installer --- setup/upload.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/setup/upload.py b/setup/upload.py index a73d0d2c31..f4e8706d1d 100644 --- a/setup/upload.py +++ b/setup/upload.py @@ -47,6 +47,21 @@ def installer_description(fname): return 'Calibre Portable' return 'Unknown file' +def upload_signatures(): + tdir = mkdtemp() + for installer in installers(): + if not os.path.exists(installer): + continue + with open(installer, 'rb') as f: + raw = f.read() + fingerprint = hashlib.sha512(raw).hexdigest() + fname = os.path.basename(installer+'.sha512') + with open(os.path.join(tdir, fname), 'wb') as f: + f.write(fingerprint) + check_call('scp %s/*.sha512 divok:%s/signatures/' % (tdir, DOWNLOADS), + shell=True) + shutil.rmtree(tdir) + class ReUpload(Command): # {{{ description = 'Re-uplaod any installers present in dist/' @@ -57,6 +72,7 @@ class ReUpload(Command): # {{{ opts.replace = True def run(self, opts): + upload_signatures() for x in installers(): if os.path.exists(x): os.remove(x) @@ -223,19 +239,7 @@ class UploadToServer(Command): # {{{ %(__version__, DOWNLOADS), shell=True) check_call('ssh divok /etc/init.d/apache2 graceful', shell=True) - tdir = mkdtemp() - for installer in installers(): - if not os.path.exists(installer): - continue - with open(installer, 'rb') as f: - raw = f.read() - fingerprint = hashlib.sha512(raw).hexdigest() - fname = os.path.basename(installer+'.sha512') - with open(os.path.join(tdir, fname), 'wb') as f: - f.write(fingerprint) - check_call('scp %s/*.sha512 divok:%s/signatures/' % (tdir, DOWNLOADS), - shell=True) - shutil.rmtree(tdir) + upload_signatures() # }}} # Testing {{{