tis-firefox-multi

84.0.1-17
Mozilla Firefox, is a free and open-source web browser - The package is multi-language and pre-configured
4874 downloads
Download

  Description 

  • package : tis-firefox-multi
  • version : 84.0.1-17
  • architecture : x86
  • categories : Internet
  • maintainer : WAPT Team, Tranquil IT, Jimmy PELÉ
  • description : Mozilla Firefox, is a free and open-source web browser - The package is multi-language and pre-configured
  • locale : all
  • target_os : windows
  • min_os_version : 6.1
  • max_os_version :
  • min_wapt_version : 1.8
  • sources : https://www.mozilla.org/firefox/all/#product-desktop-release
  • installed_size :
  • impacted_process : firefox
  • description_fr : Mozilla Firefox, est un navigateur web gratuit et open source - Le paquet est multilingue et préconfiguré
  • description_pl :
  • description_de :
  • description_es :
  • description_pt :
  • description_it :
  • description_nl :
  • description_ru :
  • editor : Mozilla Foundation,Mozilla Corporation
  • licence : MPL 2.0
  • signature_date : 2020-12-23T08:56:48.635714
  • Homepage : https://www.mozilla.org/
  • Conflicts :

  Setup.py 

# -*- coding: UTF-8 -*-
from setuphelpers import *
import time
import json
import platform

uninstallkey = []

# Installation procedure: https://firefox-source-docs.mozilla.org/browser/installer/windows/installer/FullConfig.html
# Configuration procedure: https://support.mozilla.org/kb/customizing-firefox-using-policiesjson

# Defining variables
bin_name_string = 'Firefox_Setup_%s.exe'
app_name ='Mozilla Firefox'
silent_args = '/S /InstallDirectoryName="%s" /PreventRebootRequired=false /TaskbarShortcut=false /DesktopShortcut=false /StartMenuShortcut=true /MaintenanceService=false /RegisterDefaultAgent=false /RemoveDistributionDir=true /OptionalExtensions=false' % app_name
list_pre_installed_lang = ['fr','en-GB','es-ES','de','it'] # Reminder: 'en-US' will be native
app_dir = makepath(programfiles,app_name)
dist_dir = 'distribution'
dist_path = makepath(app_dir,dist_dir)
ext_dir = 'extensions'
ext_path = makepath(dist_path,ext_dir)
policies_file = 'policies.json'
policies_path = makepath(dist_path,policies_file)


def install():
    # Initializing variables
    package_version = control.version.split('-')[0]
    bin_name = bin_name_string % package_version
    app_arch = control.architecture
    lang = get_language()
    app_processes_list = control.impacted_process.split(',')
    app_uninstallkey='Mozilla Firefox %s (%s en-US)' % (package_version,app_arch)
    basedir_policies_file = makepath(basedir,policies_file)
    policies_content = json_load(policies_file)
    if app_arch == 'x64':
        arch_to_uninstall = 'x86'
    else:
        arch_to_uninstall = 'x64'

    # Uninstalling others versions
    for uninstall in installed_softwares(name=app_name):
        if arch_to_uninstall in uninstall['name'] or 'ESR' in uninstall['name']:
            print('Incorrect version of %s found: %s' % (app_name,uninstall['name']))
            print('Removing: %s' % (uninstall['name']))
            killalltasks(app_processes_list)
            run(uninstall_cmd(uninstall['key']))
            time.sleep(15) # Required for Firefox

    # Installing the package
    print('Installing: %s' % bin_name)
    install_exe_if_needed(bin_name
        ,silentflags=silent_args
        ,key=app_uninstallkey
        ,min_version=package_version)

    # Making sure that Mozilla Maintenance Service is not installed
    for uninstall in installed_softwares(name="Mozilla Maintenance Service"):
        print('Removing: %s' % (uninstall['name']))
        run(uninstall_cmd(uninstall['key']))

    # Removing policies from registry since it bypass the policies.json file (source: https://support.mozilla.org/bm/questions/1236197)
    ffox_policies_reg_path = r'SOFTWARE\Policies\Mozilla\Firefox'
    if reg_key_exists(HKEY_LOCAL_MACHINE,ffox_policies_reg_path):
        registry_deletekey(HKEY_LOCAL_MACHINE,ffox_policies_reg_path,'',force=True)

    # Adding distribution folder for language packs, dictionaries, extensions and configuration
    if isdir(dist_path):
        remove_tree(dist_path)
    mkdirs(dist_path)
    filecopyto(makepath(basedir,policies_file),dist_path)
    copytree2(makepath(basedir,ext_dir),ext_path)

    # Changing default language
    data = json_load(policies_path)
    my_lang = get_language()
    for select_lang in list_pre_installed_lang:
        if my_lang in select_lang:
            if select_lang == 'en-GB':
                select_lang = 'en-US' 
            default_lang = {"RequestedLocales": ["%s" % select_lang]}
    data['policies'].update(default_lang)
    json_write(policies_path,data,indent=2)


