aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2022-02-12 20:25:25 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2022-02-12 20:25:25 +0100
commitf93842f12ac7681cbe1def656dbbb301907f7fb2 (patch)
treee203a7e2b6b591001b60c70773402fbfbe33383e
parentf3992316ad3611b5c1d62469e201fea555702b86 (diff)
downloadlite-xl-f93842f12ac7681cbe1def656dbbb301907f7fb2.tar.gz
lite-xl-f93842f12ac7681cbe1def656dbbb301907f7fb2.zip
Add a script to repackage a release into an appimage
-rw-r--r--scripts/repackage-appimage.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/scripts/repackage-appimage.sh b/scripts/repackage-appimage.sh
new file mode 100644
index 00000000..b21cdfa0
--- /dev/null
+++ b/scripts/repackage-appimage.sh
@@ -0,0 +1,73 @@
+#!/bin/env bash
+set -e
+
+wget="wget --retry-connrefused --waitretry=1 --read-timeout=20 --no-check-certificate"
+
+workdir=".repackage"
+rm -fr "$workdir" && mkdir "$workdir" && pushd "$workdir"
+
+ARCH="x86_64"
+
+create_appimage() {
+ rm -fr LiteXL.AppDir
+
+ echo "Creating LiteXL.AppDir..."
+
+ mkdir -p LiteXL.AppDir/usr
+ tar xf "$1" -C LiteXL.AppDir/usr --strip-components=1
+ cp AppRun LiteXL.AppDir/
+ pushd LiteXL.AppDir
+ strip AppRun
+ mv usr/share/applications/org.lite_xl.lite_xl.desktop .
+ mv usr/share/icons/hicolor/scalable/apps/lite-xl.svg .
+ rm -fr usr/share/{icons,applications,metainfo}
+ popd
+
+ echo "Generating AppImage..."
+ local appimage_name="${1/lite-xl/LiteXL}"
+ appimage_name="${appimage_name/-linux/}"
+ appimage_name="${appimage_name/%.tar.gz/.AppImage}"
+
+ ./appimagetool LiteXL.AppDir "$appimage_name"
+}
+
+repackage_from_github () {
+ assets=($($wget -q -nv -O- https://api.github.com/repos/franko/lite-xl/releases/latest | grep "browser_download_url" | cut -d '"' -f 4))
+
+ for url in "${assets[@]}"; do
+ if [[ $url == *"linux-x86_64"* ]]; then
+ echo "getting: $url"
+ $wget -q "$url" || exit 1
+ create_appimage "${url##*/}"
+ fi
+ done
+}
+
+setup_appimagetool() {
+ if ! which appimagetool > /dev/null ; then
+ if [ ! -e appimagetool ]; then
+ if ! wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-${ARCH}.AppImage" ; then
+ echo "Could not download the appimagetool for the arch '${ARCH}'."
+ exit 1
+ else
+ chmod 0755 appimagetool
+ fi
+ fi
+ fi
+}
+
+download_appimage_apprun() {
+ if [ ! -e AppRun ]; then
+ if ! wget -O AppRun "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${ARCH}" ; then
+ echo "Could not download AppRun for the arch '${ARCH}'."
+ exit 1
+ else
+ chmod 0755 AppRun
+ fi
+ fi
+}
+
+setup_appimagetool
+download_appimage_apprun
+repackage_from_github
+