Compare commits

..

10 Commits
master ... f28

Author SHA1 Message Date
Javier Martinez Canillas 9e23454f08
Add %{_libexecdir}/installkernel directory to the %files list
Only the %{_libexecdir}/installkernel/installkernel file was added to the
%files directive, but the dir containing the file should also be listed.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-08-11 22:07:12 +02:00
Javier Martinez Canillas e10461b754 Make installkernel to use kernel-install scripts on BLS configuration
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-08-06 13:34:28 -04:00
Javier Martinez Canillas 907d2ed59e
Fix grubby wrapper paths
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-07-25 09:43:54 +02:00
Peter Jones b7409e8032 Fix permissions on /usr/sbin/grubby
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-24 13:45:35 -04:00
Peter Jones c555f75234 Fix some minor install directory path issues
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-18 13:43:47 -04:00
Peter Jones 2d40f773c6 Add a grubby-bls package that conflicts with grubby
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-18 13:30:09 -04:00
Javier Martinez Canillas 504ff4446b
Add grubby-bls package
Add a grubby wrapper script that allows to manage BootLoaderSpec files by
using the same command line options supported by the grubby tool. This is
provided for backward compatibility for grubby users that swtich to BLS.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-07-13 18:59:53 +02:00
Javier Martinez Canillas 83d4145e20 Use .rpmsave as backup suffix when switching to BLS configuration
By default the grub2-switch-to-blscfg script uses .bak as the suffix for
saved files, but it should use .rpmsave when called from a RPM scriptlet.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-04-11 10:09:46 -04:00
Javier Martinez Canillas 8813fe1f7c Switch grub2 config to BLS configuration on %postun
When grubby is not installed, the GRUB 2 configuration has to be
changed to use the BLS configuration files.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-04-06 14:03:37 -04:00
Nathaniel McCallum 7d47e62c2e Add support for /boot on btrfs 2018-03-06 10:24:41 -05:00
19 changed files with 193 additions and 1572 deletions

9
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.tar.bz2
*.tar.gz
grubby-*.tar.bz2
clog
*.rpm
.build*log
*/
/8.40-1.tar.gz
grubby-*/
.build*.log
.*sw?

View File

@ -1,7 +1,7 @@
From 3afc4c0ed28d443bb71956b07fd45c8cfb07566f Mon Sep 17 00:00:00 2001
From c1c46d21182974181f5b4c2ed0a02288b4bfd880 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccallum@redhat.com>
Date: Fri, 2 Mar 2018 14:59:32 -0500
Subject: [PATCH 2/8] Change return type in getRootSpecifier()
Subject: [PATCH 1/3] 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 d4ebb86168d..a062ef8e567 100644
index d4ebb86..a062ef8 100644
--- a/grubby.c
+++ b/grubby.c
@@ -675,7 +675,7 @@ static int lineWrite(FILE * out, struct singleLine * line,
@ -139,5 +139,5 @@ index d4ebb86168d..a062ef8e567 100644
return 0;
--
2.17.1
2.14.3

View File

@ -1,7 +1,7 @@
From 112b6e5fc690b2a73b6ad8c92dc4645db08503b6 Mon Sep 17 00:00:00 2001
From 5dec033b19bb5b07a0a136a7357e16c8ca9f5dd6 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccallum@redhat.com>
Date: Fri, 2 Mar 2018 08:40:18 -0500
Subject: [PATCH 3/8] Add btrfs subvolume support for grub2
Subject: [PATCH 2/3] 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 a062ef8e567..96d252a0a83 100644
index a062ef8..96d252a 100644
--- a/grubby.c
+++ b/grubby.c
@@ -68,6 +68,8 @@ int isEfi = 0;
@ -205,5 +205,5 @@ index a062ef8e567..96d252a0a83 100644
_("don't sanity check images in boot entries (for testing only)"),
NULL },
--
2.17.1
2.14.3

View File

