Mozilla Thunderbird for WAPT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.py 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # -----------------------------------------------------------------------
  4. # This file is part of WAPT
  5. # Copyright (C) 2013 Tranquil IT Systems http://www.tranquil.it
  6. # WAPT aims to help Windows systems administrators to deploy
  7. # setup and update applications on users PC.
  8. #
  9. # WAPT is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # WAPT is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with WAPT. If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # -----------------------------------------------------------------------
  23. from setuphelpers import *
  24. import time
  25. import subprocess
  26. uninstallkey = []
  27. def install():
  28. waptversion = Version(__version__)
  29. if waptversion > Version('1.5') :
  30. softname = 'Mozilla Thunderbird'
  31. versionsoft = control['version'].split('-',1)[0]
  32. check_installed = installed_softwares(softname)
  33. diskfreespacebefore = get_disk_free_space(programfiles)
  34. if check_installed:
  35. for uninstall in check_installed:
  36. if iswin64():
  37. if 'x86' in uninstall['name'] :
  38. print(u'Remove Thunderbird x86 for install Thunderbird x64' )
  39. if uninstall_key_exists(uninstall['key']):
  40. killalltasks('thunderbird.exe')
  41. cmd = WAPT.uninstall_cmd(uninstall['key'])
  42. run(cmd)
  43. time.sleep (5)
  44. version = control.version.split('-',1)[0]
  45. arch = control.architecture
  46. #locale = control.locale
  47. locale = 'fr'
  48. key='Mozilla Thunderbird %s (%s %s)' % (version,'x64' if iswin64() else 'x86',locale)
  49. 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'])
  50. print('Copy local settings')
  51. filecopyto("local-settings.cfg",install_location(key))
  52. filecopyto("local-settings.js",makepath(install_location(key),"defaults","pref"))
  53. diskfreespaceafter = get_disk_free_space(programfiles)
  54. difffreespace = diskfreespacebefore - diskfreespaceafter
  55. print(ur"Needed disk space : " + str(difffreespace))
  56. else:
  57. error('This package is not compatible with your WAPT version. Please upgrade to WAPT 1.5 or more.')
  58. def update_package():
  59. """updates the package / control version with the latest stable thunderbird version"""
  60. import re,requests,urlparse,glob
  61. filename = ''
  62. url = requests.head('https://download.mozilla.org/?product=thunderbird-latest').headers['Location']
  63. exe = urlparse.unquote(url.rsplit('/',1)[1])
  64. version = re.findall(r'Thunderbird Setup (.*)\.exe',exe)[0]
  65. control = PackageEntry().load_control_from_wapt ('.')
  66. for arch in ['32','64']:
  67. filename = makepath('win%s' % arch, exe)
  68. url = 'https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/%s/win%s/fr/Thunderbird%sSetup%s%s.exe' % (version,arch,'%20','%20',version)
  69. if not isfile(filename):
  70. print('Downloading %s from %s'%(filename,url))
  71. wget(url,filename)
  72. # removes old exe
  73. if isfile(filename):
  74. exes = glob.glob(r'win%s\Thunderbird*.exe' % arch)
  75. for fn in exes:
  76. if fn != filename:
  77. remove_file(fn)
  78. if Version(version) > Version(control['version'].split('-',1)[0]):
  79. print('Updating package to %s' % version)
  80. # updates control version from filename, increment package version.
  81. control.version = '%s-%s'%(re.findall(r'Thunderbird Setup (.*)\.exe',filename)[0],0)
  82. control.save_control_to_wapt('.')
  83. else:
  84. print('No update available')
  85. if __name__ == '__main__':
  86. update_package()