• package: tis-git
  • name: Git
  • version: 2.41.0-11
  • categories: Development,Utilities
  • maintainer: WAPT Team,Tranquil IT,Jimmy PELÉ
  • editor: Software Freedom Conservancy
  • licence: GPLv2
  • locale: all
  • target_os: windows
  • impacted_process: git-bash,git-cmd,git,git-gui,gitk,git-lfs,git
  • architecture: x64
  • signature_date:
  • size: 60.14 Mo
  • installed_size: 783.22 Mo
  • homepage : https://git-scm.com/
  • conflicts :

package           : tis-git
version           : 2.41.0-11
architecture      : x64
section           : base
priority          : optional
name              : Git
categories        : Development,Utilities
maintainer        : WAPT Team,Tranquil IT,Jimmy PELÉ
description       : Git is a free and open source distributed version control system
depends           : 
conflicts         : tis-git-lfs
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 1.8
sources           : https://github.com/git-for-windows/git/releases
installed_size    : 783220736
impacted_process  : git-bash,git-cmd,git,git-gui,gitk,git-lfs,git
description_fr    : Git est un logiciel de gestion de versions décentralisé
description_pl    : Git – rozproszony system kontroli wersji
description_de    : Git ist eine freie Software zur verteilten Versionsverwaltung von Dateien
description_es    : Git es un software de control de versiones
description_pt    : Git é um sistema de controlo de versões distribuído gratuito e de código aberto
description_it    : Git è un sistema di controllo di versione distribuito, gratuito e open source
description_nl    : Git is een gratis en open source gedistribueerd versiebeheersysteem
description_ru    : Git - это бесплатная распределенная система контроля версий с открытым исходным кодом
audit_schedule    : 
editor            : Software Freedom Conservancy
keywords          : version,control,system
licence           : GPLv2
homepage          : https://git-scm.com/
package_uuid      : 014e9027-b740-454c-be0a-23fc60982dd1
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : https://github.com/git/git/blob/master/Documentation/RelNotes
min_os_version    : 6.1
max_os_version    : 
icon_sha256sum    : 4a6e5031edc6e22a06cb5f12e89dea8738b88839c2cb99e2e7e0d9df345e2252
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature         : BVjcUD5fTdiFoPhkeeLSM+u6qVPyGLKxOVdhtqLod7tGmCFm4S86BG8zxBQtHHmCBuVxmmMMLEGpoYGAO+PXGhZKE/Dp502G5KkXjtF5iKg8IW44VSdffdwZfO+AWJ56VpgvJ8el3NzHgoj12NUQcsMA9/E2yY95L1sijwBe2C79VjAn4qAAFCm33bmGETrp5atCfNK/WMLE8LAOlFJfQOixOHaEJ1XVktGH8chVGMRhrO1XDJm/H3KgLo1azaytF8XFT7KAEdZ5N60OENw+5WMaV9UVMFnXokjl8iHQBpKKqgREmPOIp815C6s/avdUbADgP9bjR/JF0mYqPMu5fw==
signature_date    : 2023-06-06T22:02:11.251055
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes

# -*- coding: utf-8 -*-
from setuphelpers import *
import platform
import json

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
bin_contains = "Git-"
silent_args = '/LOADINF="git.inf" /VERYSILENT /CLOSEAPPLICATIONS /NORESTART'
app_uninstallkey = "Git_is1"


def install():
    # Declaring local variables
    package_version = control.get_software_version()
    bin_name = glob.glob("*%s*.exe" % bin_contains)[0]

    # Installing the software
    print("Installing: %s" % bin_name)
    install_exe_if_needed(
        bin_name,
        silentflags=silent_args,
        key=app_uninstallkey,
        min_version=package_version,
        timeout=600,
    )

    # Disable credential provider web detection
    run('"%s" config --global credential.provider generic' % makepath(installed_softwares(app_uninstallkey)[0]["install_location"], "bin", "git.exe"))


