#!/usr/bin/python # -*- coding: utf-8 -*- # ----------------------------------------------------------------------- # This file is part of WAPT # Copyright (C) 2013 Tranquil IT Systems http://www.tranquil.it # WAPT aims to help Windows systems administrators to deploy # setup and update applications on users PC. # # WAPT is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # WAPT is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with WAPT. If not, see . # # ----------------------------------------------------------------------- from setuphelpers import * import time import subprocess uninstallkey = [] def on_dist_backup(operation,src,dst): # When we backup the distribution dir, we have to exclude # lightning as a new version will be installed, bundled with TB itself. # Everything else should be backed up if src.endswith("{e2fda1a4-762b-4020-b5ad-a41df1933103}.xpi"): print("Skiping Lightning XPI") return False else: return True def install(): waptversion = Version(__version__) # Backup distribution/extensions as a TB upgrade wipe it backup_dist = False if isdir(makepath(programfiles, "Mozilla Thunderbird", "distribution")): print("Taking a backup of the distribution directory") backup_dist = True copytree2(src=makepath(programfiles, "Mozilla Thunderbird", "distribution"), dst="distribution", oncopy=on_dist_backup) if waptversion > Version('1.5') : softname = 'Mozilla Thunderbird' versionsoft = control['version'].split('-',1)[0] check_installed = installed_softwares(softname) diskfreespacebefore = get_disk_free_space(programfiles) if check_installed: for uninstall in check_installed: if iswin64(): if 'x86' in uninstall['name'] : print(u'Remove Thunderbird x86 for install Thunderbird x64' ) if uninstall_key_exists(uninstall['key']): killalltasks('thunderbird.exe') cmd = WAPT.uninstall_cmd(uninstall['key']) run(cmd) time.sleep (5) version = control.version.split('-',1)[0] major_version = control.version.split('.',1)[0] arch = control.architecture #locale = control.locale locale = 'fr' key='Mozilla Thunderbird %s (%s %s)' % (version,'x64' if iswin64() else 'x86',locale) install_exe_if_needed(r'win%s\Thunderbird Setup %s.exe' % ('64' if iswin64() else '32',version),silentflags='-ms',key=key ,min_version=version,killbefore=['thunderbird.exe']) print('Copy local settings') filecopyto("local-settings.cfg",install_location(key)) filecopyto("local-settings.js",makepath(install_location(key),"defaults","pref")) diskfreespaceafter = get_disk_free_space(programfiles) difffreespace = diskfreespacebefore - diskfreespaceafter print(ur"Needed disk space : " + str(difffreespace)) # Now restore distribution backup if backup_dist: print("Restoring distribution directory") copytree2(src=r'distribution', dst=makepath(programfiles, "Mozilla Thunderbird", "distribution")) else: error('This package is not compatible with your WAPT version. Please upgrade to WAPT 1.5 or more.') def update_package(): """updates the package / control version with the latest stable thunderbird version""" import re,requests,urlparse,glob filename = '' url = requests.head('https://download.mozilla.org/?product=thunderbird-latest').headers['Location'] exe = urlparse.unquote(url.rsplit('/',1)[1]) version = re.findall(r'Thunderbird Setup (.*)\.exe',exe)[0] control = PackageEntry().load_control_from_wapt ('.') for arch in ['32','64']: filename = makepath('win%s' % arch, exe) url = 'https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/%s/win%s/fr/Thunderbird%sSetup%s%s.exe' % (version,arch,'%20','%20',version) if not isfile(filename): print('Downloading %s from %s'%(filename,url)) wget(url,filename) # removes old exe if isfile(filename): exes = glob.glob(r'win%s\Thunderbird*.exe' % arch) for fn in exes: if fn != filename: remove_file(fn) if Version(version) > Version(control['version'].split('-',1)[0]): print('Updating package to %s' % version) # updates control version from filename, increment package version. control.version = '%s-%s'%(re.findall(r'Thunderbird Setup (.*)\.exe',filename)[0],0) control.maturity = 'PREPROD' control.save_control_to_wapt('.') else: print('No update available') if __name__ == '__main__': update_package()