Linux installer: Fix downloading of signatures for older versions

Fixes #2042748 [Unable to install previous version in isolated mode](https://bugs.launchpad.net/calibre/+bug/2042748)
This commit is contained in:
Kovid Goyal 2023-11-05 08:18:56 +05:30
parent 018ce6dd93
commit b1aad38a4b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 6 deletions

View File

@ -654,8 +654,13 @@ def get_tarball_info(version):
global dl_url, signature, calibre_version
print('Downloading tarball signature securely...')
if version:
signature = get_https_resource_securely(
'https://code.calibre-ebook.com/signatures/calibre-' + version + '-' + arch + '.txz.sha512')
sigfname = 'calibre-' + version + '-' + arch + '.txz.sha512'
try:
signature = get_https_resource_securely('https://code.calibre-ebook.com/signatures/' + sigfname)
except HTTPError as err:
if err.code != 404:
raise
signature = get_https_resource_securely('https://code.calibre-ebook.com/signatures/old/' + sigfname)
calibre_version = version
dl_url = 'https://download.calibre-ebook.com/' + version + '/calibre-' + version + '-' + arch + '.txz'
else:
@ -815,7 +820,7 @@ except NameError:
def update_intaller_wrapper():
# To run: python3 -c "import runpy; runpy.run_path('setup/linux-installer.py', run_name='update_wrapper')"
# To update: python3 -c "import runpy; runpy.run_path('setup/linux-installer.py', run_name='update_wrapper')"
with open(__file__, 'rb') as f:
src = f.read().decode('utf-8')
wrapper = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'linux-installer.sh')

View File

@ -89,7 +89,8 @@ if py3:
from urllib.parse import urlparse
from urllib.request import BaseHandler, build_opener, Request, urlopen, getproxies, addinfourl
import http.client as httplib
encode_for_subprocess = lambda x: x
def encode_for_subprocess(x):
return x
else:
from future_builtins import map
from urlparse import urlparse
@ -702,8 +703,13 @@ def get_tarball_info(version):
global dl_url, signature, calibre_version
print('Downloading tarball signature securely...')
if version:
signature = get_https_resource_securely(
'https://code.calibre-ebook.com/signatures/calibre-' + version + '-' + arch + '.txz.sha512')
sigfname = 'calibre-' + version + '-' + arch + '.txz.sha512'
try:
signature = get_https_resource_securely('https://code.calibre-ebook.com/signatures/' + sigfname)
except HTTPError as err:
if err.code != 404:
raise
signature = get_https_resource_securely('https://code.calibre-ebook.com/signatures/old/' + sigfname)
calibre_version = version
dl_url = 'https://download.calibre-ebook.com/' + version + '/calibre-' + version + '-' + arch + '.txz'
else: