From 49c1bc1e8b6271863723302c71c1ae9f25e653a9 Mon Sep 17 00:00:00 2001 From: Qiumiao Zhang Date: Fri, 18 Mar 2022 16:51:24 +0800 Subject: [PATCH] get SI_GRUB2_PATH by ID in /etc/os-release (cherry picked from commit 2eefc488c8917b162c1ff16e4eb92bf007e5b4cc) --- ...I_GRUB2_PATH-by-ID-in-etc-os-release.patch | 106 ++++++++++++++++++ install-scripts.spec | 17 ++- 2 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 0001-get-SI_GRUB2_PATH-by-ID-in-etc-os-release.patch diff --git a/0001-get-SI_GRUB2_PATH-by-ID-in-etc-os-release.patch b/0001-get-SI_GRUB2_PATH-by-ID-in-etc-os-release.patch new file mode 100644 index 0000000..a77afab --- /dev/null +++ b/0001-get-SI_GRUB2_PATH-by-ID-in-etc-os-release.patch @@ -0,0 +1,106 @@ +From 3c30d35cf23b7c7fd15877d832b4052aa632409b Mon Sep 17 00:00:00 2001 +From: Qiumiao Zhang +Date: Sat, 19 Mar 2022 04:16:51 -0400 +Subject: [PATCH] get SI_GRUB2_PATH by ID in /etc/os-release + +--- + usr/Euler/project/install/setupOS.sh | 33 +++++++++++++++++++--------- + 1 file changed, 23 insertions(+), 10 deletions(-) + +diff --git a/usr/Euler/project/install/setupOS.sh b/usr/Euler/project/install/setupOS.sh +index 66b263d..fdbf17c 100644 +--- a/usr/Euler/project/install/setupOS.sh ++++ b/usr/Euler/project/install/setupOS.sh +@@ -46,6 +46,11 @@ export SI_SYSTEMMAP + MENU_VERSION= + export MENU_VERSION + ++#/etc/os-release in OS ++SI_OS_RELEASE=/etc/os-release ++OS_NAME= ++VENDOR= ++ + #OS.tar.gz包解压次数 + SI_UNCOMPRESS_TIME=1 + +@@ -60,11 +65,7 @@ SI_GRUB_PATH=/boot/grub + + GRUB_DIR=/usr/lib/grub + GRUB2_DIR=/usr/lib/grub2 +-if [ ${EFI_FLAG} -eq 1 ]; then +- SI_GRUB2_PATH=/boot/efi/EFI/openEuler +-else +- SI_GRUB2_PATH=/boot/grub2 +-fi ++SI_GRUB2_PATH= + GRUB2_EFI=EFI/grub2 + + GRUB2_CMD="`which grub2-install`" +@@ -113,6 +114,11 @@ function SetupOS_ParserSdf() + return 1 + fi + ++ if [ ! -f "${SI_OS_RELEASE}" ]; then ++ g_LOG_Error "the ${SI_OS_RELEASE} is not exist." ++ return 1 ++ fi ++ + SI_OSTARNAME="`INIT_Get_CmdLineParamValue 'name' ${SI_OS_PACKAGE_SDF}`" + SI_VERSION="`INIT_Get_CmdLineParamValue 'kernelversion' ${SI_OS_PACKAGE_SDF}`" + LOCAL_SI_VERSION="`INIT_Get_CmdLineParamValue 'localversion' ${SI_OS_PACKAGE_SDF}`" +@@ -120,12 +126,13 @@ function SetupOS_ParserSdf() + + euler_version="`INIT_Get_CmdLineParamValue 'eulerversion' ${SI_OS_PACKAGE_SDF}`" + os_version="`INIT_Get_CmdLineParamValue 'os_version' ${SI_OS_PACKAGE_SDF}`" ++ OS_NAME="`INIT_Get_CmdLineParamValue 'NAME' ${SI_OS_RELEASE} | sed 's/\"//g'`" + if [ ! -z "${euler_version}" ]; then + MENU_VERSION=${euler_version} + elif [ ! -z "${os_version}" ]; then + MENU_VERSION=${os_version} + else +- MENU_VERSION="openEuler" ++ MENU_VERSION=${OS_NAME} + fi + + if [ -z "$LOCAL_SI_VERSION" ]; then +@@ -596,7 +603,7 @@ function SetupOS_Grub2Install() + mount -t efivarfs efivarfs /sys/firmware/efi/efivars + fi + +- slot_id=`efibootmgr | grep -w "openEuler Linux" | awk -F "*" '{print $1}' | awk -F "Boot" '{print $2}'` ++ slot_id=`efibootmgr | grep -w "${OS_NAME}" | awk -F "*" '{print $1}' | awk -F "Boot" '{print $2}'` + if [ ! -z "${slot_id}" ]; then + efibootmgr -b ${slot_id} -B + fi +@@ -607,12 +614,12 @@ function SetupOS_Grub2Install() + g_LOG_Debug "boot partition name is "${boot_devname}", boot partition id is "${boot_partition_id}"" + + if [ "${arch}" = "aarch64" ]; then +- efibootmgr -q -c -d ${SI_DISK} -p ${boot_partition_id} -w -L 'openEuler Linux' -l '\EFI\openEuler\grubaa64.efi' ++ efibootmgr -q -c -d ${SI_DISK} -p ${boot_partition_id} -w -L "${OS_NAME}" -l "\EFI\\${VENDOR}\grubaa64.efi" + else + if [ "x${BOOT_ESP}" = "xtrue" ]; then +- efibootmgr -q -c -d ${SI_DISK} -p ${boot_partition_id} -w -L 'openEuler Linux' -l '\efi\EFI\openEuler\grubx64.efi' ++ efibootmgr -q -c -d ${SI_DISK} -p ${boot_partition_id} -w -L "${OS_NAME}" -l "\efi\EFI\\${VENDOR}\grubx64.efi" + else +- efibootmgr -q -c -d ${SI_DISK} -p ${boot_partition_id} -w -L 'openEuler Linux' -l '\EFI\openEuler\grubx64.efi' ++ efibootmgr -q -c -d ${SI_DISK} -p ${boot_partition_id} -w -L "${OS_NAME}" -l "\EFI\\${VENDOR}\grubx64.efi" + fi + fi + if [ $? -ne 0 ]; then +@@ -1010,6 +1017,12 @@ function SetupOS_Install() + if [ -f "${GRUB2_CMD}" ]; then + #安装grub2# + g_LOG_Info "${GRUB2_CMD} exist,install grub2 start." ++ VENDOR="`INIT_Get_CmdLineParamValue 'ID' ${SI_OS_RELEASE} | sed 's/\"//g'`" ++ if [ ${EFI_FLAG} -eq 1 ]; then ++ SI_GRUB2_PATH=/boot/efi/EFI/${VENDOR} ++ else ++ SI_GRUB2_PATH=/boot/grub2 ++ fi + SetupOS_Grub2Install + if [ $? -ne 0 ]; then + g_LOG_Error "Install grub2 failed." +-- +2.19.1 + diff --git a/install-scripts.spec b/install-scripts.spec index a2c3110..d89dffa 100644 --- a/install-scripts.spec +++ b/install-scripts.spec @@ -3,8 +3,11 @@ Summary: scripts for system installation Group: Applications/System License: Mulan PSL v2 Version: 1.1 -Release: 1 +Release: 2 SOURCE0: %{name}-%{version}.tar.bz2 + +Patch0001: 0001-get-SI_GRUB2_PATH-by-ID-in-etc-os-release.patch + Requires: kernel BuildRequires: dos2unix coreutils findutils BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -13,11 +16,9 @@ BuildArch: noarch This is a package of scripts for install OS from openEuler. %prep -%setup -c -%install - -cd %{name}-%{version} +%autosetup -n %{name}-%{version} -p1 +%install dos2unix `find -name "*.sh"` mkdir -m 750 -p $RPM_BUILD_ROOT/usr/Euler/ @@ -101,6 +102,12 @@ rm -rf %{_tmppath}/%{name}-%{version} rm -rf $RPM_BUILD_DIR/%{name}-%{version} %changelog +* Fri Mar 18 2022 zhangqiumiao - 1.1-2 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:get SI_GRUB2_PATH by ID in /etc/os-release + * Mon Feb 28 2022 zhangqiumiao - 1.1-1 - Type:requirement - CVE:NA -- Gitee