Compare commits
67 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
12e62c4f0a | ||
|
770392fcd0 | ||
|
959c481fa9 | ||
|
b2ab29059a | ||
|
f24781c87b | ||
|
b1eee22db8 | ||
|
1621d288b6 | ||
|
670185c682 | ||
|
303821d014 | ||
|
f57406f3ab | ||
|
8c7d866907 | ||
|
5f9558c222 | ||
|
03b13cef75 | ||
|
b5070e2278 | ||
|
3ffa2d2706 | ||
|
08153fc1d6 | ||
|
5dafc374ee | ||
|
77a8c0bcac | ||
|
9baffd002d | ||
|
4009bc7ed4 | ||
|
b50c79e71c | ||
|
7c6e97e809 | ||
|
7b4b34aa74 | ||
|
73b809baaf | ||
|
dc24f2cedf | ||
|
8213073fa4 | ||
|
6abeb6fc77 | ||
|
40d73389b4 | ||
|
ac9b25b31e | ||
|
a77221432e | ||
|
f742fa15b3 | ||
|
9f336a65dd | ||
|
290786e606 | ||
|
6b2ae0e335 | ||
|
2ad4f485f1 | ||
|
27cf1e7399 | ||
|
f1aafa632f | ||
|
b84a214b99 | ||
|
4b1d63cacd | ||
|
d1dd184403 | ||
|
e777519e08 | ||
|
695377d276 | ||
|
6cdfe45ece | ||
|
791d55400b | ||
|
4925c9ded9 | ||
|
f9d8ee1b64 | ||
|
d72135ede9 | ||
|
7babbb04df | ||
|
6ed71042bd | ||
|
2ef6823a35 | ||
|
9a80bb6f8e | ||
|
1c345197a4 | ||
|
db3ffac800 | ||
|
7d53b5e0a6 | ||
|
84881fb396 | ||
|
a5e56a6e7d | ||
|
b40ea5be18 | ||
|
cf425061aa | ||
|
0f5ce5a543 | ||
|
4aa091811b | ||
|
33ab171b28 | ||
|
28952a66c8 | ||
|
f9880644e6 | ||
|
b8c8cdcf6c | ||
|
e4c6ac2467 | ||
|
656faab212 | ||
|
c8647003fc |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,6 +1,6 @@
|
||||
grubby-*.tar.bz2
|
||||
*.tar.bz2
|
||||
*.tar.gz
|
||||
clog
|
||||
*.rpm
|
||||
/8.40-1.tar.gz
|
||||
.build*log
|
||||
grubby-*/
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 3689d4cebedf115e41c192bf034b6f86fcb80acb Mon Sep 17 00:00:00 2001
|
||||
From aa4472dbc10f3d669e24ac07293d7ac19e606866 Mon Sep 17 00:00:00 2001
|
||||
From: Dennis Gilmore <dennis@ausil.us>
|
||||
Date: Wed, 30 Aug 2017 14:03:45 -0500
|
||||
Subject: [PATCH] remove the old crufty u-boot support
|
||||
Subject: [PATCH 1/8] remove the old crufty u-boot support
|
||||
|
||||
Fedora has only supported extlinux.conf for a few releases now
|
||||
as a result it should be the only way we boot systems. Remove
|
||||
@ -9,13 +9,13 @@ the no longer needed uboot file
|
||||
|
||||
Signed-off-by: Dennis Gilmore <dennis@ausil.us>
|
||||
---
|
||||
new-kernel-pkg | 116 ---------------------------------------------------------
|
||||
uboot | 43 ---------------------
|
||||
new-kernel-pkg | 116 -------------------------------------------------
|
||||
uboot | 43 ------------------
|
||||
2 files changed, 159 deletions(-)
|
||||
delete mode 100644 uboot
|
||||
|
||||
diff --git a/new-kernel-pkg b/new-kernel-pkg
|
||||
index 64225de..0fe6caa 100755
|
||||
index b634388a83f..962008e3c9d 100755
|
||||
--- a/new-kernel-pkg
|
||||
+++ b/new-kernel-pkg
|
||||
@@ -37,7 +37,6 @@ else
|
||||
@ -48,7 +48,7 @@ index 64225de..0fe6caa 100755
|
||||
mounted=""
|
||||
liloFlag=""
|
||||
isx86=""
|
||||
@@ -386,53 +377,6 @@ remove() {
|
||||
@@ -382,53 +373,6 @@ remove() {
|
||||
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
|
||||
fi
|
||||
|
||||
@ -102,7 +102,7 @@ index 64225de..0fe6caa 100755
|
||||
if [ -n "$cfgExtlinux" ]; then
|
||||
[ -n "$verbose" ] && echo "removing $version from $extlinuxConfig"
|
||||
$grubby --extlinux -c $extlinuxConfig \
|
||||
@@ -534,36 +478,6 @@ update() {
|
||||
@@ -530,36 +474,6 @@ update() {
|
||||
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
|
||||
fi
|
||||
|
||||
@ -139,7 +139,7 @@ index 64225de..0fe6caa 100755
|
||||
if [ -n "$cfgExtlinux" ]; then
|
||||
[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
|
||||
ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \
|
||||
@@ -874,33 +788,6 @@ fi
|
||||
@@ -877,33 +791,6 @@ fi
|
||||
[ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1;
|
||||
[ -n "$extlinuxConfig" ] && [ -f "$extlinuxConfig" ] && cfgExtlinux=1;
|
||||
|
||||
@ -183,7 +183,7 @@ index 64225de..0fe6caa 100755
|
||||
exit 0
|
||||
diff --git a/uboot b/uboot
|
||||
deleted file mode 100644
|
||||
index 07d8671..0000000
|
||||
index 07d8671822f..00000000000
|
||||
--- a/uboot
|
||||
+++ /dev/null
|
||||
@@ -1,43 +0,0 @@
|
||||
@ -230,3 +230,6 @@ index 07d8671..0000000
|
||||
-
|
||||
-# option to tell new-kernel-pkg a specific dtb file to load in extlinux.conf
|
||||
-#dtbfile=foo.dtb
|
||||
--
|
||||
2.17.1
|
||||
|
@ -1,7 +1,7 @@
|
||||
From c1c46d21182974181f5b4c2ed0a02288b4bfd880 Mon Sep 17 00:00:00 2001
|
||||
From 3afc4c0ed28d443bb71956b07fd45c8cfb07566f Mon Sep 17 00:00:00 2001
|
||||
From: Nathaniel McCallum <npmccallum@redhat.com>
|
||||
Date: Fri, 2 Mar 2018 14:59:32 -0500
|
||||
Subject: [PATCH 1/3] Change return type in getRootSpecifier()
|
||||
Subject: [PATCH 2/8] Change return type in getRootSpecifier()
|
||||
|
||||
Rather than returning a new allocation of the prefix, just return the
|
||||
length of the prefix. This change accomplishes a couple things. First,
|
||||
@ -13,7 +13,7 @@ in the length of the prefix.
|
||||
1 file changed, 27 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/grubby.c b/grubby.c
|
||||
index d4ebb86..a062ef8 100644
|
||||
index d4ebb86168d..a062ef8e567 100644
|
||||
--- a/grubby.c
|
||||
+++ b/grubby.c
|
||||
@@ -675,7 +675,7 @@ static int lineWrite(FILE * out, struct singleLine * line,
|
||||
@ -139,5 +139,5 @@ index d4ebb86..a062ef8 100644
|
||||
return 0;
|
||||
|
||||
--
|
||||
2.14.3
|
||||
2.17.1
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 5dec033b19bb5b07a0a136a7357e16c8ca9f5dd6 Mon Sep 17 00:00:00 2001
|
||||
From 112b6e5fc690b2a73b6ad8c92dc4645db08503b6 Mon Sep 17 00:00:00 2001
|
||||
From: Nathaniel McCallum <npmccallum@redhat.com>
|
||||
Date: Fri, 2 Mar 2018 08:40:18 -0500
|
||||
Subject: [PATCH 2/3] Add btrfs subvolume support for grub2
|
||||
Subject: [PATCH 3/8] Add btrfs subvolume support for grub2
|
||||
|
||||
In order to find the subvolume prefix from a given path, we parse
|
||||
/proc/mounts. In cases where /proc/mounts doesn't contain the
|
||||
@ -12,11 +12,11 @@ Btrfs subvolumes are already supported by grub2 and by grub2-mkconfig.
|
||||
|
||||
Fixes #22
|
||||
---
|
||||
grubby.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
grubby.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 143 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/grubby.c b/grubby.c
|
||||
index a062ef8..96d252a 100644
|
||||
index a062ef8e567..96d252a0a83 100644
|
||||
--- a/grubby.c
|
||||
+++ b/grubby.c
|
||||
@@ -68,6 +68,8 @@ int isEfi = 0;
|
||||
@ -205,5 +205,5 @@ index a062ef8..96d252a 100644
|
||||
_("don't sanity check images in boot entries (for testing only)"),
|
||||
NULL },
|
||||
--
|
||||
2.14.3
|
||||
2.17.1
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 20d92194d03750d5d839c501d0539f9258614aae Mon Sep 17 00:00:00 2001
|
||||
From e319f73ca691b9cc138def3a9c19f1cb6e581475 Mon Sep 17 00:00:00 2001
|
||||
From: Gene Czarcinski <gczarcinski@gmail.com>
|
||||
Date: Mon, 9 Jun 2014 21:11:37 -0400
|
||||
Subject: [PATCH 3/3] Add tests for btrfs support
|
||||
Subject: [PATCH 4/8] Add tests for btrfs support
|
||||
|
||||
The tests performed are:
|
||||
- add kernel with /boot on btrfs subvol (20)
|
||||
@ -13,25 +13,25 @@ The tests performed are:
|
||||
- add kernel and initrd with rootfs on btrfs subvol and /boot
|
||||
a directory (25)
|
||||
---
|
||||
test.sh | 40 ++++++++++
|
||||
test.sh | 40 +++++++
|
||||
test/grub2-support_files/g2.20-mounts | 2 +
|
||||
test/grub2-support_files/g2.21-mounts | 1 +
|
||||
test/grub2-support_files/g2.22-mounts | 1 +
|
||||
test/grub2-support_files/g2.23-mounts | 1 +
|
||||
test/grub2-support_files/g2.24-mounts | 1 +
|
||||
test/grub2-support_files/g2.25-mounts | 1 +
|
||||
test/grub2.20 | 126 +++++++++++++++++++++++++++++
|
||||
test/grub2.21 | 140 +++++++++++++++++++++++++++++++++
|
||||
test/grub2.22 | 128 ++++++++++++++++++++++++++++++
|
||||
test/grub2.23 | 143 +++++++++++++++++++++++++++++++++
|
||||
test/grub2.24 | 126 +++++++++++++++++++++++++++++
|
||||
test/grub2.25 | 128 ++++++++++++++++++++++++++++++
|
||||
test/results/add/g2-1.20 | 140 +++++++++++++++++++++++++++++++++
|
||||
test/results/add/g2-1.21 | 141 +++++++++++++++++++++++++++++++++
|
||||
test/results/add/g2-1.22 | 143 +++++++++++++++++++++++++++++++++
|
||||
test/results/add/g2-1.23 | 144 ++++++++++++++++++++++++++++++++++
|
||||
test/results/add/g2-1.24 | 141 +++++++++++++++++++++++++++++++++
|
||||
test/results/add/g2-1.25 | 144 ++++++++++++++++++++++++++++++++++
|
||||
test/grub2.20 | 126 ++++++++++++++++++++++
|
||||
test/grub2.21 | 140 +++++++++++++++++++++++++
|
||||
test/grub2.22 | 128 +++++++++++++++++++++++
|
||||
test/grub2.23 | 143 +++++++++++++++++++++++++
|
||||
test/grub2.24 | 126 ++++++++++++++++++++++
|
||||
test/grub2.25 | 128 +++++++++++++++++++++++
|
||||
test/results/add/g2-1.20 | 140 +++++++++++++++++++++++++
|
||||
test/results/add/g2-1.21 | 141 +++++++++++++++++++++++++
|
||||
test/results/add/g2-1.22 | 143 +++++++++++++++++++++++++
|
||||
test/results/add/g2-1.23 | 144 ++++++++++++++++++++++++++
|
||||
test/results/add/g2-1.24 | 141 +++++++++++++++++++++++++
|
||||
test/results/add/g2-1.25 | 144 ++++++++++++++++++++++++++
|
||||
19 files changed, 1691 insertions(+)
|
||||
create mode 100644 test/grub2-support_files/g2.20-mounts
|
||||
create mode 120000 test/grub2-support_files/g2.21-mounts
|
||||
@ -53,7 +53,7 @@ The tests performed are:
|
||||
create mode 100644 test/results/add/g2-1.25
|
||||
|
||||
diff --git a/test.sh b/test.sh
|
||||
index 6379698..c35bfca 100755
|
||||
index 6379698c6de..c35bfca1c89 100755
|
||||
--- a/test.sh
|
||||
+++ b/test.sh
|
||||
@@ -629,6 +629,46 @@ if [ "$testgrub2" == "y" ]; then
|
||||
@ -105,7 +105,7 @@ index 6379698..c35bfca 100755
|
||||
|
||||
diff --git a/test/grub2-support_files/g2.20-mounts b/test/grub2-support_files/g2.20-mounts
|
||||
new file mode 100644
|
||||
index 0000000..00bdb48
|
||||
index 00000000000..00bdb48e4ab
|
||||
--- /dev/null
|
||||
+++ b/test/grub2-support_files/g2.20-mounts
|
||||
@@ -0,0 +1,2 @@
|
||||
@ -113,7 +113,7 @@ index 0000000..00bdb48
|
||||
+/dev/sda /boot btrfs subvol=/boot6,defaults 0 0
|
||||
diff --git a/test/grub2-support_files/g2.21-mounts b/test/grub2-support_files/g2.21-mounts
|
||||
new file mode 120000
|
||||
index 0000000..42ef3fd
|
||||
index 00000000000..42ef3fd4272
|
||||
--- /dev/null
|
||||
+++ b/test/grub2-support_files/g2.21-mounts
|
||||
@@ -0,0 +1 @@
|
||||
@ -121,14 +121,14 @@ index 0000000..42ef3fd
|
||||
\ No newline at end of file
|
||||
diff --git a/test/grub2-support_files/g2.22-mounts b/test/grub2-support_files/g2.22-mounts
|
||||
new file mode 100644
|
||||
index 0000000..5b664e7
|
||||
index 00000000000..5b664e72519
|
||||
--- /dev/null
|
||||
+++ b/test/grub2-support_files/g2.22-mounts
|
||||
@@ -0,0 +1 @@
|
||||
+/dev/sda / btrfs defaults,subvol=/root4,ro 0 0
|
||||
diff --git a/test/grub2-support_files/g2.23-mounts b/test/grub2-support_files/g2.23-mounts
|
||||
new file mode 120000
|
||||
index 0000000..74f036f
|
||||
index 00000000000..74f036fc4a3
|
||||
--- /dev/null
|
||||
+++ b/test/grub2-support_files/g2.23-mounts
|
||||
@@ -0,0 +1 @@
|
||||
@ -136,7 +136,7 @@ index 0000000..74f036f
|
||||
\ No newline at end of file
|
||||
diff --git a/test/grub2-support_files/g2.24-mounts b/test/grub2-support_files/g2.24-mounts
|
||||
new file mode 120000
|
||||
index 0000000..42ef3fd
|
||||
index 00000000000..42ef3fd4272
|
||||
--- /dev/null
|
||||
+++ b/test/grub2-support_files/g2.24-mounts
|
||||
@@ -0,0 +1 @@
|
||||
@ -144,7 +144,7 @@ index 0000000..42ef3fd
|
||||
\ No newline at end of file
|
||||
diff --git a/test/grub2-support_files/g2.25-mounts b/test/grub2-support_files/g2.25-mounts
|
||||
new file mode 120000
|
||||
index 0000000..74f036f
|
||||
index 00000000000..74f036fc4a3
|
||||
--- /dev/null
|
||||
+++ b/test/grub2-support_files/g2.25-mounts
|
||||
@@ -0,0 +1 @@
|
||||
@ -152,7 +152,7 @@ index 0000000..74f036f
|
||||
\ No newline at end of file
|
||||
diff --git a/test/grub2.20 b/test/grub2.20
|
||||
new file mode 100644
|
||||
index 0000000..23b75fa
|
||||
index 00000000000..23b75fa8d3c
|
||||
--- /dev/null
|
||||
+++ b/test/grub2.20
|
||||
@@ -0,0 +1,126 @@
|
||||
@ -284,7 +284,7 @@ index 0000000..23b75fa
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/grub2.21 b/test/grub2.21
|
||||
new file mode 100644
|
||||
index 0000000..579c2f6
|
||||
index 00000000000..579c2f6744a
|
||||
--- /dev/null
|
||||
+++ b/test/grub2.21
|
||||
@@ -0,0 +1,140 @@
|
||||
@ -430,7 +430,7 @@ index 0000000..579c2f6
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/grub2.22 b/test/grub2.22
|
||||
new file mode 100644
|
||||
index 0000000..9466bc3
|
||||
index 00000000000..9466bc35153
|
||||
--- /dev/null
|
||||
+++ b/test/grub2.22
|
||||
@@ -0,0 +1,128 @@
|
||||
@ -564,7 +564,7 @@ index 0000000..9466bc3
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/grub2.23 b/test/grub2.23
|
||||
new file mode 100644
|
||||
index 0000000..5cb240f
|
||||
index 00000000000..5cb240fc1de
|
||||
--- /dev/null
|
||||
+++ b/test/grub2.23
|
||||
@@ -0,0 +1,143 @@
|
||||
@ -713,7 +713,7 @@ index 0000000..5cb240f
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/grub2.24 b/test/grub2.24
|
||||
new file mode 100644
|
||||
index 0000000..23b75fa
|
||||
index 00000000000..23b75fa8d3c
|
||||
--- /dev/null
|
||||
+++ b/test/grub2.24
|
||||
@@ -0,0 +1,126 @@
|
||||
@ -845,7 +845,7 @@ index 0000000..23b75fa
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/grub2.25 b/test/grub2.25
|
||||
new file mode 100644
|
||||
index 0000000..9466bc3
|
||||
index 00000000000..9466bc35153
|
||||
--- /dev/null
|
||||
+++ b/test/grub2.25
|
||||
@@ -0,0 +1,128 @@
|
||||
@ -979,7 +979,7 @@ index 0000000..9466bc3
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/results/add/g2-1.20 b/test/results/add/g2-1.20
|
||||
new file mode 100644
|
||||
index 0000000..579c2f6
|
||||
index 00000000000..579c2f6744a
|
||||
--- /dev/null
|
||||
+++ b/test/results/add/g2-1.20
|
||||
@@ -0,0 +1,140 @@
|
||||
@ -1125,7 +1125,7 @@ index 0000000..579c2f6
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/results/add/g2-1.21 b/test/results/add/g2-1.21
|
||||
new file mode 100644
|
||||
index 0000000..c0dded9
|
||||
index 00000000000..c0dded9724c
|
||||
--- /dev/null
|
||||
+++ b/test/results/add/g2-1.21
|
||||
@@ -0,0 +1,141 @@
|
||||
@ -1272,7 +1272,7 @@ index 0000000..c0dded9
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/results/add/g2-1.22 b/test/results/add/g2-1.22
|
||||
new file mode 100644
|
||||
index 0000000..5cb240f
|
||||
index 00000000000..5cb240fc1de
|
||||
--- /dev/null
|
||||
+++ b/test/results/add/g2-1.22
|
||||
@@ -0,0 +1,143 @@
|
||||
@ -1421,7 +1421,7 @@ index 0000000..5cb240f
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/results/add/g2-1.23 b/test/results/add/g2-1.23
|
||||
new file mode 100644
|
||||
index 0000000..c3e87cf
|
||||
index 00000000000..c3e87cf7897
|
||||
--- /dev/null
|
||||
+++ b/test/results/add/g2-1.23
|
||||
@@ -0,0 +1,144 @@
|
||||
@ -1571,7 +1571,7 @@ index 0000000..c3e87cf
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/results/add/g2-1.24 b/test/results/add/g2-1.24
|
||||
new file mode 100644
|
||||
index 0000000..c0dded9
|
||||
index 00000000000..c0dded9724c
|
||||
--- /dev/null
|
||||
+++ b/test/results/add/g2-1.24
|
||||
@@ -0,0 +1,141 @@
|
||||
@ -1718,7 +1718,7 @@ index 0000000..c0dded9
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
diff --git a/test/results/add/g2-1.25 b/test/results/add/g2-1.25
|
||||
new file mode 100644
|
||||
index 0000000..c3e87cf
|
||||
index 00000000000..c3e87cf7897
|
||||
--- /dev/null
|
||||
+++ b/test/results/add/g2-1.25
|
||||
@@ -0,0 +1,144 @@
|
||||
@ -1867,5 +1867,5 @@ index 0000000..c3e87cf
|
||||
+fi
|
||||
+### END /etc/grub.d/41_custom ###
|
||||
--
|
||||
2.14.3
|
||||
2.17.1
|
||||
|
@ -1,14 +1,14 @@
|
||||
From fbc4d4feef66df7224fde64adae95525e73bf141 Mon Sep 17 00:00:00 2001
|
||||
From e08c858af4d2b09e62441560f3ccecc9e750c87a Mon Sep 17 00:00:00 2001
|
||||
From: Rafael dos Santos <rdossant@redhat.com>
|
||||
Date: Tue, 29 May 2018 15:15:24 +0200
|
||||
Subject: [PATCH] Use system LDFLAGS
|
||||
Subject: [PATCH 5/8] Use system LDFLAGS
|
||||
|
||||
---
|
||||
Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index ac14404..f0d1372 100644
|
||||
index ac144046133..f0d13720db5 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -25,7 +25,7 @@ OBJECTS = grubby.o log.o
|
||||
@ -21,5 +21,5 @@ index ac14404..f0d1372 100644
|
||||
grubby_LIBS = -lblkid -lpopt
|
||||
|
||||
--
|
||||
2.17.0
|
||||
2.17.1
|
||||
|
@ -1,7 +1,7 @@
|
||||
From a56df998177574ef2db332220c15f11bccd98f7e Mon Sep 17 00:00:00 2001
|
||||
From db200499551e386e7616c621fcbd69e350081664 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 18 Jul 2018 13:41:02 -0400
|
||||
Subject: [PATCH] Honor sbindir
|
||||
Subject: [PATCH 6/8] Honor sbindir
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
@ -9,7 +9,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index ac144046133..2b18dd6404b 100644
|
||||
index f0d13720db5..cfa8e0d60ab 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -42,14 +42,14 @@ test: all
|
@ -1,7 +1,7 @@
|
||||
From f93a35be5bdec17044dd2a17980689d3cbf73d58 Mon Sep 17 00:00:00 2001
|
||||
From fa1bf7b54cb71fa193da16ffc404f8535d7d16ac Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 31 Jul 2018 17:43:53 +0200
|
||||
Subject: [PATCH] Make installkernel to use kernel-install scripts on BLS
|
||||
Subject: [PATCH 7/8] Make installkernel to use kernel-install scripts on BLS
|
||||
configuration
|
||||
|
||||
The kernel make install target executes the arch/$ARCH/boot/install.sh
|
418
0008-Add-usr-libexec-rpm-sort.patch
Normal file
418
0008-Add-usr-libexec-rpm-sort.patch
Normal file
@ -0,0 +1,418 @@
|
||||
From b8a581014170c6a9bb8ffb799090401a57a4bbe6 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Fri, 12 Oct 2018 16:39:37 -0400
|
||||
Subject: [PATCH 8/8] Add /usr/libexec/rpm-sort
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
rpm-sort.c | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
Makefile | 9 +-
|
||||
.gitignore | 1 +
|
||||
3 files changed, 363 insertions(+), 2 deletions(-)
|
||||
create mode 100644 rpm-sort.c
|
||||
|
||||
diff --git a/rpm-sort.c b/rpm-sort.c
|
||||
new file mode 100644
|
||||
index 00000000000..f19635645ba
|
||||
--- /dev/null
|
||||
+++ b/rpm-sort.c
|
||||
@@ -0,0 +1,355 @@
|
||||
+#define _GNU_SOURCE
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <unistd.h>
|
||||
+#include <errno.h>
|
||||
+#include <assert.h>
|
||||
+#include <argp.h>
|
||||
+#include <rpm/rpmlib.h>
|
||||
+#include <err.h>
|
||||
+
|
||||
+typedef enum {
|
||||
+ RPMNVRCMP,
|
||||
+ VERSNVRCMP,
|
||||
+ RPMVERCMP,
|
||||
+ STRVERSCMP,
|
||||
+} comparitors;
|
||||
+
|
||||
+static comparitors comparitor = RPMNVRCMP;
|
||||
+
|
||||
+static inline void *xmalloc(size_t sz)
|
||||
+{
|
||||
+ void *ret = malloc(sz);
|
||||
+
|
||||
+ assert(sz == 0 || ret != NULL);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static inline void *xrealloc(void *p, size_t sz)
|
||||
+{
|
||||
+ void *ret = realloc(p, sz);
|
||||
+
|
||||
+ assert(sz == 0 || ret != NULL);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static inline char *xstrdup(const char * const s)
|
||||
+{
|
||||
+ void *ret = strdup(s);
|
||||
+
|
||||
+ assert(s == NULL || ret != NULL);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static size_t
|
||||
+read_file (const char *input, char **ret)
|
||||
+{
|
||||
+ FILE *in;
|
||||
+ size_t s;
|
||||
+ size_t sz = 2048;
|
||||
+ size_t offset = 0;
|
||||
+ char *text;
|
||||
+
|
||||
+ if (!strcmp(input, "-"))
|
||||
+ in = stdin;
|
||||
+ else
|
||||
+ in = fopen(input, "r");
|
||||
+
|
||||
+ text = xmalloc (sz);
|
||||
+
|
||||
+ if (!in)
|
||||
+ err(1, "cannot open `%s'", input);
|
||||
+
|
||||
+ while ((s = fread (text + offset, 1, sz - offset, in)) != 0)
|
||||
+ {
|
||||
+ offset += s;
|
||||
+ if (sz - offset == 0)
|
||||
+ {
|
||||
+ sz += 2048;
|
||||
+ text = xrealloc (text, sz);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ text[offset] = '\0';
|
||||
+ *ret = text;
|
||||
+
|
||||
+ if (in != stdin)
|
||||
+ fclose(in);
|
||||
+
|
||||
+ return offset + 1;
|
||||
+}
|
||||
+
|
||||
+/* returns name/version/release */
|
||||
+/* NULL string pointer returned if nothing found */
|
||||
+static void
|
||||
+split_package_string (char *package_string, char **name,
|
||||
+ char **version, char **release)
|
||||
+{
|
||||
+ char *package_version, *package_release;
|
||||
+
|
||||
+ /* Release */
|
||||
+ package_release = strrchr (package_string, '-');
|
||||
+
|
||||
+ if (package_release != NULL)
|
||||
+ *package_release++ = '\0';
|
||||
+
|
||||
+ *release = package_release;
|
||||
+
|
||||
+ /* Version */
|
||||
+ package_version = strrchr(package_string, '-');
|
||||
+
|
||||
+ if (package_version != NULL)
|
||||
+ *package_version++ = '\0';
|
||||
+
|
||||
+ *version = package_version;
|
||||
+ /* Name */
|
||||
+ *name = package_string;
|
||||
+
|
||||
+ /* Bubble up non-null values from release to name */
|
||||
+ if (*name == NULL)
|
||||
+ {
|
||||
+ *name = (*version == NULL ? *release : *version);
|
||||
+ *version = *release;
|
||||
+ *release = NULL;
|
||||
+ }
|
||||
+ if (*version == NULL)
|
||||
+ {
|
||||
+ *version = *release;
|
||||
+ *release = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+cmprpmversp(const void *p1, const void *p2)
|
||||
+{
|
||||
+ return rpmvercmp(*(char * const *)p1, *(char * const *)p2);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+cmpstrversp(const void *p1, const void *p2)
|
||||
+{
|
||||
+ return strverscmp(*(char * const *)p1, *(char * const *)p2);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * package name-version-release comparator for qsort
|
||||
+ * expects p, q which are pointers to character strings (char *)
|
||||
+ * which will not be altered in this function
|
||||
+ */
|
||||
+static int
|
||||
+package_version_compare (const void *p, const void *q)
|
||||
+{
|
||||
+ char *local_p, *local_q;
|
||||
+ char *lhs_name, *lhs_version, *lhs_release;
|
||||
+ char *rhs_name, *rhs_version, *rhs_release;
|
||||
+ int vercmpflag = 0;
|
||||
+ int (*cmp)(const char *s1, const char *s2);
|
||||
+
|
||||
+ switch(comparitor)
|
||||
+ {
|
||||
+ default: /* just to shut up -Werror=maybe-uninitialized */
|
||||
+ case RPMNVRCMP:
|
||||
+ cmp = rpmvercmp;
|
||||
+ break;
|
||||
+ case VERSNVRCMP:
|
||||
+ cmp = strverscmp;
|
||||
+ break;
|
||||
+ case RPMVERCMP:
|
||||
+ return cmprpmversp(p, q);
|
||||
+ break;
|
||||
+ case STRVERSCMP:
|
||||
+ return cmpstrversp(p, q);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ local_p = alloca (strlen (*(char * const *)p) + 1);
|
||||
+ local_q = alloca (strlen (*(char * const *)q) + 1);
|
||||
+
|
||||
+ /* make sure these allocated */
|
||||
+ assert (local_p);
|
||||
+ assert (local_q);
|
||||
+
|
||||
+ strcpy (local_p, *(char * const *)p);
|
||||
+ strcpy (local_q, *(char * const *)q);
|
||||
+
|
||||
+ split_package_string (local_p, &lhs_name, &lhs_version, &lhs_release);
|
||||
+ split_package_string (local_q, &rhs_name, &rhs_version, &rhs_release);
|
||||
+
|
||||
+ /* Check Name and return if unequal */
|
||||
+ vercmpflag = cmp ((lhs_name == NULL ? "" : lhs_name),
|
||||
+ (rhs_name == NULL ? "" : rhs_name));
|
||||
+ if (vercmpflag != 0)
|
||||
+ return vercmpflag;
|
||||
+
|
||||
+ /* Check version and return if unequal */
|
||||
+ vercmpflag = cmp ((lhs_version == NULL ? "" : lhs_version),
|
||||
+ (rhs_version == NULL ? "" : rhs_version));
|
||||
+ if (vercmpflag != 0)
|
||||
+ return vercmpflag;
|
||||
+
|
||||
+ /* Check release and return the version compare value */
|
||||
+ vercmpflag = cmp ((lhs_release == NULL ? "" : lhs_release),
|
||||
+ (rhs_release == NULL ? "" : rhs_release));
|
||||
+
|
||||
+ return vercmpflag;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+add_input (const char *filename, char ***package_names, size_t *n_package_names)
|
||||
+{
|
||||
+ char *orig_input_buffer = NULL;
|
||||
+ char *input_buffer;
|
||||
+ char *position_of_newline;
|
||||
+ char **names = *package_names;
|
||||
+ char **new_names = NULL;
|
||||
+ size_t n_names = *n_package_names;
|
||||
+
|
||||
+ if (!*package_names)
|
||||
+ new_names = names = xmalloc (sizeof (char *) * 2);
|
||||
+
|
||||
+ if (read_file (filename, &orig_input_buffer) < 2)
|
||||
+ {
|
||||
+ if (new_names)
|
||||
+ free (new_names);
|
||||
+ if (orig_input_buffer)
|
||||
+ free (orig_input_buffer);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ input_buffer = orig_input_buffer;
|
||||
+ while (input_buffer && *input_buffer &&
|
||||
+ (position_of_newline = strchrnul (input_buffer, '\n')))
|
||||
+ {
|
||||
+ size_t sz = position_of_newline - input_buffer;
|
||||
+ char *new;
|
||||
+
|
||||
+ if (sz == 0)
|
||||
+ {
|
||||
+ input_buffer = position_of_newline + 1;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ new = xmalloc (sz+1);
|
||||
+ strncpy (new, input_buffer, sz);
|
||||
+ new[sz] = '\0';
|
||||
+
|
||||
+ names = xrealloc (names, sizeof (char *) * (n_names + 1));
|
||||
+ names[n_names] = new;
|
||||
+ n_names++;
|
||||
+
|
||||
+ /* move buffer ahead to next line */
|
||||
+ input_buffer = position_of_newline + 1;
|
||||
+ if (*position_of_newline == '\0')
|
||||
+ input_buffer = NULL;
|
||||
+ }
|
||||
+
|
||||
+ free (orig_input_buffer);
|
||||
+
|
||||
+ *package_names = names;
|
||||
+ *n_package_names = n_names;
|
||||
+}
|
||||
+
|
||||
+static char *
|
||||
+help_filter (int key, const char *text, void *input __attribute__ ((unused)))
|
||||
+{
|
||||
+ return (char *)text;
|
||||
+}
|
||||
+
|
||||
+static struct argp_option options[] = {
|
||||
+ { "comparitor", 'c', "COMPARITOR", 0, "[rpm-nvr-cmp|vers-nvr-cmp|rpmvercmp|strverscmp]", 0},
|
||||
+ { 0, }
|
||||
+};
|
||||
+
|
||||
+struct arguments
|
||||
+{
|
||||
+ size_t ninputs;
|
||||
+ size_t input_max;
|
||||
+ char **inputs;
|
||||
+};
|
||||
+
|
||||
+static error_t
|
||||
+argp_parser (int key, char *arg, struct argp_state *state)
|
||||
+{
|
||||
+ struct arguments *arguments = state->input;
|
||||
+ switch (key)
|
||||
+ {
|
||||
+ case 'c':
|
||||
+ if (!strcmp(arg, "rpm-nvr-cmp") || !strcmp(arg, "rpmnvrcmp"))
|
||||
+ comparitor = RPMNVRCMP;
|
||||
+ else if (!strcmp(arg, "vers-nvr-cmp") || !strcmp(arg, "versnvrcmp"))
|
||||
+ comparitor = VERSNVRCMP;
|
||||
+ else if (!strcmp(arg, "rpmvercmp"))
|
||||
+ comparitor = RPMVERCMP;
|
||||
+ else if (!strcmp(arg, "strverscmp"))
|
||||
+ comparitor = STRVERSCMP;
|
||||
+ else
|
||||
+ err(1, "Invalid comparitor \"%s\"", arg);
|
||||
+ break;
|
||||
+ case ARGP_KEY_ARG:
|
||||
+ assert (arguments->ninputs < arguments->input_max);
|
||||
+ arguments->inputs[arguments->ninputs++] = xstrdup (arg);
|
||||
+ break;
|
||||
+ default:
|
||||
+ return ARGP_ERR_UNKNOWN;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct argp argp = {
|
||||
+ options, argp_parser, "[INPUT_FILES]",
|
||||
+ "Sort a list of strings in RPM version sort order.",
|
||||
+ NULL, help_filter, NULL
|
||||
+};
|
||||
+
|
||||
+int
|
||||
+main (int argc, char *argv[])
|
||||
+{
|
||||
+ struct arguments arguments;
|
||||
+ char **package_names = NULL;
|
||||
+ size_t n_package_names = 0;
|
||||
+ int i;
|
||||
+
|
||||
+ memset (&arguments, 0, sizeof (struct arguments));
|
||||
+ arguments.input_max = argc+1;
|
||||
+ arguments.inputs = xmalloc ((arguments.input_max + 1)
|
||||
+ * sizeof (arguments.inputs[0]));
|
||||
+ memset (arguments.inputs, 0, (arguments.input_max + 1)
|
||||
+ * sizeof (arguments.inputs[0]));
|
||||
+
|
||||
+ /* Parse our arguments */
|
||||
+ if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
|
||||
+ errx(1, "%s", "Error in parsing command line arguments\n");
|
||||
+
|
||||
+ /* If there's no inputs in argv, add one for stdin */
|
||||
+ if (!arguments.ninputs)
|
||||
+ {
|
||||
+ arguments.ninputs = 1;
|
||||
+ arguments.inputs[0] = xmalloc (2);
|
||||
+ strcpy(arguments.inputs[0], "-");
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < arguments.ninputs; i++)
|
||||
+ add_input(arguments.inputs[i], &package_names, &n_package_names);
|
||||
+
|
||||
+ if (package_names == NULL || n_package_names < 1)
|
||||
+ errx(1, "Invalid input");
|
||||
+
|
||||
+ qsort (package_names, n_package_names, sizeof (char *),
|
||||
+ package_version_compare);
|
||||
+
|
||||
+ /* send sorted list to stdout */
|
||||
+ for (i = 0; i < n_package_names; i++)
|
||||
+ {
|
||||
+ fprintf (stdout, "%s\n", package_names[i]);
|
||||
+ free (package_names[i]);
|
||||
+ }
|
||||
+
|
||||
+ free (package_names);
|
||||
+ for (i = 0; i < arguments.ninputs; i++)
|
||||
+ free (arguments.inputs[i]);
|
||||
+
|
||||
+ free (arguments.inputs);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/Makefile b/Makefile
|
||||
index cfa8e0d60ab..1ab58aeb039 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -29,7 +29,7 @@ LDFLAGS := $(RPM_LD_FLAGS)
|
||||
|
||||
grubby_LIBS = -lblkid -lpopt
|
||||
|
||||
-all: grubby
|
||||
+all: grubby rpm-sort
|
||||
|
||||
debug : clean
|
||||
$(MAKE) CFLAGS="${CFLAGS} -DDEBUG=1" all
|
||||
@@ -52,12 +52,17 @@ install: all
|
||||
install -m 755 grubby $(DESTDIR)$(PREFIX)$(sbindir) ; \
|
||||
install -m 644 grubby.8 $(DESTDIR)/$(mandir)/man8 ; \
|
||||
fi
|
||||
+ install -m 755 -d $(DESTDIR)$(PREFIX)$(libexecdir)/grubby/
|
||||
+ install -m 755 rpm-sort $(DESTDIR)$(PREFIX)$(libexecdir)/grubby/rpm-sort
|
||||
|
||||
grubby:: $(OBJECTS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(grubby_LIBS)
|
||||
|
||||
+rpm-sort::rpm-sort.o
|
||||
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpm
|
||||
+
|
||||
clean:
|
||||
- rm -f *.o grubby *~
|
||||
+ rm -f *.o grubby rpm-sort *~
|
||||
|
||||
GITTAG = $(VERSION)-1
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index e64d3bc0986..1a5a546eee3 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -1,3 +1,4 @@
|
||||
grubby
|
||||
+rpm-sort
|
||||
version.h
|
||||
*.o
|
||||
--
|
||||
2.17.1
|
||||
|
30
0009-Improve-man-page-for-info-option.patch
Normal file
30
0009-Improve-man-page-for-info-option.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From 64f91f29b03639b0726f0c46f004a20f11379e22 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Stodola <jstodola@redhat.com>
|
||||
Date: Sat, 1 Dec 2018 02:33:23 +0100
|
||||
Subject: [PATCH] Improve man page for --info option
|
||||
|
||||
1) commit 941d4a0b removed description of --info DEFAULT
|
||||
2) Add description of --info ALL
|
||||
---
|
||||
grubby.8 | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grubby.8 b/grubby.8
|
||||
index 355b6eb6908..9ffef895b0f 100644
|
||||
--- a/grubby.8
|
||||
+++ b/grubby.8
|
||||
@@ -132,7 +132,10 @@ is the default on ia32 platforms.
|
||||
|
||||
.TP
|
||||
\fB-\-info\fR=\fIkernel-path\fR
|
||||
-Display information on all boot entries which match \fIkernel-path\fR. I
|
||||
+Display information on all boot entries which match \fIkernel-path\fR. If
|
||||
+\fIkernel-path\fR is \fBDEFAULT\fR, then information on the default kernel
|
||||
+is displayed. If \fIkernel-path\fR is \fBALL\fR, then information on all boot
|
||||
+entries are displayed.
|
||||
|
||||
.TP
|
||||
\fB-\-initrd\fR=\fIinitrd-path\fR
|
||||
--
|
||||
2.19.1
|
||||
|
104
0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch
Normal file
104
0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch
Normal file
@ -0,0 +1,104 @@
|
||||
From 00241c65a5c0b4bb32a847a6abb5a86d0c704a8f Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 5 Feb 2019 20:08:43 +0100
|
||||
Subject: [PATCH] Fix GCC warnings about possible string truncations and buffer
|
||||
overflows
|
||||
|
||||
Building with -Werror=stringop-truncation and -Werror=stringop-overflow
|
||||
leads to GCC complaining about possible string truncation and overflows.
|
||||
|
||||
Fix this by using memcpy(), explicitly calculating the buffers lenghts
|
||||
and set a NUL byte terminator after copying the buffers.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grubby.c | 35 +++++++++++++++++++++++++++--------
|
||||
1 file changed, 27 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/grubby.c b/grubby.c
|
||||
index 96d252a0a83..5ca689539cf 100644
|
||||
--- a/grubby.c
|
||||
+++ b/grubby.c
|
||||
@@ -459,20 +459,26 @@ char *grub2ExtractTitle(struct singleLine * line) {
|
||||
snprintf(result, resultMaxSize, "%s", ++current);
|
||||
|
||||
i++;
|
||||
+ int result_len = 0;
|
||||
for (; i < line->numElements; ++i) {
|
||||
current = line->elements[i].item;
|
||||
current_len = strlen(current);
|
||||
current_indent = line->elements[i].indent;
|
||||
current_indent_len = strlen(current_indent);
|
||||
|
||||
- strncat(result, current_indent, current_indent_len);
|
||||
+ memcpy(result + result_len, current_indent, current_indent_len);
|
||||
+ result_len += current_indent_len;
|
||||
+
|
||||
if (!isquote(current[current_len-1])) {
|
||||
- strncat(result, current, current_len);
|
||||
+ memcpy(result + result_len, current_indent, current_indent_len);
|
||||
+ result_len += current_len;
|
||||
} else {
|
||||
- strncat(result, current, current_len - 1);
|
||||
+ memcpy(result + result_len, current_indent, current_indent_len);
|
||||
+ result_len += (current_len - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
+ result[result_len] = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1281,6 +1287,7 @@ static struct grubConfig * readConfig(const char * inName,
|
||||
extras = malloc(len + 1);
|
||||
*extras = '\0';
|
||||
|
||||
+ int buf_len = 0;
|
||||
/* get title. */
|
||||
for (int i = 0; i < line->numElements; i++) {
|
||||
if (!strcmp(line->elements[i].item, "menuentry"))
|
||||
@@ -1292,13 +1299,18 @@ static struct grubConfig * readConfig(const char * inName,
|
||||
|
||||
len = strlen(title);
|
||||
if (isquote(title[len-1])) {
|
||||
- strncat(buf, title,len-1);
|
||||
+ memcpy(buf + buf_len, title, len - 1);
|
||||
+ buf_len += (len - 1);
|
||||
break;
|
||||
} else {
|
||||
- strcat(buf, title);
|
||||
- strcat(buf, line->elements[i].indent);
|
||||
+ memcpy(buf + buf_len, title, len);
|
||||
+ buf_len += len;
|
||||
+ len = strlen(line->elements[i].indent);
|
||||
+ memcpy(buf + buf_len, line->elements[i].indent, len);
|
||||
+ buf_len += len;
|
||||
}
|
||||
}
|
||||
+ buf[buf_len] = '\0';
|
||||
|
||||
/* get extras */
|
||||
int count = 0;
|
||||
@@ -4494,10 +4506,17 @@ int main(int argc, const char ** argv) {
|
||||
exit(1);
|
||||
}
|
||||
saved_command_line[0] = '\0';
|
||||
+ int cmdline_len = 0, arg_len;
|
||||
for (int j = 1; j < argc; j++) {
|
||||
- strcat(saved_command_line, argv[j]);
|
||||
- strncat(saved_command_line, j == argc -1 ? "" : " ", 1);
|
||||
+ arg_len = strlen(argv[j]);
|
||||
+ memcpy(saved_command_line + cmdline_len, argv[j], arg_len);
|
||||
+ cmdline_len += arg_len;
|
||||
+ if (j != argc - 1) {
|
||||
+ memcpy(saved_command_line + cmdline_len, " ", 1);
|
||||
+ cmdline_len++;
|
||||
+ }
|
||||
}
|
||||
+ saved_command_line[cmdline_len] = '\0';
|
||||
|
||||
optCon = poptGetContext("grubby", argc, argv, options, 0);
|
||||
poptReadDefaultConfig(optCon, 1);
|
||||
--
|
||||
2.20.1
|
||||
|
72
0011-Fix-stringop-overflow-warning.patch
Normal file
72
0011-Fix-stringop-overflow-warning.patch
Normal file
@ -0,0 +1,72 @@
|
||||
From ed5e255c023c9b78120d9ff2246d6516f652d4b7 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 10 Feb 2020 19:32:39 +0100
|
||||
Subject: [PATCH] Fix stringop-overflow warning
|
||||
|
||||
GCC gives the following compile warning:
|
||||
|
||||
grubby.c: In function 'main':
|
||||
grubby.c:4508:27: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
|
||||
4508 | saved_command_line[0] = '\0';
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
|
||||
grubby.c:4503:26: note: at offset 0 to an object with size 0 allocated by 'malloc' here
|
||||
4503 | saved_command_line = malloc(i);
|
||||
| ^~~~~~~~~
|
||||
cc1: all warnings being treated as errors
|
||||
make: *** [Makefile:38: grubby.o] Error 1
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grubby.c | 35 +++++++++++++++++++----------------
|
||||
1 file changed, 19 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/grubby.c b/grubby.c
|
||||
index 5ca689539cf..0c0f67a0ae5 100644
|
||||
--- a/grubby.c
|
||||
+++ b/grubby.c
|
||||
@@ -4500,23 +4500,26 @@ int main(int argc, const char ** argv) {
|
||||
int i = 0;
|
||||
for (int j = 1; j < argc; j++)
|
||||
i += strlen(argv[j]) + 1;
|
||||
- saved_command_line = malloc(i);
|
||||
- if (!saved_command_line) {
|
||||
- fprintf(stderr, "grubby: %m\n");
|
||||
- exit(1);
|
||||
- }
|
||||
- saved_command_line[0] = '\0';
|
||||
- int cmdline_len = 0, arg_len;
|
||||
- for (int j = 1; j < argc; j++) {
|
||||
- arg_len = strlen(argv[j]);
|
||||
- memcpy(saved_command_line + cmdline_len, argv[j], arg_len);
|
||||
- cmdline_len += arg_len;
|
||||
- if (j != argc - 1) {
|
||||
- memcpy(saved_command_line + cmdline_len, " ", 1);
|
||||
- cmdline_len++;
|
||||
- }
|
||||
+
|
||||
+ if (i > 0) {
|
||||
+ saved_command_line = malloc(i);
|
||||
+ if (!saved_command_line) {
|
||||
+ fprintf(stderr, "grubby: %m\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ saved_command_line[0] = '\0';
|
||||
+ int cmdline_len = 0, arg_len;
|
||||
+ for (int j = 1; j < argc; j++) {
|
||||
+ arg_len = strlen(argv[j]);
|
||||
+ memcpy(saved_command_line + cmdline_len, argv[j], arg_len);
|
||||
+ cmdline_len += arg_len;
|
||||
+ if (j != argc - 1) {
|
||||
+ memcpy(saved_command_line + cmdline_len, " ", 1);
|
||||
+ cmdline_len++;
|
||||
+ }
|
||||
+ }
|
||||
+ saved_command_line[cmdline_len] = '\0';
|
||||
}
|
||||
- saved_command_line[cmdline_len] = '\0';
|
||||
|
||||
optCon = poptGetContext("grubby", argc, argv, options, 0);
|
||||
poptReadDefaultConfig(optCon, 1);
|
||||
--
|
||||
2.24.1
|
||||
|
35
0012-Fix-maybe-uninitialized-warning.patch
Normal file
35
0012-Fix-maybe-uninitialized-warning.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From ee9f80190d4c458a09309fbd9a88d2756dc2d3fa Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Mon, 10 Feb 2020 20:13:13 +0100
|
||||
Subject: [PATCH] Fix maybe-uninitialized warning
|
||||
|
||||
GCC gives the following compile warning:
|
||||
|
||||
grubby.c: In function 'suseGrubConfGetBoot':
|
||||
grubby.c:2770:5: error: 'grubDevice' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|
||||
2770 | free(grubDevice);
|
||||
| ^~~~~~~~~~~~~~~~
|
||||
cc1: all warnings being treated as errors
|
||||
make: *** [Makefile:38: grubby.o] Error 1
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grubby.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grubby.c b/grubby.c
|
||||
index 0c0f67a0ae5..779c25a2bf9 100644
|
||||
--- a/grubby.c
|
||||
+++ b/grubby.c
|
||||
@@ -2755,7 +2755,7 @@ int grubGetBootFromDeviceMap(const char * device,
|
||||
}
|
||||
|
||||
int suseGrubConfGetBoot(const char * path, char ** bootPtr) {
|
||||
- char * grubDevice;
|
||||
+ char * grubDevice = NULL;
|
||||
|
||||
if (suseGrubConfGetInstallDevice(path, &grubDevice))
|
||||
dbgPrintf("error looking for grub installation device\n");
|
||||
--
|
||||
2.24.1
|
||||
|
33
95-kernel-hooks.install
Executable file
33
95-kernel-hooks.install
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
COMMAND="$1"
|
||||
KERNEL_VERSION="$2"
|
||||
BOOT_DIR_ABS="$3"
|
||||
|
||||
# If $BOOT_DIR_ABS exists, some other boot loader is active.
|
||||
[[ -d "$BOOT_DIR_ABS" ]] && exit 0
|
||||
|
||||
run_hooks()
|
||||
{
|
||||
local f
|
||||
local files="$1"
|
||||
for f in $files ; do
|
||||
[ -x "$f" ] || continue
|
||||
"$f" "$KERNEL_VERSION" "/boot/vmlinuz-$KERNEL_VERSION"
|
||||
done
|
||||
}
|
||||
|
||||
case "$COMMAND" in
|
||||
add)
|
||||
run_hooks "/etc/kernel/postinst.d/*[^~] /etc/kernel/postinst.d/$KERNEL_VERSION/*[^~]"
|
||||
;;
|
||||
remove)
|
||||
run_hooks "/etc/kernel/prerm.d/*[^~] /etc/kernel/prerm.d/$KERNEL_VERSION/*[^~]"
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
360
grubby-bls
360
grubby-bls
@ -48,6 +48,10 @@ print_error() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
print_info() {
|
||||
echo "$1" >&2
|
||||
}
|
||||
|
||||
if [[ ${#} = 0 ]]; then
|
||||
print_error "no action specified"
|
||||
fi
|
||||
@ -56,7 +60,7 @@ get_bls_value() {
|
||||
local bls="$1" && shift
|
||||
local key="$1" && shift
|
||||
|
||||
echo "$(grep "^${key}[ \t]" "${bls}" | sed -e "s,^${key}[ \t]*,,")"
|
||||
echo "$(grep "^${key}[ \t]" "${bls}" | sed -e "s!^${key}[ \t]*!!")"
|
||||
}
|
||||
|
||||
set_bls_value() {
|
||||
@ -64,7 +68,8 @@ set_bls_value() {
|
||||
local key="$1" && shift
|
||||
local value="$1" && shift
|
||||
|
||||
sed -i -e "s,^${key}.*,${key} ${value}," "${bls}"
|
||||
value=$(echo $value | sed -e 's/\//\\\//g')
|
||||
sed -i -e "s/^${key}.*/${key} ${value}/" "${bls}"
|
||||
}
|
||||
|
||||
append_bls_value() {
|
||||
@ -72,20 +77,32 @@ append_bls_value() {
|
||||
local key="$1" && shift
|
||||
local value="$1" && shift
|
||||
|
||||
old_value="$(get_bls_value ${bls} ${key})"
|
||||
old_value="$(get_bls_value "${bls}" ${key})"
|
||||
set_bls_value "${bls}" "${key}" "${old_value}${value}"
|
||||
}
|
||||
|
||||
get_bls_values() {
|
||||
count=0
|
||||
for bls in $(ls -vr ${blsdir}/*.conf 2> /dev/null); do
|
||||
bls_file[$count]="${bls}"
|
||||
bls_title[$count]="$(get_bls_value ${bls} title)"
|
||||
bls_version[$count]="$(get_bls_value ${bls} version)"
|
||||
bls_linux[$count]="$(get_bls_value ${bls} linux)"
|
||||
bls_initrd[$count]="$(get_bls_value ${bls} initrd)"
|
||||
bls_options[$count]="$(get_bls_value ${bls} options)"
|
||||
bls_id[$count]="$(get_bls_value ${bls} id)"
|
||||
local -a files
|
||||
local IFS=$'\n'
|
||||
files=($(for bls in ${blsdir}/*.conf ; do
|
||||
if ! [[ -e "${bls}" ]] ; then
|
||||
continue
|
||||
fi
|
||||
bls="${bls%.conf}"
|
||||
bls="${bls##*/}"
|
||||
echo "${bls}"
|
||||
done | /usr/libexec/grubby/rpm-sort -c rpmnvrcmp 2>/dev/null | tac)) || :
|
||||
|
||||
for bls in "${files[@]}" ; do
|
||||
blspath="${blsdir}/${bls}.conf"
|
||||
bls_file[$count]="${blspath}"
|
||||
bls_title[$count]="$(get_bls_value ${blspath} title)"
|
||||
bls_version[$count]="$(get_bls_value ${blspath} version)"
|
||||
bls_linux[$count]="$(get_bls_value ${blspath} linux)"
|
||||
bls_initrd[$count]="$(get_bls_value ${blspath} initrd)"
|
||||
bls_options[$count]="$(get_bls_value ${blspath} options)"
|
||||
bls_id[$count]="${bls}"
|
||||
|
||||
count=$((count+1))
|
||||
done
|
||||
@ -108,16 +125,13 @@ get_default_index() {
|
||||
index="$default"
|
||||
fi
|
||||
|
||||
# GRUB2 and zipl use different fields to set the default entry
|
||||
if [[ $bootloader = "grub2" ]]; then
|
||||
title="$default"
|
||||
else
|
||||
version="$default"
|
||||
fi
|
||||
|
||||
for i in ${!bls_file[@]}; do
|
||||
if [[ $title = ${bls_title[$i]} || $version = ${bls_version[$i]} ||
|
||||
$i -eq $index ]]; then
|
||||
if [[ $i -eq $index ]]; then
|
||||
echo $i
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $default = ${bls_id[$i]} || $default = ${bls_title[$i]} ]]; then
|
||||
echo $i
|
||||
return
|
||||
fi
|
||||
@ -125,9 +139,11 @@ get_default_index() {
|
||||
}
|
||||
|
||||
display_default_value() {
|
||||
local prefix=$(get_prefix)
|
||||
|
||||
case "$display_default" in
|
||||
kernel)
|
||||
echo "${bls_linux[$default_index]}"
|
||||
echo "${prefix}${bls_linux[$default_index]}"
|
||||
exit 0
|
||||
;;
|
||||
index)
|
||||
@ -159,7 +175,7 @@ param_to_indexes() {
|
||||
fi
|
||||
|
||||
for i in ${!bls_file[@]}; do
|
||||
if [[ $param = "${bls_linux[$i]}" ]]; then
|
||||
if [[ $param = "${bls_linux[$i]}" || "/${param##*/}" = "${bls_linux[$i]}" ]]; then
|
||||
indexes="$indexes $i"
|
||||
fi
|
||||
|
||||
@ -180,15 +196,89 @@ param_to_indexes() {
|
||||
echo -n "-1"
|
||||
}
|
||||
|
||||
get_prefix() {
|
||||
if [[ $bootloader = grub2 ]] && mountpoint -q /boot; then
|
||||
echo "/boot"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
expand_var() {
|
||||
local var=$1
|
||||
|
||||
if [[ $bootloader == "grub2" ]]; then
|
||||
local value="$(grub2-editenv "${env}" list | grep ${var##$} | sed -e "s/${var##$}=//")"
|
||||
value="$(echo ${value} | sed -e 's/\//\\\//g')"
|
||||
if [[ -n $value ]]; then
|
||||
var="$value"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $var
|
||||
}
|
||||
|
||||
has_kernelopts()
|
||||
{
|
||||
local args=${bls_options[$1]}
|
||||
local opts=(${args})
|
||||
|
||||
for opt in ${opts[*]}; do
|
||||
[[ $opt = "\$kernelopts" ]] && echo "true"
|
||||
done
|
||||
|
||||
echo "false"
|
||||
}
|
||||
|
||||
get_bls_args() {
|
||||
local args=${bls_options[$1]}
|
||||
local opts=(${args})
|
||||
|
||||
for opt in ${opts[*]}; do
|
||||
if [[ $opt =~ ^\$ ]]; then
|
||||
value="$(expand_var $opt)"
|
||||
args="$(echo ${args} | sed -e "s/${opt}/${value}/")"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${args}
|
||||
}
|
||||
|
||||
display_info_values() {
|
||||
local indexes=($(param_to_indexes "$1"))
|
||||
local prefix=$(get_prefix)
|
||||
|
||||
if [[ $indexes = "-1" ]]; then
|
||||
print_error "The param $1 is incorrect"
|
||||
fi
|
||||
|
||||
for i in ${indexes[*]}; do
|
||||
local root=""
|
||||
local value=""
|
||||
local args="$(get_bls_args "$i")"
|
||||
|
||||
local opts=(${args})
|
||||
|
||||
for opt in ${opts[*]}; do
|
||||
if echo $opt | grep -q "^root="; then
|
||||
root="$(echo $opt | sed -e 's/root=//')"
|
||||
value="$(echo ${opt} | sed -e 's/\//\\\//g')"
|
||||
args="$(echo ${args} | sed -e "s/${value}[ \t]*//")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "index=$i"
|
||||
echo "kernel=${bls_linux[$i]}"
|
||||
echo "args=\"${bls_options[$i]}\""
|
||||
echo "initrd=${bls_initrd[$i]}"
|
||||
echo "title=${bls_title[$i]}"
|
||||
echo "kernel=\"${prefix}${bls_linux[$i]}\""
|
||||
echo "args=\"${args}\""
|
||||
|
||||
if [[ -n $root ]]; then
|
||||
echo "root=\"${root}\""
|
||||
fi
|
||||
|
||||
echo "initrd=\"${prefix}${bls_initrd[$i]}\""
|
||||
echo "title=\"${bls_title[$i]}\""
|
||||
echo "id=\"${bls_id[$i]}\""
|
||||
done
|
||||
exit 0
|
||||
}
|
||||
@ -200,6 +290,11 @@ mkbls() {
|
||||
|
||||
local debugname=""
|
||||
local flavor=""
|
||||
local prefix=""
|
||||
|
||||
if [[ $(get_prefix) = "" ]]; then
|
||||
prefix="/boot"
|
||||
fi
|
||||
|
||||
if [[ $kernelver == *\+* ]] ; then
|
||||
local flavor=-"${kernelver##*+}"
|
||||
@ -213,7 +308,7 @@ mkbls() {
|
||||
title ${NAME} (${kernelver}) ${VERSION}${debugname}
|
||||
version ${kernelver}${debugid}
|
||||
linux ${kernel}
|
||||
initrd /initramfs-${kernelver}.img
|
||||
initrd ${prefix}/initramfs-${kernelver}.img
|
||||
options \$kernelopts
|
||||
id ${ID}-${datetime}-${kernelver}${debugid}
|
||||
grub_users \$grub_users
|
||||
@ -222,18 +317,61 @@ grub_class kernel${flavor}
|
||||
EOF
|
||||
}
|
||||
|
||||
unset_default_bls()
|
||||
{
|
||||
if [[ $bootloader = grub2 ]]; then
|
||||
grub2-editenv "${env}" unset saved_entry
|
||||
else
|
||||
sed -i -e "/^default=.*/d" "${zipl_config}"
|
||||
fi
|
||||
}
|
||||
|
||||
remove_bls_fragment() {
|
||||
local indexes=($(param_to_indexes "$1"))
|
||||
|
||||
if [[ $indexes = "-1" ]]; then
|
||||
print_error "The param $1 is incorrect"
|
||||
print_error "The param $(get_prefix)$1 is incorrect"
|
||||
fi
|
||||
|
||||
for i in ${indexes[*]}; do
|
||||
for i in "${indexes[@]}"; do
|
||||
if [[ $default_index = $i ]]; then
|
||||
unset_default_bls
|
||||
fi
|
||||
rm -f "${bls_file[$i]}"
|
||||
done
|
||||
|
||||
get_bls_values
|
||||
|
||||
update_grubcfg
|
||||
}
|
||||
|
||||
get_custom_bls_filename() {
|
||||
local kernelver=$1
|
||||
local bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
|
||||
count=0
|
||||
local -a files
|
||||
local IFS=$'\n'
|
||||
|
||||
prefix="${bls_target%%.conf}"
|
||||
prefix="${bls_target%%${arch}}"
|
||||
prefix="${prefix%.*}"
|
||||
|
||||
last=($(for bls in ${prefix}.*~custom*.conf ; do
|
||||
if ! [[ -e "${bls}" ]] ; then
|
||||
continue
|
||||
fi
|
||||
bls="${bls##${prefix}.}"
|
||||
bls="${bls%%~custom*}"
|
||||
echo "${bls}"
|
||||
done | tail -n1)) || :
|
||||
|
||||
if [[ -z $last ]]; then
|
||||
last="0"
|
||||
else
|
||||
last=$((last+1))
|
||||
fi
|
||||
|
||||
echo "${bls_target}" | sed -e "s!${prefix}!${prefix}.${last}~custom!"
|
||||
}
|
||||
|
||||
add_bls_fragment() {
|
||||
@ -245,11 +383,12 @@ add_bls_fragment() {
|
||||
|
||||
if [[ $kernel = *"vmlinuz-"* ]]; then
|
||||
kernelver="${kernel##*/vmlinuz-}"
|
||||
prefix="vmlinuz-"
|
||||
else
|
||||
kernelver="${kernel##*/}"
|
||||
fi
|
||||
|
||||
if [[ ! -d "/lib/modules/${kernelver}" || ! -f "/boot/vmlinuz-${kernelver}" ]] &&
|
||||
if [[ ! -f "/boot/${prefix}${kernelver}" ]] &&
|
||||
[[ $bad_image != "true" ]]; then
|
||||
print_error "The ${kernelver} kernel isn't installed in the machine"
|
||||
fi
|
||||
@ -263,18 +402,20 @@ add_bls_fragment() {
|
||||
fi
|
||||
|
||||
bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
|
||||
kernel_dir="/lib/modules/${kernelver}"
|
||||
if [[ -f "${kernel_dir}/bls.conf" ]]; then
|
||||
cp -aT "${kernel_dir}/bls.conf" "${bls_target}" || exit $?
|
||||
else
|
||||
if [[ -d $kernel_dir ]]; then
|
||||
datetime="$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")"
|
||||
else
|
||||
datetime=0
|
||||
fi
|
||||
mkbls "${kernel}" "${kernelver}" "${datetime}" > "${bls_target}"
|
||||
|
||||
if [[ -e ${bls_target} ]]; then
|
||||
bls_target="$(get_custom_bls_filename "${kernelver}")"
|
||||
print_info "An entry for kernel ${kernelver} already exists, adding ${bls_target}"
|
||||
fi
|
||||
|
||||
kernel_dir="/lib/modules/${kernelver}"
|
||||
if [[ -d $kernel_dir ]]; then
|
||||
datetime="$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")"
|
||||
else
|
||||
datetime=0
|
||||
fi
|
||||
mkbls "${kernel}" "${kernelver}" "${datetime}" > "${bls_target}"
|
||||
|
||||
if [[ -n $title ]]; then
|
||||
set_bls_value "${bls_target}" "title" "${title}"
|
||||
fi
|
||||
@ -292,13 +433,12 @@ add_bls_fragment() {
|
||||
fi
|
||||
|
||||
if [[ $MAKEDEBUG = "yes" ]]; then
|
||||
arch="$(uname -m)"
|
||||
bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")"
|
||||
bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")"
|
||||
cp -aT "${bls_target}" "${bls_debug}"
|
||||
append_bls_value "${bls_debug}" "title" "${LINUX_DEBUG_TITLE_POSTFIX}"
|
||||
append_bls_value "${bls_debug}" "version" "${LINUX_DEBUG_VERSION_POSTFIX}"
|
||||
append_bls_value "${bls_debug}" "options" "${CMDLINE_LINUX_DEBUG}"
|
||||
blsid="$(get_bls_value ${bls_debug} "id" | sed -e "s/\.${arch}/-debug.${arch}/")"
|
||||
blsid="$(get_bls_value ${bls_debug} "id" | sed -e "s/${kernelver}/${kernelver}~debug/")"
|
||||
set_bls_value "${bls_debug}" "id" "${blsid}"
|
||||
fi
|
||||
|
||||
@ -308,6 +448,8 @@ add_bls_fragment() {
|
||||
set_default_bls "TITLE=${title}"
|
||||
fi
|
||||
|
||||
update_grubcfg
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
@ -317,55 +459,89 @@ update_args() {
|
||||
local add_args=($1) && shift
|
||||
|
||||
for arg in ${remove_args[*]}; do
|
||||
args="$(echo $args | sed -e "s,$arg[^ ]*,,")"
|
||||
arg="$(echo $arg | sed -e 's/\//\\\//g')"
|
||||
if [[ $arg = *"="* ]]; then
|
||||
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg([[:space:]]|$)/ /")"
|
||||
else
|
||||
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")"
|
||||
fi
|
||||
done
|
||||
|
||||
for arg in ${add_args[*]}; do
|
||||
if [[ $arg = *"="* ]]; then
|
||||
value=${arg##*=}
|
||||
key=${arg%%=$value}
|
||||
exist=$(echo $args | grep "${key}=")
|
||||
if [[ -n $exist ]]; then
|
||||
args="$(echo $args | sed -e "s,$key=[^ ]*,$key=$value,")"
|
||||
else
|
||||
args="$args $key=$value"
|
||||
fi
|
||||
else
|
||||
exist=$(echo $args | grep $arg)
|
||||
if ! [[ -n $exist ]]; then
|
||||
args="$args $arg"
|
||||
fi
|
||||
fi
|
||||
arg="${arg%%=*}"
|
||||
arg="$(echo $arg | sed -e 's/\//\\\//g')"
|
||||
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")"
|
||||
done
|
||||
|
||||
for arg in ${add_args[*]}; do
|
||||
args="$args $arg"
|
||||
done
|
||||
|
||||
echo ${args}
|
||||
}
|
||||
|
||||
update_bls_fragment() {
|
||||
local param="$1"
|
||||
local indexes=($(param_to_indexes "$1")) && shift
|
||||
local remove_args=$1 && shift
|
||||
local add_args=$1 && shift
|
||||
local initrd=$1 && shift
|
||||
local opts
|
||||
|
||||
if [[ $indexes = "-1" ]]; then
|
||||
print_error "The param $(get_prefix)${param} is incorrect"
|
||||
fi
|
||||
|
||||
if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then
|
||||
local old_args=""
|
||||
|
||||
if [[ -z $no_etc_update ]] && [[ -e ${grub_etc_default} ]]; then
|
||||
old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})"
|
||||
if [[ -n $old_args ]]; then
|
||||
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
|
||||
opts="$(echo "$opts" | sed -e 's/\//\\\//g')"
|
||||
sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}"
|
||||
fi
|
||||
fi
|
||||
|
||||
old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
|
||||
if [[ -n $old_args ]]; then
|
||||
opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
|
||||
grub2-editenv "${env}" set kernelopts="${opts}"
|
||||
fi
|
||||
elif [[ $bootloader = grub2 ]]; then
|
||||
opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")"
|
||||
fi
|
||||
|
||||
for i in ${indexes[*]}; do
|
||||
if [[ -n $remove_args || -n $add_args ]]; then
|
||||
local new_args="$(update_args "${bls_options[$i]}" "${remove_args}" "${add_args}")"
|
||||
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
|
||||
local old_args="$(get_bls_args "$i")"
|
||||
local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
|
||||
|
||||
if [[ $param != "ALL" || "$(has_kernelopts "$i")" = "false" ]]; then
|
||||
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n $initrd ]]; then
|
||||
set_bls_value "${bls_file[$i]}" "initrd" "${initrd}"
|
||||
fi
|
||||
done
|
||||
|
||||
update_grubcfg
|
||||
}
|
||||
|
||||
set_default_bls() {
|
||||
local index=($(param_to_indexes "$1"))
|
||||
|
||||
if [[ $index = "-1" ]]; then
|
||||
print_error "The param $1 is incorrect"
|
||||
fi
|
||||
|
||||
if [[ $bootloader = grub2 ]]; then
|
||||
grub2-editenv "${env}" set saved_entry="${bls_title[$index]}"
|
||||
grub2-editenv "${env}" set saved_entry="${bls_id[$index]}"
|
||||
else
|
||||
local default="${bls_version[$index]}"
|
||||
local default="${bls_title[$index]}"
|
||||
local current="$(grep '^default=' ${zipl_config} | sed -e 's/^default=//')"
|
||||
if [[ -n $current ]]; then
|
||||
sed -i -e "s,^default=.*,default=${default}," "${zipl_config}"
|
||||
@ -373,27 +549,40 @@ set_default_bls() {
|
||||
echo "default=${default}" >> "${zipl_config}"
|
||||
fi
|
||||
fi
|
||||
|
||||
print_info "The default is ${bls_file[$index]} with index $index and kernel $(get_prefix)${bls_linux[$index]}"
|
||||
}
|
||||
|
||||
remove_var_prefix() {
|
||||
local prefix="$1"
|
||||
|
||||
[ -z "${prefix}" ] && return
|
||||
|
||||
if [[ -n $remove_kernel && $remove_kernel =~ ^/ ]]; then
|
||||
remove_kernel="/${remove_kernel##*/}"
|
||||
remove_kernel="/${remove_kernel##${prefix}/}"
|
||||
fi
|
||||
|
||||
if [[ -n $initrd ]]; then
|
||||
initrd="/${initrd##*/}"
|
||||
initrd="/${initrd##${prefix}/}"
|
||||
fi
|
||||
|
||||
if [[ -n $extra_initrd ]]; then
|
||||
extra_initrd=" /${extra_initrd##*/}"
|
||||
extra_initrd=" /${extra_initrd##${prefix}/}"
|
||||
fi
|
||||
|
||||
if [[ -n $kernel ]]; then
|
||||
kernel="/${kernel##*/}"
|
||||
kernel="/${kernel##${prefix}/}"
|
||||
fi
|
||||
|
||||
if [[ -n $update_kernel && $update_kernel =~ ^/ ]]; then
|
||||
update_kernel="/${update_kernel##*/}"
|
||||
update_kernel="/${update_kernel##${prefix}/}"
|
||||
fi
|
||||
}
|
||||
|
||||
update_grubcfg()
|
||||
{
|
||||
if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then
|
||||
grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@ -416,7 +605,6 @@ Usage: grubby [OPTION...]
|
||||
--initrd=initrd-path initrd image for the new kernel
|
||||
-i, --extra-initrd=initrd-path auxiliary initrd image for things other than the new kernel
|
||||
--make-default make the newly added entry the default boot entry
|
||||
-o, --output-file=path path to output updated config file ("-" for stdout)
|
||||
--remove-args=STRING remove kernel arguments
|
||||
--remove-kernel=kernel-path remove all entries for the specified kernel
|
||||
--set-default=kernel-path make the first entry referencing the specified kernel the default
|
||||
@ -425,6 +613,7 @@ Usage: grubby [OPTION...]
|
||||
--update-kernel=kernel-path updated information for the specified kernel
|
||||
--zipl configure zipl bootloader
|
||||
-b, --bls-directory path to directory containing the BootLoaderSpec fragment files
|
||||
--no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub
|
||||
|
||||
Help options:
|
||||
-?, --help Show this help message
|
||||
@ -432,11 +621,11 @@ Help options:
|
||||
EOF
|
||||
}
|
||||
|
||||
OPTS="$(getopt -o c:i:o:b:? --long help,add-kernel:,args:,bad-image-okay,\
|
||||
OPTS="$(getopt -o c:i:b:? --long help,add-kernel:,args:,bad-image-okay,\
|
||||
config-file:,copy-default,default-kernel,default-index,default-title,env:,\
|
||||
grub2,info:,initrd:,extra-initrd:,make-default,output-file:,remove-args:,\
|
||||
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\
|
||||
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\
|
||||
bls-directory:,add-kernel:,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\
|
||||
bls-directory:,no-etc-grub-update,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\
|
||||
bootloader-probe,debug,devtree,devtreedir:,elilo,efi,extlinux,grub,lilo,\
|
||||
output-file:,remove-mbargs:,remove-multiboot:,silo,yaboot -n ${SCRIPTNAME} -- "$@")"
|
||||
|
||||
@ -462,6 +651,7 @@ while [ ${#} -gt 0 ]; do
|
||||
bad_image=true
|
||||
;;
|
||||
--config-file|-c)
|
||||
grub_config="${2}"
|
||||
zipl_config="${2}"
|
||||
shift
|
||||
;;
|
||||
@ -499,10 +689,6 @@ while [ ${#} -gt 0 ]; do
|
||||
--make-default)
|
||||
make_default=true
|
||||
;;
|
||||
--output-file|-o)
|
||||
output_file="${2}"
|
||||
shift
|
||||
;;
|
||||
--remove-args)
|
||||
remove_args="${2}"
|
||||
shift
|
||||
@ -534,7 +720,11 @@ while [ ${#} -gt 0 ]; do
|
||||
blsdir="${2}"
|
||||
shift
|
||||
;;
|
||||
--add-kernel|--add-multiboot|--mbargs|--mounts|--boot-filesystem|\
|
||||
--no-etc-grub-update)
|
||||
no_etc_update=true
|
||||
shift
|
||||
;;
|
||||
--add-multiboot|--mbargs|--mounts|--boot-filesystem|\
|
||||
--bootloader-probe|--debug|--devtree|--devtreedir|--elilo|--efi|\
|
||||
--extlinux|--grub|--lilo|--output-file|--remove-mbargs|--silo|\
|
||||
--remove-multiboot|--slilo|--yaboot)
|
||||
@ -559,6 +749,10 @@ while [ ${#} -gt 0 ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $update_kernel && -z $kernel ]] && [[ -n $args || -n $remove_args ]]; then
|
||||
print_error "no action specified"
|
||||
fi
|
||||
|
||||
if [[ -z $blsdir ]]; then
|
||||
blsdir="/boot/loader/entries"
|
||||
fi
|
||||
@ -571,6 +765,14 @@ if [[ -z $zipl_config ]]; then
|
||||
zipl_config="/etc/zipl.conf"
|
||||
fi
|
||||
|
||||
if [[ -z $grub_config ]]; then
|
||||
grub_config="/boot/grub2/grub.cfg"
|
||||
fi
|
||||
|
||||
if [[ -z $grub_etc_default ]]; then
|
||||
grub_etc_default="/etc/default/grub"
|
||||
fi
|
||||
|
||||
get_bls_values
|
||||
|
||||
default_index="$(get_default_index)"
|
||||
@ -583,9 +785,7 @@ if [[ -n $display_info ]]; then
|
||||
display_info_values "${display_info}"
|
||||
fi
|
||||
|
||||
if [[ $bootloader = grub2 ]]; then
|
||||
remove_var_prefix
|
||||
fi
|
||||
remove_var_prefix "$(get_prefix)"
|
||||
|
||||
if [[ -n $kernel ]]; then
|
||||
if [[ $copy_default = "true" ]]; then
|
||||
|
179
grubby.8
Normal file
179
grubby.8
Normal file
@ -0,0 +1,179 @@
|
||||
.TH GRUBBY 8 "Wed Apr 29 2020"
|
||||
.SH NAME
|
||||
grubby \- command line tool for configuring grub and zipl
|
||||
|
||||
.SH SYNOPSIS
|
||||
\fBgrubby\fR [--add-kernel=\fIkernel-path\fR] [--args=\fIargs\fR]
|
||||
[--bad-image-okay] [--config-file=\fIpath\fR] [--copy-default]
|
||||
[--default-kernel] [--default-index] [--default-title]
|
||||
[--env=\fIpath\fR] [--grub2] [--info=\fIkernel-path\fR]
|
||||
[--initrd=\fIinitrd-path\fR] [--extra-initrd=\fIinitrd-path\fR]
|
||||
[--make-default] [--remove-args=\fIargs\fR]
|
||||
[--remove-kernel=\fIkernel-path\fR] [--set-default=\fIkernel-path\fR]
|
||||
[--set-default-index=\fientry-index\fR] [--title=\fentry-title\fR]
|
||||
[--update-kernel=\fIkernel-path\fR] [--zipl] [--bls-directory=\fIpath\fR]
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fBgrubby\fR is a command line tool for updating and displaying information
|
||||
about the configuration files for the \fBgrub2\fR and \fBzipl\fR boot loaders.
|
||||
It is primarily designed to be used from scripts which install new kernels and
|
||||
need to find information about the current boot environment.
|
||||
|
||||
On BIOS-based Intel x86 platforms, \fBgrub2\fR is the default bootloader and
|
||||
the configuration file is in \fB/boot/grub2/grub.cfg\fR. On UEFI-based Intel
|
||||
x86 platforms, \fBgrub2\fR is the default bootloader, and the configuration
|
||||
file is in \fB/boot/efi/EFI/redhat/grub.cfg\fR. On PowerPC platforms, systems
|
||||
based on Power8 and Power9 support \fBgrub2\fR as a bootloader and use a
|
||||
configuration stored in \fB/boot/grub2/grub.cfg\fR. On s390x platforms the
|
||||
\fBzipl\fR bootloader use a default configuration in \fB/etc/zipl.conf\fR.
|
||||
|
||||
All bootloaders define the boot entries as individual configuration fragments
|
||||
that are stored by default in \fB/boot/loader/entries\fR. The format for the
|
||||
config files is specified at \fBhttps://systemd.io/BOOT_LOADER_SPECIFICATION\fR.
|
||||
The \fBgrubby\fR tool is used to update and display the configuration defined
|
||||
in the BootLoaderSpec fragment files.
|
||||
|
||||
There are a number of ways to specify the kernel used for \fB-\-info\fR,
|
||||
\fB-\-remove-kernel\fR, and \fB-\-update-kernel\fR. Specificying \fBDEFAULT\fR
|
||||
or \fBALL\fR selects the default entry and all of the entries, respectively.
|
||||
Also, the title of a boot entry may be specified by using \fBTITLE=\fItitle\fR
|
||||
as the argument; all entries with that title are used.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB-\-add-kernel\fR=\fIkernel-path\fR
|
||||
Add a new boot entry for the kernel located at \fIkernel-path\fR.
|
||||
|
||||
.TP
|
||||
\fB-\-args\fR=\fIkernel-args\fR
|
||||
When a new kernel is added, this specifies the command line arguments
|
||||
which should be passed to the kernel by default (note they are merged
|
||||
with the arguments of the default entry if \fB-\-copy-default\fR is used).
|
||||
When \fB-\-update-kernel\fR is used, this specifies new arguments to add
|
||||
to the argument list. Multiple, space separated arguments may be used. If
|
||||
an argument already exists the new value replaces the old values. The
|
||||
\fBroot=\fR kernel argument gets special handling if the configuration
|
||||
file has special handling for specifying the root filesystem.
|
||||
|
||||
.TP
|
||||
\fB-\-bad-image-okay\fR
|
||||
When \fBgrubby\fR is looking for an entry to use for something (such
|
||||
as a default boot entry) it uses sanity checks, such as ensuring that
|
||||
the kernel exists in the filesystem, to make sure entries that obviously
|
||||
won't work aren't selected. This option overrides that behavior, and is
|
||||
designed primarily for testing.
|
||||
|
||||
.TP
|
||||
\fB-\-config-file\fR=\fIpath\fR
|
||||
Use \fIpath\fR as the configuration file rather then the default.
|
||||
|
||||
.TP
|
||||
\fB-\-copy-default\fR
|
||||
\fBgrubby\fR will copy as much information (such as kernel arguments and
|
||||
root device) as possible from the current default kernel. The kernel path
|
||||
and initrd path will never be copied.
|
||||
|
||||
.TP
|
||||
\fB-\-default-kernel\fR
|
||||
Display the full path to the current default kernel and exit.
|
||||
|
||||
.TP
|
||||
\fB-\-default-index\fR
|
||||
Display the numeric index of the current default boot entry and exit.
|
||||
|
||||
.TP
|
||||
\fB-\-default-title\fR
|
||||
Display the title of the current default boot entry and exit.
|
||||
|
||||
.TP
|
||||
\fB-\-env\fR=\fIpath\fR
|
||||
Use \fIpath\fR as the grub2 environment block file rather then the default path.
|
||||
|
||||
.TP
|
||||
\fB-\-grub2\fR
|
||||
Configure \fBgrub2\fR bootloader.
|
||||
|
||||
.TP
|
||||
\fB-\-info\fR=\fIkernel-path\fR
|
||||
Display information on all boot entries which match \fIkernel-path\fR. If
|
||||
\fIkernel-path\fR is \fBDEFAULT\fR, then information on the default kernel
|
||||
is displayed. If \fIkernel-path\fR is \fBALL\fR, then information on all boot
|
||||
entries are displayed.
|
||||
|
||||
.TP
|
||||
\fB-\-initrd\fR=\fIinitrd-path\fR
|
||||
Use \fIinitrd-path\fR as the path to an initial ram disk for a new kernel
|
||||
being added.
|
||||
|
||||
.TP
|
||||
\fB-\-extrainitrd\fR=\fIinitrd-path\fR
|
||||
Use \fIinitrd-path\fR as the path to an auxiliary init ram disk image to be
|
||||
added to the boot entry.
|
||||
|
||||
.TP
|
||||
\fB-\-make-default\fR
|
||||
Make the new kernel entry being added the default entry.
|
||||
|
||||
.TP
|
||||
\fB-\-remove-args\fR=\fIkernel-args\fR
|
||||
The arguments specified by \fIkernel-args\fR are removed from the kernels
|
||||
specified by \fB-\-update-kernel\fR. The \fBroot\fR argument gets special
|
||||
handling for configuration files that support separate root filesystem
|
||||
configuration.
|
||||
|
||||
.TP
|
||||
\fB-\-remove-kernel\fR=\fIkernel-path\fR
|
||||
Removes all boot entries which match \fIkernel-path\fR. This may be used
|
||||
along with -\-add-kernel, in which case the new kernel being added will
|
||||
never be removed.
|
||||
|
||||
.TP
|
||||
\fB-\-set-default\fR=\fIkernel-path\fR
|
||||
The first entry which boots the specified kernel is made the default
|
||||
boot entry.
|
||||
|
||||
.TP
|
||||
\fB-\-set-default-index\fR=\fIentry-index\fR
|
||||
Makes the given entry number the default boot entry.
|
||||
|
||||
.TP
|
||||
\fB-\-title\fR=\fIentry-title\fR
|
||||
When a new kernel entry is added \fIentry-title\fR is used as the title
|
||||
for the entry.
|
||||
|
||||
.TP
|
||||
\fB-\-update-kernel\fR=\fIkernel-path\fR
|
||||
The entries for kernels matching \fRkernel-path\fR are updated. Currently
|
||||
the only items that can be updated is the kernel argument list, which is
|
||||
modified via the \fB-\-args\fR and \fB-\-remove-args\fR options. If the
|
||||
\fBALL\fR argument is used the variable \fB GRUB_CMDLINE_LINUX\fR in
|
||||
\fB/etc/default/grub\fR is updated with the latest kernel argument list,
|
||||
unless the \fB-\-no-etc-grub-update\fR option is used.
|
||||
|
||||
.TP
|
||||
\fB-\-zipl\fR
|
||||
Configure \fBzipl\fR bootloader.
|
||||
|
||||
.TP
|
||||
\fB-\-bls-directory\fR=\fIpath\fR
|
||||
Use \fIpath\fR as the directory for the BootLoaderSpec config files rather
|
||||
than the default \fB/boot/loader/entries\fR.
|
||||
|
||||
.TP
|
||||
\fB-\-no-etc-grub-update\fR
|
||||
Makes grubby to not update the \fBGRUB_CMDLINE_LINUX\fR variable in
|
||||
\fB/etc/default/grub\fR when the \fB-\-update-kernel\fR option is
|
||||
used with the \fBALL\fR argument.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR zipl (8),
|
||||
.BR mkinitrd (8),
|
||||
.BR kernel-install (8)
|
||||
|
||||
.SH AUTHORS
|
||||
.nf
|
||||
Erik Troan
|
||||
Jeremy Katz
|
||||
Peter Jones
|
||||
Javier Martinez
|
||||
.fi
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
if [[ -x @@LIBEXECDIR@@/grubby-bls ]] ; then
|
||||
exec @@LIBEXECDIR@@/grubby-bls "${@}"
|
||||
elif [[ -x @@LIBEXECDIR@@/grubby ]] ; then
|
||||
if [[ -x @@LIBEXECDIR@@/grubby ]] ; then
|
||||
exec @@LIBEXECDIR@@/grubby "${@}"
|
||||
elif [[ -x @@LIBEXECDIR@@/grubby-bls ]] ; then
|
||||
exec @@LIBEXECDIR@@/grubby-bls "${@}"
|
||||
fi
|
||||
echo "Grubby is not installed correctly." >>/dev/stderr
|
||||
exit 1
|
||||
|
258
grubby.spec
258
grubby.spec
@ -1,6 +1,6 @@
|
||||
Name: grubby
|
||||
Version: 8.40
|
||||
Release: 18%{?dist}
|
||||
Release: 45%{?dist}
|
||||
Summary: Command line tool for updating bootloader configs
|
||||
License: GPLv2+
|
||||
URL: https://github.com/rhinstaller/grubby
|
||||
@ -12,19 +12,28 @@ Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz
|
||||
Source1: grubby-bls
|
||||
Source2: grubby.in
|
||||
Source3: installkernel.in
|
||||
Patch1: drop-uboot-uImage-creation.patch
|
||||
Patch2: 0001-Change-return-type-in-getRootSpecifier.patch
|
||||
Patch3: 0002-Add-btrfs-subvolume-support-for-grub2.patch
|
||||
Patch4: 0003-Add-tests-for-btrfs-support.patch
|
||||
Patch5: 0004-Use-system-LDFLAGS.patch
|
||||
Patch6: 0004-Honor-sbindir.patch
|
||||
Patch7: 0005-installkernel-use-kernel-install.patch
|
||||
Source4: installkernel-bls
|
||||
Source5: 95-kernel-hooks.install
|
||||
Source6: grubby.8
|
||||
Patch0001: 0001-remove-the-old-crufty-u-boot-support.patch
|
||||
Patch0002: 0002-Change-return-type-in-getRootSpecifier.patch
|
||||
Patch0003: 0003-Add-btrfs-subvolume-support-for-grub2.patch
|
||||
Patch0004: 0004-Add-tests-for-btrfs-support.patch
|
||||
Patch0005: 0005-Use-system-LDFLAGS.patch
|
||||
Patch0006: 0006-Honor-sbindir.patch
|
||||
Patch0007: 0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch
|
||||
Patch0008: 0008-Add-usr-libexec-rpm-sort.patch
|
||||
Patch0009: 0009-Improve-man-page-for-info-option.patch
|
||||
Patch0010: 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch
|
||||
Patch0011: 0011-Fix-stringop-overflow-warning.patch
|
||||
Patch0012: 0012-Fix-maybe-uninitialized-warning.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: pkgconfig glib2-devel popt-devel
|
||||
BuildRequires: libblkid-devel git-core sed make
|
||||
# for make test / getopt:
|
||||
BuildRequires: util-linux-ng
|
||||
BuildRequires: rpm-devel
|
||||
%ifarch aarch64 i686 x86_64 %{power64}
|
||||
BuildRequires: grub2-tools-minimal
|
||||
Requires: grub2-tools-minimal
|
||||
@ -33,15 +42,15 @@ Requires: grub2-tools
|
||||
%ifarch s390 s390x
|
||||
Requires: s390utils-base
|
||||
%endif
|
||||
Requires: findutils
|
||||
Requires: util-linux
|
||||
|
||||
Obsoletes: %{name}-bls < %{version}-%{release}
|
||||
|
||||
%description
|
||||
grubby is a command line tool for updating and displaying information about
|
||||
the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc)
|
||||
and zipl (s390) boot loaders. It is primarily designed to be used from scripts
|
||||
which install new kernels and need to find information about the current boot
|
||||
environment.
|
||||
|
||||
%global debug_package %{nil}
|
||||
This package provides a grubby compatibility script that manages
|
||||
BootLoaderSpec files and is meant to only be used for legacy compatibility
|
||||
users with existing grubby users.
|
||||
|
||||
%prep
|
||||
%setup -q -n grubby-%{version}-1
|
||||
@ -56,7 +65,8 @@ git config --unset user.email
|
||||
git config --unset user.name
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags}
|
||||
%set_build_flags
|
||||
make %{?_smp_mflags} LDFLAGS="${LDFLAGS}"
|
||||
|
||||
%ifnarch aarch64 %{arm}
|
||||
%check
|
||||
@ -64,47 +74,225 @@ make test
|
||||
%endif
|
||||
|
||||
%install
|
||||
make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir}
|
||||
make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} libexecdir=%{_libexecdir}
|
||||
|
||||
mkdir -p %{buildroot}%{_libexecdir}/{grubby,installkernel}/ %{buildroot}%{_sbindir}/
|
||||
mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby
|
||||
mv -v %{buildroot}%{_sbindir}/installkernel %{buildroot}%{_libexecdir}/installkernel/installkernel
|
||||
cp -v %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/
|
||||
install -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/
|
||||
install -m 0755 %{SOURCE4} %{buildroot}%{_libexecdir}/installkernel/
|
||||
sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \
|
||||
> %{buildroot}%{_sbindir}/grubby
|
||||
sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \
|
||||
> %{buildroot}%{_sbindir}/installkernel
|
||||
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5}
|
||||
rm %{buildroot}%{_mandir}/man8/grubby.8*
|
||||
install -m 0644 %{SOURCE6} %{buildroot}%{_mandir}/man8/
|
||||
|
||||
%package bls
|
||||
Summary: Command line tool for updating BootLoaderSpec files
|
||||
Conflicts: %{name} <= 8.40-13
|
||||
BuildArch: noarch
|
||||
%post
|
||||
if [ "$1" = 2 ]; then
|
||||
arch=$(uname -m)
|
||||
[[ $arch == "s390x" ]] && \
|
||||
zipl-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || :
|
||||
fi
|
||||
|
||||
%description bls
|
||||
This package provides a grubby wrapper that manages BootLoaderSpec files and is
|
||||
meant to only be used for legacy compatibility users with existing grubby users.
|
||||
%package deprecated
|
||||
Summary: Legacy command line tool for updating bootloader configs
|
||||
Conflicts: %{name} <= 8.40-18
|
||||
|
||||
%description deprecated
|
||||
This package provides deprecated, legacy grubby. This is for temporary
|
||||
compatibility only.
|
||||
|
||||
grubby is a command line tool for updating and displaying information about
|
||||
the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc)
|
||||
and zipl (s390) boot loaders. It is primarily designed to be used from
|
||||
scripts which install new kernels and need to find information about the
|
||||
current boot environment.
|
||||
|
||||
%files
|
||||
%{!?_licensedir:%global license %%doc}
|
||||
%license COPYING
|
||||
%dir %{_libexecdir}/grubby
|
||||
%attr(0755,root,root) %{_libexecdir}/grubby/grubby
|
||||
%dir %{_libexecdir}/installkernel
|
||||
%attr(0755,root,root) %{_libexecdir}/grubby/grubby-bls
|
||||
%attr(0755,root,root) %{_libexecdir}/grubby/rpm-sort
|
||||
%attr(0755,root,root) %{_sbindir}/grubby
|
||||
%attr(0755,root,root) %{_libexecdir}/installkernel/installkernel-bls
|
||||
%attr(0755,root,root) %{_sbindir}/installkernel
|
||||
%attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install
|
||||
%{_mandir}/man8/[gi]*.8*
|
||||
|
||||
%files deprecated
|
||||
%{!?_licensedir:%global license %%doc}
|
||||
%license COPYING
|
||||
%dir %{_libexecdir}/grubby
|
||||
%dir %{_libexecdir}/installkernel
|
||||
%attr(0755,root,root) %{_libexecdir}/grubby/grubby
|
||||
%attr(0755,root,root) %{_libexecdir}/installkernel/installkernel
|
||||
%attr(0755,root,root) %{_sbindir}/grubby
|
||||
%attr(0755,root,root) %{_sbindir}/installkernel
|
||||
%attr(0755,root,root) %{_sbindir}/new-kernel-pkg
|
||||
%{_mandir}/man8/*.8*
|
||||
|
||||
%files bls
|
||||
%{!?_licensedir:%global license %%doc}
|
||||
%license COPYING
|
||||
%dir %{_libexecdir}/grubby
|
||||
%attr(0755,root,root) %{_libexecdir}/grubby/grubby-bls
|
||||
%attr(0755,root,root) %{_sbindir}/grubby
|
||||
%{_mandir}/man8/*.8*
|
||||
%{_mandir}/man8/*.8*
|
||||
|
||||
%changelog
|
||||
* Wed May 13 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-45
|
||||
- grubby-bls: don't replace options with kernelopts if values are the same
|
||||
|
||||
* Wed May 06 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-44
|
||||
- Fix installed man page file mode bits
|
||||
|
||||
* Tue May 05 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-43
|
||||
- grubby-bls: always escape the delimiter character used in sed commands
|
||||
- grubby-bls: add a --no-etc-grub-update option
|
||||
|
||||
* Wed Apr 29 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-42
|
||||
- grubby-bls: fix corner case when a kernel param value contains a '='
|
||||
- grubby-bls: update man page to match options in current wrapper script
|
||||
|
||||
* Mon Mar 30 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-41
|
||||
- Make grubby to also update GRUB_CMDLINE_LINUX in /etc/default/grub
|
||||
Related: rhbz#1287854
|
||||
|
||||
* Mon Feb 10 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-40
|
||||
- Fix FTBFS
|
||||
Resolves: rhbz#1799496
|
||||
- Fix wrong S-o-B tag in patch
|
||||
- Fix warning about using unversioned Obsoletes
|
||||
|
||||
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-39
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Fri Nov 29 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-38
|
||||
- grubby-bls: don't update grubenv when generating grub.cfg for ppc64le
|
||||
Related: rhbz#1726514
|
||||
|
||||
* Thu Nov 28 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-37
|
||||
- grubby-bls: don't print rpm-sort error messages
|
||||
Resolves: rhbz#1731924
|
||||
- grubby-bls: remove -o option and support -c for ppc64le grub config
|
||||
Resolves: rhbz#1758598
|
||||
- grubby-bls: fix logic to check if the kernelopts var is defined in a BLS
|
||||
Resolves: rhbz#1726514
|
||||
|
||||
* Tue Aug 06 2019 Yuval Turgeman <yturgema@redhat.com> - 8.40-36
|
||||
- grubby-bls: strip only /boot from paths
|
||||
|
||||
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-35
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Mon Jun 17 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-34
|
||||
- Add a kernel-install plugin to execute hook scripts in /etc/kernel/
|
||||
Resolves: rhbz#1696202
|
||||
|
||||
* Mon Jun 10 22:13:19 CET 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 8.40-33
|
||||
- Rebuild for RPM 4.15
|
||||
|
||||
* Mon Jun 10 15:42:02 CET 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 8.40-32
|
||||
- Rebuild for RPM 4.15
|
||||
|
||||
* Fri May 03 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-31
|
||||
- Use mountpoint command to check whether /boot is a mount point
|
||||
Resolves: rhbz#1706091
|
||||
|
||||
* Thu Mar 21 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-30
|
||||
- grubby-bls: fix --add-kernel not working when using the --args option
|
||||
Resolves: rhbz#1691004
|
||||
|
||||
* Mon Mar 11 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-29
|
||||
- Only switch to BLS config for s390x / zipl
|
||||
Related: rhbz#1652806
|
||||
|
||||
* Fri Mar 01 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-28
|
||||
- grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv
|
||||
|
||||
* Thu Feb 14 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-27
|
||||
- grubby-bls: error if args or remove-args is used without update-kernel
|
||||
|
||||
* Tue Feb 05 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-26
|
||||
- Fix GCC warnings about possible string truncations and buffer overflows
|
||||
- grubby-bls: unset default entry if is the one being removed
|
||||
- grubby-bls: show absolute path when printing error about incorrect param
|
||||
|
||||
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-25
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Mon Jan 14 2019 Javier Martinez Canillas <javierm@redhat.com> - 8.40-24
|
||||
- Correctly set LDFLAGS to include hardened flags (pjones)
|
||||
Related: rhbz#1654936
|
||||
- grubby-bls: expand all variables in options field when updating it
|
||||
Resolves: rhbz#1660700
|
||||
|
||||
* Tue Dec 11 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-23
|
||||
- grubby-bls: lookup default entry by either id or title on grub2
|
||||
Related: rhbz#1654936
|
||||
|
||||
* Fri Nov 30 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-22
|
||||
- grubby-bls: also print the absolute path in the --default-kernel option
|
||||
Resolves: rhbz#1649778
|
||||
- grubby-bls: allow to specify the same kernel param multiple times
|
||||
Resolves: rhbz#1652486
|
||||
- grubby-bls: expand kernel options if these are environment variables
|
||||
Resolves: rhbz#1649785
|
||||
- grubby-bls: always generate the BLS snippets when adding new entries
|
||||
Resolves: rhbz#1653365
|
||||
- Improve man page for --info option (jstodola)
|
||||
Resolves: rhbz#1651672
|
||||
- Make the old grubby take precedence over grubby-bls if is installed
|
||||
Related: rhbz#165484
|
||||
|
||||
* Wed Nov 21 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-21
|
||||
- installkernel-bls: remove unnecessary check for GRUB_ENABLE_BLSCFG=true
|
||||
Resolves: rhbz#1647721
|
||||
- grubby-bls: use title field instead of version for zipl default entry
|
||||
Related: rhbz#1645200
|
||||
- grubby-bls: print the absolute kernel and initramfs images paths
|
||||
Resolves: rhbz#1649778
|
||||
- grubby-bls: make info print the root parameter if is present in cmdline
|
||||
Resolves: rhbz#1649791
|
||||
|
||||
* Tue Nov 13 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-20
|
||||
- Switch to a BLS configuration on %%post
|
||||
|
||||
* Tue Nov 06 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-19
|
||||
- Make the temporary config wrapper be what "grubby" contains, and put
|
||||
traditional grubby in grubby-deprecated (pjones)
|
||||
- Re-enable debuginfo generation (pjones)
|
||||
Related: rhbz#1619344
|
||||
- Install installkernel-bls here as well, not just in the grub2 package,
|
||||
since s390x doesn't have grubby packages (pjones)
|
||||
Related: rhbz#1619344
|
||||
- Make grubby-bls execute grub2-mkconfig on ppc64
|
||||
Resolves: rhbz#1636039
|
||||
- grubby-bls should only check if kernel exists and not if was installed
|
||||
Resolves: rhbz#1634740
|
||||
- Use ! instead of , as sed delimiter in grubby-bls script
|
||||
Resolves: rhbz#1634744
|
||||
- Print information about the entry set as default
|
||||
Resolves: rhbz#1636180
|
||||
- grubby-bls: make "id" be the filename, and include it in --info=ALL (pjones)
|
||||
Related: rhbz#1638103
|
||||
- grubby-bls: Make grubby-bls sort everything the same way grub2 does (pjones)
|
||||
Resolves: rhbz#1638103
|
||||
- grubby-bls: Consistently use the filename as the bls id
|
||||
Related: rhbz#1638103
|
||||
- grubby-bls: check if entry exists before attempting to print its info
|
||||
Resolves: rhbz#1634712
|
||||
- grubby-bls: make a copy of the cmdline if is modified for an entry
|
||||
Resolves: rhbz#1629054
|
||||
- grubby-bls: escape delimiter character before replacing the options field
|
||||
Resolves: rhbz#1640017
|
||||
- grubby-bls: grubby-bls: use id instead of title to get the default entry
|
||||
Resolves: rhbz#1638103
|
||||
- grubby-bls: use ~debug instead of -debug as suffix to sort correctly
|
||||
Related: rhbz#1638103
|
||||
- grubby-bls: allow to add many BLS entries for the same kernel image
|
||||
Resolves: rhbz#1634752
|
||||
- grubby-bls: fix --default-* options for s390x
|
||||
Resolves: rhbz#1644608
|
||||
- grubby-bls: only compare using relative paths if /boot is a mount point
|
||||
Resolves: rhbz#1642078
|
||||
|
||||
* Fri Aug 10 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-18
|
||||
- Make installkernel to use kernel-install scripts on BLS configuration
|
||||
|
||||
|
83
installkernel-bls
Executable file
83
installkernel-bls
Executable file
@ -0,0 +1,83 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# /sbin/installkernel
|
||||
#
|
||||
# Copyright 2007-2008 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Author(s): tyson@rwii.com
|
||||
#
|
||||
|
||||
usage() {
|
||||
echo "Usage: `basename $0` <kernel_version> <bootimage> <mapfile>" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cfgLoader=
|
||||
|
||||
if [ -z "$INSTALL_PATH" -o "$INSTALL_PATH" == "/boot" ]; then
|
||||
INSTALL_PATH=/boot
|
||||
cfgLoader=1
|
||||
fi
|
||||
|
||||
LINK_PATH=/boot
|
||||
RELATIVE_PATH=`echo "$INSTALL_PATH/" | sed "s|^$LINK_PATH/||"`
|
||||
KERNEL_VERSION=$1
|
||||
BOOTIMAGE=$2
|
||||
MAPFILE=$3
|
||||
ARCH=$(uname -m)
|
||||
if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then
|
||||
KERNEL_NAME=vmlinux
|
||||
else
|
||||
KERNEL_NAME=vmlinuz
|
||||
fi
|
||||
|
||||
if [ -z "$KERNEL_VERSION" -o -z "$BOOTIMAGE" -o -z "$MAPFILE" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ -f $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION ]; then
|
||||
mv $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION \
|
||||
$INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION.old;
|
||||
fi
|
||||
|
||||
if [ ! -L $INSTALL_PATH/$KERNEL_NAME ]; then
|
||||
if [ -e $INSTALLPATH/$KERNEL_NAME ]; then
|
||||
mv $INSTALL_PATH/$KERNEL_NAME $INSTALL_PATH/$KERNEL_NAME.old
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f $INSTALL_PATH/System.map-$KERNEL_VERSION ]; then
|
||||
mv $INSTALL_PATH/System.map-$KERNEL_VERSION \
|
||||
$INSTALL_PATH/System.map-$KERNEL_VERSION.old;
|
||||
fi
|
||||
|
||||
if [ ! -L $INSTALL_PATH/System.map ]; then
|
||||
if [ -e $INSTALLPATH/System.map ]; then
|
||||
mv $INSTALL_PATH/System.map $INSTALL_PATH/System.map.old
|
||||
fi
|
||||
fi
|
||||
ln -sf ${RELATIVE_PATH}$INSTALL_PATH/System.map-$KERNEL_VERSION $LINK_PATH/System.map
|
||||
|
||||
cat $BOOTIMAGE > $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION
|
||||
cp $MAPFILE $INSTALL_PATH/System.map-$KERNEL_VERSION
|
||||
|
||||
ln -fs ${RELATIVE_PATH}$INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION $LINK_PATH/$KERNEL_NAME
|
||||
ln -fs ${RELATIVE_PATH}$INSTALL_PATH/System.map-$KERNEL_VERSION $LINK_PATH/System.map
|
||||
|
||||
if [ -n "$cfgLoader" ]; then
|
||||
kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION
|
||||
exit $?
|
||||
fi
|
Loading…
Reference in New Issue
Block a user