[RISOLTO] Pacchetto WAPT per Brave
Pubblicato: 7 luglio 2023 - 10:28
Buongiorno,
Vorrei offrirvi un pacchetto da me progettato per l'installazione del browser Brave. La sua creazione è stata ispirata dal pacchetto tis-chrome, dato che i due browser condividono la stessa base.
Ho eseguito l'installazione, la disinstallazione e l'aggiornamento del pacchetto.
In questo pacchetto ho integrato anche i file ADMX per i GPO, una funzionalità che potrebbe interessare ad alcuni utenti.
Poiché non posso caricare l'archivio .waptCondividerò con voi il codice della funzione.
Ecco il codice del file setup.py :
Ecco il codice del file update_package.py :
E infine, il file controllare :
Informazioni generali:
Server WAPT: Debian 11, versione 2.4.0.14080, Enterprise Edition
Macchina di amministrazione: Windows 11, versione WAPT 2.4.0.14080
Vorrei offrirvi un pacchetto da me progettato per l'installazione del browser Brave. La sua creazione è stata ispirata dal pacchetto tis-chrome, dato che i due browser condividono la stessa base.
Ho eseguito l'installazione, la disinstallazione e l'aggiornamento del pacchetto.
In questo pacchetto ho integrato anche i file ADMX per i GPO, una funzionalità che potrebbe interessare ad alcuni utenti.
Poiché non posso caricare l'archivio .waptCondividerò con voi il codice della funzione.
Ecco il codice del file setup.py :
Codice: Seleziona tutto
# -*- coding: utf-8 -*-
from setuphelpers import *
app_scheduled_tasks = ["BraveSoftwareUpdateTaskMachineCore", "BraveSoftwareUpdateTaskMachineUA"]
app_services = ["BraveElevationService", "brave", "bravem", "BraveVpnService"]
def install():
# Declaring local variables
package_version = control.version.split("-", 1)[0]
bin_name = glob.glob("brave_installer_*.exe")[0]
skip = False
if isdir(makepath(programfiles32, "BraveSoftware", "Brave-Browser", "Application")):
brave_app_path = makepath(programfiles32, "BraveSoftware", "Brave-Browser", "Application")
else:
brave_app_path = makepath(programfiles, "BraveSoftware", "Brave-Browser", "Application")
brave_bin_path = makepath(brave_app_path, "brave.exe")
app_uninstallkey = "BraveSoftware Brave-Browser"
def get_version_brave():
return get_file_properties(brave_bin_path)["ProductVersion"]
if windows_version() < WindowsVersions.Windows10:
# Uninstalling newer versions of the software
for to_uninstall in installed_softwares(name="^Brave$"):
if Version(to_uninstall["version"]) > Version(control.get_software_version()) or force:
print("Removing: %s (%s)" % (to_uninstall["name"], to_uninstall["version"]))
try:
killalltasks(control.get_impacted_process_list())
run(uninstall_cmd(to_uninstall["key"]))
wait_uninstallkey_absent(to_uninstall["key"])
except Exception as e:
print(e)
print("Remove failed: %s (%s)\nContinuing..." % (to_uninstall["name"], to_uninstall["version"]))
# Installing the package
if isfile(brave_bin_path):
if Version(get_version_brave()) >= Version(package_version):
if uninstall_key_exists(app_uninstallkey):
uninstallkey.append(app_uninstallkey)
skip = True
if (not skip) or force:
print("Installing: %s" % bin_name)
install_exe_if_needed(
bin_name,
silentflags="--install --silent --system-level --qn",
key=app_uninstallkey,
min_version=package_version,
)
# Disabling application scheduled tasks
for task in get_all_scheduled_tasks():
if task.split("{")[0] in app_scheduled_tasks:
if task_exists(task):
try:
disable_task(task)
except:
print("Unable to disable the task: %s" % task)
# Changing default start mode of the application services
for service_name in app_services:
set_service_start_mode(service_name, "Manual")
# Disabling Brave Auto-Update and Reporting
registry_setstring(HKEY_LOCAL_MACHINE, r"SOFTWARE\Policies\BraveSoftware\Brave", "ComponentUpdatesEnabled", 0, type=REG_DWORD)
registry_setstring(HKEY_LOCAL_MACHINE, r"SOFTWARE\Policies\BraveSoftware\Brave", "MetricsReportingEnabled", 0, type=REG_DWORD)
# # Adding master preferences file (instead, we recommend that you to create a package like tis-brave-config)
# filecopyto("master_preferences", brave_app_path)
def uninstall():
if isdir(makepath(programfiles32, "BraveSoftware", "Brave-Browser", "Application")):
brave_app_path = makepath(programfiles32, "BraveSoftware", "Brave-Browser", "Application")
else:
brave_app_path = makepath(programfiles, "BraveSoftware", "Brave-Browser", "Application")
brave_bin_path = makepath(brave_app_path, "brave.exe")
app_uninstallkey = "BraveSoftware Brave-Browser"
# Uninstalling the package
if uninstall_key_exists(app_uninstallkey):
if not "msiexec" in " ".join(list(uninstall_cmd(app_uninstallkey))).lower():
versionsoft = get_file_properties(brave_bin_path)["ProductVersion"]
run(
'"%s" --uninstall --system-level --force-uninstall --qn'
% makepath(install_location(app_uninstallkey), versionsoft, "Installer", "setup.exe"),
accept_returncodes=[19],
)
def session_setup():
# Needed on Brave ??
swreporter_path = makepath(user_local_appdata, "BraveSoftware", "Brave-Browser", "User Data", "SwReporter")
if isdir(swreporter_path):
print("Removing: %s" % swreporter_path)
remove_tree(swreporter_path)
Codice: Seleziona tutto
# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *
import re
import json
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_api = "https://api.github.com/repos/brave/brave-browser/releases/latest"
url_dl = "https://brave-browser-downloads.s3.brave.com/latest/brave_installer-x64.exe"
# Getting latest informations from official Google API
json_load = json.loads(wgets(url_api))
tag_version = json_load['tag_name'][1:]
chromium_version = re.search(r"Chromium (\d+(?:\.\d+)+)", json_load['name']).group(1)
version = f"{chromium_version.split('.')[0]}.{tag_version}"
latest_bin = f"brave_installer_x64_{version}.exe"
print(f"Latest {app_name} version is: {version}")
print(f"Download url is: {url_dl}")
# Downloading latest binaries
if not isfile(latest_bin):
print("Downloading: " + latest_bin)
wget(url_dl, latest_bin, proxies=proxies)
# Get version from description exe
exe_version = get_version_from_binary(latest_bin)
if exe_version != version:
remove_file(latest_bin)
error("The version returned by the API and the version returned by the exe does not match")
# Changing version of the package
if 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(version))
control.save_control_to_wapt()
# Deleting outdated binaries
remove_outdated_binaries(version)
# Validating update-package-sources
return result
Codice: Seleziona tutto
package : loq-brave
version : 114.1.52.129-3
architecture : x64
section : base
priority : optional
name : Brave
categories : Internet
maintainer : Flavien Schelfaut (Loquidy)
description : Brave is a free and open-source web browser developed by Brave Software, Inc. It blocks ads and website trackers, and provides a way for users to send cryptocurrency contributions in the form of Basic Attention Tokens to websites and content creators
depends :
conflicts :
maturity : PROD
locale : all
target_os : windows
min_wapt_version : 2.1
sources : https://laptop-updates.brave.com/latest/winx64
installed_size : 684132243
impacted_process : brave,chrome_proxy,chrome_pwa_launcher,chrmstp
description_fr : Brave est un navigateur web gratuit et open-source développé par Brave Software, Inc. Il bloque les publicités et les traqueurs de sites web, et permet aux utilisateurs d'envoyer des contributions en crypto-monnaie sous la forme de jetons d'attention de base à des sites web et à des créateurs de contenu.
description_pl :
description_de : Brave ist ein freier und quelloffener Webbrowser, der von Brave Software, Inc. entwickelt wurde. Er blockiert Werbung und Website-Tracker und bietet Nutzern die Möglichkeit, Kryptowährungsbeiträge in Form von Basic Attention Tokens an Websites und Inhaltsersteller zu senden
description_es : Brave es un navegador web gratuito y de código abierto desarrollado por Brave Software, Inc. Bloquea los anuncios y los rastreadores de sitios web, y permite a los usuarios enviar contribuciones en criptomoneda en forma de Basic Attention Tokens a sitios web y creadores de contenidos.
description_pt :
description_it :
description_nl :
description_ru :
audit_schedule :
editor : Brave Software, Inc.
keywords : browser,navigateur,brave,chromium
licence : MPL-2.0
homepage : https://brave.com/
package_uuid : 4774f883-f37e-4cba-8e8d-3843983f4836
valid_from :
valid_until :
forced_install_on :
changelog : https://brave.com/latest/
min_os_version : 10.0
max_os_version :
icon_sha256sum : 6795ee5386706c0b9b19fa54c995beebe9f986612b31f5ab8311afe3be34e614
signer : loqwapt
signer_fingerprint: b4bf538731a5e9de85fe3a5014052844fe130cb54afab01cd1aaf90f284bd72e
signature : ibLdu+pbcsnoy1DPJUd7sEOPdcIxzmBTrFb/PzzwyWndc2VVvI9UI33sX3riHA8yxsqvKfegnz3vuGSqhfHHoaOYfFkninw7zn2l0J0AwBzR6n1Elxc9Axrj/ToDL2ZGx0eJYnGRy7omgAQtEjl8e7PU4eRMTtliftpE16hb2elbtcGncmgQ10D/Jsmfwmu+JZXhVGtwDYhWs8ataFn5DD3kBSNrR7vPbsX1L7gY15hDHq9FmOhX8yJdT+ZgHq3oxQ+yR+Opzdmrq5g8C4zL3Fs/r70pbypCXLwyiEYptP0/JxfB+vl8AIjYounw2tc10SsARFl13Nvc+ckii71+5Q==
signature_date : 2023-07-07T09:46:57.730886
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
Server WAPT: Debian 11, versione 2.4.0.14080, Enterprise Edition
Macchina di amministrazione: Windows 11, versione WAPT 2.4.0.14080