tis-wsl2-ubuntu icon

Ubuntu WSL 2

Paquet d’installation silencieuse pour Ubuntu WSL 2

2204.1.7.0-2

  • package: tis-wsl2-ubuntu
  • name: Ubuntu WSL 2
  • version: 2204.1.7.0-2
  • categories: System and network
  • maintainer: WAPT Team,Tranquil IT,Joffrey Le Piquet,Simon Fonteneau
  • locale: all
  • target_os: windows
  • architecture: all
  • signature_date:
  • size: 1.11 Go
  • depends:
  • conflicts :

package           : tis-wsl2-ubuntu
version           : 2204.1.7.0-2
architecture      : all
section           : base
priority          : optional
name              : Ubuntu WSL 2
categories        : System and network
maintainer        : WAPT Team,Tranquil IT,Joffrey Le Piquet,Simon Fonteneau
description       : Ubuntu Windows Subsystem for Linux 2
depends           : tis-wsl2
conflicts         : tis-virtualbox
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 2.0
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : Sous-système Windows de Debian pour Linux 2
description_pl    : Ubuntu Windows Subsystem for Linux 2
description_de    : Ubuntu Windows-Subsystem für Linux 2
description_es    : Subsistema Ubuntu Windows para Linux 2
description_pt    : Subsistema Ubuntu Windows para Linux 2
description_it    : Sottosistema Ubuntu Windows per Linux 2
description_nl    : Ubuntu Windows Subsystem voor Linux 2
description_ru    : Подсистема Ubuntu Windows для Linux 2
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 62d2b82f-d044-4305-8a7a-a6306187dcad
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
min_os_version    : 10.0.18362
max_os_version    : 
icon_sha256sum    : 19c7ca52fc2d3cf5e484ba8617bf14628bde075b6004449f90aaf51b8d7fee07
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2024-10-16T11:04:15.000000
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
signature         : lyajZJmO8o7poMNG7OHQcz7tzcGIgCoxV801twEYDBWjT2TYOH5wyku1tocpMOpIB6Lr6FwsdcMPyu5PSpfJhwp/RJQPDYMcHvgCiOZDStwxBByTO1pYM/NRns+eUEVG2QbKe89UKgb26gVi4PePZscdPcmbK2b4BvfDh4lMuBTlfI+usv2Z9oThp+wYYK1JheAA6wMnuPd85zNIDeYIoLK9dDM1h+m7HuyrdySIrmMuUhQnNa8V3cq6EZoSJLzS0RuAU8xOjOBAK/F9es7j7OrLwTeM0R99K0KMGyWsJZseZrWAwQB8zZl8F9zCW/I9BXoNXBYdvaYZLeXzZrCg3A==

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

bin_name_string = "Ubuntu_%s.Appx"
package_name = "CanonicalGroupLimited.Ubuntu18.04onWindows"


def set_variables():
    # Declaring variables
    global package_version
    package_version = control.version.split("-")[0]
    global bin_name
    bin_name = bin_name_string % package_version
    global app_name
    app_name = control.name
    global wsl_dir
    wsl_dir = makepath(programfiles, "WSL")
    global wsl_ubuntu
    wsl_ubuntu = makepath(wsl_dir, bin_name)


def install():
    # Initializing variables
    set_variables()

    # Installing the package
    if not isdir(wsl_dir):
        mkdirs(wsl_dir)
    for bin_in_dir in glob.glob(makepath(wsl_dir, "*ubuntu*")):
        if bin_in_dir != wsl_ubuntu:
            print("Removing %s" % bin_in_dir)
            remove_file(bin_in_dir)

    if not isfile(wsl_ubuntu):
        print("Copying %s in %s " % (bin_name, wsl_dir))
        filecopyto(bin_name, wsl_dir)


def uninstall():
    # Initializing variables
    set_variables()

    # Uninstalling the package
    print("Removing %s for all users" % package_name)
    run_powershell("Get-AppxPackage -Name %s -AllUsers | Remove-AppxPackage" % package_name)


