tis-thunderbird-en 52.0-44

  • package : tis-thunderbird-en
  • version : 52.0-44
  • description : Mozilla Email client POP IMAP LDAP
  • maintainer : TIS <technique@tranquil-it-systems.fr>
  • date : 2018-02-27 19:08:34

setup.py

#!/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 <http://www.gnu.org/licenses/>.
#
# -----------------------------------------------------------------------
from setuphelpers import *

uninstallkey = []

def in_use():
    return isrunning('thunderbird.exe')

def need_install(key,min_version=None,force=False):
    """Return True if the software with key can be found in uninstall registry
        and the registred version is equal or greater than min_version

    Args:
        key (str) : uninstall key
        min_version (str) : minimum version or None if don't check verion
    Returns:
        boolean

    """
    if force or not key:
        return True
    else:
        current = installed_softwares(uninstallkey=key)
        for soft in current:
            if not min_version or Version(soft['version']) >= Version(min_version):
                return False
        return True


def install_exe_if_needed(exe,silentflags='',key=None,min_version=None,killbefore=[],accept_returncodes=[0,1603,3010],timeout=300):
    """Install silently the supplied setup executable file, and add the uninstall key to
    global uninstallkey list if it is defined.

    Check if already installed at the supllied min_version.

    Kill the processes in killbefore list before launching the setup.

    Raises an error if, after the setup install, the uninstall key is not found in registry.

    Args:
        exe (str) : path to the setup exe file
        silentflags (str) : flags to append to the exe command line for silent install
                            if not provided, tries to guess them.
        key (str) : uninstall key to check in registry and to add to uninstallkey global list
        min_version (str) : if installed version is equal or gretaer than this, don't install
                            if not provided, guess it from exe setup file properties.
        kill_before (list of str) : processes to kill before setup, to avoid file locks
                                    issues.
    Returns:
        None

    """
    if not isfile(exe):
        error('setup exe file %s not found in package' % exe)
    if not silentflags:
        silentflags = getsilentflags(exe)
    if not min_version:
        min_version = getproductprops(exe)['version']

    import inspect
    caller_globals = inspect.stack()[1][0].f_globals
    WAPT = caller_globals.get('WAPT',None)
    force = WAPT and WAPT.options.force

    if need_install(key,min_version=min_version,force=force):
        if killbefore:
            killalltasks(killbefore)
        run(r'"%s" %s' % (exe,silentflags),accept_returncodes=accept_returncodes,timeout=timeout)
        if key and not installed_softwares(uninstallkey=key):
            error('Setup %s has been ran but the uninstall key %s can not be found' % (exe,key))
    else:
        print('Exe setup %s already installed. Skipping' % exe)
    if key:
        # will try to add key in the caller's (setup.py) uninstallkey list
        if 'uninstallkey' in caller_globals and not key in caller_globals['uninstallkey']:
            caller_globals['uninstallkey'].append(key)


def install():
    version = control.version.split('-',1)[0]
    ukey = 'Mozilla Thunderbird %s (x86 en-US)'%version
    exe = 'Thunderbird Setup %s.exe'%version

    print("Uninstall key %s"%ukey)
    install_exe_if_needed(exe,'-ms',key=ukey,min_version=version,killbefore=['thunderbird.exe'])

    print("Disabling auto update")
    filecopyto("mozilla.cfg",makepath(programfiles32,"Mozilla Thunderbird"))
    filecopyto("local-settings.js",makepath(programfiles32,"Mozilla Thunderbird","defaults","pref"))

def session_setup():
    #create_user_desktop_shortcut('thunderbird',makepath(programfiles32,"Mozilla Thunderbird","thunderbird.exe"))
    pass


def update_package():
    """updates the package / control version with the latest stable firefox version"""
    import re,requests,urlparse,glob

    # get index of all dowloads
    """
    url_base = 'https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/latest/win32/fr/'
    index = wgets(url_base)

    # get list of lastest french versions
    re_setup = re.compile(r'<a href=".*/(Thunderbird%20Setup%20[0-9.]*\.exe)">Thunderbird')
    url = url_base+filename
    """
    url = requests.head('https://download.mozilla.org/?product=thunderbird-latest&os=win&lang=en-US').headers['Location']
    filename = urlparse.unquote(url.rsplit('/',1)[1])

    if not isfile(filename):
        print('Downloading %s from %s'%(filename,url))
        wget(url,filename)

    # removes old exe
    if isfile(filename):
        exes = glob.glob('Thunderbird*.exe')
        for fn in exes:
            if fn != filename:
                remove_file(fn)

        # updates control version from filename, increment package version.
        control = PackageEntry().load_control_from_wapt ('.')
        control.version = '%s-%s'%(re.findall(r'Thunderbird Setup (.*)\.exe',filename)[0],int(control.version.split('-',1)[1])+1)
        control.save_control_to_wapt('.')


if __name__ == '__main__':
    update_package()

    

Changelog

No changelog
    

manifest.sha256

[["override.ini", "3c930ba0fce98f0a232101b76885a8fade8edd4a6ea19a00d372aaff426f0125"], ["local-settings.js", "78498a0d8c1e6b137e93081a785aacf63fccc3fb8f7ea04354d48224f5e1b357"], ["WAPT/icon.png", "b923d513ebd9944d0b686bc63806b5792582bdc3aa6b577e0743f1a674a7ad58"], ["WAPT/certificate.crt", "79e5388683c0b6cb03f4f81e4e58e3a11463b2b6cf169dd9c453098027dcfaa4"], ["WAPT/wapt.psproj", "bc34bb5f85d78dffc7effd37bd0639580a0e140c155973c04d79eb9aa31eb57a"], ["setup.py", "40936911a1f19b817fdf34ddb0f5d0b5a1c0e0f030e7e3576a67a9a2fccb4953"], ["mozilla.cfg", "a1075fa9c4f3ef5b34afa8e7db5919d95f23671f2046a791b050308a6e66dcd2"], ["userChrome.css", "46620dc25abe0400e625a0f078fc3ad9c4a668e0f880a7b451feb7d4fc084c26"], ["WAPT/control", "fc889ac93a5711ae234358e9f5646719af8f23aaf555e90dd439585b772f6d18"], ["Thunderbird Setup 52.0.exe", "03f67857d6e17a618ade66d0da56919d4597f5b44a1c461726aed444e33bda73"]]