@ -1,7 +1,7 @@
From e319f73ca691b9cc138def3a9c19f1cb6e581475 Mon Sep 17 00:00:00 2001
From 20d92194d03750d5d839c501d0539f9258614aae Mon Sep 17 00:00:00 2001
From: Gene Czarcinski <gczarcinski@gmail.com>
Date: Mon, 9 Jun 2014 21:11:37 -0400
Subject: [PATCH 4/8] Add tests for btrfs support
Subject: [PATCH 3/3] 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 6379698c6de..c35bfca1c89 100755
index 6379698..c35bfca 100755
--- a/test.sh
+++ b/test.sh
@@ -629,6 +629,46 @@ if [ "$testgrub2" == "y" ]; then
@ -105,7 +105,7 @@ index 6379698c6de..c35bfca1c89 100755
diff --git a/test/grub2-support_files/g2.20-mounts b/test/grub2-support_files/g2.20-mounts
new file mode 100644
index 00000000000..00bdb48e4ab
index 0000000..00bdb48
--- /dev/null
+++ b/test/grub2-support_files/g2.20-mounts
@@ -0,0 +1,2 @@
@ -113,7 +113,7 @@ index 00000000000..00bdb48e4ab
+/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 00000000000..42ef3fd4272
index 0000000..42ef3fd
--- /dev/null
+++ b/test/grub2-support_files/g2.21-mounts
@@ -0,0 +1 @@
@ -121,14 +121,14 @@ index 00000000000..42ef3fd4272
\ 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 00000000000..5b664e72519
index 0000000..5b664e7
--- /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 00000000000..74f036fc4a3
index 0000000..74f036f
--- /dev/null
+++ b/test/grub2-support_files/g2.23-mounts
@@ -0,0 +1 @@
@ -136,7 +136,7 @@ index 00000000000..74f036fc4a3
\ 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 00000000000..42ef3fd4272
index 0000000..42ef3fd
--- /dev/null
+++ b/test/grub2-support_files/g2.24-mounts
@@ -0,0 +1 @@
@ -144,7 +144,7 @@ index 00000000000..42ef3fd4272
\ 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 00000000000..74f036fc4a3
index 0000000..74f036f
--- /dev/null
+++ b/test/grub2-support_files/g2.25-mounts
@@ -0,0 +1 @@
@ -152,7 +152,7 @@ index 00000000000..74f036fc4a3
\ No newline at end of file
diff --git a/test/grub2.20 b/test/grub2.20
new file mode 100644
index 00000000000..23b75fa8d3c
index 0000000..23b75fa
--- /dev/null
+++ b/test/grub2.20
@@ -0,0 +1,126 @@
@ -284,7 +284,7 @@ index 00000000000..23b75fa8d3c
+### END /etc/grub.d/41_custom ###
diff --git a/test/grub2.21 b/test/grub2.21
new file mode 100644
index 00000000000..579c2f6744a
index 0000000..579c2f6
--- /dev/null
+++ b/test/grub2.21
@@ -0,0 +1,140 @@
@ -430,7 +430,7 @@ index 00000000000..579c2f6744a
+### END /etc/grub.d/41_custom ###
diff --git a/test/grub2.22 b/test/grub2.22
new file mode 100644
index 00000000000..9466bc35153
index 0000000..9466bc3
--- /dev/null
+++ b/test/grub2.22
@@ -0,0 +1,128 @@
@ -564,7 +564,7 @@ index 00000000000..9466bc35153
+### END /etc/grub.d/41_custom ###
diff --git a/test/grub2.23 b/test/grub2.23
new file mode 100644
index 00000000000..5cb240fc1de
index 0000000..5cb240f
--- /dev/null
+++ b/test/grub2.23
@@ -0,0 +1,143 @@
@ -713,7 +713,7 @@ index 00000000000..5cb240fc1de
+### END /etc/grub.d/41_custom ###
diff --git a/test/grub2.24 b/test/grub2.24
new file mode 100644
index 00000000000..23b75fa8d3c
index 0000000..23b75fa
--- /dev/null
+++ b/test/grub2.24
@@ -0,0 +1,126 @@
@ -845,7 +845,7 @@ index 00000000000..23b75fa8d3c
+### END /etc/grub.d/41_custom ###
diff --git a/test/grub2.25 b/test/grub2.25
new file mode 100644
index 00000000000..9466bc35153
index 0000000..9466bc3
--- /dev/null
+++ b/test/grub2.25
@@ -0,0 +1,128 @@
@ -979,7 +979,7 @@ index 00000000000..9466bc35153
+### 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 00000000000..579c2f6744a
index 0000000..579c2f6
--- /dev/null
+++ b/test/results/add/g2-1.20
@@ -0,0 +1,140 @@
@ -1125,7 +1125,7 @@ index 00000000000..579c2f6744a
+### 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 00000000000..c0dded9724c
index 0000000..c0dded9
--- /dev/null
+++ b/test/results/add/g2-1.21
@@ -0,0 +1,141 @@
@ -1272,7 +1272,7 @@ index 00000000000..c0dded9724c
+### 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 00000000000..5cb240fc1de
index 0000000..5cb240f
--- /dev/null
+++ b/test/results/add/g2-1.22
@@ -0,0 +1,143 @@
@ -1421,7 +1421,7 @@ index 00000000000..5cb240fc1de
+### 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 00000000000..c3e87cf7897
index 0000000..c3e87cf
--- /dev/null
+++ b/test/results/add/g2-1.23
@@ -0,0 +1,144 @@
@ -1571,7 +1571,7 @@ index 00000000000..c3e87cf7897
+### 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 00000000000..c0dded9724c
index 0000000..c0dded9
--- /dev/null
+++ b/test/results/add/g2-1.24
@@ -0,0 +1,141 @@
@ -1718,7 +1718,7 @@ index 00000000000..c0dded9724c
+### 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 00000000000..c3e87cf7897
index 0000000..c3e87cf
--- /dev/null
+++ b/test/results/add/g2-1.25
@@ -0,0 +1,144 @@
@ -1867,5 +1867,5 @@ index 00000000000..c3e87cf7897
+fi
+### END /etc/grub.d/41_custom ###
--
2.17.1
2.14.3

