Insmonia package

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
Answer
jorico
Messages: 27
Registration: August 11, 2022 - 4:42 PM
Location: NIORT

September 27, 2023 - 2:18 PM

Good morning

I tried to create a package for installing the Insomnia program (https://insomnia.rest/downloadThis can be installed via a portable application or with an application that installs in AppData (I was unable to complete the installation using this method)

I tried to base my work on the tis-bitwarden-portable package

Below is the setup.py file

Code: Select all

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

app_bin = "Insomnia.Core-2023.5.8-portable.exe"
app_dir = makepath(programfiles32, "Insomnia")
app_bin_path = makepath(app_dir, app_bin)
processes_to_kill = ["Insomnia"]


def install():
    # Initializing variables
    package_version = control.version.split("-", 1)[0]
    bin_name = bin_name = glob.glob("Insomnia.Core-*.exe")[0]

    # Installing the package
    print("Installing: %s" % bin_name)
    if get_version_from_binary(app_bin_path) != package_version:
        killalltasks(processes_to_kill)
        if isdir(app_dir):
            remove_tree(app_dir)
        mkdirs(app_dir)
        print("Copying %s to %s " % (bin_name, app_bin_path))
        filecopyto(bin_name, app_bin_path)
        # remove_programs_menu_shortcut("Insomnia")

        # Adding this package to the "list-registry"
        register_windows_uninstall(control)  # control is a PackageEntry object corresponding to this package
    else:
        print("%s portable version is already installed in the correct version" % "Insomnia")


def session_setup():
    # Initializing variables
    user_app_dir = makepath(application_data, "Insomnia")
    user_app_bin_path = makepath(user_app_dir, app_bin)

    # Installing the package in user env
    print("Installing: %s in user env" % "Insomnia")
    if get_version_from_binary(user_app_bin_path) != installed_softwares("Insomnia")[0]["version"]:
        killalltasks(processes_to_kill)
        if isdir(user_app_dir):
            remove_tree(user_app_dir)
        mkdirs(user_app_dir)
        print("Copying %s to %s " % (app_bin_path, user_app_bin_path))
        filecopyto(app_bin_path, user_app_bin_path)
        create_user_programs_menu_shortcut("Insomnia", user_app_bin_path)
    else:
        print("%s portable version in user env is already installed in the correct version" % "Insomnia")

def uninstall():
    # Uninstalling the package
    killalltasks(processes_to_kill)
    if isdir(app_dir):
        remove_tree(app_dir)
        unregister_uninstall("Insomnia")
However, during uninstallation, the application stored in AppData is not deleted...
And I have the impression that the session setup doesn't start after the application is installed; I have to force the session setup with `wapt-get session-setup -f ALL`

Can you help me improve my package?

Thank you all :D
WAPT Enterprise 2.5.5.15697
Server = Debian 11 Bullseye
Console = Windows Server 2019
--------------------------------------------------------------------------

Johan
Benoit
Messages: 43
Registration: June 26, 2023 - 11:52
Location: Tarbes

October 12, 2023 - 09:57

Good morning,

Unless I'm mistaken, it seems that your "session_setup()" function is not being called anywhere.
The following should be done in the install() function so that it is called at the end of the installation.
Furthermore, the session_setup() function should be positioned before the install() function so that it is read first.

Code: Select all

def install():
    # Initializing variables
    package_version = control.version.split("-", 1)[0]
    bin_name = bin_name = glob.glob("Insomnia.Core-*.exe")[0]

    # Installing the package
    print("Installing: %s" % bin_name)
    if get_version_from_binary(app_bin_path) != package_version:
        killalltasks(processes_to_kill)
        if isdir(app_dir):
            remove_tree(app_dir)
        mkdirs(app_dir)
        print("Copying %s to %s " % (bin_name, app_bin_path))
        filecopyto(bin_name, app_bin_path)
        # remove_programs_menu_shortcut("Insomnia")

        # Adding this package to the "list-registry"
        register_windows_uninstall(control)  # control is a PackageEntry object corresponding to this package
    else:
        print("%s portable version is already installed in the correct version" % "Insomnia")
    session_setup()
Edit: I just realized my answer was irrelevant. My apologies.
Regards,
Last edited by Benoit on Oct 12, 2023 - 4:11 PM, edited 1 time.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

October 12, 2023 - 2:11 PM

jorico wrote: Sep 27, 2023 - 2:18 PM And I have the impression that the session setup doesn't start after the application is installed; I have to force the session setup with `wapt-get session-setup -f ALL`
Actually, it's subtle...

After the installation of a package by the wapt service, the SERVICE Wapt will launch a session setup in all open sessions.
However, if you run a wapt-get install tis-insmonia, then the command line does not launch the session-setup.

So when you are in DEV mode, the session setup will not run.

I suppose that's your concern

Also, be careful during testing; you must increment the version of the control file and then run an installation, otherwise the session setup will do nothing. This is a common pitfall in WAPT training ;)
jorico
Messages: 27
Registration: August 11, 2022 - 4:42 PM
Location: NIORT

