Skip to content

Commit 165cb14

Browse files
Add AppImage build on linux
This consists of a meson option that - sets a flag to make Aegisub read paths relative to the executable - makes meson set up the symlinks like AppRun and .DirIcon as following the AppDir format and a CI workflow that builds with this option, installs to an AppDir directory, and bundles it as an AppImage. Modified from #12 . Co-authored-by: Fred Brennan <copypaste@kittens.ph>
1 parent 8633e2c commit 165cb14

5 files changed

Lines changed: 57 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ jobs:
4949
buildtype: release,
5050
args: ''
5151
}
52+
- name: Ubuntu AppImage
53+
os: ubuntu-22.04
54+
buildtype: release
55+
appimage: true
56+
# distro ffms is currently broken
57+
args: >-
58+
--prefix=/usr
59+
-Dbuild_appimage=true
60+
-Ddefault_library=static
61+
--force-fallback-for=ffms2
62+
-Davisynth=enabled
63+
-Dbestsource=enabled
64+
-Dvapoursynth=enabled
5265
- {
5366
name: macOS Debug,
5467
os: macos-latest,
@@ -102,13 +115,13 @@ jobs:
102115
brew install pulseaudio # NO OpenAL in github CI
103116
104117
- name: Install dependencies (Linux)
105-
if: matrix.config.os == 'ubuntu-latest'
118+
if: startsWith(matrix.config.os, 'ubuntu-')
106119
run: |
107120
sudo apt-get update
108121
sudo apt-get install ninja-build build-essential libx11-dev libwxgtk3.0-gtk3-dev libfreetype6-dev pkg-config libfontconfig1-dev libass-dev libasound2-dev libffms2-dev intltool libboost-all-dev
109122
110123
- name: Configure
111-
run: meson build ${{ matrix.config.args }} -Dbuildtype=${{ matrix.config.buildtype }}
124+
run: meson setup build ${{ matrix.config.args }} -Dbuildtype=${{ matrix.config.buildtype }}
112125

113126
- name: Build
114127
run: meson compile -C build
@@ -157,3 +170,28 @@ jobs:
157170
name: ${{ matrix.config.name }} - installer
158171
path: build/Aegisub-*.dmg
159172
if-no-files-found: error
173+
174+
# Linux artifacts (AppImage)
175+
- name: Generate AppImage
176+
if: matrix.config.appimage
177+
run: |
178+
mkdir -p appimage/appdir
179+
meson install -C build --destdir=../appimage/appdir
180+
181+
cd appimage
182+
sudo apt-get install libfuse2
183+
curl -L "https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20220822-1/linuxdeploy-x86_64.AppImage" -o linuxdeploy
184+
curl -L "https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage" -o appimagetool
185+
chmod +x linuxdeploy appimagetool
186+
187+
./linuxdeploy --appdir appdir --desktop-file=appdir/aegisub.desktop
188+
./appimagetool appdir
189+
# ./appimagetool -g -s appdir --comp xz
190+
191+
- name: Upload artifacts - Linux AppImage
192+
uses: actions/upload-artifact@v3
193+
if: matrix.config.appimage
194+
with:
195+
name: ${{ matrix.config.name }}
196+
path: appimage/*.AppImage
197+
if-no-files-found: error

libaegisub/unix/path.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,13 @@ void Path::FillPlatformSpecificPaths() {
7575
SetToken("?local", home/".aegisub");
7676

7777
#ifdef APPIMAGE_BUILD
78-
agi::fs::path data = exe_dir();
79-
if (data == "") data = home/".aegisub";
80-
SetToken("?data", data);
81-
SetToken("?dictionary", Decode("?data/dictionaries"));
78+
agi::fs::path exe = exe_dir();
79+
agi::fs::path data_from_bin = agi::fs::path(P_DATA).lexically_relative(P_BIN);
80+
SetToken("?data", (exe != "" ? exe/data_from_bin : home/".aegisub").make_preferred());
8281
#else
8382
SetToken("?data", P_DATA);
84-
SetToken("?dictionary", "/usr/share/hunspell");
8583
#endif
84+
SetToken("?dictionary", "/usr/share/hunspell");
8685

8786
#else
8887
agi::fs::path app_support = agi::util::GetApplicationSupportDirectory();

meson.build

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project('Aegisub', ['c', 'cpp'],
22
license: 'BSD-3-Clause',
3-
meson_version: '>=0.57.0',
3+
meson_version: '>=0.61.0',
44
default_options: ['cpp_std=c++14', 'buildtype=debugoptimized'],
55
version: '3.2.2')
66

@@ -57,11 +57,15 @@ if get_option('buildtype') == 'release'
5757
endif
5858

5959
conf = configuration_data()
60+
conf.set_quoted('P_BIN', bindir)
6061
conf.set_quoted('P_DATA', dataroot)
6162
conf.set_quoted('P_LOCALE', localedir)
6263
if get_option('credit') != ''
6364
conf.set_quoted('BUILD_CREDIT', get_option('credit'))
6465
endif
66+
if get_option('build_appimage')
67+
conf.set('APPIMAGE_BUILD', 1)
68+
endif
6569
conf.set('WITH_UPDATE_CHECKER', get_option('enable_update_checker'))
6670

6771
deps = []
@@ -94,7 +98,7 @@ deps += dependency('libass', version: '>=0.9.7',
9498

9599
boost_modules = ['chrono', 'filesystem', 'thread', 'locale', 'regex']
96100
if not get_option('local_boost')
97-
boost_dep = dependency('boost', version: '>=1.50.0',
101+
boost_dep = dependency('boost', version: '>=1.60.0',
98102
modules: boost_modules + ['system'],
99103
required: false,
100104
static: get_option('default_library') == 'static')

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ option('update_server', type: 'string', value: 'updates.aegisub.org', descriptio
2525
option('update_url', type: 'string', value: '/trunk', description: 'Base path to use for the update checker')
2626

2727
option('build_osx_bundle', type: 'boolean', value: 'false', description: 'Package Aegisub.app on OSX')
28+
option('build_appimage', type: 'boolean', value: 'false', description: 'Prepare for AppImage packaging')

packages/meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,10 @@ else
3838
install_data('desktop' / dir / 'aegisub.' + ext,
3939
install_dir: datadir / 'icons' / 'hicolor' / dir / 'apps')
4040
endforeach
41+
42+
if get_option('build_appimage')
43+
install_symlink('AppRun', install_dir: '/', pointing_to: bindir.strip('/') / 'aegisub')
44+
install_symlink('.DirIcon', install_dir: '/', pointing_to: datadir.strip('/') / 'icons' / 'hicolor' / 'scalable' / 'apps' / 'aegisub.svg')
45+
install_symlink('aegisub.desktop', install_dir: '/', pointing_to: datadir.strip('/') / 'applications' / 'aegisub.desktop')
46+
endif
4147
endif

0 commit comments

Comments
 (0)