Select appimagetool version

This commit is contained in:
Valentin Niess
2025-02-10 18:31:05 +01:00
parent 583a61686a
commit 72a52b6f34
3 changed files with 45 additions and 13 deletions

View File

@@ -27,6 +27,8 @@ def main():
help='Command to execute',
dest='command')
parser.add_argument('-a', '--appimagetool-version',
help='set appimagetool version')
parser.add_argument('-q', '--quiet', help='disable logging',
dest='verbosity', action='store_const', const='ERROR')
parser.add_argument('-v', '--verbose', help='print extra information',
@@ -98,6 +100,10 @@ def main():
from .utils import log
log.set_level(args.verbosity)
if args.appimagetool_version:
from .utils import deps
deps.APPIMAGETOOL_VERSION = args.appimagetool_version
# check if no arguments are passed
if args.command is None:
parser.print_help()

View File

@@ -5,7 +5,7 @@ import subprocess
import sys
from ..utils.compat import decode
from ..utils.deps import APPIMAGETOOL, ensure_appimagetool
from ..utils.deps import ensure_appimagetool
from ..utils.docker import docker_run
from ..utils.fs import copy_tree
from ..utils.log import debug, log
@@ -22,10 +22,10 @@ def build_appimage(appdir=None, destination=None):
appdir = 'AppDir'
log('BUILD', appdir)
ensure_appimagetool()
appimagetool = ensure_appimagetool()
arch = platform.machine()
cmd = ['ARCH=' + arch, APPIMAGETOOL, '--no-appstream', appdir]
cmd = ['ARCH=' + arch, appimagetool, '--no-appstream', appdir]
if destination is not None:
cmd.append(destination)
cmd = ' '.join(cmd)
@@ -45,7 +45,8 @@ def build_appimage(appdir=None, destination=None):
elif out:
out = out.replace('%', '%%')[:-1]
for line in out.split(os.linesep):
if line.startswith('WARNING'):
if line.startswith('WARNING') and \
not line[9:].startswith('zsyncmake command is missing'):
log('WARNING', line[9:])
elif line.startswith('Error'):
raise RuntimeError(line)

View File

@@ -19,31 +19,56 @@ _ARCH = platform.machine()
PREFIX = os.path.abspath(os.path.dirname(__file__) + '/..')
'''Package installation prefix'''
APPIMAGETOOL = os.path.expanduser('~/.local/bin/appimagetool')
APPIMAGETOOL_DIR = os.path.expanduser('~/.local/bin')
'''Location of the appimagetool binary'''
APPIMAGETOOL_VERSION = '12'
'''Version of the appimagetool binary'''
EXCLUDELIST = PREFIX + '/data/excludelist'
'''AppImage exclusion list'''
PATCHELF = os.path.expanduser('~/.local/bin/patchelf')
'''Location of the PatchELF binary'''
def ensure_appimagetool():
'''Fetch appimagetool from the web if not available locally
'''
if os.path.exists(APPIMAGETOOL):
return False
if APPIMAGETOOL_VERSION == '12':
appimagetool_name = 'appimagetool'
else:
appimagetool_name = 'appimagetool-' + APPIMAGETOOL_VERSION
appimagetool = os.path.join(APPIMAGETOOL_DIR, appimagetool_name)
appdir_name = '.'.join(('', appimagetool_name, 'appdir', _ARCH))
appdir = os.path.join(APPIMAGETOOL_DIR, appdir_name)
apprun = os.path.join(appdir, 'AppRun')
if os.path.exists(apprun):
return apprun
appimage = 'appimagetool-{0:}.AppImage'.format(_ARCH)
baseurl = 'https://github.com/AppImage/appimagetool/releases/download/continuous'
if APPIMAGETOOL_VERSION in map(str, range(1, 14)):
repository = 'AppImageKit'
else:
repository = 'appimagetool'
baseurl = os.path.join(
'https://github.com/AppImage',
repository,
'releases/download',
APPIMAGETOOL_VERSION
)
log('INSTALL', 'appimagetool from %s', baseurl)
make_tree(os.path.dirname(APPIMAGETOOL))
urlretrieve(os.path.join(baseurl, appimage), APPIMAGETOOL)
os.chmod(APPIMAGETOOL, stat.S_IRWXU)
if not os.path.exists(appdir):
make_tree(os.path.dirname(appdir))
with TemporaryDirectory() as tmpdir:
urlretrieve(os.path.join(baseurl, appimage), appimage)
os.chmod(appimage, stat.S_IRWXU)
system(('./' + appimage, '--appimage-extract'))
copy_tree('squashfs-root', appdir)
return True
return apprun
# Installers for dependencies