October 12, 2023 - 2:34 PM

Hello Simon,

Thanks for your reply. Indeed, there are a few subtleties. Below is the package as it works for me

Setup.py

Code: Select all

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

app_bin = glob.glob("Insomnia.Core-*.exe")[0]
app_dir = makepath(programfiles32, "Insomnia")
app_bin_path = makepath(app_dir, app_bin)
processes_to_kill = ["Insomnia"]


def session_setup():
    # Initializing variables
    user_app_dir = makepath(application_data, "Insomnia")
    user_app_bin_path = makepath(user_app_dir, app_bin)

    # Installing the package in user env
    print("Installing: %s in user env" % "Insomnia")
    if get_version_from_binary(user_app_bin_path) != installed_softwares("Insomnia")[0]["version"]:
        killalltasks(processes_to_kill)
        if isdir(user_app_dir):
            remove_tree(user_app_dir)
        mkdirs(user_app_dir)
        print("Copying %s to %s " % (app_bin_path, user_app_bin_path))
        filecopyto(app_bin_path, user_app_bin_path)
        create_user_programs_menu_shortcut("Insomnia", user_app_bin_path)
    else:
        print("%s portable version in user env is already installed in the correct version" % "Insomnia")

def install():
    # Initializing variables
    package_version = control.version.split("-", 1)[0]
    bin_name = bin_name = glob.glob("Insomnia.Core-*.exe")[0]

    # Installing the package
    print("Installing: %s" % bin_name)
    if get_version_from_binary(app_bin_path) != package_version:
        killalltasks(processes_to_kill)
        if isdir(app_dir):
            remove_tree(app_dir)
        mkdirs(app_dir)
        print("Copying %s to %s " % (bin_name, app_bin_path))
        filecopyto(bin_name, app_bin_path)
        # remove_programs_menu_shortcut("Insomnia")

        # Adding this package to the "list-registry"
        register_windows_uninstall(control)  # control is a PackageEntry object corresponding to this package
    else:
        print("%s portable version is already installed in the correct version" % "Insomnia")
    session_setup()

def uninstall():
    # Uninstalling the package
    killalltasks(processes_to_kill)
    if isdir(app_dir):
        remove_tree(app_dir)
        unregister_uninstall("Insomnia")
Control

Code: Select all

package           : cam-insomnia
version           : 8.2.0-9
architecture      : all
section           : base
priority          : optional
name              : Insomnia
categories        :
maintainer        : Johan RICOLLEAU
description       : Build better APIs faster and collaboratively with a dev-friendly interface, built-in automation, and an extensible plugin ecosystem.
depends           : 
conflicts         : 
maturity          : DEV
locale            : 
target_os         : windows
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            : Kong
keywords          : 
licence           :
homepage          : 
package_uuid      : 3682ac4f-05de-420d-b1ff-6e6f399c31d3
valid_from        : 
valid_until       :
forced_install_on : 
changelog         :
min_os_version    : 
max_os_version    : 
icon_sha256sum    :
signer            : ca-cert
signer_fingerprint: 42456f1e5e301d26521eeabdeb31734cf4c4c041fc7457e72108eae6a7868ac2
signature         : CXTKrvJIypc3UhJmEmSaMnEjbEe5wGavLw4rlfgK0uyVVvYkeesD7j6anRcdFNnkQCTPSeFoFqcd+6Ed36zsY8nIxcAt+BptModpMkc8NNSnTTPolmVawAO6PN2VeNz6pUs3QKC7h/plMalytb0f7eJMot8QfCzs2bs1AQwme5ColNPne2jMYADXYfbpkhGSTx0dYg7vTXr7rZnWkXU5O7c/DfF4b4/cns9NcH6dyazVTfndl1Oha/VChuJf06fNVaRuIzu7GqRBpj8z3p4ncf3B5AT+RGu4H2ixCAqj399VW12lM4tGB44ZjjUU6gM8kAgkUMbw2cofvIkfPSqEcQ==
signature_date    : 2023-10-12T14:23:08.439762
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
I even tried an update_package

Code: Select all

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