View File

@ -1,7 +1,7 @@
From db200499551e386e7616c621fcbd69e350081664 Mon Sep 17 00:00:00 2001
From a56df998177574ef2db332220c15f11bccd98f7e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 18 Jul 2018 13:41:02 -0400
Subject: [PATCH 6/8] Honor sbindir
Subject: [PATCH] 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 f0d13720db5..cfa8e0d60ab 100644
index ac144046133..2b18dd6404b 100644
--- a/Makefile
+++ b/Makefile
@@ -42,14 +42,14 @@ test: all

View File

@ -1,25 +0,0 @@
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 5/8] Use system LDFLAGS
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index ac144046133..f0d13720db5 100644
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@ OBJECTS = grubby.o log.o
CC = gcc
RPM_OPT_FLAGS ?= -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector
CFLAGS += $(RPM_OPT_FLAGS) -std=gnu99 -Wall -Werror -Wno-error=unused-function -Wno-unused-function -ggdb
-LDFLAGS :=
+LDFLAGS := $(RPM_LD_FLAGS)
grubby_LIBS = -lblkid -lpopt
--
2.17.1

View File

@ -1,7 +1,7 @@
From fa1bf7b54cb71fa193da16ffc404f8535d7d16ac Mon Sep 17 00:00:00 2001
From f93a35be5bdec17044dd2a17980689d3cbf73d58 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 7/8] Make installkernel to use kernel-install scripts on BLS
Subject: [PATCH] Make installkernel to use kernel-install scripts on BLS
configuration
The kernel make install target executes the arch/$ARCH/boot/install.sh

View File

@ -1,418 +0,0 @@
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

View File

@ -1,30 +0,0 @@
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

View File

@ -1,104 +0,0 @@
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

View File

@ -1,72 +0,0 @@
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

View File