def session_setup():
    # Initializing variables
    set_variables()

    # Install the Appx in user environment
    try:
        installed_wsl_ubuntu_version = run_powershell('Get-AppxPackage -Name "%s" | Select-Object version' % package_name)["Version"]
    except:
        installed_wsl_ubuntu_version = "0.0.0"

    if package_version > installed_wsl_ubuntu_version:
        print("Installing %s for the current user" % app_name)
        run_powershell('Add-AppxPackage -Path "%s"' % wsl_ubuntu)

    # Upgrading WSL Ubuntu to WSL 2
    # Upgrade procedure: https://docs.microsoft.com/en-us/windows/wsl/install-win10#set-your-distribution-version-to-wsl-1-or-wsl-2
    if windows_version() >= "10.0.19041":
        try:
            print("Upgrading Ubuntu to WSL 2")
            run_powershell("wsl --set-version Ubuntu-18.04 2")
        except:
            print("Ubuntu is already in WSL 2, or the upgrade do not complete")
    else:
        print("You need Windows 10 version 2004 minimum for upgrading Ubuntu to WSL 2")

# -*- coding: utf-8 -*-
from setuphelpers import *
import platform
import xml.etree.ElementTree as ET

bin_name_string = "Ubuntu_%s.Appx"


def set_variables():
    # Declaring variables
    global package_version
    package_version = control.version.split("-")[0]
    global bin_name
    bin_name = bin_name_string % package_version
    global app_name
    app_name = control.name
    global wsl_dir
    wsl_dir = makepath(programfiles, "WSL")
    global wsl_debian
    wsl_debian = makepath(wsl_dir, bin_name)


def update_package():
    print("Download/Update package content from upstream binary sources")

    # Getting proxy informations from WAPT settings
    proxy = {}
    if platform.system() == "Windows" and isfile(makepath(user_local_appdata(), "waptconsole", "waptconsole.ini")):
        proxywapt = inifile_readstring(makepath(user_local_appdata(), "waptconsole", "waptconsole.ini"), "global", "http_proxy")
        if proxywapt:
            proxy = {"http": proxywapt, "https": proxywapt}

    # Initializing variables
    set_variables()
    latest_bin = bin_name_string.split("_")[0] + ".Appxbundle"
    url_dl = "https://aka.ms/wslubuntu2204"

    print("Download url is: " + url_dl)

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

        # Unzip to get file version
        unzip(latest_bin, target="ubuntu_wsl_temp")

        # Checking version from file
        xml_to_read = ET.parse(r"ubuntu_wsl_temp\AppxMetadata\AppxBundleManifest.xml")
        xml_content = xml_to_read.getroot()

        for vers in list(xml_content):
            if vers.get("Name") == "CanonicalGroupLimited.Ubuntu":
                version_from_file = vers.get("Version")

        version = version_from_file
        old_latest_bin = latest_bin
        latest_bin = bin_name_string % version
        if isfile(latest_bin):
            remove_file(latest_bin)
        os.rename(old_latest_bin, latest_bin)
        print("Verified latest " + app_name + " version is: " + version)

        # Removing temp folder
        remove_tree("ubuntu_wsl_temp")

        # 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 " + control.version + " in WAPT\\control")

    # Deleting outdated binaries
    for bin_in_dir in glob.glob("*.Appx"):
        if bin_in_dir != latest_bin:
            print("Outdated binary: " + bin_in_dir + " Deleted")
            remove_file(bin_in_dir)

6ad6d88763451a50f98f2469ce80464d666204c08d07f8f6a89e0d5ca05b097a : Ubuntu_2204.1.7.0.Appx
38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
817f33979e6ef647e99e73545f93178403c17a113cdd66563bd73eea946f089e : WAPT/control
19c7ca52fc2d3cf5e484ba8617bf14628bde075b6004449f90aaf51b8d7fee07 : WAPT/icon.png
e8f9d95e1e77bf7c3fa7adb35669e3dc96f4c670256997b4555010c777604346 : luti.json
86b68d2d9dd8a12a316f7bb7237243bd3a6ac6f02a505973fdfb3c048bcc3ac9 : setup.py
49bf0dc85575cec639b5e818dc46e854f1f785b7356af969e368d27bec0c960d : update_package.py