antos-appimage/mkimg.sh

91 lines
2.1 KiB
Bash
Raw Normal View History

2022-09-20 11:41:59 +02:00
#! /bin/bash
set -e
set -x
2022-09-20 12:13:53 +02:00
# modprobe fuse
2022-09-20 11:41:59 +02:00
arch=$1
2022-09-20 14:11:17 +02:00
[ -z $arch ] && arch=amd64
tag=$2
[ -z $tag ] && tag=latest
2022-09-20 11:41:59 +02:00
# download the appimagetools
echo "Downloading the appimage tools"
archname=x86_64
case $arch in
amd64|x86_64)
archname=x86_64
;;
aarch64|arm64)
archname=aarch64
;;
armv7l|arm)
archname=armhf
;;
*)
echo "Unkown architecture"
exit 1
;;
esac
2022-09-20 14:11:17 +02:00
[ -f appimagetool.AppImage ] || wget --no-check-certificate -O appimagetool.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool.AppImage
2022-09-20 11:41:59 +02:00
2022-09-20 14:11:17 +02:00
wget --no-check-certificate https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-$archname
2022-09-20 12:35:11 +02:00
2022-09-29 23:46:16 +02:00
W="$WORKSPACE/antos/"
2022-09-20 11:41:59 +02:00
[ -d antos.AppDir ] && rm -rf antos.AppDir
echo "Building app image for $arch"
mkdir antos.AppDir
# AppRun
cat << "EOF" >> antos.AppDir/AppRun
#!/bin/sh
set -e
echo "Runing AntOS"
W=$(realpath $1)
B=$(dirname $0)
cd $B
[ ! -d "$W" ] && echo "$W is not a directory" && exit 1
# start antd-tunnel service
2022-10-03 16:35:51 +02:00
if [ ! -f "$W/antd-config.ini" ]; then
2022-10-03 16:33:31 +02:00
cp ./opt/www/antd-config.ini $W/antd-config.ini
fi
2022-09-20 11:41:59 +02:00
[ ! -f "$W/runner.ini" ] && cp ./opt/www/runner.ini $W/runner.ini
export LD_LIBRARY_PATH="$B/usr/lib/"
2022-10-03 16:23:24 +02:00
echo "Runing Antd in $B with configuration $W/antd-config.ini"
2022-10-03 16:33:31 +02:00
# TODO this is not good
2022-09-20 11:41:59 +02:00
touch /tmp/.antos_pkgcache
2022-10-03 16:59:56 +02:00
ln -sf $W/ /tmp/antos-db
2022-09-20 11:41:59 +02:00
./usr/bin/antd $W/antd-config.ini >/dev/null 2>&1 | ( sleep 2 && ./opt/www/bin/runner $W/runner.ini >/dev/null 2>&1 &)
EOF
chmod +x antos.AppDir/AppRun
# desktop file
cat << "EOF" >> antos.AppDir/antos.desktop
[Desktop Entry]
Name=AntOS
Exec=antd
Icon=antos
Type=Application
Categories=Utility;
Terminal=true
EOF
# copy all neccessary file
cp antos.png antos.AppDir
2022-09-29 23:46:16 +02:00
cp -rf $W/backend/build/$arch/* antos.AppDir/
2022-09-20 11:41:59 +02:00
2022-09-29 23:46:16 +02:00
cp -rf $W/frontend/$tag/build/* antos.AppDir/
2022-09-20 11:41:59 +02:00
cp antd-config.ini antos.AppDir/opt/www/
cp runner.ini antos.AppDir/opt/www/
ln -sf /tmp/.antos_pkgcache antos.AppDir/opt/www/htdocs/os/packages/packages.json
tree antos.AppDir
2022-09-20 14:11:17 +02:00
./appimagetool.AppImage --runtime-file runtime-$archname antos.AppDir build/AntOS_$archname-$tag.AppImage