@ -1,35 +0,0 @@
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

View File

@ -1,33 +0,0 @@
#!/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

View File

@ -1,7 +1,7 @@
From aa4472dbc10f3d669e24ac07293d7ac19e606866 Mon Sep 17 00:00:00 2001
From 3689d4cebedf115e41c192bf034b6f86fcb80acb Mon Sep 17 00:00:00 2001
From: Dennis Gilmore <dennis@ausil.us>
Date: Wed, 30 Aug 2017 14:03:45 -0500
Subject: [PATCH 1/8] remove the old crufty u-boot support
Subject: [PATCH] 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 b634388a83f..962008e3c9d 100755
index 64225de..0fe6caa 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -37,7 +37,6 @@ else
@ -48,7 +48,7 @@ index b634388a83f..962008e3c9d 100755
mounted=""
liloFlag=""
isx86=""
@@ -382,53 +373,6 @@ remove() {
@@ -386,53 +377,6 @@ remove() {
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
fi
@ -102,7 +102,7 @@ index b634388a83f..962008e3c9d 100755
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "removing $version from $extlinuxConfig"
$grubby --extlinux -c $extlinuxConfig \
@@ -530,36 +474,6 @@ update() {
@@ -534,36 +478,6 @@ update() {
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"
fi
@ -139,7 +139,7 @@ index b634388a83f..962008e3c9d 100755
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \
@@ -877,33 +791,6 @@ fi
@@ -874,33 +788,6 @@ fi
[ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1;
[ -n "$extlinuxConfig" ] && [ -f "$extlinuxConfig" ] && cfgExtlinux=1;
@ -183,7 +183,7 @@ index b634388a83f..962008e3c9d 100755
exit 0
diff --git a/uboot b/uboot
deleted file mode 100644
index 07d8671822f..00000000000
index 07d8671..0000000
--- a/uboot
+++ /dev/null
@@ -1,43 +0,0 @@
@ -230,6 +230,3 @@ index 07d8671822f..00000000000
-
-# option to tell new-kernel-pkg a specific dtb file to load in extlinux.conf
-#dtbfile=foo.dtb
--
2.17.1

View File

@ -48,10 +48,6 @@ print_error() {
exit 1
}
print_info() {
echo "$1" >&2
}
if [[ ${#} = 0 ]]; then
print_error "no action specified"
fi
@ -60,7 +56,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() {
@ -68,8 +64,7 @@ set_bls_value() {
local key="$1" && shift
local value="$1" && shift
value=$(echo $value | sed -e 's/\//\\\//g')
sed -i -e "s/^${key}.*/${key} ${value}/" "${bls}"
sed -i -e "s,^${key}.*,${key} ${value}," "${bls}"
}
append_bls_value() {
@ -77,32 +72,20 @@ 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
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}"
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)"
count=$((count+1))
done
@ -125,13 +108,16 @@ get_default_index() {
index="$default"
fi
for i in ${!bls_file[@]}; do
if [[ $i -eq $index ]]; then
echo $i
return
fi
# GRUB2 and zipl use different fields to set the default entry
if [[ $bootloader = "grub2" ]]; then
title="$default"
else
version="$default"
fi
if [[ $default = ${bls_id[$i]} || $default = ${bls_title[$i]} ]]; then
for i in ${!bls_file[@]}; do
if [[ $title = ${bls_title[$i]} || $version = ${bls_version[$i]} ||
$i -eq $index ]]; then
echo $i
return
fi
@ -139,11 +125,9 @@ get_default_index() {
}
display_default_value() {
local prefix=$(get_prefix)
case "$display_default" in
kernel)
echo "${prefix}${bls_linux[$default_index]}"
echo "${bls_linux[$default_index]}"
exit 0
;;
index)
@ -175,7 +159,7 @@ param_to_indexes() {
fi
for i in ${!bls_file[@]}; do
if [[ $param = "${bls_linux[$i]}" || "/${param##*/}" = "${bls_linux[$i]}" ]]; then
if [[ $param = "${bls_linux[$i]}" ]]; then
indexes="$indexes $i"
fi
@ -196,89 +180,15 @@ 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=\"${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]}\""
echo "kernel=${bls_linux[$i]}"
echo "args=\"${bls_options[$i]}\""
echo "initrd=${bls_initrd[$i]}"
echo "title=${bls_title[$i]}"
done
exit 0
}
@ -290,11 +200,6 @@ mkbls() {
local debugname=""
local flavor=""
local prefix=""
if [[ $(get_prefix) = "" ]]; then
prefix="/boot"
fi
if [[ $kernelver == *\+* ]] ; then
local flavor=-"${kernelver##*+}"
@ -308,7 +213,7 @@ mkbls() {
title ${NAME} (${kernelver}) ${VERSION}${debugname}
version ${kernelver}${debugid}
linux ${kernel}
initrd ${prefix}/initramfs-${kernelver}.img
initrd /initramfs-${kernelver}.img
options \$kernelopts
id ${ID}-${datetime}-${kernelver}${debugid}
grub_users \$grub_users
@ -317,61 +222,18 @@ 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 $(get_prefix)$1 is incorrect"
print_error "The param $1 is incorrect"
fi
for i in "${indexes[@]}"; do
if [[ $default_index = $i ]]; then
unset_default_bls
fi
for i in ${indexes[*]}; do
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() {
@ -383,12 +245,11 @@ add_bls_fragment() {
if [[ $kernel = *"vmlinuz-"* ]]; then
kernelver="${kernel##*/vmlinuz-}"
prefix="vmlinuz-"
else
kernelver="${kernel##*/}"
fi
if [[ ! -f "/boot/${prefix}${kernelver}" ]] &&
if [[ ! -d "/lib/modules/${kernelver}" || ! -f "/boot/vmlinuz-${kernelver}" ]] &&
[[ $bad_image != "true" ]]; then
print_error "The ${kernelver} kernel isn't installed in the machine"
fi
@ -402,19 +263,17 @@ add_bls_fragment() {
fi
bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
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}")")"
if [[ -f "${kernel_dir}/bls.conf" ]]; then
cp -aT "${kernel_dir}/bls.conf" "${bls_target}" || exit $?
else
datetime=0
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}"
fi
mkbls "${kernel}" "${kernelver}" "${datetime}" > "${bls_target}"
if [[ -n $title ]]; then
set_bls_value "${bls_target}" "title" "${title}"
@ -433,12 +292,13 @@ add_bls_fragment() {
fi
if [[ $MAKEDEBUG = "yes" ]]; then
bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")"
arch="$(uname -m)"
bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")"
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/${kernelver}/${kernelver}~debug/")"
blsid="$(get_bls_value ${bls_debug} "id" | sed -e "s/\.${arch}/-debug.${arch}/")"
set_bls_value "${bls_debug}" "id" "${blsid}"
fi
@ -448,8 +308,6 @@ add_bls_fragment() {
set_default_bls "TITLE=${title}"
fi
update_grubcfg
exit 0
}
@ -459,89 +317,55 @@ update_args() {
local add_args=($1) && shift
for arg in ${remove_args[*]}; do
arg="$(echo $arg | sed -e 's/\//\\\//g')"
args="$(echo $args | sed -e "s,$arg[^ ]*,,")"
done
for arg in ${add_args[*]}; do
if [[ $arg = *"="* ]]; then
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg([[:space:]]|$)/ /")"
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
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")"
exist=$(echo $args | grep $arg)
if ! [[ -n $exist ]]; then
args="$args $arg"
fi
fi
done
for arg in ${add_args[*]}; do
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 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
local new_args="$(update_args "${bls_options[$i]}" "${remove_args}" "${add_args}")"
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
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_id[$index]}"
grub2-editenv "${env}" set saved_entry="${bls_title[$index]}"
else
local default="${bls_title[$index]}"
local default="${bls_version[$index]}"
local current="$(grep '^default=' ${zipl_config} | sed -e 's/^default=//')"
if [[ -n $current ]]; then
sed -i -e "s,^default=.*,default=${default}," "${zipl_config}"
@ -549,40 +373,27 @@ 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##${prefix}/}"
remove_kernel="/${remove_kernel##*/}"
fi
if [[ -n $initrd ]]; then
initrd="/${initrd##${prefix}/}"
initrd="/${initrd##*/}"
fi
if [[ -n $extra_initrd ]]; then
extra_initrd=" /${extra_initrd##${prefix}/}"
extra_initrd=" /${extra_initrd##*/}"
fi
if [[ -n $kernel ]]; then
kernel="/${kernel##${prefix}/}"
kernel="/${kernel##*/}"
fi
if [[ -n $update_kernel && $update_kernel =~ ^/ ]]; then
update_kernel="/${update_kernel##${prefix}/}"
fi
}
update_grubcfg()
{
if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then
grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null
update_kernel="/${update_kernel##*/}"
fi
}
@ -605,6 +416,7 @@ 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
@ -613,7 +425,6 @@ 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
@ -621,11 +432,11 @@ Help options:
EOF
}
OPTS="$(getopt -o c:i:b:? --long help,add-kernel:,args:,bad-image-okay,\
OPTS="$(getopt -o c:i:o: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,remove-args:,\
grub2,info:,initrd:,extra-initrd:,make-default,output-file:,remove-args:,\
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\
bls-directory:,no-etc-grub-update,add-multiboot:,mbargs:,mounts:,boot-filesystem:,\
bls-directory:,add-kernel:,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} -- "$@")"
@ -651,7 +462,6 @@ while [ ${#} -gt 0 ]; do
bad_image=true
;;
--config-file|-c)
grub_config="${2}"
zipl_config="${2}"
shift
;;
@ -689,6 +499,10 @@ while [ ${#} -gt 0 ]; do
--make-default)
make_default=true
;;
--output-file|-o)
output_file="${2}"
shift
;;
--remove-args)
remove_args="${2}"
shift
@ -720,11 +534,7 @@ while [ ${#} -gt 0 ]; do
blsdir="${2}"
shift
;;
--no-etc-grub-update)
no_etc_update=true
shift
;;
--add-multiboot|--mbargs|--mounts|--boot-filesystem|\
--add-kernel|--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)
@ -749,10 +559,6 @@ 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
@ -765,14 +571,6 @@ 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)"
@ -785,7 +583,9 @@ if [[ -n $display_info ]]; then
display_info_values "${display_info}"
fi
remove_var_prefix "$(get_prefix)"
if [[ $bootloader = grub2 ]]; then
remove_var_prefix
fi
if [[ -n $kernel ]]; then
if [[ $copy_default = "true" ]]; then

179
grubby.8
View File

@ -1,179 +0,0 @@
.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

View File

@ -1,8 +1,8 @@
#!/bin/bash
if [[ -x @@LIBEXECDIR@@/grubby ]] ; then
exec @@LIBEXECDIR@@/grubby "${@}"
elif [[ -x @@LIBEXECDIR@@/grubby-bls ]] ; then
if [[ -x @@LIBEXECDIR@@/grubby-bls ]] ; then
exec @@LIBEXECDIR@@/grubby-bls "${@}"
elif [[ -x @@LIBEXECDIR@@/grubby ]] ; then
exec @@LIBEXECDIR@@/grubby "${@}"
fi
echo "Grubby is not installed correctly." >>/dev/stderr
exit 1

View File

@ -1,6 +1,6 @@
Name: grubby
Version: 8.40
Release: 45%{?dist}
Release: 16%{?dist}
Summary: Command line tool for updating bootloader configs
License: GPLv2+
URL: https://github.com/rhinstaller/grubby
@ -12,28 +12,17 @@ Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz
Source1: grubby-bls
Source2: grubby.in
Source3: installkernel.in
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
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-Honor-sbindir.patch
Patch6: 0005-installkernel-use-kernel-install.patch
BuildRequires: gcc
BuildRequires: pkgconfig glib2-devel popt-devel
BuildRequires: libblkid-devel git-core sed make
BuildRequires: libblkid-devel git-core sed gcc 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
@ -42,15 +31,15 @@ Requires: grub2-tools
%ifarch s390 s390x
Requires: s390utils-base
%endif
Requires: findutils
Requires: util-linux
Obsoletes: %{name}-bls < %{version}-%{release}
%description
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.
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}
%prep
%setup -q -n grubby-%{version}-1
@ -65,8 +54,7 @@ git config --unset user.email
git config --unset user.name
%build
%set_build_flags
make %{?_smp_mflags} LDFLAGS="${LDFLAGS}"
make %{?_smp_mflags}
%ifnarch aarch64 %{arm}
%check
@ -74,245 +62,59 @@ make test
%endif
%install
make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} libexecdir=%{_libexecdir}
make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir}
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
install -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/
install -m 0755 %{SOURCE4} %{buildroot}%{_libexecdir}/installkernel/
cp -v %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/
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/
%post
if [ "$1" = 2 ]; then
arch=$(uname -m)
[[ $arch == "s390x" ]] && \
zipl-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || :
fi
%package bls
Summary: Command line tool for updating BootLoaderSpec files
Conflicts: %{name} <= 8.40-13
BuildArch: noarch
%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.
%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.
%files
%{!?_licensedir:%global license %%doc}
%license COPYING
%dir %{_libexecdir}/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
%dir %{_libexecdir}/installkernel
%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*
%{_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*
%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
* Fri Aug 03 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-16
- Make installkernel to use kernel-install scripts on BLS configuration
* Tue Jul 24 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-17
* Tue Jul 24 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-15
- Fix grubby wrapper paths
Resolves: rhbz#1607981
* Tue Jul 24 2018 Peter Jones <pjones@redhat.com> - 8.40-16
* Tue Jul 24 2018 Peter Jones <pjones@redhat.com> - 8.40-14
- Fix permissions on /usr/sbin/grubby
* Fri Jul 13 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-15
* Fri Jul 13 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-13
- Add a grubby-bls package that conflicts with grubby
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu Jun 14 2018 Peter Jones <pjones@redhat.com> - 8.40-13
- Use standard Fedora linker flags (rhbz#1543502) (rdossant)
- Switch zipl config to BLS configuration on %%postun for s390x (javierm)
* Tue Apr 10 2018 Javier Martinez Canillas <javierm@redhat.com> - 8.40-12
- Use .rpmsave as backup suffix when switching to BLS configuration
@ -568,16 +370,16 @@ current boot environment.
* Thu Dec 08 2011 Adam Williamson <awilliam@redhat.com> - 8.4-1
- Update to 8.4:
+ fix Loading... line for updated kernels
+ Add new '--default-title' feature
+ Add new '--default-index' feature
+ add feature for testing the output of a grubby command
+ Fix detection when comparing stage1 to MBR
+ do not link against glib-2.0
+ Don't crash if grubConfig not found
+ Adding extlinux support for new-kernel-pkg
+ Look for Debian / Ubuntu grub config files (#703260)
+ Make grubby recognize Ubuntu's spin of Grub2 (#703260)
+ fix Loading... line for updated kernels
+ Add new '--default-title' feature
+ Add new '--default-index' feature
+ add feature for testing the output of a grubby command
+ Fix detection when comparing stage1 to MBR
+ do not link against glib-2.0
+ Don't crash if grubConfig not found
+ Adding extlinux support for new-kernel-pkg
+ Look for Debian / Ubuntu grub config files (#703260)
+ Make grubby recognize Ubuntu's spin of Grub2 (#703260)
* Thu Sep 29 2011 Peter Jones <pjones@redhat.com> - 8.3-1
- Fix new-kernel-pkg invocation of grubby for grub (patch from Mads Kiilerich)

View File

@ -1,83 +0,0 @@
#! /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