File get-gitea-source.sh of Package gitea
#!/bin/bash
# Enable for debug
#set -ex
clear
function usage (){
echo
echo "Usage: $0 [options]"
echo " -help : help"
echo " -i : install needed packages for build before get source"
echo
exit 0
}
while getopts 'hi' OPTION ; do
case $OPTION in
help) usage
;;
i) INSTALL="yes"
;;
esac
done
shift $(( OPTIND - 1 ))
if [ "$INSTALL" == "yes" ]; then
echo "========================================"
echo " First install local needed packages... "
echo "========================================"
sudo zypper in npm \
obs-service-download_url \
obs-service-go_modules
echo ""
echo "Also need glup global install because path variable does not work in this script and i don't know why. :-("
echo "Any advice for me? "
echo "----------------------------------------------------------------------------------------------------------"
sudo npm install gulp -g
fi
echo "================================="
echo " Show environment... "
echo "================================="
if [ -f _service ]; then
VERSION=$(cat _service | grep \"revision\" | sed -E 's|.*>v(.*)</param>|\1|g')
PFAD=`pwd`
echo "Version: $VERSION"
echo "Pfad: $PFAD"
echo ""
else
echo "Couldn't find _service file"
echo ""
exit 1
fi
echo "================================="
echo " version query... "
echo "================================="
while true; do
read -p "Do you have insert the correct version in _service file? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo "================================="
echo " Cleanup... "
echo "================================="
rm -rf gitea-dl
rm -rf gitea
rm -rf gitea*.tar.gz
rm -rf gitea*.tar.gz.asc
rm -rf vendor.tar.gz
rm -rf node_modules.*
rm -rf package*.json
echo "======================================"
echo "Download gitea source from _service..."
echo "======================================"
osc service mr
echo "====================="
echo "Patch package.json..."
echo "====================="
mkdir gitea-dl
cd gitea-dl
tar -xvzf ../gitea-$VERSION.tar.gz
cd gitea-$VERSION
# Install node_modules from package-lock.json
echo "=============================="
echo "Download node_modules gitea ..."
echo "=============================="
npm install --no-save
npm install --no-save gulp
# Install node_modules for fomatic-ui
echo "=========================================="
echo "Download node_modules fomantic ..."
echo "=========================================="
(
cd web_src/fomantic/
mkdir bin
ln -s ../../../node_modules/gulp-cli/bin/gulp.js bin/gulp
chmod a+x ../../node_modules/gulp-cli/bin/gulp.js
export PATH=$PWD/bin:$PATH
npm install --no-save
)
echo "===================================================="
echo "Download only pack node_modules esbuild-optional ..."
echo "===================================================="
esbuild_ver=$(jq -er '.["packages"]["node_modules/esbuild"]["version"]' package-lock.json)
echo "esbuild version: $esbuild_ver"
npm pack @esbuild/linux-x64@$esbuild_ver
npm pack @esbuild/linux-arm64@$esbuild_ver
npm pack @esbuild/linux-arm@$esbuild_ver
npm pack @esbuild/linux-ppc64@$esbuild_ver
install -d @esbuild
tar -xvzf esbuild-linux-x64-$esbuild_ver.tgz
mv package node_modules/@esbuild/linux-x64
tar -xvzf esbuild-linux-arm64-$esbuild_ver.tgz
mv package node_modules/@esbuild/linux-arm64
tar -xvzf esbuild-linux-arm-$esbuild_ver.tgz
mv package node_modules/@esbuild/linux-arm
tar -xvzf esbuild-linux-ppc64-$esbuild_ver.tgz
mv package node_modules/@esbuild/linux-ppc64
# remove local home
echo "====================="
echo "Remove local path ..."
echo "====================="
find node_modules web_src/fomantic/node_modules -type f -exec sed -i -e 's|'$PFAD'/gitea-dl/gitea-'$VERSION'||g' {} \;
# pack node_modules
echo "==========================="
echo "Pack gitea-node_modules ..."
echo "==========================="
tar -czf ../gitea-node_modules-$VERSION.tar.gz node_modules web_src/fomantic/node_modules/
cd ..
# Copy
echo "==========================="
echo "Copy tars from /tmp to $PFAD ..."
echo "==========================="
cp gitea-node_modules-$VERSION.tar.gz $PFAD
echo "==========="
echo "CleanUp ..."
echo "==========="
cd $PFAD
osc addremove
rm -rf gitea
rm -rf gitea-dl