diff --git a/bin/build.sh b/bin/build.sh index b0f309e..3f8e024 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -56,7 +56,7 @@ fi ProjectL=omc ProjectU=OMC PROJECT=${ProjectL} -VERSION=2.2508.1 +VERSION={version} RelDate=`date +%Y%m%d` RelVer=${VERSION}-${RelDate}-mt Ky10Arch=ky10.aarch64 @@ -111,15 +111,7 @@ fi case "${pkgtype}" in rpm) echo "Begin to make ${pkgtype} package ======>" - ReleasePkgDir=${ReleaseDir}/rpms/${RelArch} - ProcList="restagent sshsvc" - cd $EmsBEDir - for procName in $ProcList;do - cd $EmsBEDir/$procName - echo "Make $procName ..." - make - done - + cd $EmsBEDir # make rpm # clear build cache @@ -153,7 +145,8 @@ case "${pkgtype}" in #cp -rf ${BuildDir}/systemd ${RpmBuildDir}/BUILD/lib/ cd ${RpmBuildDir} rpmbuild -bb -D "_topdir ${RpmBuildDir}" ${RpmBuildDir}/SPECS/omc.spec - + + ReleasePkgDir=${ReleaseDir}/rpms/${RelArch} mv -f $RpmsDir/$RpmArch/$RpmPkgName ${ReleasePkgDir}/$RpmPkgRename cd ${ReleasePkgDir} rm -f omc-md5sum.txt @@ -163,14 +156,6 @@ case "${pkgtype}" in ;; deb) echo "Begin to make ${pkgtype} package ======>" - ReleasePkgDir=${ReleaseDir}/debs/${RelArch} - ProcList="restagent sshsvc" - cd $EmsBEDir - for procName in $ProcList;do - cd $EmsBEDir/$procName - echo "Make $procName ..." - make - done VersionID=`grep VERSION_ID /etc/os-release` if [[ ${VersionID} =~ 'VERSION_ID="22.04"' ]]; then @@ -237,6 +222,7 @@ case "${pkgtype}" in #cp -rf ${BuildDir}/systemd/*.service ${DebBuildDir}/lib/systemd/system/ chmod +x ${DebBuildDir}/usr/local/omc/bin/* sed -i "s/YYYYMMDD/${RelDate}/g" ${DebBuildDir}/DEBIAN/control + ReleasePkgDir=${ReleaseDir}/debs/${RelArch} dpkg -b ${DebBuildDir} ${ReleasePkgDir}/${DebPkgFile} cd ${ReleasePkgDir} @@ -247,14 +233,6 @@ case "${pkgtype}" in ;; badeb) echo "Begin to make ${pkgtype} package ======>" - ReleasePkgDir=${ReleaseDir}/debs/${RelArch} - ProcList="restagent sshsvc" - cd $EmsBEDir - for procName in $ProcList;do - cd $EmsBEDir/$procName - echo "Make $procName ..." - make - done VersionID=`grep VERSION_ID /etc/os-release` if [[ ${VersionID} =~ 'VERSION_ID="22.04"' ]]; then @@ -314,6 +292,7 @@ case "${pkgtype}" in echo "Replace all chinese character." chmod +x ${DebBuildDir}/usr/local/omc/bin sed -i "s/YYYYMMDD/${RelDate}/g" ${DebBuildDir}/DEBIAN/control + ReleasePkgDir=${ReleaseDir}/debs/${RelArch} dpkg -b ${DebBuildDir} ${ReleasePkgDir}/${DebPkgFile} cd ${ReleasePkgDir} diff --git a/bin/makepkg.sh b/bin/makepkg.sh index 3485c65..cea89f3 100755 --- a/bin/makepkg.sh +++ b/bin/makepkg.sh @@ -111,6 +111,15 @@ makefe() { makebe() { cd ${builddir}/bin #chmod +x mkpkg.sh + EmsBEDir=${rootdir}/be.ems + ProcList="restagent sshsvc" + cd $EmsBEDir + for procName in $ProcList;do + cd $EmsBEDir/$procName + echo "Make $procName ..." + make + done + chmod +x build.sh ./build.sh ${be_args[@]} } diff --git a/debbuild/22.04/DEBIAN/control b/debbuild/22.04/DEBIAN/control index dd44cdb..68173df 100644 --- a/debbuild/22.04/DEBIAN/control +++ b/debbuild/22.04/DEBIAN/control @@ -1,5 +1,5 @@ Package: OMC -Version: 2.2508.1-YYYYMMDD-mt +Version: {version}-YYYYMMDD-mt Section: AGrandTech Prioritt: optional Architecture: amd64 diff --git a/debbuild/DEBIAN/control b/debbuild/DEBIAN/control index dd44cdb..68173df 100644 --- a/debbuild/DEBIAN/control +++ b/debbuild/DEBIAN/control @@ -1,5 +1,5 @@ Package: OMC -Version: 2.2508.1-YYYYMMDD-mt +Version: {version}-YYYYMMDD-mt Section: AGrandTech Prioritt: optional Architecture: amd64 diff --git a/pkg.sh b/pkg.sh new file mode 100644 index 0000000..093a293 --- /dev/null +++ b/pkg.sh @@ -0,0 +1,96 @@ +#!/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 diff --git a/rpmbuild/SPECS/omc.spec b/rpmbuild/SPECS/omc.spec index 31a051b..a6afbda 100644 --- a/rpmbuild/SPECS/omc.spec +++ b/rpmbuild/SPECS/omc.spec @@ -8,7 +8,7 @@ Name: %{project_lname} Summary: 5GC OMC -Version: 2.2508.1 +Version: {version} Release: %{release_date} Vendor: omc URL: https://www.omc.com/