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 15, 2021
1 parent b74db1d commit 0a66ab2
Show file tree
Hide file tree
Showing 29 changed files with 1,389 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 }
- { id: i386 }
env:
NONINTERACTIVE: 1

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
8 changes: 6 additions & 2 deletions mesonbuild/mesonlib/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@

from glob import glob

if os.path.basename(sys.executable) == 'meson.exe':
if 'MESON_PYTHON_BIN' in os.environ:
python_command = shlex.split(os.environ['MESON_PYTHON_BIN'])
elif os.path.basename(sys.executable) == 'meson.exe':
# In Windows and using the MSI installed executable.
python_command = [sys.executable, 'runpython']
else:
Expand Down Expand Up @@ -219,7 +221,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 0a66ab2

Please sign in to comment.