tis-libreoffice64 5.4.7.2-22

  • package : tis-libreoffice64
  • version : 5.4.7.2-22
  • description : Office Suite LibreOffice stable 64b + Help. Uninstall libreooffice 3.xx and OpenOffice 3.xx
  • maintainer : TIS <technique@tranquil-it-systems.fr>
  • date : 2018-05-18 11:57:33

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/>.
#
# -----------------------------------------------------------------------
import platform
from setuphelpers import *

uninstallkey = []

def file_assoc(ext):
    """Renvoie le type d'application associe à une extension (exemple : .doc)"""
    return registry_readstring(HKEY_CLASSES_ROOT,ext,None).lower()

def find_msis():
    """Returns msi filename and properties"""
    allmsi = glob.glob('*.msi')

    result = []
    for msi in allmsi:
        # uninstallkey is in msi db
        props = get_msi_properties(msi)
        result.append((msi,props))
    return result


def update_control(entry):
    """Magic Callback to update control version data at build step"""
    (version,packaging) = entry.version.split('-',1)
    msis = find_msis()
    # use first msi's version for the package version
    for (msi,props) in msis:
        if not 'helppack' in msi:
            entry.version = "%s-%s"%(props['ProductVersion'],packaging)
            break

def install():
    """Called by wapt-get or waptservice to install the package"""

    diskfreespacebefore = get_disk_free_space(programfiles)

    # uninstall previous libreoffice or openoffice 3.xx
    old_libreoff = installed_softwares('libreoffice 3.')
    old_openoff = installed_softwares('openoffice')
    old_office = old_libreoff + old_openoff
    if old_office:
        for uninstall in old_office:
            if uninstall['version'].startswith('3.'):
                cmd = WAPT.uninstall_cmd(uninstall['key'])
                print(u'uninstalling %s' % (uninstall['name'],))
                run(cmd)

    msis = find_msis()
    for (msi,props) in msis:
        # uninstallkey is in msi db
        msikey = props['ProductCode']
        print('Adding uninstall key : %s'%msikey)
        uninstallkey.append(msikey)

        # check if product is already installed
        if WAPT.options.force or not installed_softwares(msikey):
            killalltasks('soffice.bin')
            print("Installing %s..."%(props['ProductName']))
            args = ["msiexec /norestart /quiet /i %s"%msi]
            if not 'helppack' in msi:
                # don't register extensions if Office is installed
                if not file_assoc('.doc').startswith('word.'):
                    args.append('SELECT_WORD=1')
                if not file_assoc('.xls').startswith('excel'):
                    args.append('SELECT_EXCEL=1')
                if not file_assoc('.ppt').startswith('powerpoint'):
                    args.append('SELECT_POWERPOINT=1')

                args.append('CREATEDESKTOPLINK=0')
                args.append('RebootYesNo=No')
                args.append('ALLUSER=1')
                args.append('ISCHECKFORPRODUCTUPDATES=0')
                args.append('QUICKSTART=0')
            cmd = ' '.join(args)
            run(cmd,timeout=1200,accept_returncodes=[0,1601])
            print("Done install %s..."%(props['ProductName']))
        else:
            print("%s already installed, skipping..."%props['ProductName'])

    diskfreespaceafter = get_disk_free_space(programfiles)

    difffreespace = diskfreespacebefore - diskfreespaceafter
    print (ur"Espace disque occupé :" + str(difffreespace))

def update_package():
    htmlSource = wgets("https://www.libreoffice.org/download/download/").splitlines()
    foundoffice = False
    found = False
    for line in htmlSource :
        if 'enterprise' in line:
            found = True
        if found == True:
            if 'http://download.documentfoundation.org/libreoffice/stable/' in line:
                start = line.find("/stable/")
                startversion = start + 8
                end = line.find("/win/")
                realversion = line[startversion:end]
                break

    helpx64 = "LibreOffice_%s_Win_x64_helppack_fr.msi" % realversion
    msix64 = "LibreOffice_%s_Win_x64.msi" % realversion
    url = "http://download.documentfoundation.org/libreoffice/stable/%s/win/" % realversion


    if not isfile(msix64):
        wget(url + "x86_64/" +msix64,msix64)
    else:
        print(msix64 + ' already exist')

    if not isfile(helpx64):
        wget(url + "x86_64/" +helpx64,helpx64)
    else:
        print(helpx64 + ' already exist')


    lastest_version = get_msi_properties(msix64)['ProductVersion']

    allmsi = glob.glob('*.msi')
    for msi in allmsi:
        vers = get_msi_properties(msi)['ProductVersion']
        if vers != lastest_version :
            remove_file(msi)

    # change version of package
    from waptpackage import PackageEntry
    pe = PackageEntry()
    pe.load_control_from_wapt(os.getcwd())
    pe.version = lastest_version +'-0'
    pe.save_control_to_wapt(os.getcwd())

if __name__ == '__main__':
    update_package()


    

Changelog

No changelog
    

manifest.sha256

[["WAPT/icon.png", "3f684b7ed5fd1b380e8f796ddb42056eb7a44c4005c894a7c44711b064886cdc"], ["WAPT/certificate.crt", "13fb474c5c23c135a77aba592eb8821b9ecbcc463f5b7312312b87b20eac6779"], ["WAPT/wapt.psproj", "df3e2fa87fea9c7bdfcc22039b9ef7303f092898882d9f3f4233f5d92f90b3c7"], ["LibreOffice_5.4.7_Win_x64_helppack_fr.msi", "f03c974bc6e722d10d1353a5fbc00f0963f04ee0b2c5fa7b4cb103e3f75ef916"], ["LibreOffice_5.4.7_Win_x64.msi", "25ac7a7bf942430524249bbd5990e84ce8555d1e53294f1e49f487d4f1e5a642"], ["setup.py", "ac74ea9b9efa9a65df56ff2fe138cc41312c3d1b480ce374e921b46b3dd737c4"], ["WAPT/control", "015be1977b269206a1da9ddaf4d424e72ccfb5b1813ee38836092923b3a5a291"]]