def update_package():
    print('Downloading/Updating package content from upstream binary sources')

    # Initializing variables
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()

    app_arch = control.architecture
    bin_name_temp = 'Firefox_Setup.exe'
    latest_bin = bin_name_temp
    bin_exe = 'firefox.exe'
    policies_content = json_load(policies_file)

    # Translating package architechture
    if app_arch == 'x64':
        app_os = 'win64'
    else:
        app_os = 'win'

    # Download informations: https://archive.mozilla.org/pub/firefox/releases/latest/README.txt
    url_dl = 'https://download.mozilla.org/?product=firefox-latest-ssl&os=%s&lang=en-US' % app_os

    #print("Latest %s version is: %s" % (app_name,version))
    print("Download url is: %s" % url_dl)

    # Downloading latest binaries
    if isfile(bin_name_temp):
        remove_file(bin_name_temp)
    if not isfile(latest_bin):
        print('Downloading: ' + latest_bin)
        wget(url_dl,latest_bin,proxies=proxies)

        # Checking version from file
        unzip_with_7zip(bin_name_temp, filenames='firefox.exe', target='temp', recursive=True, extract_with_full_paths=False)
        version = get_version_from_binary(r'temp\firefox.exe')
        remove_tree('temp')
        print('Verified latest %s version is: %s' % (app_name,version))
        latest_bin = bin_name_string % version

        # Renaming the binary
        rename_filename(bin_name_temp,latest_bin)

        # Changing version of the package
        control.version = '%s-%s'%(version,int(control.version.split('-')[-1])+1)
        control.save_control_to_wapt()
        print('Changing version to: %s in WAPT\\control' % control.version)

    # Deleting outdated binaries
    remove_outdated_binary(version)

    # Download Firefox Language Packs
    #https://addons.mozilla.org/firefox/addon/fran%C3%A7ais-language-pack/versions/
    #https://addons.mozilla.org/firefox/addon/english-gb-language-pack/versions/
    url_api_lp = 'https://services.addons.mozilla.org/api/v3/addons/language-tools/?app=firefox&type=language'
    print('API used for language packs is: %s' % url_api_lp)
    version_major = control.version.split('-')[0].split('.')[0]

    if isdir(ext_dir):
        remove_tree(ext_dir)

    for lang in list_pre_installed_lang:
        json_read = json.loads(wgets(url_api_lp,proxies=proxies))
        for lp in json_read['results']:
            if lp['target_locale'] == lang:
                url_lp = lp['url'] + 'versions/'
                break

        #https://addons.mozilla.org/firefox/downloads/file/3605597/francais_language_pack-78.0buildid20200708170202-fx.xpi?src=dp-btn-primary
        #https://addons.mozilla.org/firefox/downloads/file/3605535/english_gb_language_pack-78.0buildid20200708170202-fx.xpi?src=dp-btn-primary

        for download_lp in bs_find_all(url_lp, 'a', 'class', 'Button Button--action AMInstallButton-button Button--puffy', proxies=proxies, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:%s.0) Gecko/20100101 Firefox/%s.0' % (version_major,version_major)}):
            if version_major in download_lp['href']:
                url_dl_lp = download_lp['href']
                break
        
        # Forming polices.json file
        lp_name = '%s_language_pack.xpi' % lang
        ext_settings_content = {
                "langpack-%s@firefox.mozilla.org" % lang: {
                    "install_url": "file://%s\\%s_language_pack.xpi" % (ext_path,lang),
                    "installation_mode": "force_installed"
                }
            }
        policies_content['policies']['ExtensionSettings'].update(ext_settings_content)

        print("Download url for language pack in %s is: %s" % (lang,url_dl_lp))
        print('Downloading: ' + lp_name)
        wget(url_dl_lp,makepath(ext_dir,lp_name),proxies=proxies)

    # Downloading dictionaries
    #https://addons.mozilla.org/firefox/addon/dictionnaire-fran%C3%A7ais1/
    #https://addons.mozilla.org/firefox/addon/british-english-dictionary-2/
    url_api_dict_lang = 'https://services.addons.mozilla.org/api/v3/addons/language-tools/?app=firefox&type=dictionary'
    print('API used for language dictionaries is: %s' % url_api_dict_lang)

    for lang in list_pre_installed_lang:
        # Debuggin DE lang
        if lang == 'de':
            lang = 'de-DE'
        json_read = json.loads(wgets(url_api_dict_lang,proxies=proxies))
        for dict_lang in json_read['results']:
            if dict_lang['target_locale'] == lang:
                url_dl_dict_lang = 'https://addons.mozilla.org/firefox/downloads/latest/%s/latest.xpi' % dict_lang['slug']
                ext_add_on_id = dict_lang['guid']
                break

        #https://addons.mozilla.org/firefox/downloads/latest/dictionnaire-fran%C3%A7ais1/latest.xpi
        #https://addons.mozilla.org/firefox/downloads/latest/british-english-dictionary-2/latest.xpi

        dict_lang_name = '%s_dictionary.xpi' % lang

        print("Download url for dictionary in %s is: %s" % (lang,url_dl_dict_lang))
        print('Downloading: ' + dict_lang_name)
        wget(url_dl_dict_lang,makepath(ext_dir,dict_lang_name),proxies=proxies)

        ext_settings_dictionaries_content = {
                "%s" % ext_add_on_id: {
                    "install_url": "file://%s\\%s" % (ext_path,dict_lang_name),
                    "installation_mode": "force_installed"
                }
            }
        policies_content['policies']['ExtensionSettings'].update(ext_settings_dictionaries_content)

    print("Creating %s file for language packs, dictionaries, extensions and configuration" % policies_file)
    if isfile(policies_file):
        remove_file(policies_file)
    json_write(policies_file,policies_content,indent=2)

    # Downloading extentions
    # uBlock Origin
    wget('https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi',makepath(ext_dir,'ublock-origin.xpi'),proxies=proxies)




