Skip to content

Commit

Permalink
AppImage: AppImage builder
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda committed Aug 7, 2021
1 parent 53ce161 commit 13b54fc
Show file tree
Hide file tree
Showing 29 changed files with 1,365 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

# Run on all tags
on:
push:
tags:
- '*'

jobs:
runtime_builder:
name: Runtime ${{ matrix.cfg.id }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cfg:
- { id: x86_64, img: alpine }
- { id: i386 , img: i386/alpine }
container: ${{ matrix.cfg.img }}:latest

steps:
- uses: actions/checkout@v2
- name: Building ${{ matrix.cfg.id }} Meson runtime
run: ./packaging/appimage/build_${{ matrix.cfg.id }}.sh
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: appimage/meson-${{ matrix.cfg.id }}.runtime
tag: ${{ github.ref }}
overwrite: true
body: ${{ github.ref }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ __pycache__
.DS_Store
*~
*.swp
meson*.runtime
packagecache
/MANIFEST
/build
/appimage
/dist
/meson.egg-info

Expand Down
4 changes: 3 additions & 1 deletion mesonbuild/mesonlib/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ def set_meson_command(mainfile: str) -> None:
global _meson_command
# On UNIX-like systems `meson` is a Python script
# On Windows `meson` and `meson.exe` are wrapper exes
if not mainfile.endswith('.py'):
if 'MESON_COMMAND' in os.environ:
_meson_command = shlex.split(os.environ['MESON_COMMAND'])
elif not mainfile.endswith('.py'):
_meson_command = [mainfile]
elif os.path.isabs(mainfile) and mainfile.endswith('mesonmain.py'):
# Can't actually run meson with an absolute path to mesonmain.py, it must be run as -m mesonbuild.mesonmain
Expand Down
18 changes: 18 additions & 0 deletions mesonbuild/msetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
import sys, stat
import datetime
import os.path
import os
import platform
import cProfile as profile
import argparse
import tempfile
import shutil
import glob
import subprocess

from pathlib import Path

from . import environment, interpreter, mesonlib
from . import build
Expand Down Expand Up @@ -74,6 +78,20 @@ def __init__(self, options: argparse.Namespace) -> None:
options.sourcedir,
options.reconfigure,
options.wipe)
# Detect if we are running from the AppImage runtime. Then self-extract
# and relaunch with the extracted binaries
if 'APPIMAGE' in os.environ:
rc = subprocess.run([os.environ['APPIMAGE'], '--runtime-setup', self.build_dir]).returncode
if rc == 0:
del os.environ['APPIMAGE'] # avoid infinite loops
del os.environ['APPDIR']
meson_exe = Path(self.build_dir) / 'meson-runtime' / 'fakebin' / 'meson'
meson_exe = meson_exe.resolve()
os.execve(meson_exe.as_posix(), [meson_exe.as_posix(), *sys.argv[1:]], os.environ)
# execve never returns. See `man 3 exec`.

mlog.warning('Failed to self extract', mlog.bold(os.environ['APPIMAGE']), 'to', mlog.bold(options.builddir), f'(rc = {rc})')

if options.wipe:
# Make a copy of the cmd line file to make sure we can always
# restore that file if anything bad happens. For example if
Expand Down
Loading

0 comments on commit 13b54fc

Please sign in to comment.