diff --git a/build.sh b/build.sh index 0def12d..3f1eb76 100755 --- a/build.sh +++ b/build.sh @@ -66,7 +66,7 @@ DebPkgName=${ProjectL}-r${RelVer}-ub*.deb EmsBEDir=${GitLocalRoot}/be.ems EmsBuildRoot=${GitLocalRoot}/build.ems RpmArch=`arch` -RpmsDir=${EmsBuildRoot}/rpmbuild/RPMS/ +RpmsDir=${EmsBuildRoot}/rpmbuild/RPMS ReleaseDir=${EmsBuildRoot}/release DumpToolDir=${EmsBEDir}/tools/misc ProjectTag="" @@ -102,12 +102,69 @@ FrontBuildDir=${BuildOMCDir}/htdocs FrontSrcDir=${EmsBEDir}/front BinWriterDir=${HOME}/bin -if [[ ${RpmArch} =~ "x86_64" ]];then +# Get the output of uname -a +UnameOutput=$(uname -a) + +# Extract hardware architecture +if [[ $UnameOutput =~ "x86_64" ]]; then RelArch=amd64 -elif [[ ${RpmArch} =~ "aarch64" ]];then + RpmArch=x86_64 +elif [[ $UnameOutput =~ "aarch64" ]]; then RelArch=arm64 + RpmArch=aarch64 +else + echo "Unsupported hardware architecture" + exit 1 fi +get_os_info() { + if [ -f /etc/os-release ]; then + . /etc/os-release + echo $ID + else + echo "unknown" + fi +} + +get_os_version() { + if [ -f /etc/os-release ]; then + . /etc/os-release + echo $VERSION_ID + else + echo "unknown" + fi +} + +OSVersion=$(get_os_version) +case $(get_os_info) in + ubuntu|debian) + pkgtype=deb + if [[ "$OSVersion" == "22.04" ]]; then + RelOS=ub22 + elif [[ "$OSVersion" == "18.04" ]]; then + RelOS=ub18 + else + echo "Unsupported Ubuntu version: $OSVersion" + exit 1 + fi + ;; + centos|rhel) + pkgtype=rpm + RelOS=ct8 + RpmPkgRename=${ProjectL}-${RelVer}.${RelOS}.${RelArch}.${pkgtype} + ;; + openEuler) + pkgtype=rpm + RelOS=oe20 + RpmPkgName=${ProjectL}-${RelVer}.${RpmArch}.rpm + RpmPkgRename=${ProjectL}-${RelVer}.${RelOS}.${RelArch}.${pkgtype} + ;; + *) + echo "Unsupported OS" + exit 1 + ;; +esac + case "${pkgtype}" in rpm) echo "Begin to make ${pkgtype} package ======>"