1 Star 0 Fork 50

山竹/grub2

forked from src-anolis-os/grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0158-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch 3.83 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2022-04-13 15:15 . update to grub2-2.02-120.el8.src.rpm
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 22 Jun 2018 14:01:06 -0400
Subject: [PATCH] grub-switch-to-blscfg.in: get rid of a bunch of bashisms
Since this says /bin/sh at the top, it should work with dash.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
util/grub-switch-to-blscfg.in | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
index 2482483a4..dac41e738 100644
--- a/util/grub-switch-to-blscfg.in
+++ b/util/grub-switch-to-blscfg.in
@@ -151,18 +151,18 @@ done
find_grub_cfg() {
local candidate=""
- while [[ -e "${candidate}" || $# -gt 0 ]]
+ while [ -e "${candidate}" -o $# -gt 0 ]
do
- if [[ ! -e "${candidate}" ]] ; then
+ if [ ! -e "${candidate}" ] ; then
candidate="$1"
shift
fi
- if [[ -L "${candidate}" ]]; then
+ if [ -L "${candidate}" ]; then
candidate="$(realpath "${candidate}")"
fi
- if [[ -f "${candidate}" ]]; then
+ if [ -f "${candidate}" ]; then
export GRUB_CONFIG_FILE="${candidate}"
return 0
fi
@@ -175,11 +175,11 @@ if ! find_grub_cfg ${startlink} ${grubdir}/grub.cfg ; then
exit 1
fi
-if [[ ! -d "${blsdir}" ]]; then
+if [ ! -d "${blsdir}" ]; then
install -m 700 -d "${blsdir}"
fi
-if [[ -f /etc/machine-id ]]; then
+if [ -f /etc/machine-id ]; then
MACHINE_ID=$(cat /etc/machine-id)
else
MACHINE_ID=$(dmesg | sha256sum)
@@ -194,9 +194,9 @@ mkbls() {
local debugid=""
local flavor=""
- if [[ "$kernelver" == *\+* ]] ; then
+ if [ "$kernelver" == *\+* ] ; then
local flavor=-"${kernelver##*+}"
- if [[ "${flavor}" == "-debug" ]]; then
+ if [ "${flavor}" == "-debug" ]; then
local debugname=" with debugging"
local debugid="-debug"
fi
@@ -219,15 +219,15 @@ EOF
}
for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
- if [[ ! -d "/lib/modules/${kernelver}" ]] ; then
+ if [ ! -d "/lib/modules/${kernelver}" ] ; then
continue
fi
- if [[ ! -f "/boot/vmlinuz-${kernelver}" ]]; then
+ if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then
continue
fi
bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
kernel_dir="/lib/modules/${kernelver}"
- if [[ -f "${kernel_dir}/bls.conf" ]]; then
+ if [ -f "${kernel_dir}/bls.conf" ]; then
cp -af "${kernel_dir}/bls.conf" "${bls_target}"
else
mkbls "${kernelver}" \
@@ -240,7 +240,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
linux_relpath="$("${grub_mkrelpath}" /boot/$linux)"
initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)"
- if [[ $linux != $linux_relpath ]]; then
+ if [ $linux != $linux_relpath ] ; then
sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}"
sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}"
fi
@@ -257,8 +257,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
fi
done
-if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then
- if [[ $linux != $linux_relpath ]]; then
+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
+ if [ $linux != $linux_relpath ]; then
bootprefix="$(dirname ${linux_relpath})"
fi
mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf"
@@ -282,7 +282,7 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then
GENERATE=1
fi
-if [[ "${GENERATE}" -eq 1 ]] ; then
+if [ "${GENERATE}" -eq 1 ] ; then
cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then
cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangpingping000/grub2.git
git@gitee.com:wangpingping000/grub2.git
wangpingping000
grub2
grub2
a8

搜索帮助