From 39edc1f2a07944ffa2968cc9d0d78f8bfb246626 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Tue, 20 Sep 2022 11:41:59 +0200 Subject: [PATCH] Initial commit --- Jenkinsfile | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ antd-config.ini | 51 ++++++++++++++++++++++++++++ mkimg.sh | 85 ++++++++++++++++++++++++++++++++++++++++++++++ runner.ini | 4 +++ 4 files changed, 229 insertions(+) create mode 100644 Jenkinsfile create mode 100644 antd-config.ini create mode 100755 mkimg.sh create mode 100644 runner.ini diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..8f2b956 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,89 @@ +def build_appimage() +{ + sh ''' + set -e + set -x + cd $WORKSPACE + [ -d build ] && rm -rf build + mkdir build + for tag in /var/jenkins_home/workspace/nightly-antosaio/build/frontend/*; do + echo "Building for $arch version $tag" + ./mkimage.sh $arch $tag + done + ''' +} + +pipeline{ + agent { node{ label'master' }} + options { + // Limit build history with buildDiscarder option: + // daysToKeepStr: history is only kept up to this many days. + // numToKeepStr: only this many build logs are kept. + // artifactDaysToKeepStr: artifacts are only kept up to this many days. + // artifactNumToKeepStr: only this many builds have their artifacts kept. + buildDiscarder(logRotator(numToKeepStr: "1")) + // Enable timestamps in build log console + timestamps() + // Maximum time to run the whole pipeline before canceling it + timeout(time: 3, unit: 'HOURS') + // Use Jenkins ANSI Color Plugin for log console + ansiColor('xterm') + // Limit build concurrency to 1 per branch + disableConcurrentBuilds() + } + stages + { + stage('Build AMD64') { + agent { + docker { + image 'xsangle/ci-tools:latest-amd64' + args '-v /var/jenkins_home/workspace/nightly-antosaio:/var/jenkins_home/workspace/nightly-antosaio' + reuseNode true + } + } + steps { + script{ + env.arch = "amd64" + } + build_appimage() + } + } + stage('Build ARM64') { + agent { + docker { + image 'xsangle/ci-tools:latest-arm64' + args '-v /var/jenkins_home/workspace/nightly-antosaio:/var/jenkins_home/workspace/nightly-antosaio' + reuseNode true + } + } + steps { + script{ + env.arch = "arm64" + } + build_appimage() + } + } + stage('Build ARM') { + agent { + docker { + image 'xsangle/ci-tools:latest-arm' + args '-v /var/jenkins_home/workspace/nightly-antosaio:/var/jenkins_home/workspace/nightly-antosaio' + reuseNode true + } + } + steps { + script{ + env.arch = "arm" + } + build_appimage() + } + } + stage('Archive') { + steps { + script { + archiveArtifacts artifacts: 'build/', fingerprint: true + } + } + } + } +} \ No newline at end of file diff --git a/antd-config.ini b/antd-config.ini new file mode 100644 index 0000000..6adadf5 --- /dev/null +++ b/antd-config.ini @@ -0,0 +1,51 @@ +[SERVER] +plugins=./opt/www/lib/ +plugins_ext=.so +database=/opt/www/database +tmpdir=/tmp/ +maxcon=500 +backlog=5000 +workers = 4 +max_upload_size = 20000000 +gzip_enable = 1 +gzip_types = text\/.*,.*\/css.*,.*\/json.*,.*\/javascript.* + +[PORT:8888] +htdocs=./opt/www/htdocs +ssl.enable=0 +^/os/(.*)$ = /os/router.lua?r=<1>& + + +[MIMES] +image/bmp=bmp +image/jpeg=jpg,jpeg +text/css=css +text/markdown=md +text/csv=csv +application/pdf=pdf +image/gif=gif +text/html=html,htm,chtml +application/json=json +application/javascript=js +image/png=png +image/x-portable-pixmap=ppm +application/x-rar-compressed=rar +image/tiff=tiff +application/x-tar=tar +text/plain=txt +application/x-font-ttf=ttf +application/xhtml+xml=xhtml +application/xml=xml +application/zip=zip +image/svg+xml=svg +application/vnd.ms-fontobject=eot +application/x-font-woff=woff,woff2 +application/x-font-otf=otf +audio/mpeg=mp3,mpeg + +[FILEHANDLER] +lua = lua + +[AUTOSTART] +plugin = tunnel +plugin = lua \ No newline at end of file diff --git a/mkimg.sh b/mkimg.sh new file mode 100755 index 0000000..6242e4f --- /dev/null +++ b/mkimg.sh @@ -0,0 +1,85 @@ +#! /bin/bash + +set -e +set -x +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 + +wget -O appimagetool.AppImage https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-$archname.AppImage +chmod +x appimagetool.AppImage + +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 antos.AppDir build/AntOS_$archname-$tag.AppImage \ No newline at end of file diff --git a/runner.ini b/runner.ini new file mode 100644 index 0000000..abdaf5a --- /dev/null +++ b/runner.ini @@ -0,0 +1,4 @@ +[vterm] +exec = ./opt/www/bin/vterm +param = /tmp/channels/antd_hotline.sock +debug = 0 \ No newline at end of file