From 93e8ee129c0a3df08261e7477d6f31e6aec12c42 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Tue, 9 Feb 2021 15:47:13 +0100
Subject: [PATCH] Add a script to generate an AppImage from aegisub

---
 .gitignore          |  8 +++++---
 src/main.cpp        |  2 +-
 tools/appimage.bash | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100755 tools/appimage.bash

diff --git a/.gitignore b/.gitignore
index 75c278598..2570c4780 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,15 +12,19 @@ tests/*.json
 tools/osx-bundle.sed
 tools/repack-thes-dict
 tools/repack-thes-dict.dSYM
+*.AppImage
 
 # IDE-specific
 .nuget
 .vs
 .kdev4/
 *.kdev4
+cscope.files
+tags
 
 # Platform-specific
 .DS_Store
+AppImage
 
 # Meson
 build*/
@@ -37,8 +41,6 @@ subprojects/ffmpeg
 subprojects/ffms2*
 subprojects/boost*
 
-# Build and tag files
-cscope.files
+# Build files
 git_version.h
 git_version.xml
-tags
diff --git a/src/main.cpp b/src/main.cpp
index 7f6d9162c..e3fc95d2a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -293,7 +293,7 @@ bool AegisubApp::OnInit() {
 
 		// Open main frame
 		StartupLog("Create main window");
-		NewProjectContext();
+		NewProjectContext(); // XXX Criticals and errors generated on `Show();`, a widget has a width of -17 (GtkSpinButton)
 
 		// Version checker
 		StartupLog("Possibly perform automatic updates check");
diff --git a/tools/appimage.bash b/tools/appimage.bash
new file mode 100755
index 000000000..7b402b095
--- /dev/null
+++ b/tools/appimage.bash
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+URL_APPIMAGETOOL="https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-`arch`.AppImage"
+URL_LINUXDEPLOY="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-`arch`.AppImage"
+
+APPIMAGETOOL="tools/appimagetool-`arch`.AppImage"
+LINUXDEPLOY="tools/linuxdeploy-`arch`.AppImage"
+
+echo "You will need patchelf and wget." \
+    "The linuxdeploy and appimagetool dependencies will be downloaded." \
+    "Aegisub also needs to be in your path."
+
+WGET=`which wget 2>/dev/null`
+[ $? -ne 0 ] && exit 1
+echo "wget: $WGET"
+
+PATCHELF=`which patchelf 2>/dev/null`
+[ $? -ne 0 ] && exit 1
+echo "patchelf: $PATCHELF"
+
+AEGISUB=`which aegisub 2>/dev/null`
+[ $? -ne 0 ] && exit 1
+echo "Aegisub: $AEGISUB"
+
+# DL
+[ -e "$APPIMAGETOOL" ] || { wget "$URL_APPIMAGETOOL" -O "$APPIMAGETOOL" || exit 1; }
+[ -e "$LINUXDEPLOY"  ] || { wget "$URL_LINUXDEPLOY"  -O "$LINUXDEPLOY"  || exit 1; }
+
+chmod +x "$APPIMAGETOOL" "$LINUXDEPLOY"
+
+# Setup & deploy
+[ -d "AppImage/Aegisub" ] || { mkdir -p "AppImage/Aegisub" || exit 1; }
+cp packages/desktop/aegisub.desktop.template.in AppImage/aegisub.desktop || exit 1;
+cp packages/desktop/64x64.png AppImage/aegisub.png                       || exit 1;
+sed -i -e 's/@AEGISUB_COMMAND@/aegisub/g' AppImage/aegisub.desktop       || exit 1;
+$LINUXDEPLOY                                    \
+    --appdir AppImage/Aegisub                   \
+    --icon-file AppImage/aegisub.png            \
+    --desktop-file AppImage/aegisub.desktop     \
+    --executable "$AEGISUB" || exit 1;
+$APPIMAGETOOL AppImage/Aegisub
-- 
GitLab