[RESOLVED] Package for Sourcetree

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

November 12, 2024 - 1:44 PM

Good morning,

If it's of any use, here's the package code I use for the Sourcetree software (https://www.sourcetreeapp.com/) :

For Windows:

Code: Select all

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

uninstallkey = []

def install():
    appver = control.version.split('-',1)[0]
    bin_name = r'SourcetreeEnterpriseSetup_%s.msi' % appver
    parameters = {'ACCEPTEULA':'1'}
    install_msi_if_needed(bin_name, min_version=appver, killbefore=control.impacted_process, properties=parameters)

def update_package():
    appver = control.version.split('-',1)[0]
    url = r'https://www.sourcetreeapp.com/download-archives'

    print(r'Checking latest version...')
    for release in bs_find_all(url, "a"):
        if "Download free" in release:
            continue
        if release["href"].endswith(".msi"):
            url_dl = (release["href"])
            break
    latest_version = url_dl.split("/")[-1].split(".msi")[0].split("_")[-1]

    if Version(latest_version) > Version(appver):
        bin_name = url_dl.split("/")[-1]
        print(r'Latest version is: %s' % latest_version)
        print(r'Downloading latest binary...')
        wget(url_dl, bin_name)
        # Changing version of the package
        control.version = '%s-%s'%(latest_version,(control.version.split('-')[-1]))
        control.save_control_to_wapt()
        print('Changing version to: %s in WAPT\\control' % control.version)
    else:
        print(r'Already up to date !')

    # Deleting outdated binaries
    remove_outdated_binaries(latest_version)
For macOS:

Code: Select all

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

uninstallkey = []

zip_name_begin = r'Sourcetree'
app_name = r'Sourcetree.app'

def install():
    zip_name = glob.glob('%s*.zip' % zip_name_begin)[0]
    run(r'unzip -qq %s %s/*' % (zip_name, app_name))
    install_app(app_name)

def uninstall():
    uninstall_app(app_name)

def update_package():
    appver = control.version.split('-',1)[0]
    url = r'https://www.sourcetreeapp.com/download-archives'

    print(r'Checking latest version...')
    for release in bs_find_all(url, "a"):
        if "Download free" in release:
            continue
        if release["href"].endswith(".zip"):
            url_dl = (release["href"])
            break
    latest_version = url_dl.split("/")[-1].split(".zip")[0].split("_")[-2]

    if Version(latest_version) > Version(appver):
        bin_name = url_dl.split("/")[-1]
        # Remove older version ZIP file
        try:
            old_zip_name = glob.glob('%s*.zip' % zip_name_begin)[0]
            if isfile(old_zip_name):
                remove_file(old_zip_name)
        except:
            pass
        print(r'Latest version is: %s' % latest_version)
        print(r'Downloading latest binary...')
        wget(url_dl, bin_name)
        # Changing version of the package
        control.version = '%s-%s'%(latest_version,(control.version.split('-')[-1]))
        control.save_control_to_wapt()
        print('Changing version to: %s in WAPT\\control' % control.version)
    else:
        print(r'Already up to date !')
If it's possible for it to be adopted for the TIS store, that would be nice too :D
Thanks in advance.
italbot
Messages: 61
Registration: Sep 26, 2023 - 3:50 p.m.

November 12, 2024 - 4:54 PM

Hello,

thank you for sharing. I've just created the package; it will be on the store in 5 days.

Have a good day.

Best regards,

Ingrid
Tranquil IT
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

November 12, 2024 - 4:56 PM

Thank you so much! :D
Locked