Page 1 sur 1

Paquet insmonia

Posté : 27 sept. 2023 - 14:18
par jorico
Bonjour

J'ai essayé de créer un paquet pour l'installation du programme Insomnia (https://insomnia.rest/download), celui ci peut s'installer via une application portable ou bien avec une application s'installant dans appdata ( je n'ai pas réussi à réaliser l'installlation avec cette méthode)

J'ai essayé de me baser sur le paquet tis-bitwarden-portable

Ci dessous le setup.py

Code : Tout sélectionner

# -*- 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")
Cependant lors de la désinstallation l'application stockée dans le Appdata ne se supprime pas...
Et j'ai limpression que le session setup ne se lance pas après l'installation de l'application, je dois forcer le session setup avec wapt-get session-setup -f ALL

Pouvez vous m'aider à améliorer mon paquet ?

Merci à tous :D

Re: Paquet insmonia

Posté : 12 oct. 2023 - 09:57
par Benoit
Bonjour,

Sauf erreur de ma part, il semble que votre fonction "session_setup()" ne soit appelée nulle part.
Il faudrait faire comme suit dans la fonction install() pour qu'elle soit appelée à la fin de l'installation.
De plus, il faudrait positionner la fonction session_setup() avant la fonction install() pour qu'elle soit lue avant.

Code : Tout sélectionner

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()
Édit : Je viens de m'apercevoir que ma réponse était hors de propos. Mille excuses.
Cdt,

Re: Paquet insmonia

Posté : 12 oct. 2023 - 14:11
par sfonteneau
jorico a écrit : 27 sept. 2023 - 14:18 Et j'ai limpression que le session setup ne se lance pas après l'installation de l'application, je dois forcer le session setup avec wapt-get session-setup -f ALL
En faite c'est subtile ...

Après l'installation d'un paquet par le service wapt, le SERVICE wapt, celui-ci va lancer un session setup dans toutes les session ouverte.
En revanche si vous lancer un wapt-get install tis-insmonia, alors la ligne de commmande ne lance pas le session-setup.

Donc quand vous êtes en DEV le session setup ne s'executera pas.

Je suppose que c'est ça votre soucis

Attenetion lors des test égallement, il faut bien incrémenter la version du fichier control puis lancer une install, sinon le session setup ne fera rien. C'est un piège classique en formation wapt ;)

Re: Paquet insmonia

Posté : 12 oct. 2023 - 14:34
par jorico
Bonjour Simon,

Merci pour ta réponse en effet il y a quelques subtilités, ci dessous le paquet tel qu'il fonctionne chez moi

Setup.py

Code : Tout sélectionner

# -*- 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 : Tout sélectionner

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
J'ai même tenté un update_package

Code : Tout sélectionner

# -*- 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


Re: Paquet insmonia

Posté : 12 oct. 2023 - 14:55
par jorico
Par contre j'ai une erreur d'audit, je ne sais pas a quoi elle correspond ni comment la résoudre
capture.png
capture.png (2.84 Kio) Vu 2220 fois

Re: Paquet insmonia

Posté : 12 oct. 2023 - 15:01
par sfonteneau

Code : Tout sélectionner

app_bin = glob.glob("Insomnia.Core-*.exe")[0]
app_bin devrait être dans install au moment de l'audit et du session setup le fichier n'existe plus
ce qui explique l'erreur

Re: Paquet insmonia

Posté : 12 oct. 2023 - 16:23
par jorico
Merci Simon,

J'ai corrigé, comme ceci

Code : Tout sélectionner

# -*- 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")
Je n'ai plus d'erreur d'audit , mais je suis obligé d'inscrire le nom du binaire en dur ... cela ne fonctionnera plus pour l'update package

Re: Paquet insmonia

Posté : 12 oct. 2023 - 17:46
par dcardon
Bonjour Johan,

le nom du binaire est dispo dans le paquet au moment de l'install, et dans le répertoire c:\program files (x86)\Insomnia une fois l'appli installé. Vous pouvez dans déplacer votre variable app_bin dans les différentes fonction en appelant un

Code : Tout sélectionner

glob.glob('insomnia*.exe')
au moment de l'installation, et un

Code : Tout sélectionner

glob.glob(makepath(programfiles32,'insomnia','insomnia*.exe'))
au moment du session_setup et du uninstall

Cordialement,

Denis