[RESOLVED] Package for reMarkable

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Answer
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

November 29, 2024 - 11:22

Good morning,

Here is the package I made for the reMarkable software (software for electronic ink tablets), if it can be of use.

Note: Windows version only, but there is also a macOS version; we just don't need it, but if anyone is interested, I can package it ;)

Note 2: This is a clever piece of software that puts its uninstallation key in the registry of the user who installs it, even if it installs in Program Files, which means that it doesn't appear in the list of installed programs in the Control Panel when you're not logged in as the user who installed it...

setup.py:

Code: Select all

# -*- 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')
control:

Code: Select all

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
...
Answer