1
0
Files
build.ems/pkg.sh

97 lines
2.3 KiB
Bash

#!/bin/bash
# front-end Catalog
WebDir=/root/omc.git/fe.ems.vue3
WebBranch=multi-tenant
BuildWeb=""
# back-end Catalog
ApiDir=/root/omc.git/be.ems
ApiBranch=multi-tenant
BuildApi=""
# Package Catalog
BuildDir=/root/omc.git/build.ems
BuildBranch=multi-tenant
# Default Version Value
VERSION="2.2508.1"
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Build Software Package OPTION:"
echo " -v Specify the version"
echo " --web Build Web ($WebDir) Branch ($WebBranch)"
echo " --api Build Api ($ApiDir) Branch ($ApiBranch)"
echo " -h Display this help message"
echo
exit 1
}
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v) VERSION="$2"; shift 2 ;;
--web) BuildWeb="build"; shift ;;
--api) BuildApi="build"; shift ;;
*) usage ;;
esac
done
# =================== build branch
echo
cd $BuildDir
rm -rf debbuild/*
git checkout .
git pull
git checkout $BuildBranch
git pull
echo "===> build checkout directory: $BuildDir"
# =================== Web
echo
# Determine if --web is passed in
if [ -n "$BuildWeb" ]; then
cd $WebDir
git checkout .
git pull
git checkout $WebBranch
git pull
cp -rf $BuildDir/customized/ba.d/images/background_light.jpg $WebDir/public/background/light.jpg
cp -rf $BuildDir/customized/ba.d/images/background_dark.jpg $WebDir/public/background/dark.jpg
cp -rf $BuildDir/customized/ba.d/locales/zh-CN.ts $WebDir/src/i18n/locales/zh-CN.ts
npm install --registry https://registry.npmmirror.com
npm run build
fi
# =================== Api
echo
# Determine if --api is passed in
if [ -n "$BuildApi" ]; then
cd $ApiDir
git checkout .
git pull
git checkout $ApiBranch
git pull
ProcList="restagent sshsvc"
for procName in $ProcList;do
cd $ApiDir/$procName
echo "Make $procName ..."
make
done
fi
# =================== ba deb
echo
cd $BuildDir
sed -i "s/{version}/${VERSION}/g" $BuildDir/bin/build.sh
sed -i "s/{version}/${VERSION}/g" $BuildDir/bin/makepkg.sh
sed -i "s/{version}/${VERSION}/g" $BuildDir/debbuild/DEBIAN/control
sed -i "s/{version}/${VERSION}/g" $BuildDir/debbuild/22.04/DEBIAN/control
sed -i "s/{version}/${VERSION}/g" $BuildDir/rpmbuild/SPECS/omc.spec
bash bin/build.sh badeb
# bash pkg.sh --web --api -v 2.2508.1
# bash pkg.sh --web --api