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