Files
openGauss-OM/build/get_PlatForm_str.sh
huchangqi 3c52ea3600 add loongarch and loongnix-server support
1. 名称使用  loongnix 而不是 loongnix-server
是由于部分脚本是通过 /etc/loongnix-release 的文件名去判断版本的,这样只
能匹配到 loongnix.

2. loongnix-server 修改LD_LIBRARY_PATH 之后,会导致 sudo ,su等命令失
效,只好在执行su命令的时候 export LD_LIBRARY_PATH=/usr/lib64, 保证su
命令成功, 试过 alias su='export LD_LIBRARY_PATH=/usr/lib64; su'
但是 py 需要 subprocess.run(cmd, shell=True) 才能读取这种环境变量,还是
全部替换了。
2024-08-15 11:04:20 +08:00

52 lines
1.8 KiB
Bash

#!/bin/bash
# *************************************************************************
# Copyright: (c) Huawei Technologies Co., Ltd. 2020. All rights reserved
#
# description: the script is to get platform string value
# date: 2020-06-01
# version: 1.0
# history:
#
# *************************************************************************
function get_os_str() {
if [ -f "/etc/os-release" ]; then
os_name=$(source /etc/os-release; echo $ID)
else
echo "Can not get /etc/os-release file, please check it!"
exit 1
fi
cpu_arc=$(uname -p)
if [ "$os_name"x = "centos"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=centos7.6_x86_64
elif [ "$os_name"x = "euleros"x ] && [ "$cpu_arc"x = "aarch64"x ]; then
os_str=euleros2.0_sp8_aarch64
elif [ "$os_name"x = "openEuler"x ] && [ "$cpu_arc"x = "aarch64"x ]; then
os_str=openeuler_aarch64
elif [ "$os_name"x = "openEuler"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=openeuler_x86_64
elif [ "$os_name"x = "fusionos"x ] && [ "$cpu_arc"x = "aarch64"x ]; then
os_str=fusionos_aarch64
elif [ "$os_name"x = "fusionos"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=fusionos_x86_64
elif [ "$os_name"x = "ubuntu"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=ubuntu18.04_x86_64
elif [ "$os_name"x = "asianux"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=asianux7.6_x86_64
elif [ "$os_name"x = "asianux"x ] && [ "$cpu_arc"x = "aarch64"x ]; then
os_str=asianux7.5_aarch64
elif [ "$os_name"x = "uos"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=UnionTech_x86_64
elif [ "$os_name"x = "loongnix-server"x ] && [ "$cpu_arc"x = "loongarch64"x ]; then
os_str=loongnix-server8.4_loongarch64
else
os_str="Failed"
fi
echo $os_str
}
get_os_str