Pagina 1 di 1

[RISOLTO] Pacchetto per reMarkable

Pubblicato: 29 novembre 2024 - 11:22
di bastien30
Buongiorno,

Ecco il pacchetto che ho realizzato per il software reMarkable (software per tavolette a inchiostro elettronico), se può essere utile.

Nota: solo la versione per Windows, ma esiste anche una versione per macOS; non ne abbiamo bisogno, ma se qualcuno è interessato, posso fornirla ;)

Nota 2: Si tratta di un software intelligente che inserisce la sua chiave di disinstallazione nel registro dell'utente che lo installa, anche se l'installazione avviene in Programmi, il che significa che non compare nell'elenco dei programmi installati nel Pannello di controllo quando non si è effettuato l'accesso come utente che lo ha installato...

setup.py:

Codice: Seleziona tutto

# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *
import requests

uninstallkey = []

def install():
    to_install = True
    appver = control.get_software_version()
    app_name = control.name
    bin_name = r'%s-%s-win64.exe' % (app_name, appver)
    
    # Checking installed version
    installed_bin = makepath(programfiles64, app_name, r'%s.exe' % app_name)
    if isfile(installed_bin):
        installed_version = get_file_properties(installed_bin)["ProductVersion"]
        if Version(installed_version) >= Version(appver):
            to_install = False

    if to_install or WAPT.options.force:
        if isfile(installed_bin):
            print(r'Removing installed application before to avoid errors...')
            uninstall()
            time.sleep(2)
        # Remove directory if exists as it block new installation
        if isdir(makepath(programfiles64, app_name)):
            remove_tree(makepath(programfiles64, app_name))
        print(r'Installing %s version %s ...' % (app_name, appver))
        run(r'"%s" install --accept-licenses --default-answer --confirm-command' % bin_name)
        # Create program menu shortcut for all users
        create_programs_menu_shortcut(app_name, target=installed_bin)
    else:
        print(r'%s version %s or newer is already installed, use "-f" argument to force installation.' % (app_name, appver))

def uninstall():
    print(r'Uninstalling reMarkable ...')
    uninstaller = makepath(programfiles64, r'reMarkable', r'maintenancetool.exe')
    if isfile(uninstaller):
        run(r'"%s" purge --confirm-command' % uninstaller)
        # Remove leftovers
        if isdir(makepath(programfiles64, r'reMarkable')):
            remove_tree(makepath(programfiles64, r'reMarkable'))
    else:
        error(r'Error uninstalling package, uninstaller %s does not exists !' % uninstaller)

def update_package():
    print(r'Checking latest version...')
    response = requests.get(control.sources)
    latest_version = response.url.split(r'/')[-1].split(r'-')[1]
    print(r'Latest version is %s' % latest_version)

    if Version(latest_version) > Version(control.get_software_version()):
        print(r'Downloading latest version from %s' % response.url)
        latest_bin = response.url.split(r'/')[-1]
        wget(response.url, latest_bin)
        
        # Changing version of the package
        control.version = '%s-%s'%(latest_version, control.version.split('-')[-1])
        control.save_control_to_wapt()
        print('Changing version to: %s in WAPT\\control' % control.version)

        # Deleting outdated binaries
        remove_outdated_binaries(latest_version)
    else:
        print('Already up to date')
controllare:

Codice: Seleziona tutto

package           : xxx-remarkable
version           : 3.15.1.895-9
architecture      : x64
section           : base
priority          : optional
name              : reMarkable
categories        : 
maintainer        : admin
description       : reMarkable desktop app (upok)
depends           : 
conflicts         : 
maturity          : PROD
locale            : 
target_os         : windows
min_wapt_version  : 
sources           : https://downloads.remarkable.com/latest/windows
installed_size    : 
impacted_process  : reMarkable
...