antos-appimage/mkimg.sh

92 lines
2.0 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
# 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 13:34:16 +02:00
wget --no-check-certificate -O appimagetool.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$archname.AppImage
chmod +x appimagetool.AppImage
2022-09-20 11:41:59 +02:00
file appimagetool.AppImage
2022-09-20 12:35:11 +02:00
2022-09-20 11:41:59 +02:00
W="/var/jenkins_home/workspace/nightly-antosaio/build/"
[ -d antos.AppDir ] && rm -rf antos.AppDir
[ -z $arch ] && arch=amd64
tag=$2
[ -z $tag ] && tag=latest
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
[ ! -f "$W/antd-config.ini" ] && cp ./opt/www/antd-config.ini $W/antd-config.ini
[ ! -f "$W/runner.ini" ] && cp ./opt/www/runner.ini $W/runner.ini
export LD_LIBRARY_PATH="$B/usr/lib/"
echo "Runing Antd in $B"
touch /tmp/.antos_pkgcache
./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
cp -rf $W/backend/$arch/* antos.AppDir/
cp -rf $W/frontend/$tag/* antos.AppDir/
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
./appimagetool.AppImage --appimage-extract
./squashfs-root/AppRun antos.AppDir build/AntOS_$archname-$tag.AppImage
2022-09-20 12:34:03 +02:00
# clean up
rm -rf squashfs-root
rm appimagetool.AppImage