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')
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
...
