2024-10-22 17:53:17 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-09-25 22:59:01 +02:00
|
|
|
set -e
|
2021-08-09 12:19:27 +02:00
|
|
|
|
|
|
|
if [ ! -e "src/api/api.h" ]; then
|
|
|
|
echo "Please run this script from the root directory of Lite XL."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
source scripts/common.sh
|
|
|
|
|
2022-09-25 22:59:01 +02:00
|
|
|
ARCH="$(uname -m)"
|
|
|
|
BUILD_DIR="$(get_default_build_dir)"
|
|
|
|
ADDONS=false
|
|
|
|
|
2021-08-09 12:19:27 +02:00
|
|
|
show_help(){
|
|
|
|
echo
|
2021-08-29 10:15:55 +02:00
|
|
|
echo "Usage: $0 <OPTIONS>"
|
2021-08-09 12:19:27 +02:00
|
|
|
echo
|
|
|
|
echo "Available options:"
|
|
|
|
echo
|
|
|
|
echo "-h --help Show this help and exits."
|
|
|
|
echo "-b --builddir DIRNAME Sets the name of the build dir (no path)."
|
2022-09-25 22:59:01 +02:00
|
|
|
echo " Default: '${BUILD_DIR}'."
|
|
|
|
echo " --debug Debug this script."
|
2021-08-09 12:19:27 +02:00
|
|
|
echo "-n --nobuild Skips the build step, use existing files."
|
|
|
|
echo "-v --version VERSION Specify a version, non whitespace separated string."
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
2022-09-25 22:59:01 +02:00
|
|
|
-h|--help)
|
2021-08-09 12:19:27 +02:00
|
|
|
show_help
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-b|--builddir)
|
|
|
|
BUILD_DIR="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
2022-09-25 22:59:01 +02:00
|
|
|
--debug)
|
|
|
|
set -x
|
|
|
|
shift
|
|
|
|
;;
|
2021-08-09 12:19:27 +02:00
|
|
|
-v|--version)
|
|
|
|
VERSION="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
setup_appimagetool() {
|
2022-09-25 22:59:01 +02:00
|
|
|
if [ ! -e appimagetool ]; then
|
2024-11-15 03:39:11 +01:00
|
|
|
if ! wget -O appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${ARCH}.AppImage" ; then
|
2022-09-25 22:59:01 +02:00
|
|
|
echo "Could not download the appimagetool for the arch '${ARCH}'."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
chmod 0755 appimagetool
|
2021-08-09 12:19:27 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-08-29 10:15:55 +02:00
|
|
|
generate_appimage() {
|
2024-10-22 17:53:17 +02:00
|
|
|
[[ ! -e $BUILD_DIR ]] && scripts/build.sh $@
|
|
|
|
|
2021-08-09 12:19:27 +02:00
|
|
|
if [ -e LiteXL.AppDir ]; then
|
|
|
|
rm -rf LiteXL.AppDir
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating LiteXL.AppDir..."
|
|
|
|
|
2024-10-22 17:53:17 +02:00
|
|
|
DESTDIR="$(realpath LiteXL.AppDir)" meson install -C ${BUILD_DIR}
|
2024-11-15 03:39:11 +01:00
|
|
|
|
2021-08-09 12:19:27 +02:00
|
|
|
cp resources/icons/lite-xl.svg LiteXL.AppDir/
|
2023-06-09 15:18:02 +02:00
|
|
|
cp resources/linux/com.lite_xl.LiteXL.desktop LiteXL.AppDir/
|
2021-08-09 12:19:27 +02:00
|
|
|
|
2024-11-15 03:39:11 +01:00
|
|
|
# https://github.com/lite-xl/lite-xl/issues/1912
|
|
|
|
mkdir -p ./LiteXL.AppDir/usr/share/../bin
|
|
|
|
mv ./LiteXL.AppDir/lite-xl ./LiteXL.AppDir/usr/bin
|
|
|
|
mv ./LiteXL.AppDir/data ./LiteXL.AppDir/usr/share/lite-xl
|
|
|
|
rm -rf ./LiteXL.AppDir/lib64 ./LiteXL.AppDir/include
|
|
|
|
|
|
|
|
echo "Creating AppRun..."
|
|
|
|
cat >> LiteXL.AppDir/AppRun <<- 'EOF'
|
|
|
|
#!/bin/sh
|
|
|
|
CURRENTDIR="$(dirname "$(readlink -f "$0")")"
|
|
|
|
exec "$CURRENTDIR/usr/bin/lite-xl" "$@"
|
|
|
|
EOF
|
|
|
|
chmod +x LiteXL.AppDir/AppRun
|
|
|
|
|
2021-08-09 12:19:27 +02:00
|
|
|
echo "Generating AppImage..."
|
|
|
|
local version=""
|
|
|
|
if [ -n "$VERSION" ]; then
|
|
|
|
version="-$VERSION"
|
|
|
|
fi
|
|
|
|
|
2024-11-15 03:39:11 +01:00
|
|
|
APPIMAGE_EXTRACT_AND_RUN=1 ./appimagetool LiteXL.AppDir LiteXL${version}-${ARCH}-linux.AppImage
|
2024-10-22 17:53:17 +02:00
|
|
|
rm -rf LiteXL.AppDir
|
2021-08-09 12:19:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_appimagetool
|
2024-10-22 17:53:17 +02:00
|
|
|
generate_appimage
|