From 8f9fa74586b7f05461902a9fa530916c5db7407c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 29 Jun 2014 19:05:19 +0530 Subject: [PATCH] Use LZMA insteap of BZIP2 to compress the linux binary tarball, for a large size reduction (~30%) --- setup/hosting.py | 4 ++-- setup/installer/linux/__init__.py | 2 +- setup/installer/linux/freeze2.py | 10 ++++++---- setup/linux-installer.py | 6 ++++-- setup/upload.py | 6 +++--- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/setup/hosting.py b/setup/hosting.py index 29509a7417..650e4db325 100644 --- a/setup/hosting.py +++ b/setup/hosting.py @@ -164,7 +164,7 @@ class GoogleCode(Base): # {{{ fname.endswith('.zip') else 'Installer') ext = os.path.splitext(fname)[1][1:] op = 'OpSys-'+{'msi':'Windows','exe':'Windows', - 'dmg':'OSX','bz2':'Linux','xz':'All'}[ext] + 'dmg':'OSX','txz':'Linux','xz':'All'}[ext] desc = self.files[fname] start = time.time() for i in range(retries): @@ -445,7 +445,7 @@ def generate_index(): # {{{ if osx: body.append('
Apple Mac
{1}
'.format( osx[0], 'OS X Disk Image (.dmg)')) - linux = [x for x in files if x.endswith('.bz2')] + linux = [x for x in files if x.endswith('.txz')] if linux: linux = ['
  • {1}
  • '.format( x, 'Linux 64-bit binary' if 'x86_64' in x else 'Linux 32-bit binary') diff --git a/setup/installer/linux/__init__.py b/setup/installer/linux/__init__.py index 20a8e7a31a..890edc825a 100644 --- a/setup/installer/linux/__init__.py +++ b/setup/installer/linux/__init__.py @@ -14,7 +14,7 @@ class Linux32(VMInstaller): description = 'Build 32bit linux binary installer' - INSTALLER_EXT = 'tar.bz2' + INSTALLER_EXT = 'txz' VM_NAME = 'linux32-build' FREEZE_COMMAND = 'linux_freeze' FREEZE_TEMPLATE = 'python -OO setup.py {freeze_command}' diff --git a/setup/installer/linux/freeze2.py b/setup/installer/linux/freeze2.py index b25b34e400..704a5139c6 100644 --- a/setup/installer/linux/freeze2.py +++ b/setup/installer/linux/freeze2.py @@ -260,10 +260,12 @@ class LinuxFreeze(Command): tf.add(x) finally: os.chdir(cwd) - subprocess.check_call(['bzip2', '-f', '-9', dist]) - dist += '.bz2' - self.info('Archive %s created: %.2f MB'%(dist, - os.stat(dist).st_size/(1024.**2))) + self.info('Compressing archive...') + subprocess.check_call(['xz', '-f', '-9', dist]) + ans = dist.rpartition('.')[0] + '.txz' + os.rename(dist + '.xz', ans) + self.info('Archive %s created: %.2f MB'%( + os.path.basename(ans), os.stat(ans).st_size/(1024.**2))) def build_launchers(self): self.obj_dir = self.j(self.src_root, 'build', 'launcher') diff --git a/setup/linux-installer.py b/setup/linux-installer.py index 780af4426f..776f90ebc7 100644 --- a/setup/linux-installer.py +++ b/setup/linux-installer.py @@ -290,7 +290,8 @@ def do_download(dest): prints('Downloaded %s bytes'%os.path.getsize(dest)) def download_tarball(): - fname = 'calibre-%s-i686.tar.bz2'%calibre_version + ext = 'tar.bz2' if calibre_version.startswith('1.') else 'txz' + fname = 'calibre-%s-i686.%s'%(calibre_version, ext) if is64bit: fname = fname.replace('i686', 'x86_64') tdir = tempfile.gettempdir() @@ -592,9 +593,10 @@ def get_https_resource_securely(url, timeout=60, max_redirects=5, ssl_version=No # }}} def extract_tarball(raw, destdir): + c = 'j' if calibre_version.startswith('1.') else 'J' prints('Extracting application files...') with open('/dev/null', 'w') as null: - p = subprocess.Popen(['tar', 'xjof', '-', '-C', destdir], stdout=null, stdin=subprocess.PIPE, close_fds=True, + p = subprocess.Popen(['tar', 'x%sof' % c, '-', '-C', destdir], stdout=null, stdin=subprocess.PIPE, close_fds=True, preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL)) p.stdin.write(raw) diff --git a/setup/upload.py b/setup/upload.py index 8ef0dc1fc8..6fc2cba8aa 100644 --- a/setup/upload.py +++ b/setup/upload.py @@ -26,8 +26,8 @@ STAGING_USER = 'root' STAGING_DIR = '/root/staging' def installers(): - installers = list(map(installer_name, ('dmg', 'msi', 'tar.bz2'))) - installers.append(installer_name('tar.bz2', is64bit=True)) + installers = list(map(installer_name, ('dmg', 'msi', 'txz'))) + installers.append(installer_name('txz', is64bit=True)) installers.append(installer_name('msi', is64bit=True)) installers.insert(0, 'dist/%s-%s.tar.xz'%(__appname__, __version__)) installers.append('dist/%s-portable-installer-%s.exe'%(__appname__, __version__)) @@ -36,7 +36,7 @@ def installers(): def installer_description(fname): if fname.endswith('.tar.xz'): return 'Source code' - if fname.endswith('.tar.bz2'): + if fname.endswith('.txz'): bits = '32' if 'i686' in fname else '64' return bits + 'bit Linux binary' if fname.endswith('.msi'):