Use LZMA insteap of BZIP2 to compress the linux binary tarball, for a large size reduction (~30%)

This commit is contained in:
Kovid Goyal 2014-06-29 19:05:19 +05:30
parent d6b5176c65
commit 8f9fa74586
5 changed files with 16 additions and 12 deletions

View File

@ -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('<dt>Apple Mac</dt><dd><a href="{0}" title="{1}">{1}</a></dd>'.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 = ['<li><a href="{0}" title="{1}">{1}</a></li>'.format(
x, 'Linux 64-bit binary' if 'x86_64' in x else 'Linux 32-bit binary')

View File

@ -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}'

View File

@ -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')

View File

@ -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)

View File

@ -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'):