def unzip_with_7zip(filename, filenames=[], target=None, recursive=True, extract_with_full_paths=True):
    if not isinstance(filenames, list):
        filenames = [filenames]
    sevenzip_path = makepath(programfiles, '7-Zip', '7z.exe')
    if not filenames:
        if extract_with_full_paths:
            run(r'"%s" x "%s" %s %s -aoa' % (sevenzip_path, filename, '' if not target else '-o"%s"' % target, '' if not recursive else '-r'))
        else:
            run(r'"%s" e "%s" %s %s -aoa' % (sevenzip_path, filename, '' if not target else '-o"%s"' % target, '' if not recursive else '-r'))
    else:
        for extract in filenames:
            if extract_with_full_paths:
                run(r'"%s" x "%s" %s "%s" %s -aoa' % (sevenzip_path, filename, '' if not target else '-o"%s"' % target, extract, '' if not recursive else '-r'))
            else:
                run(r'"%s" e "%s" %s "%s" %s -aoa' % (sevenzip_path, filename, '' if not target else '-o"%s"' % target, extract, '' if not recursive else '-r'))


def get_language(full_locale=False, separator='_'):
    """Get the default locale like fr, en, pl etc..  etc

    >>> get_language()
    'fr'
    """
    import ctypes
    import locale
    import sys
    if sys.platform == 'win32':
        lang = locale.windows_locale[ctypes.windll.kernel32.GetUserDefaultUILanguage()]
    else:
        lang = locale.getdefaultlocale()[0]
    if full_locale:
        return lang.replace('_', separator)
    return lang.split(separator)[0]

def json_write(json_file,data,sort_keys=True, indent=4):
    import codecs
    with codecs.open(json_file, 'w', encoding='utf-8') as write_file:
        json.dump(data, write_file, sort_keys=sort_keys, indent=indent)

def json_load(json_file):
    with open(json_file) as read_file:
        data = json.load(read_file)
    return data

def bs_find_all(url, element, attribute=None, value=None, headers=None, proxies=None, features='html.parser', **kwargs):
    """"You may need to use a header for some websites. For example: headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0'}
    """
    import requests
    page = requests.get(url, proxies=proxies, headers=headers, **kwargs).text
    try:
        import bs4 as BeautifulSoup
        soup = BeautifulSoup.BeautifulSoup(page, features=features)
    except:
        import BeautifulSoup
        soup = BeautifulSoup.BeautifulSoup(page)
    if value:
        return soup.find_all(element, {attribute:value})
    else:
        return soup.find_all(element)

def get_proxies():
    import platform
    if platform.python_version_tuple()[0] == '3':
        from urllib.request import getproxies
    else:
        from urllib import getproxies
    return getproxies()

