[SOLVED] Arduino-IDE Package v2.0.2
Published: October 4, 2022 - 11:38 AM
Good morning,
- 24/11/2022: Code updated for version 2.0.2 with uninstall function for clean uninstallation and modification of the session-setup conf file for French language by default.
I'm sharing my Arduino-IDE v2.0.0 package, which required quite a bit of adaptation compared to version 1.8.19...
First, it's important to know that the new version creates a data folder in %localappdata% for each user. It is absolutely essential that the user has full read, write, and execution on this file for the proper functioning of the software.
My problem: I use a Software Restriction Strategy (SRP) that prohibits the execution of certain types of files from the user profile.
It's also important to know that each time a user opens the software for the first time, an Arduino15 folder will be created in %localappdata% and libraries will be downloaded. This folder is 346MB; if a large number of users are using the software, it can quickly become a mess.
And one last thing: the Arduino drivers are no longer included in this version; they are a separate download. Therefore, I've created a dependency package: viewtopic.php?t=3222
I therefore propose a code that copies the Arduino15 folder (retrieved earlier from the package) into the c:\ProgramData\Arduino15 folder, modifies the permissions on this folder to meet the prerequisites, and also modifies the software's configuration file via the session-setup function to point to the single Arduino15 folder for all users.
Users will therefore have write, read and execute rights on this folder which is hidden in the ProgramData folder and inaccessible to users via Windows Explorer and authorized to execute in my SRP.
I have also added an audit function to detect if the previous version (<=1.8.19) is installed because this version is installed separately.
Setup.py:
control:
- 24/11/2022: Code updated for version 2.0.2 with uninstall function for clean uninstallation and modification of the session-setup conf file for French language by default.
I'm sharing my Arduino-IDE v2.0.0 package, which required quite a bit of adaptation compared to version 1.8.19...
First, it's important to know that the new version creates a data folder in %localappdata% for each user. It is absolutely essential that the user has full read, write, and execution on this file for the proper functioning of the software.
My problem: I use a Software Restriction Strategy (SRP) that prohibits the execution of certain types of files from the user profile.
It's also important to know that each time a user opens the software for the first time, an Arduino15 folder will be created in %localappdata% and libraries will be downloaded. This folder is 346MB; if a large number of users are using the software, it can quickly become a mess.
And one last thing: the Arduino drivers are no longer included in this version; they are a separate download. Therefore, I've created a dependency package: viewtopic.php?t=3222
I therefore propose a code that copies the Arduino15 folder (retrieved earlier from the package) into the c:\ProgramData\Arduino15 folder, modifies the permissions on this folder to meet the prerequisites, and also modifies the software's configuration file via the session-setup function to point to the single Arduino15 folder for all users.
Users will therefore have write, read and execute rights on this folder which is hidden in the ProgramData folder and inaccessible to users via Windows Explorer and authorized to execute in my SRP.
I have also added an audit function to detect if the previous version (<=1.8.19) is installed because this version is installed separately.
Setup.py:
Code: Select all
# -*- 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-ide_%s_Windows_64bit.msi'
app_uninstallkey = "{547C91EB-BA23-4620-83BA-3E850277CD61}"
def install():
# Declaring local variables
package_version = control.get_software_version()
bin_name = bin_name_string % package_version
impacted_process = control.impacted_process.split(",")
all_user_data = makepath(programdata,'Arduino15')
# Installing the software
print("Installing: %s" % bin_name)
install_msi_if_needed(bin_name,
properties='/qn ALLUSERS=1',
killbefore=impacted_process,
timeout=900
)
uninstallkey.remove(app_uninstallkey)
copytree2('Arduino15',all_user_data)
print('Restricting permissions on %s' % all_user_data)
run(r'icacls "%s" /t /grant *S-1-5-21-3299883279-2723331061-3856246482-1728:(OI)(CI)M' % all_user_data) # groupe AD ELEVES (Get-ADGroup -Identity ELEVES | select Name, SID)
run(r'icacls "%s" /t /grant *S-1-5-21-3299883279-2723331061-3856246482-1732:(OI)(CI)M' % all_user_data) # groupe AD PROFESSEUR (Get-ADGroup -Identity PROFESSEUR | select Name, SID)
run(r'icacls "%s\\package_index.json" /inheritance:e /t /c' % all_user_data)
run(r'icacls "%s\\package_index.json.sig" /inheritance:e /t /c' % all_user_data)
def session_setup():
import tempfile
pathparamsfile = makepath(tempfile.gettempdir(),'arduino-cli.yaml')
currentuser = os.getlogin()
configpath = makepath(r'c:\users',currentuser,'.arduinoIDE')
data = r"""board_manager:
additional_urls: []
daemon:
port: "50051"
directories:
data: C:\ProgramData\Arduino15
downloads: C:\Users\%s\AppData\Local\Arduino15\staging
user: C:\Users\%s\Documents\Arduino
library:
enable_unsafe_install: false
locale: fr
logging:
file: ""
format: text
level: info
metrics:
addr: :9090
enabled: true
output:
no_color: false
sketch:
always_export_binaries: false
updater:
enable_notification: true
""" % (currentuser,currentuser)
fichier = open(pathparamsfile, "w")
fichier.write(data)
fichier.close()
mkdirs(configpath)
filecopyto(pathparamsfile,configpath)
remove_file(pathparamsfile)
def audit():
if isfile(r'%s\Arduino\uninstall.exe' % programfiles32):
print('Version précédente détectée')
return "WARNING"
else:
return "OK"
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.split(' ')[+2]
latest_bin = bin_name_string % version
download_url = 'https://downloads.arduino.cc/arduino-ide/arduino-ide_%s_Windows_64bit.msi' % 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():
run(r'"MsiExec.exe" /X%s /quiet' % app_uninstallkey,timeout=900)
print(r'Uninstalling all_user_data')
remove_tree(makepath(programdata,'Arduino15'))
Code: Select all
package : wapt-arduino
version : 2.0.0-1
architecture : x64
section : base
priority : optional
name : Arduino IDE
categories :
maintainer : olaplanche
description : The Arduino Integrated Development Environment is a cross-platform application that is written in functions from C and C++. It is used to write and upload programs to Arduino compatible boards, but also, with the help of third-party cores, other vendor development boards.
depends : wapt-ftdi-vcp-drivers,wapt-arduino-drivers
conflicts :
maturity : PROD
locale : fr
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 : Free
homepage : www.arduino.cc