perf: 构建工具调整
This commit is contained in:
1 parent
0838ac49e7
commit
d987553af5
284 files changed
+25
-1089
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
# build
|
||||||
|
|
||||||
|
打包添加到构建工具的 `/tmp/usr/local/etc/omc` 目录内
|
||||||
|
|
||||||
|
## 文件资源
|
||||||
|
|
||||||
|
| 路径 | 说明 |
|
||||||
|
| -------- | ---------------- |
|
||||||
|
| database | 数据库 |
|
||||||
|
| default | 默认配置文件 |
|
||||||
|
| vendor | 各厂商的定制修改 |
|
||||||
|
|
||||||
|
## 编译发布
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
OMCDir=xxx/build
|
||||||
|
BuildOMCEtcDir=xxx/tmp/usr/local/etc/omc
|
||||||
|
|
||||||
|
dirList="database default vendor"
|
||||||
|
for v in ${dirList}; do
|
||||||
|
rm -rf ${BuildOMCEtcDir}/${v}
|
||||||
|
cp -rf ${OMCDir}/${v} ${BuildOMCEtcDir}/${v}
|
||||||
|
done
|
||||||
|
```
|
||||||
-173
@@ -1,173 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# 默认版本值
|
|
||||||
VERSION="1.0.0"
|
|
||||||
# usage
|
|
||||||
usage() {
|
|
||||||
echo "Usage: bash $0 [OPTION]"
|
|
||||||
echo
|
|
||||||
echo "Build Software Package OPTION:"
|
|
||||||
echo " -v Specify the version"
|
|
||||||
echo " -h Display this help message"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
# 读取命令行参数
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
-v) VERSION="$2"; shift 2 ;; # 处理 -v 后面的版本
|
|
||||||
*) usage ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
# 输出结果
|
|
||||||
echo "Version: $VERSION"
|
|
||||||
|
|
||||||
# ===================
|
|
||||||
|
|
||||||
# 操作系统名称
|
|
||||||
get_os_name() {
|
|
||||||
if [ -f /etc/os-release ]; then
|
|
||||||
. /etc/os-release
|
|
||||||
# 检查 $ID 是否为空
|
|
||||||
if [ -z "$ID" ]; then
|
|
||||||
echo "ID is not defined in /etc/os-release"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "$ID"
|
|
||||||
else
|
|
||||||
echo "unknown ID: /etc/os-release not found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
# 获取当前操作系统名称
|
|
||||||
OS_NAME=$(get_os_name)
|
|
||||||
echo "OS: $OS_NAME"
|
|
||||||
|
|
||||||
# 包管理器
|
|
||||||
get_manager() {
|
|
||||||
if command -v rpm &> /dev/null; then
|
|
||||||
echo "rpm"
|
|
||||||
elif command -v dpkg &> /dev/null; then
|
|
||||||
echo "deb"
|
|
||||||
else
|
|
||||||
echo "unknown manager"
|
|
||||||
cat /etc/os-release
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
# 获取当前系统的包管理器
|
|
||||||
PACKAGE_MANAGER=$(get_manager)
|
|
||||||
echo "Package Manager: $PACKAGE_MANAGER"
|
|
||||||
|
|
||||||
# 架构
|
|
||||||
get_arch() {
|
|
||||||
ARCH_UNAME=$(uname -m)
|
|
||||||
case $ARCH_UNAME in
|
|
||||||
x86_64) echo "amd64" ;;
|
|
||||||
aarch64) echo "arm64" ;;
|
|
||||||
i386|i686) echo "i386" ;;
|
|
||||||
*)
|
|
||||||
echo "unknown architecture: $ARCH_UNAME"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
# 获取当前系统的架构
|
|
||||||
PACKAGE_ARCH=$(get_arch)
|
|
||||||
echo "Architecture: $PACKAGE_ARCH"
|
|
||||||
|
|
||||||
# ===================
|
|
||||||
|
|
||||||
# 编译日期
|
|
||||||
Date=`date +%Y%m%d`
|
|
||||||
# 脚本所在路径
|
|
||||||
RootDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
||||||
# 编译Linux目录
|
|
||||||
BuildLinuxDir=${RootDir}/linux
|
|
||||||
# 编译包管理目录
|
|
||||||
BuildPackagelDir=${RootDir}/pkg
|
|
||||||
# 编译目录
|
|
||||||
BuildDir=${RootDir}/tmp
|
|
||||||
# 发布包目录
|
|
||||||
ReleaseDir=${RootDir}/release/${PACKAGE_MANAGER}/${PACKAGE_ARCH}
|
|
||||||
# 发布包文件名称
|
|
||||||
ReleaseFileName=omc-r${VERSION}-${Date}-${OS_NAME}-${PACKAGE_ARCH}.${PACKAGE_MANAGER}
|
|
||||||
|
|
||||||
# ===================
|
|
||||||
|
|
||||||
# 应用文件处理
|
|
||||||
app() {
|
|
||||||
# 数据库脚本 common属于重建脚本
|
|
||||||
modeList="standard lite"
|
|
||||||
for v in ${modeList}; do
|
|
||||||
cp -rf $BuildDir/usr/local/etc/omc/database/${v}/common/* $BuildDir/usr/local/etc/omc/database/${v}/install/
|
|
||||||
cp -rf $BuildDir/usr/local/etc/omc/database/${v}/common/* $BuildDir/usr/local/etc/omc/database/${v}/upgrade/
|
|
||||||
rm -rf $BuildDir/usr/local/etc/omc/database/${v}/common
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# ===================
|
|
||||||
|
|
||||||
# deb包管理器
|
|
||||||
deb() {
|
|
||||||
cd ${BuildDir}
|
|
||||||
|
|
||||||
# 替换标签 {version} {arch}
|
|
||||||
sed -i "s/{arch}/${PACKAGE_ARCH}/g" ./DEBIAN/control
|
|
||||||
sed -i "s/{version}/${VERSION}/g" ./DEBIAN/control
|
|
||||||
sed -i "s/{date}/${Date}/g" ./DEBIAN/control
|
|
||||||
|
|
||||||
# 打包deb
|
|
||||||
chmod 755 -R ${BuildDir}
|
|
||||||
dpkg -b ${BuildDir} ${ReleaseDir}/${ReleaseFileName}
|
|
||||||
|
|
||||||
# 生成MD5文件
|
|
||||||
rm -f omc_md5sum.txt
|
|
||||||
md5sum ${ReleaseDir}/${ReleaseFileName} >${ReleaseDir}/omc_md5sum.txt
|
|
||||||
cat ${ReleaseDir}/omc_md5sum.txt
|
|
||||||
}
|
|
||||||
|
|
||||||
# rpm包管理器
|
|
||||||
rpm() {
|
|
||||||
cd ${BuildDir}
|
|
||||||
ARCH_UNAME=$(uname -m)
|
|
||||||
# 替换标签 {version} {arch} {date}
|
|
||||||
sed -i "s/{version}/${VERSION}/g" ./SPECS/omc.spec
|
|
||||||
sed -i "s/{arch}/${ARCH_UNAME}/g" ./SPECS/omc.spec
|
|
||||||
sed -i "s/{date}/${Date}/g" ./SPECS/omc.spec
|
|
||||||
|
|
||||||
# 打包rpm
|
|
||||||
chmod 755 -R ${BuildDir}
|
|
||||||
rpmbuild -bb -D "_topdir ${BuildDir}" ${BuildDir}/SPECS/omc.spec
|
|
||||||
mv ${BuildDir}/RPMS/${ARCH_UNAME}/omc-${VERSION}-${Date}.${ARCH_UNAME}.rpm ${ReleaseDir}/${ReleaseFileName}
|
|
||||||
rm -rf ${BuildDir}/RPMS
|
|
||||||
|
|
||||||
# 生成MD5文件
|
|
||||||
rm -f omc_md5sum.txt
|
|
||||||
md5sum ${ReleaseDir}/${ReleaseFileName} >${ReleaseDir}/omc_md5sum.txt
|
|
||||||
cat ${ReleaseDir}/omc_md5sum.txt
|
|
||||||
}
|
|
||||||
|
|
||||||
# ===================
|
|
||||||
echo
|
|
||||||
echo "building omc..."
|
|
||||||
rm -rf ${BuildDir} && mkdir -p ${BuildDir}
|
|
||||||
cp -rf ${BuildPackagelDir}/${PACKAGE_MANAGER}/* ${BuildDir}
|
|
||||||
if [[ $PACKAGE_MANAGER = "deb" ]]; then
|
|
||||||
cp -rf ${BuildLinuxDir}/* ${BuildDir}
|
|
||||||
cd ${BuildDir}
|
|
||||||
# 应用处理
|
|
||||||
app
|
|
||||||
# 打包
|
|
||||||
deb
|
|
||||||
elif [[ $PACKAGE_MANAGER = "rpm" ]]; then
|
|
||||||
cp -rf ${BuildLinuxDir}/* ${BuildDir}/BUILD
|
|
||||||
cd ${BuildDir}/BUILD
|
|
||||||
# 应用处理
|
|
||||||
app
|
|
||||||
# 打包
|
|
||||||
rpm
|
|
||||||
else
|
|
||||||
echo "unknown runing: $PACKAGE_MANAGER"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
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.
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 284 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user