[RESOLU] Paquet Arduino
Publié : 15 déc. 2021 - 08:37
Bonjour,
Changelog du 24/03/2022 :
- Correction de la fonction def install(): qui ne pouvait pas fonctionner en l'état !
Je partage mon paquet pour le logiciel Arduino que je viens de réaliser :
Fichier control :
Fichier setup :
Changelog du 24/03/2022 :
- Correction de la fonction def install(): qui ne pouvait pas fonctionner en l'état !
Je partage mon paquet pour le logiciel Arduino que je viens de réaliser :
Fichier control :
Code : Tout sélectionner
package : wapt-arduino
version : 1.8.16-2
architecture : all
section : base
priority : optional
name :
categories :
maintainer : olaplanche
description : Arduino IDE
depends :
conflicts :
maturity : PROD
locale :
target_os : windows
min_wapt_version :
sources : https://www.arduino.cc/en/software
installed_size :
impacted_process : arduino
description_fr :
description_pl :
description_de :
description_es :
description_pt :
description_it :
description_nl :
description_ru :
audit_schedule :
editor : Arduino.cc
keywords :
licence :
homepage : www.arduino.cc
package_uuid :
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version :
max_os_version :
icon_sha256sum :
Code : Tout sélectionner
# -*- coding: utf-8 -*-
from setuphelpers import *
import platform
"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
bin_name_string = 'arduino-%s-windows.exe'
def install():
# Declaring local variables
package_version = control.get_software_version()
bin_name = bin_name_string % package_version
impacted_process = control.impacted_process.split(",")
# Installing the software
print("Installing: %s" % bin_name)
install_exe_if_needed(bin_name,
silentflags='/S',
key='Arduino',
min_version=package_version,
killbefore=impacted_process,
)
def update_package():
# Declaring local variables
result = False
proxies = get_proxies()
if not proxies:
proxies = get_proxies_from_wapt_console()
app_name = control.name
url = control.sources
# Getting latest version from official website
version_temp = bs_find_all(url, 'span', 'class', 'download-title',proxies=proxies)[0].string
version = version_temp[-6:]
latest_bin = bin_name_string % version
download_url = 'https://downloads.arduino.cc/arduino-%s-windows.exe' % version
print("Latest %s version is: %s" % (app_name, version))
print("Download URL is: %s" % download_url)
# Downloading latest binaries
if not isfile(latest_bin):
print("Downloading: %s" % latest_bin)
wget(download_url, latest_bin, proxies=proxies)
# Checking version from file
version_from_file = get_version_from_binary(latest_bin)
if not version_from_file.startswith(version) and version_from_file != '':
print("Changing version to the version number of the binary (from: %s to: %s)" % (version, version_from_file))
os.rename(latest_bin, bin_contains + version_from_file + ends_bin_name)
version = version_from_file
else:
print("Binary file version corresponds to online 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
else:
print("Software version up-to-date (%s)" % Version(version))
control.version = '%s-%s' % (Version(version), control.version.split('-', 1)[-1])
#control.set_software_version(version)
control.save_control_to_wapt()
# Deleting outdated binaries
remove_outdated_binaries(version)
# Validating update-package-sources
return result
def get_proxies():
if platform.python_version_tuple()[0] == '3':
from urllib.request import getproxies
else:
from urllib import getproxies
return getproxies()
def get_version_from_binary(filename):
if filename.endswith('.msi'):
return get_msi_properties(filename)['ProductVersion']
else:
return get_file_properties(filename)['ProductVersion']
def remove_outdated_binaries(version, list_extensions=['exe','msi','deb','rpm','dmg','pkg'], list_filename_contain=None):
if type(list_extensions) != list:
list_extensions = [list_extensions]
if list_filename_contain:
if type(list_filename_contain) != list:
list_filename_contain = [list_filename_contain]
list_extensions = ['.' + ext for ext in list_extensions if ext[0] != '.']
for file_ext in list_extensions:
for bin_in_dir in glob.glob('*%s' % file_ext):
if not version in bin_in_dir:
remove_file(bin_in_dir)
if list_filename_contain:
for filename_contain in list_filename_contain:
if not filename_contain in bin_in_dir:
remove_file(bin_in_dir)
def get_proxies_from_wapt_console():
proxies = {}
if platform.system() == 'Windows':
waptconsole_ini_path = makepath(user_local_appdata(), 'waptconsole', 'waptconsole.ini')
else:
waptconsole_ini_path = makepath(user_home_directory(), '.config', 'waptconsole', 'waptconsole.ini')
if isfile(waptconsole_ini_path):
proxy_wapt = inifile_readstring(waptconsole_ini_path, 'global', 'http_proxy')
if proxy_wapt:
proxies = {'http': proxy_wapt, 'https': proxy_wapt}
return proxies
def uninstall():
print("Uninstalling: %s" % control.package)
run(r'"%s\Arduino\uninstall.exe" /s' % programfiles32)