build: 打包支持rpm
This commit is contained in:
1 parent
3c186b34ae
commit
40a2b496e6
178 files changed
+201
-32
No files matched your search
@@ -1,5 +1,33 @@
|
||||
#!/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
|
||||
ProjectU=OMC
|
||||
VERSION=2.2407.1
|
||||
@@ -9,43 +37,92 @@ RelVer=${VERSION}-${RelDate}
|
||||
EmsBEDir=/home/agtuser/probject/nms_cxy
|
||||
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
|
||||
DebBuildDirOMCBin=${DebBuildDir}/usr/local/omc/bin
|
||||
DebBuildDirOMCEtc=${DebBuildDir}/usr/local/omc/etc
|
||||
DebBuildDirOMCFront=${DebBuildDir}/usr/local/omc/htdocs/front
|
||||
DebBuildDirOMC=${DebBuildDir}/usr/local/omc
|
||||
DebBuildDirOMCBin=${DebBuildDirOMC}/bin
|
||||
DebBuildDirOMCFront=${DebBuildDirOMC}/htdocs/front
|
||||
DebReleaseDebsDir=${EmsBEDir}/build/release/debs/amd64
|
||||
|
||||
# 还原打包目录
|
||||
rm -rf ${DebBuildDir}
|
||||
git checkout .
|
||||
case "${pkgtype}" in
|
||||
rpm)
|
||||
# 还原打包目录
|
||||
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文件
|
||||
rm -rf ${DebBuildDirOMCFront}/*
|
||||
cp -rf ${EmsFEDir}/* ${DebBuildDirOMCFront}
|
||||
echo '/*use nginx*/' | sudo tee ${DebBuildDirOMCFront}/config.js
|
||||
# 前端dist文件
|
||||
rm -rf ${RpmBuildDirOMCFront}
|
||||
cp -rf ${EmsFEDir}/* ${RpmBuildDirOMCFront}
|
||||
echo '/*use nginx*/' | tee ${RpmBuildDirOMCFront}/config.js
|
||||
|
||||
# 打包可执行文件
|
||||
cd $EmsBEDir/omc
|
||||
echo "Make omc ..."
|
||||
make
|
||||
cp -rf ${EmsBEDir}/omc/omc ${RpmBuildDirOMCBin}/omc
|
||||
chmod +x ${RpmBuildDirOMCBin}/*
|
||||
|
||||
# 打包可执行文件
|
||||
cd $EmsBEDir/omc
|
||||
echo "Make omc ..."
|
||||
make
|
||||
cp -rf ${EmsBEDir}/omc/omc ${DebBuildDirOMCBin}/omc
|
||||
chmod +x ${DebBuildDirOMCBin}/*
|
||||
# 打包rpm
|
||||
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
|
||||
|
||||
cp -rf ${DebBuildDirOMCEtc}/db/common/* ${DebBuildDirOMCEtc}/db/install
|
||||
cp -rf ${DebBuildDirOMCEtc}/db/common/* ${DebBuildDirOMCEtc}/db/upgrade
|
||||
# 生成MD5文件
|
||||
cd $RpmReleaseDebsDir
|
||||
rm -f omc-md5sum.txt
|
||||
md5sum ${RpmReleaseDebsDir}/${DebPkgFile} >omc-md5sum.txt
|
||||
;;
|
||||
deb)
|
||||
# 还原打包目录
|
||||
rm -rf ${DebBuildDir}
|
||||
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
|
||||
|
||||
# 打包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}
|
||||
# 前端dist文件
|
||||
rm -rf ${DebBuildDirOMCFront}
|
||||
cp -rf ${EmsFEDir}/* ${DebBuildDirOMCFront}
|
||||
echo '/*use nginx*/' | tee ${DebBuildDirOMCFront}/config.js
|
||||
|
||||
# 生成MD5文件
|
||||
cd $DebReleaseDebsDir
|
||||
rm -f omc-md5sum.txt
|
||||
md5sum ${DebReleaseDebsDir}/${DebPkgFile} >omc-md5sum.txt
|
||||
|
||||
# 打包可执行文件
|
||||
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
|
||||
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -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
|
||||
Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 178 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user