def update_package():
    # Declaring local variables
    bin_contains = "Insomnia"
    result = False
    proxies = get_proxies()
    bin_search = ".exe"
    bin_name_sub = "Insomnia.Core.%s.exe"
    if not proxies:
        proxies = get_proxies_from_wapt_console()

    app_name = control.name
    git_repo = "Kong/insomnia"
    url_api = "https://api.github.com/repos/%s/releases/latest" % git_repo

    # Getting latest version information from official sources
    print("API used is: %s" % url_api)
    json_load = json.loads(wgets(url_api, proxies=proxies))
    for download in json_load["assets"]:
        if bin_search in download["name"]:
            url_dl = download["browser_download_url"]
            version = json_load["tag_name"].replace("core@", "")
            latest_bin = download["name"]
            break

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

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

        # Checking version from file
        version_from_file = get_version_from_binary(latest_bin, "FileVersion")
        if not version_from_file.startswith(version):
            # remove additional .0 at the end of the version from file
            ".".join(get_version_from_binary(latest_bin, "FileVersion").split(".")[:3])
            print("Changing version to the version number of the binary")
            version = version_from_file
            os.rename(latest_bin, bin_name_sub % 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
    control.version = "%s-%s" % (Version(version), control.version.split("-", 1)[-1])
    # control.set_software_version(Version(version))
    control.save_control_to_wapt()

    # Deleting outdated binaries
    remove_outdated_binaries(version)

    # Validating update-package-sources
    return result

WAPT Enterprise 2.5.5.15697
Server = Debian 11 Bullseye
Console = Windows Server 2019
--------------------------------------------------------------------------

Johan
jorico
Messages: 27
Registration: August 11, 2022 - 4:42 PM
Location: NIORT

October 12, 2023 - 2:55 PM

However, I have an audit error; I don't know what it is or how to resolve it
capture.png
capture.png (2.84 KB) Viewed 5449 times
WAPT Enterprise 2.5.5.15697
Server = Debian 11 Bullseye
Console = Windows Server 2019
--------------------------------------------------------------------------

Johan
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

October 12, 2023 - 3:01 PM

Code: Select all

app_bin = glob.glob("Insomnia.Core-*.exe")[0]
app_bin should be in install at the time of auditing and session setup; the file no longer exists
which explains the error
jorico
Messages: 27
Registration: August 11, 2022 - 4:42 PM
Location: NIORT

October 12, 2023 - 4:23 PM

Thank you Simon

I corrected it, like this

Code: Select all

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

app_bin = "Insomnia.Core.8.2.0.exe"
app_dir = makepath(programfiles32, "Insomnia")
app_bin_path = makepath(app_dir, app_bin)
processes_to_kill = ["Insomnia"]


def session_setup():
    # Initializing variables
    user_app_dir = makepath(application_data, "Insomnia")
    user_app_bin_path = makepath(user_app_dir, app_bin)

    # Installing the package in user env
    print("Installing: %s in user env" % "Insomnia")
    if get_version_from_binary(user_app_bin_path) != installed_softwares("Insomnia")[0]["version"]:
        killalltasks(processes_to_kill)
        if isdir(user_app_dir):
            remove_tree(user_app_dir)
        mkdirs(user_app_dir)
        print("Copying %s to %s " % (app_bin_path, user_app_bin_path))
        filecopyto(app_bin_path, user_app_bin_path)
        create_user_programs_menu_shortcut("Insomnia", user_app_bin_path)
    else:
        print("%s portable version in user env is already installed in the correct version" % "Insomnia")

def install():
    # Initializing variables
    package_version = control.version.split("-", 1)[0]
    bin_name = bin_name = glob.glob("Insomnia.Core-*.exe")[0]

    # Installing the package
    print("Installing: %s" % bin_name)
    if get_version_from_binary(app_bin_path) != package_version:
        killalltasks(processes_to_kill)
        if isdir(app_dir):
            remove_tree(app_dir)
        mkdirs(app_dir)
        print("Copying %s to %s " % (bin_name, app_bin_path))
        filecopyto(bin_name, app_bin_path)
        # remove_programs_menu_shortcut("Insomnia")

        # Adding this package to the "list-registry"
        register_windows_uninstall(control)  # control is a PackageEntry object corresponding to this package
    else:
        print("%s portable version is already installed in the correct version" % "Insomnia")
    session_setup()

def uninstall():
    # Uninstalling the package
    killalltasks(processes_to_kill)
    if isdir(app_dir):
        remove_tree(app_dir)
        unregister_uninstall("Insomnia")
I no longer have audit errors, but I'm forced to hardcode the binary name... this will no longer work for the package update
Last edited by jorico on Oct 17, 2023 - 10:07, edited 1 time.
WAPT Enterprise 2.5.5.15697
Server = Debian 11 Bullseye
Console = Windows Server 2019
--------------------------------------------------------------------------

Johan
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

October 12, 2023 - 5:46 PM

Hello Johan,

The binary name is available in the package at the time of installation, and in the c:\program files (x86)\Insomnia directory once the application is installed. You can move your app_bin variable between different functions by calling a

Code: Select all

glob.glob('insomnia*.exe')
at the time of installation, and a

Code: Select all

glob.glob(makepath(programfiles32,'insomnia','insomnia*.exe'))
at the time of session_setup and uninstall

Sincerely,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Answer