def update_control_version(version=control.version.split('-')[0]):
    control.version = '%s-%s'%(version,int(control.version.split('-')[-1])+1)
    control.save_control_to_wapt()

def is_version_different(version_x,version_y):
    if version_x == '':
        return False
    if version_y == '':
        return False
    if Version(version_x) != Version(version_y):
        return True
    else:
        return False

def remove_outdated_binary(version,list_extensions=('exe','msi','deb','rpm','dmg','pkg')):
    for file_ext in list_extensions:
        for bin_in_dir in glob.glob('*.%s' % file_ext):
            if not version in bin_in_dir:
                print('Outdated binary: %s Removed' % bin_in_dir)
                remove_file(bin_in_dir)

def get_version_from_binary(filename):
    if filename.endswith('.msi'):
        return get_msi_properties(filename)['ProductVersion']
    else:
        return get_file_properties(filename)['ProductVersion']

def rename_filename_version(filename,old_version,new_version):
    old_filename = filename
    new_filename = filename.replace(old_version,new_version)
    if isfile(new_filename):
        remove_file(new_filename)
    os.rename(old_filename,new_filename)

def rename_filename(old_filename,new_filename,force=True):
    if isfile(new_filename):
        if force:
            remove_file(new_filename)
        else:
            error('Cannot rename file since the new filename already exist and force flag is not applied')
    os.rename(old_filename,new_filename)

def get_proxies_from_wapt_console():
    proxies = {}
    if platform.system() == 'Windows':
        waptconsole_ini_path = makepath(user_local_appdata(), 'waptconsole', 'waptconsole.ini')
    else:
        waptconsole_ini_path = makepath(user_home_directory(), '.config', 'waptconsole', 'waptconsole.ini')
    if isfile(waptconsole_ini_path):
        proxy_wapt = inifile_readstring(waptconsole_ini_path, 'global', 'http_proxy')
        if proxy_wapt:
            proxies = {'http': proxy_wapt, 'https': proxy_wapt}
    return proxies

										

  Changelog 


Changelog software url : https://www.mozilla.org/en-US/firefox/releases/

No changelog
  manifest.sha256 
[["extensions/de-DE_dictionary.xpi","a7efef5e9fdf0f6460ac38951c1ca3766258d82647ad48bd87955bd5009ce9e0"],["extensions/de_language_pack.xpi","db3e509620e9cb73f32c7434c66db8a78dc9df32053e90e46424b299d42deb10"],["extensions/en-GB_dictionary.xpi","90b3eb634dffdd0dfc778a86620d5531d96b622568fd43669e2dfb4ea67b52a2"],["extensions/en-GB_language_pack.xpi","683b37f43ac9cedc6aba1e4ebe02de00e34862f8523a5824b460822bc9034783"],["extensions/es-ES_dictionary.xpi","ba08bb38d764dd991aecc3911bf23c63ad6b91e4dad71da908c96cce35942f2b"],["extensions/es-ES_language_pack.xpi","0de928ec240196a99db39a80bbff0197eb73eb4ba02ead4f8760660ddf45c8ee"],["extensions/fr_dictionary.xpi","e0e90b88b177dc1b268b019c8672eb1be943f12e174ad474dbdc46f0e6fbaa6f"],["extensions/fr_language_pack.xpi","07a0b1f84d2818653e09e438ab359b3433bc03638ac7cca0e46a8d1ac802283c"],["extensions/it_dictionary.xpi","90b173ffdde34a77108152a5ff51879767b1dd84e0aa0dfb7b2bab94cd2e7f53"],["extensions/it_language_pack.xpi","d6857adc04a8a0244792e4eb2a8f96c010b24c9f81c5d98bf2d439b924bde2d2"],["extensions/ublock-origin.xpi","d9eef701b99866565708fe69b5855c1634187630e9e223e810f10e482545e6c0"],["Firefox_Setup_84.0.1.exe","7c61d01b2ef1994860b9076c2bb23ffe932aec35f0dc11def1924b57787fdd24"],["policies.json","360ad1e4d655d18359088b234d794eb3994148ebe6be9a0e54e66e6321edb633"],["setup.py","65f5a00a8b2a55ef6f714d9c0274ee1a0ed8218f89721e0bd8e3e1848af6abe2"],["WAPT/icon.png","2dc82eade364831757e067169d0039e6e0c9b693f343ea9a62db709eb1942c9e"],["WAPT/certificate.crt","a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf"],["WAPT/control","3b2924c6112e834dbc2a0d45f91357cb807034735da28082c2b5403b2f9d73ae"]]