Projects
Eulaceura:Mainline
install-scripts
_service:obs_scm:0002-support-mbsc.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0002-support-mbsc.patch of Package install-scripts
From a179ee1222064472dad6cb09f7e97eceac69b575 Mon Sep 17 00:00:00 2001 From: zhangqiumiao <zhangqiumiao1@huawei.com> Date: Tue, 1 Nov 2022 10:56:16 +0800 Subject: [PATCH] support mbsc --- usr/Euler/project/disk/hwcompatible.sh | 27 ++++++++++ usr/Euler/project/init/LinuxSetup.sh | 8 +++ usr/Euler/project/install/setupOS.sh | 71 ++++++++++++++++++++++++-- usr/Euler/project/load/filetransfer.sh | 10 ++-- usr/Euler/project/load/load.sh | 16 +++--- 5 files changed, 115 insertions(+), 17 deletions(-) diff --git a/usr/Euler/project/disk/hwcompatible.sh b/usr/Euler/project/disk/hwcompatible.sh index 97f3b78..e28b1ff 100644 --- a/usr/Euler/project/disk/hwcompatible.sh +++ b/usr/Euler/project/disk/hwcompatible.sh @@ -16,6 +16,7 @@ #machine type CON_MACHINE_TYPE_GENERAL="general" CON_MACHINE_TYPE_HP="hp" +CON_MACHINE_TYPE_RED3="red3" #version for kernel and crash kernel CON_KERNEL_TYPE_XEN="xen" @@ -35,6 +36,8 @@ function DM_GetMachineType() #get machine type if [ ! -z "`ls -l /sys/block | grep "c0d"`" ]; then machine_type=${CON_MACHINE_TYPE_HP} + elif [ ! -z "`ls -l /sys/block | grep "md"`" ]; then + machine_type=${CON_MACHINE_TYPE_RED3} else machine_type=${CON_MACHINE_TYPE_GENERAL} fi @@ -76,6 +79,9 @@ function DM_GetPartitionName() ${CON_MACHINE_TYPE_HP}) echo "${disk_dev}p${partition_count}" ;; + ${CON_MACHINE_TYPE_RED3}) + echo "${disk_dev}p${partition_count}" + ;; *) if [[ ${disk_dev} == /dev/nvme* ]]; then echo "${disk_dev}p${partition_count}" @@ -119,6 +125,9 @@ function DM_GetPartitionNumber() ${CON_MACHINE_TYPE_HP}) echo "${partition_name}" | sed "s ${disk_dev}p " ;; + ${CON_MACHINE_TYPE_RED3}) + echo "${partition_name}" | sed "s ${disk_dev}p " + ;; *) if [[ ${disk_dev} == /dev/nvme* ]]; then echo "${partition_name}" | sed "s ${disk_dev}p " @@ -161,6 +170,9 @@ function DM_GetPartitionById() ${CON_MACHINE_TYPE_HP}) partition_by_id="`echo "${partition_by_id}" | grep "^cciss"`" ;; + ${CON_MACHINE_TYPE_RED3}) + partition_by_id="`echo "${partition_by_id}" | grep "^md-uuid"`" + ;; *) partition_by_id_tmp=${partition_by_id} partition_by_id="`echo "${partition_by_id_tmp}" | grep "^scsi"`" @@ -273,6 +285,14 @@ function DM_GetGrubInfo() command="`printf "%d" "'${harddisk_id}"` - `printf "%d" "'0"`" disk_dev="`hwinfo --disk --short | awk '{print $1}' | grep -w "${disk_dev}"`" ;; + ${CON_MACHINE_TYPE_RED3}) + first_disk="`DM_Get_FirstDiskName`" + first_disk_id="`echo ${first_disk} | awk '{print substr($NF,length($NF),1)}'`" + disk_dev="`echo ${partition_info} | awk -F "/" '{print $NF}' | sed "s p${partition_id}$ "`" + harddisk_id="`echo ${disk_dev} | awk '{print substr($NF,length($NF),1)}'`" + command="`printf "%d" "'${harddisk_id}"` - `printf "%d" "'${first_disk_id}"`" + disk_dev="/dev/${disk_dev}" + ;; *) if [[ ${partition_info} == */nvme* ]]; then disk_dev="`echo ${partition_info} | awk -F "/" '{print $NF}' | sed "s p${partition_id}$ "`" @@ -293,6 +313,13 @@ function DM_GetGrubInfo() harddisk_id="`echo ${disk_dev} | awk -F "/" '{print substr($NF,length($NF),1)}'`" command="`printf "%d" "'${harddisk_id}"` - `printf "%d" "'0"`" ;; + ${CON_MACHINE_TYPE_RED3}) + first_disk="`DM_Get_FirstDiskName`" + first_disk_id="`echo ${first_disk} | awk '{print substr($NF,length($NF),1)}'`" + disk_dev="`echo ${partition_name} | sed "s p${partition_id}$ "`" + harddisk_id="`echo ${disk_dev} | awk -F "/" '{print substr($NF,length($NF),1)}'`" + command="`printf "%d" "'${harddisk_id}"` - `printf "%d" "'${first_disk_id}"`" + ;; *) if [[ ${partition_name} == */nvme* ]]; then disk_dev="`echo ${partition_name} | sed "s p${partition_id}$ "`" diff --git a/usr/Euler/project/init/LinuxSetup.sh b/usr/Euler/project/init/LinuxSetup.sh index 0cfb8c3..7311e8a 100644 --- a/usr/Euler/project/init/LinuxSetup.sh +++ b/usr/Euler/project/init/LinuxSetup.sh @@ -126,6 +126,7 @@ function INIT_Setup_Main() local tmp= local sysconfig_conf=`basename ${SYSCONFIG_CONF}` local cmdline=/proc/cmdline + local pstore_files= #initialize the drivers ${INIT_MODULES} @@ -196,6 +197,13 @@ function INIT_Setup_Main() fi g_LOG_Notice "Initializing environment success." + if [ -d /sys/fs/pstore ]; then + g_LOG_Info "Removing files stored in nonvolatile ram created by the pstore subsystem..." + pstore_files=`find /sys/fs/pstore/ -type f` + g_LOG_Debug "Removing files: [${pstore_files}]" + find /sys/fs/pstore/ -type f -delete + fi + INIT_Execute_Hook ${BEFORE_PARTITION_HOOK_PATH} ${PARTITION_CONF} if [ $? -ne 0 ]; then g_LOG_Error "Execute custom hook failed before partition." diff --git a/usr/Euler/project/install/setupOS.sh b/usr/Euler/project/install/setupOS.sh index fdbf17c..f1040c4 100644 --- a/usr/Euler/project/install/setupOS.sh +++ b/usr/Euler/project/install/setupOS.sh @@ -813,6 +813,16 @@ function SetupOS_GrubCfg() sed -i "s/${title_str}/${MENU_VERSION}/g" ${grub_cfg} fi + if cat /proc/cmdline | grep "product=mbsc" &>/dev/null; then + g_LOG_Info "copy ${LOCAL_CONFIG_PATH}/grub.cfg to ${LOCAL_DISK_PATH}${SI_GRUB2_PATH}" + cp -af ${LOCAL_CONFIG_PATH}/grub.cfg ${LOCAL_DISK_PATH}${SI_GRUB2_PATH} >> ${OTHER_TTY} 2>&1 + chmod 600 ${grub_cfg} + if [ $? -ne 0 ]; then + g_LOG_Error "chmod grub.cfg failed." + return 1 + fi + fi + g_LOG_Notice "instsall OS grub.cfg success." return 0 @@ -906,6 +916,52 @@ function SetupOS_Menulst() return 0 } +######################################################### +# Description: SetupOS_LoadSourceToDisk +# Input none +# Return: 0: SUCCESS +# 1: Internal Error. +######################################################### +function SetupOS_LoadSourceToDisk() +{ + local cmdline=/proc/cmdline + + pxecfg_path="`INIT_Get_CmdLineParamValue 'install_saveosdir' ${cmdline}`" + if [ -z "${pxecfg_path}" ]; then + g_LOG_Notice "The install_saveosdir parameter is not set so we can not copy the source file to the target disk." + return 0 + fi + + g_LOG_Debug "Load source to disk ..." + if [ ! -d ${LOCAL_DISK_PATH}/${pxecfg_path} ]; then + mkdir -p ${LOCAL_DISK_PATH}/${pxecfg_path} + if [ $? -ne 0 ]; then + g_LOG_Error "Create directory ${LOCAL_DISK_PATH}/${pxecfg_path} failed." + return 1 + fi + fi + + dirtype=$(df -hT ${LOCAL_DISK_PATH}/${pxecfg_path} | sed -n 2p | awk '{print $1}' | grep "\/dev") + if [ -z ${dirtype} ]; then + g_LOG_Error "Directory ${pxecfg_path} is not in a disk" + return 1 + fi + + partition_size=$(df -lm ${LOCAL_DISK_PATH}/${pxecfg_path} | sed -n 2p | awk '{print $4}') + file_size=$(du -m ${LOCAL_SOURCE_PATH}/ | awk '{print $1}') + if [ ${file_size} -ge ${partition_size} ]; then + g_LOG_Error "Direcotry ${pxecfg_path} space is not enough to store source files." + return 1 + fi + + cp -ap ${LOCAL_SOURCE_PATH}/* ${LOCAL_DISK_PATH}/${pxecfg_path} + if [ $? -ne 0 ]; then + g_LOG_Error "Copy ${SI_OSTARNAME} to ${LOCAL_DISK_PATH}/${pxecfg_path} failed." + return 1 + fi + g_LOG_Debug "Copy ${SI_OSTARNAME} to ${LOCAL_DISK_PATH}/${pxecfg_path} success" +} + ######################################################### # Description: SetupOS_clean # Input none @@ -1049,6 +1105,8 @@ function SetupOS_Install() fi fi + SetupOS_LoadSourceToDisk + #拷贝new.part到/etc目录中,用于下次安装进行分区比较 if [ -f "${LOCAL_TEMPCFG_PATH}/new.part" ] && [ -d "${LOCAL_DISK_PATH}/etc" ]; then g_LOG_Info "copy ${LOCAL_TEMPCFG_PATH}/new.part to ${LOCAL_DISK_PATH}/etc" @@ -1099,13 +1157,18 @@ function SetupOS() esac } - -if [ ! -z "`cat /proc/mounts | grep " ${LOCAL_DISK_PATH} "`" ]; then +if cat /proc/cmdline | grep "product=mbsc" &>/dev/null; then + g_LOG_Info "start mbsc SetupOS" SetupOS ret=$? else - g_LOG_Error "${LOCAL_DISK_PATH} is not mounted." - ret=1 + if [ ! -z "`cat /proc/mounts | grep " ${LOCAL_DISK_PATH} "`" ]; then + SetupOS + ret=$? + else + g_LOG_Error "${LOCAL_DISK_PATH} is not mounted." + ret=1 + fi fi exit ${ret} diff --git a/usr/Euler/project/load/filetransfer.sh b/usr/Euler/project/load/filetransfer.sh index 5d75640..7066f25 100644 --- a/usr/Euler/project/load/filetransfer.sh +++ b/usr/Euler/project/load/filetransfer.sh @@ -261,7 +261,7 @@ function tftp_download() if echo ${fileName} | grep -q ${FT_FILE_LIST} ;then #download filelist first - result=`${FT_TFTP} ${serverIp} ${serverPort} -c get ${sourceFile}/${filelist} ${targetFile} 2>&1` + result=`${FT_TFTP} -m binary ${serverIp} ${serverPort} -c get ${sourceFile}/${filelist} ${targetFile} 2>&1` if [ ! -z "${result}" ];then g_LOG_Error "${result}" g_LOG_Error "Download remote file [${FT_FILE_LIST}] failed, maybe it's not exist." @@ -289,7 +289,7 @@ function tftp_download() fi echo "${line}" | grep "\/$" > /dev/null 2>&1 if [ $? -ne 0 ];then - result=`${FT_TFTP} ${serverIp} ${serverPort} -c get ${sourceFile}/${line} ${targetDir}/${line} 2>&1` + result=`${FT_TFTP} -m binary ${serverIp} ${serverPort} -c get ${sourceFile}/${line} ${targetDir}/${line} 2>&1` if [ ! -z "${result}" ]; then rm -rf ${targetDir}/${line} > /dev/null 2>&1 g_LOG_Warn "${result}" @@ -298,7 +298,7 @@ function tftp_download() fi done < ${targetFile} else - result=`${FT_TFTP} ${serverIp} ${serverPort} -c get ${sourceFile} ${targetFile} 2>&1` + result=`${FT_TFTP} -m binary ${serverIp} ${serverPort} -c get ${sourceFile} ${targetFile} 2>&1` if [ ! -z "${result}" ];then rm -rf ${targetFile} > /dev/null 2>&1 g_LOG_Error "${result}" @@ -315,7 +315,7 @@ function parseUrl() local serverUrl= local userName= local password= - local pattern="^[fF][iI][lL][eE]$|^[cC][dD]$|^[nN][fF][sS]$|^[fF][tT][pP]$|^[hH][tT][tT][pP]$|^[tT][fF][tT][pP]$" + local pattern="^[fF][iI][lL][eE]$|^[cC][dD]$|^[nN][fF][sS]$|^[cC][iI][fF][sS]$|^[fF][tT][pP]$|^[hH][tT][tT][pP]$|^[tT][fF][tT][pP]$" local ipPattern="^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$" local tmpPath= local TMP_PARAMS= @@ -327,7 +327,7 @@ function parseUrl() serverUrl=$1 FT_TRAN_PROTOCOL=`echo ${serverUrl} | awk -F ":" '{print $1}'` if ! echo ${FT_TRAN_PROTOCOL} | grep -q -E "${pattern}"; then - g_LOG_Error "The serverurl protocol must be cd, nfs, ftp, http or tftp" + g_LOG_Error "The serverurl protocol must be cd, nfs, cifs, ftp, http or tftp" return 1 fi g_LOG_Debug "file transfer protocol is ${FT_TRAN_PROTOCOL}" diff --git a/usr/Euler/project/load/load.sh b/usr/Euler/project/load/load.sh index 700e5fc..2f0a5d8 100644 --- a/usr/Euler/project/load/load.sh +++ b/usr/Euler/project/load/load.sh @@ -20,12 +20,12 @@ MODPROBE="`which modprobe`" MKFS_EXT3="`which mkfs.ext3`" MOUNT="`which mount`" ###################################################### -#function g_LOAD_CONFIG +#function g_Load_Config #input none -#dataAccess $CFG_SERVER_URL $LOCAL_CONFIG_PATH +#dataAcess $CFG_SERVER_URL $LOCAL_CONFIG_PATH # LOCAL_TEMPCFG_PATH ###################################################### -function g_LOAD_CONFIG +function g_Load_Config { local returnValue g_LOG_Info "begin load config file" @@ -65,7 +65,7 @@ function g_LOAD_CONFIG ###################################################### #function g_LOAD_Os #description load os repo to targetdir -#dataAccess $REPO_SERVER_URL $LOCAL_SOURCE_PATH +#dataAcess $REPO_SERVER_URL $LOCAL_SOURCE_PATH ###################################################### function g_Load_Os { @@ -82,7 +82,7 @@ function g_Load_Os fi if [ -n "${REPO_SERVER_URL}" -a -n "${LOCAL_SOURCE_PATH}" ];then - INIT_RAMDISK + INIT_Ramdisk if [ $? -ne 0 ];then g_LOG_Error "init load os storage error" return 1 @@ -114,7 +114,7 @@ function g_Load_Os LOCAL_SOURCE_PATH="$LOCAL_SOURCE_PATH/repo" fi else - LOCAL_SOURCE_PATH="$LOCAL_SOURCE_PATH/repo" + LOCAL_SOURCE_PATH="$LOCAL_SOURCE_PATH/repo" fi else returnValue=1 @@ -126,7 +126,7 @@ function g_Load_Os ########################################################## #description init a ramdisk and mount 2 $LOCAL_SOURCE_PATH ########################################################## -function INIT_RAMDISK() +function INIT_Ramdisk() { $MODPROBE brd rd_size=3072000 rd_nr=1 max_part=1 >>$OTHER_TTY 2>&1 if [ -b /dev/ram0 ];then @@ -136,7 +136,7 @@ function INIT_RAMDISK() g_LOG_Error "mkdir $LOCAL_SOURCE_PATH failed" return 1 fi - + $MOUNT -t ext3 /dev/ram0 $LOCAL_SOURCE_PATH >>$OTHER_TTY 2>&1 if [ $? -ne 0 ]; then g_LOG_Error "mount /dev/ram0 to $LOCAL_SOURCE_PATH error" -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2