[RESUELTO] Paquete WAPT para Brave

Preguntas sobre paquetes WAPT / Solicitudes y ayuda sobre paquetes WAPT.
Reglas del foro
Reglas del foro de la comunidad
* Soporte en inglés en www.reddit.com/r/wapt
* El soporte de la comunidad en francés está disponible en este foro
* Por favor, anteponga [RESUELTO] al título del tema si está resuelto.
* Por favor, no edite un tema que esté etiquetado como [RESUELTO]. Abra un nuevo tema haciendo referencia al anterior.
* Especifique la versión de WAPT instalada, la versión completa y el número de compilación (2.2.1.11957 / 2.2.2.12337 / etc.), así como la edición Enterprise/Discovery.
* Las versiones 1.8.2 y anteriores ya no son compatibles. Las únicas preguntas aceptadas sobre la versión 1.8.2 están relacionadas con la actualización a una versión compatible (2.1, 2.2, etc.).
* Especifique el sistema operativo del servidor (Linux/Windows) y la versión (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Especifique el sistema operativo de la máquina de administración/creación de paquetes y de la máquina con el agente problemático, si corresponde (Windows 7/10/11/Debian 11/etc.).
* Evite hacer varias preguntas al abrir un tema, ya que podría ser ignorado. Si hay varios temas, ábralos por separado, preferiblemente uno tras otro y no todos a la vez (es decir, no sature el foro con spam).
* Incluya fragmentos de código, capturas de pantalla y otras imágenes directamente en la publicación. Los enlaces a Pastebin, Bitly y otros sitios de terceros serán eliminados sistemáticamente.
* Como en cualquier foro comunitario, el soporte es proporcionado voluntariamente por los miembros. Si necesita soporte comercial, puede comunicarse con el departamento de ventas de Tranquil IT al 02.40.97.57.55.
Bloqueado
SeiyaJuego
Mensajes: 13
Inscripciones: 25 de mayo de 2023 - 15:19 horas.

7 de julio de 2023 - 10:28

Buen día,

Me gustaría ofrecerles un paquete que diseñé para instalar el navegador Brave. Su creación se inspiró en el paquete tis-chrome, dado que ambos navegadores comparten la misma base.

He realizado la instalación, desinstalación y actualización del paquete.

En este paquete, también he integrado los archivos ADMX para GPO, una característica que podría interesar a algunos usuarios.

Ya que no puedo subir el archivo .waptVoy a compartir contigo el código de función.

Aquí está el código del archivo configuración.py :

Código: Seleccionar todo

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

Aquí está el código del archivo paquete_actualizar.py :

Código: Seleccionar todo

# -*- 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
Y por último, el archivo control :

Código: Seleccionar todo

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
Información general:

Servidor WAPT: Debian 11, versión 2.4.0.14080, Enterprise Edition
Máquina de administración: Windows 11, versión WAPT 2.4.0.14080
Avatar de usuario
jpele
Mensajes: 156
Inscripción: 4 de marzo de 2019 - 12:01
Ubicación: Nantes

24 de julio de 2023 - 14:50

Hola Flavien,

gracias por compartir.
El paquete se había archivado por nuestra parte porque los binarios del repositorio de GitHub no nos permitían empaquetarlo.
Tengo curiosidad por saber dónde encontraste el enlace de descarga.
Pude arreglar la función remove(); el paquete estará disponible en la tienda pronto :)

. Saludos,
Jimmy
Bloqueado