def update_package():
    # Declaring local variables
    result = False
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    api_url = "https://api.github.com/repos/git-for-windows/git/releases/latest"
    if control.architecture == "x64":
        bin_ends = "-64-bit.exe"
    else:
        bin_ends = "-32-bit.exe"
    sub_bin_name = bin_contains + "%s" + bin_ends

    # Getting latest version information from official sources
    print("API used is: %s" % api_url)
    json_load = json.loads(wgets(api_url, proxies=proxies))
    for download in json_load["assets"]:
        if bin_contains in download["name"] and download["name"].endswith(bin_ends):
            download_url = download["browser_download_url"]
            version = json_load["tag_name"].split(".windows")[0].replace("v", "")
            latest_bin = download["name"]
            break

    print("Latest %s version is: %s" % (app_name, version))
    print("Download URL is: %s" % download_url)

    # Downloading latest binaries
    if not isfile(latest_bin):
        print("Downloading: %s" % latest_bin)
        wget(download_url, latest_bin, proxies=proxies)

        # Checking version from file
        version_from_file = get_version_from_binary(latest_bin)
        # if not version_from_file.startswith(version) and version_from_file != '':
        if Version(version_from_file) != Version(version) and version_from_file != "":
            print("Changing version to the version number of the binary")
            os.rename(latest_bin, sub_bin_name % version_from_file)
            version = version_from_file
        else:
            print("Binary file version corresponds to online version")

    # Changing version of the package
    if Version(version) > Version(control.get_software_version()):
        print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version)))
        result = True
    else:
        print("Software version up-to-date (%s)" % Version(version))
    control.version = "%s-%s" % (Version(version), control.version.split("-", 1)[-1])
    # control.set_software_version(version)
    control.save_control_to_wapt()

    # Deleting outdated binaries
    remove_outdated_binaries(version)

    # Validating update-package-sources
    return result


def get_proxies():
    r"""Return system proxy with the urllib python library

    >>> get_proxies()
    {'http': 'http://srvproxy.ad.domain.lan:8080',
    'https': 'http://srvproxy.ad.domain.lan:8080'}

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


def get_proxies_from_wapt_console():
    r"""Return proxy information from the current user WAPT console

    >>> get_proxies_from_wapt_console()
    {'http': 'http://srvproxy.ad.domain.lan:8080',
    'https': 'http://srvproxy.ad.domain.lan:8080'}

    """
    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


def get_version_from_binary(filename, property_name="ProductVersion"):
    r"""Get installer version from file informations, for now, only exe and msi files are compatibles

    Args:
        filename (str): path to the file
        property_name (str): selected property

    Returns:
        str: version number

    """
    if filename.endswith(".msi"):
        return get_msi_properties(filename)[property_name]
    else:
        return get_file_properties(filename)[property_name]


def remove_outdated_binaries(version, filename_contains=None, list_extensions=["exe", "msi", "deb", "rpm", "dmg", "pkg"]):
    r"""Remove files based on the version contained in his filename

    Args:
        version (str): version number of keeped files
        filename_contains (str or list of str): Part of the filename that must be contained (useful for distinguishing architecture and os)
        list_extensions (str or list of str): file extensions of verified files

    Returns:
        None

    .. versionadded:: 2.0

    """
    if type(list_extensions) != list:
        list_extensions = [list_extensions]
    if filename_contains:
        if type(filename_contains) != list:
            filename_contains = [filename_contains]
    list_extensions = ["." + ext for ext in list_extensions if ext[0] != "."]
    for file_ext in list_extensions:
        for bin_in_dir in glob.glob("*%s" % file_ext):
            if not version in bin_in_dir:
                remove_file(bin_in_dir)
            if filename_contains:
                for filename_contain in filename_contains:
                    if not filename_contain in bin_in_dir:
                        remove_file(bin_in_dir)

f5952d8d13f48d1423ef486f82cf78957fe84c5026a61c4db28ae1aa21b07a29 : setup.py
423eba630776ba8a9a9922ffec8fa681472560d3511dbbc304529e5d667bcc5d : git.inf
45dc30410916b8ec5501be39d01d5b60535731c04fa68283b4f9df4920877d4e : Git-2.41.0-64-bit.exe
4a6e5031edc6e22a06cb5f12e89dea8738b88839c2cb99e2e7e0d9df345e2252 : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
b10861a7831c9f21a88e96ecebd5743b79f39e3481be6b5b09e3d458249e06c2 : luti.json
61cf471dced3dffc7f657691bbd17dbaaf1ca4ddd9b9b64c549336518bd52e66 : WAPT/control