build: 打包支持rpm
This commit is contained in:
139
build.sh
139
build.sh
@@ -1,5 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [OPTION] deb|rpm"
|
||||||
|
echo
|
||||||
|
echo "Build omc package, option as follow:"
|
||||||
|
echo " deb|rpm, deb: ubuntu|debian package build by dpkg"
|
||||||
|
echo " rpm: centos/redhat package, build by rpm"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
pkgtype=""
|
||||||
|
new_args=()
|
||||||
|
# Traverse all parameters
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [[ "$arg" == "deb" || "$arg" == "rpm" ]]; then
|
||||||
|
pkgtype=$arg
|
||||||
|
else
|
||||||
|
new_args+=("$arg") # Add non pkgtype parameters to a new parameter list
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$pkgtype" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use a new parameter list
|
||||||
|
set -- "${new_args[@]}"
|
||||||
|
|
||||||
ProjectL=omc
|
ProjectL=omc
|
||||||
ProjectU=OMC
|
ProjectU=OMC
|
||||||
VERSION=2.2407.1
|
VERSION=2.2407.1
|
||||||
@@ -9,43 +37,92 @@ RelVer=${VERSION}-${RelDate}
|
|||||||
EmsBEDir=/home/agtuser/probject/nms_cxy
|
EmsBEDir=/home/agtuser/probject/nms_cxy
|
||||||
EmsFEDir=/home/agtuser/probject/ems_frontend_vue3/dist
|
EmsFEDir=/home/agtuser/probject/ems_frontend_vue3/dist
|
||||||
|
|
||||||
|
SystemDir=${EmsBEDir}/build/system
|
||||||
|
# rpm
|
||||||
|
RpmBuildDir=${EmsBEDir}/build/rpmbuild
|
||||||
|
RpmBuildDirOMC=${RpmBuildDir}/BUILD/usr/local/omc
|
||||||
|
RpmBuildDirOMCBin=${RpmBuildDirOMC}/bin
|
||||||
|
RpmBuildDirOMCFront=${RpmBuildDirOMC}/htdocs/front
|
||||||
|
RpmReleaseDebsDir=${EmsBEDir}/build/release/rpms/arm64
|
||||||
|
# deb
|
||||||
DebBuildDir=${EmsBEDir}/build/debbuild
|
DebBuildDir=${EmsBEDir}/build/debbuild
|
||||||
DebBuildDirOMCBin=${DebBuildDir}/usr/local/omc/bin
|
DebBuildDirOMC=${DebBuildDir}/usr/local/omc
|
||||||
DebBuildDirOMCEtc=${DebBuildDir}/usr/local/omc/etc
|
DebBuildDirOMCBin=${DebBuildDirOMC}/bin
|
||||||
DebBuildDirOMCFront=${DebBuildDir}/usr/local/omc/htdocs/front
|
DebBuildDirOMCFront=${DebBuildDirOMC}/htdocs/front
|
||||||
DebReleaseDebsDir=${EmsBEDir}/build/release/debs/amd64
|
DebReleaseDebsDir=${EmsBEDir}/build/release/debs/amd64
|
||||||
|
|
||||||
# 还原打包目录
|
case "${pkgtype}" in
|
||||||
rm -rf ${DebBuildDir}
|
rpm)
|
||||||
git checkout .
|
# 还原打包目录
|
||||||
|
rm -rf ${RpmBuildDir}
|
||||||
|
git checkout .
|
||||||
|
cp -rf ${SystemDir}/* ${RpmBuildDir}/BUILD
|
||||||
|
cp -rf ${RpmBuildDirOMC}/etc/db/common/* ${RpmBuildDirOMC}/etc/db/install
|
||||||
|
cp -rf ${RpmBuildDirOMC}/etc/db/common/* ${RpmBuildDirOMC}/etc/db/upgrade
|
||||||
|
rm -rf ${RpmBuildDirOMC}/etc/db/common
|
||||||
|
|
||||||
# 前端dist文件
|
# 前端dist文件
|
||||||
rm -rf ${DebBuildDirOMCFront}/*
|
rm -rf ${RpmBuildDirOMCFront}
|
||||||
cp -rf ${EmsFEDir}/* ${DebBuildDirOMCFront}
|
cp -rf ${EmsFEDir}/* ${RpmBuildDirOMCFront}
|
||||||
echo '/*use nginx*/' | sudo tee ${DebBuildDirOMCFront}/config.js
|
echo '/*use nginx*/' | tee ${RpmBuildDirOMCFront}/config.js
|
||||||
|
|
||||||
# 打包可执行文件
|
# 打包可执行文件
|
||||||
cd $EmsBEDir/omc
|
cd $EmsBEDir/omc
|
||||||
echo "Make omc ..."
|
echo "Make omc ..."
|
||||||
make
|
make
|
||||||
cp -rf ${EmsBEDir}/omc/omc ${DebBuildDirOMCBin}/omc
|
cp -rf ${EmsBEDir}/omc/omc ${RpmBuildDirOMCBin}/omc
|
||||||
chmod +x ${DebBuildDirOMCBin}/*
|
chmod +x ${RpmBuildDirOMCBin}/*
|
||||||
|
|
||||||
cp -rf ${DebBuildDirOMCEtc}/db/common/* ${DebBuildDirOMCEtc}/db/install
|
# 打包rpm
|
||||||
cp -rf ${DebBuildDirOMCEtc}/db/common/* ${DebBuildDirOMCEtc}/db/upgrade
|
cd ${EmsBEDir}
|
||||||
|
chmod 755 ${RpmBuildDir}
|
||||||
|
chmod 755 ${RpmBuildDirOMC}
|
||||||
|
DebPkgFile=omc-r${RelVer}-ky10-nms_cxy.rpm
|
||||||
|
rpmbuild -bb -D "_topdir ${RpmBuildDir}" ${RpmBuildDir}/SPECS/omc.spec
|
||||||
|
|
||||||
# 打包deb
|
# 生成MD5文件
|
||||||
cd ${EmsBEDir}
|
cd $RpmReleaseDebsDir
|
||||||
chmod 755 ${DebBuildDir}
|
rm -f omc-md5sum.txt
|
||||||
chmod 755 ${DebBuildDir}/DEBIAN/preinst
|
md5sum ${RpmReleaseDebsDir}/${DebPkgFile} >omc-md5sum.txt
|
||||||
chmod 755 ${DebBuildDir}/DEBIAN/postinst
|
;;
|
||||||
chmod 755 ${DebBuildDir}/DEBIAN/postrm
|
deb)
|
||||||
sed -i "s/YYYYMMDD/${RelDate}/g" ${DebBuildDir}/DEBIAN/control
|
# 还原打包目录
|
||||||
DebPkgFile=omc-r${RelVer}-ub22-nms_cxy.deb
|
rm -rf ${DebBuildDir}
|
||||||
dpkg -b ${DebBuildDir} ${DebReleaseDebsDir}/${DebPkgFile}
|
git checkout .
|
||||||
|
cp -rf ${SystemDir}/* ${DebBuildDir}/
|
||||||
|
cp -rf ${DebBuildDirOMC}/etc/db/common/* ${DebBuildDirOMC}/etc/db/install
|
||||||
|
cp -rf ${DebBuildDirOMC}/etc/db/common/* ${DebBuildDirOMC}/etc/db/upgrade
|
||||||
|
rm -rf ${DebBuildDirOMC}/etc/db/common
|
||||||
|
|
||||||
# 生成MD5文件
|
# 前端dist文件
|
||||||
cd $DebReleaseDebsDir
|
rm -rf ${DebBuildDirOMCFront}
|
||||||
rm -f omc-md5sum.txt
|
cp -rf ${EmsFEDir}/* ${DebBuildDirOMCFront}
|
||||||
md5sum ${DebReleaseDebsDir}/${DebPkgFile} >omc-md5sum.txt
|
echo '/*use nginx*/' | tee ${DebBuildDirOMCFront}/config.js
|
||||||
|
|
||||||
|
# 打包可执行文件
|
||||||
|
cd $EmsBEDir/omc
|
||||||
|
echo "Make omc ..."
|
||||||
|
make
|
||||||
|
cp -rf ${EmsBEDir}/omc/omc ${DebBuildDirOMCBin}/omc
|
||||||
|
chmod +x ${DebBuildDirOMCBin}/*
|
||||||
|
|
||||||
|
# 打包deb
|
||||||
|
cd ${EmsBEDir}
|
||||||
|
chmod 755 ${DebBuildDir}
|
||||||
|
chmod 755 ${DebBuildDir}/DEBIAN/preinst
|
||||||
|
chmod 755 ${DebBuildDir}/DEBIAN/postinst
|
||||||
|
chmod 755 ${DebBuildDir}/DEBIAN/postrm
|
||||||
|
sed -i "s/YYYYMMDD/${RelDate}/g" ${DebBuildDir}/DEBIAN/control
|
||||||
|
DebPkgFile=omc-r${RelVer}-ub22-nms_cxy.deb
|
||||||
|
dpkg -b ${DebBuildDir} ${DebReleaseDebsDir}/${DebPkgFile}
|
||||||
|
|
||||||
|
# 生成MD5文件
|
||||||
|
cd $DebReleaseDebsDir
|
||||||
|
rm -f omc-md5sum.txt
|
||||||
|
md5sum ${DebReleaseDebsDir}/${DebPkgFile} >omc-md5sum.txt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 4
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Binary file not shown.
0
build/release/rpms/arm64/.gitkeep
Normal file
0
build/release/rpms/arm64/.gitkeep
Normal file
0
build/rpmbuild/BUILD/usr/local/bin/.gitkeep
Normal file
0
build/rpmbuild/BUILD/usr/local/bin/.gitkeep
Normal file
0
build/rpmbuild/BUILD/usr/local/omc/.gitkeep
Normal file
0
build/rpmbuild/BUILD/usr/local/omc/.gitkeep
Normal file
0
build/rpmbuild/BUILDROOT/.gitkeep
Normal file
0
build/rpmbuild/BUILDROOT/.gitkeep
Normal file
0
build/rpmbuild/RPMS/.gitkeep
Normal file
0
build/rpmbuild/RPMS/.gitkeep
Normal file
0
build/rpmbuild/SOURCES/.gitkeep
Normal file
0
build/rpmbuild/SOURCES/.gitkeep
Normal file
92
build/rpmbuild/SPECS/omc.spec
Normal file
92
build/rpmbuild/SPECS/omc.spec
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
%define __check_files %{nil}
|
||||||
|
%define __spec_build_pre %{nil}
|
||||||
|
%define __arch_install_post %{nil}
|
||||||
|
%define release_version 1
|
||||||
|
%define release_date %(echo `date +%%Y%%m%%d`)
|
||||||
|
%define project_lname omc
|
||||||
|
%define project_Uname OMC
|
||||||
|
|
||||||
|
Name: %{project_lname}
|
||||||
|
Summary: AGrandTech 5GC OMC
|
||||||
|
Version: 2.2407.1
|
||||||
|
Release: %{release_date}
|
||||||
|
Vendor: AGrandTech
|
||||||
|
URL: https://www.agrandtech.com/
|
||||||
|
License: commercial
|
||||||
|
Group: Applications/Communications
|
||||||
|
|
||||||
|
%description
|
||||||
|
AGrandTech's 5GC OMC
|
||||||
|
|
||||||
|
%prep
|
||||||
|
rm -rf ${RPM_BUILD_ROOT}/*
|
||||||
|
|
||||||
|
mkdir -p ${RPM_BUILD_ROOT}
|
||||||
|
cd ${RPM_BUILD_ROOT}
|
||||||
|
cp -rf ${RPM_BUILD_DIR}/* ${RPM_BUILD_ROOT}/
|
||||||
|
chmod +rx ${RPM_BUILD_ROOT}/usr/local/omc
|
||||||
|
chmod +rx ${RPM_BUILD_ROOT}/usr/local/omc/*
|
||||||
|
chmod +rx ${RPM_BUILD_ROOT}/usr/local/bin/*
|
||||||
|
chmod -R 755 ${RPM_BUILD_ROOT}/usr/local/omc/htdocs/front
|
||||||
|
|
||||||
|
%build
|
||||||
|
#cd %{buildroot}/..
|
||||||
|
#make
|
||||||
|
|
||||||
|
# 安装完成后执行
|
||||||
|
%post
|
||||||
|
OmcRootDir=/usr/local/omc
|
||||||
|
OMCEtcDir=${OmcRootDir}/etc
|
||||||
|
CFileList="omc.yaml omc.conf"
|
||||||
|
LogoFileList="zh_brand.png zh_icon.png en_brand.png en_icon.png"
|
||||||
|
for CFile in ${CFileList}; do
|
||||||
|
if [ ! -e "${OMCEtcDir}/${CFile}" ]; then
|
||||||
|
cp -f ${OMCEtcDir}/default/${CFile} ${OMCEtcDir}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# setting firewall
|
||||||
|
PortList="443 80 33030"
|
||||||
|
for Port in ${PortList}; do
|
||||||
|
firewall-cmd --zone=public --add-port=${Port}/tcp --permanent
|
||||||
|
done
|
||||||
|
firewall-cmd --reload
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable omc.service
|
||||||
|
systemctl stop omc.service
|
||||||
|
systemctl start omc.service
|
||||||
|
|
||||||
|
# 卸载时执行
|
||||||
|
%postun
|
||||||
|
rm -f /usr/local/bin/omcd
|
||||||
|
rm -rf /usr/local/etc/omc
|
||||||
|
|
||||||
|
# setting firewall
|
||||||
|
PortList="443 80 33030"
|
||||||
|
for Port in ${PortList}; do
|
||||||
|
firewall-cmd --zone=public --remove-port=${Port}/tcp --permanent
|
||||||
|
done
|
||||||
|
firewall-cmd --reload
|
||||||
|
|
||||||
|
if [ "$1" = "0" ] ; then
|
||||||
|
sudo systemctl stop omc.service
|
||||||
|
rm -rf /usr/local/omc
|
||||||
|
rm -rf /usr/local/etc/omc
|
||||||
|
sudo systemctl disable omc.service
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
else
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl stop omc.service
|
||||||
|
sudo systemctl start omc.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 规定那些文件必须放入安装程序中,如果没有就报错
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root)
|
||||||
|
/usr/local/omc/.ssh
|
||||||
|
/usr/local/omc/bin
|
||||||
|
/usr/local/omc/etc
|
||||||
|
/usr/local/omc/htdocs
|
||||||
|
/usr/local/omc/static
|
||||||
|
/lib/systemd/system/omc.service
|
||||||
0
build/rpmbuild/SRPMS/.gitkeep
Normal file
0
build/rpmbuild/SRPMS/.gitkeep
Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user