From 8a91c9f29b5df7f3b9dbfa271193cbd22ff6174f Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum Date: Mon, 5 Mar 2018 13:52:23 -0500 Subject: [PATCH 001/132] Add support for /boot on btrfs --- ...ange-return-type-in-getRootSpecifier.patch | 143 ++ ...dd-btrfs-subvolume-support-for-grub2.patch | 209 ++ 0003-Add-tests-for-btrfs-support.patch | 1871 +++++++++++++++++ grubby.spec | 8 +- 4 files changed, 2230 insertions(+), 1 deletion(-) create mode 100644 0001-Change-return-type-in-getRootSpecifier.patch create mode 100644 0002-Add-btrfs-subvolume-support-for-grub2.patch create mode 100644 0003-Add-tests-for-btrfs-support.patch diff --git a/0001-Change-return-type-in-getRootSpecifier.patch b/0001-Change-return-type-in-getRootSpecifier.patch new file mode 100644 index 0000000..0a6808b --- /dev/null +++ b/0001-Change-return-type-in-getRootSpecifier.patch @@ -0,0 +1,143 @@ +From c1c46d21182974181f5b4c2ed0a02288b4bfd880 Mon Sep 17 00:00:00 2001 +From: Nathaniel McCallum +Date: Fri, 2 Mar 2018 14:59:32 -0500 +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, +it reduces some memory leaks since the return value was often never +freed. Second, it simplifies the caller who is usually only interested +in the length of the prefix. +--- + grubby.c | 54 +++++++++++++++++++++++++++--------------------------- + 1 file changed, 27 insertions(+), 27 deletions(-) + +diff --git a/grubby.c b/grubby.c +index d4ebb86..a062ef8 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -675,7 +675,7 @@ static int lineWrite(FILE * out, struct singleLine * line, + struct configFileInfo * cfi); + static int getNextLine(char ** bufPtr, struct singleLine * line, + struct configFileInfo * cfi); +-static char * getRootSpecifier(char * str); ++static size_t getRootSpecifier(const char *str); + static void requote(struct singleLine *line, struct configFileInfo * cfi); + static void insertElement(struct singleLine * line, + const char * item, int insertHere, +@@ -1840,7 +1840,7 @@ int suitableImage(struct singleEntry * entry, const char * bootPrefix, + char * fullName; + int i; + char * dev; +- char * rootspec; ++ size_t rs; + char * rootdev; + + if (skipRemoved && entry->skip) { +@@ -1866,12 +1866,11 @@ int suitableImage(struct singleEntry * entry, const char * bootPrefix, + + fullName = alloca(strlen(bootPrefix) + + strlen(line->elements[1].item) + 1); +- rootspec = getRootSpecifier(line->elements[1].item); +- int rootspec_offset = rootspec ? strlen(rootspec) : 0; ++ rs = getRootSpecifier(line->elements[1].item); + int hasslash = endswith(bootPrefix, '/') || +- beginswith(line->elements[1].item + rootspec_offset, '/'); ++ beginswith(line->elements[1].item + rs, '/'); + sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", +- line->elements[1].item + rootspec_offset); ++ line->elements[1].item + rs); + if (access(fullName, R_OK)) { + notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); + return 0; +@@ -1952,7 +1951,6 @@ struct singleEntry * findEntryByPath(struct grubConfig * config, + struct singleLine * line; + int i; + char * chptr; +- char * rootspec = NULL; + enum lineType_e checkType = LT_KERNEL; + + if (isdigit(*kernel)) { +@@ -2044,11 +2042,10 @@ struct singleEntry * findEntryByPath(struct grubConfig * config, + + if (line && line->type != LT_MENUENTRY && + line->numElements >= 2) { +- rootspec = getRootSpecifier(line->elements[1].item); +- if (!strcmp(line->elements[1].item + +- ((rootspec != NULL) ? strlen(rootspec) : 0), +- kernel + strlen(prefix))) +- break; ++ if (!strcmp(line->elements[1].item + ++ getRootSpecifier(line->elements[1].item), ++ kernel + strlen(prefix))) ++ break; + } + if(line->type == LT_MENUENTRY && + !strcmp(line->elements[1].item, kernel)) +@@ -2797,11 +2794,11 @@ struct singleLine * addLineTmpl(struct singleEntry * entry, + + /* but try to keep the rootspec from the template... sigh */ + if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { +- char * rootspec = getRootSpecifier(tmplLine->elements[1].item); +- if (rootspec != NULL) { +- free(newLine->elements[1].item); +- newLine->elements[1].item = +- sdupprintf("%s%s", rootspec, val); ++ size_t rs = getRootSpecifier(tmplLine->elements[1].item); ++ if (rs > 0) { ++ free(newLine->elements[1].item); ++ newLine->elements[1].item = sdupprintf("%.*s%s", (int) rs, ++ tmplLine->elements[1].item, val); + } + } + } +@@ -3729,15 +3726,19 @@ int checkForElilo(struct grubConfig * config) { + return 1; + } + +-static char * getRootSpecifier(char * str) { +- char * idx, * rootspec = NULL; ++static size_t getRootSpecifier(const char *str) ++{ ++ size_t rs = 0; + + if (*str == '(') { +- idx = rootspec = strdup(str); +- while(*idx && (*idx != ')') && (!isspace(*idx))) idx++; +- *(++idx) = '\0'; ++ for (; str[rs] != ')' && !isspace(str[rs]); rs++) { ++ if (!str[rs]) ++ return rs; ++ } ++ rs++; + } +- return rootspec; ++ ++ return rs; + } + + static char * getInitrdVal(struct grubConfig * config, +@@ -4616,7 +4617,7 @@ int main(int argc, const char ** argv) { + if (displayDefault) { + struct singleLine * line; + struct singleEntry * entry; +- char * rootspec; ++ size_t rs; + + if (config->defaultImage == -1) return 0; + if (config->defaultImage == DEFAULT_SAVED_GRUB2 && +@@ -4629,9 +4630,8 @@ int main(int argc, const char ** argv) { + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) return 0; + +- rootspec = getRootSpecifier(line->elements[1].item); +- printf("%s%s\n", bootPrefix, line->elements[1].item + +- ((rootspec != NULL) ? strlen(rootspec) : 0)); ++ rs = getRootSpecifier(line->elements[1].item); ++ printf("%s%s\n", bootPrefix, line->elements[1].item + rs); + + return 0; + +-- +2.14.3 + diff --git a/0002-Add-btrfs-subvolume-support-for-grub2.patch b/0002-Add-btrfs-subvolume-support-for-grub2.patch new file mode 100644 index 0000000..d460c5d --- /dev/null +++ b/0002-Add-btrfs-subvolume-support-for-grub2.patch @@ -0,0 +1,209 @@ +From 5dec033b19bb5b07a0a136a7357e16c8ca9f5dd6 Mon Sep 17 00:00:00 2001 +From: Nathaniel McCallum +Date: Fri, 2 Mar 2018 08:40:18 -0500 +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 +filesystem, the caller can use the --mounts option to specify his own +mounts file. + +Btrfs subvolumes are already supported by grub2 and by grub2-mkconfig. + +Fixes #22 +--- + grubby.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 143 insertions(+), 5 deletions(-) + +diff --git a/grubby.c b/grubby.c +index a062ef8..96d252a 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -68,6 +68,8 @@ int isEfi = 0; + + char *saved_command_line = NULL; + ++const char *mounts = "/proc/mounts"; ++ + /* comments get lumped in with indention */ + struct lineElement { + char * item; +@@ -1834,6 +1836,129 @@ static int endswith(const char *s, char c) + return s[slen] == c; + } + ++typedef struct { ++ const char *start; ++ size_t chars; ++} field; ++ ++static int iscomma(int c) ++{ ++ return c == ','; ++} ++ ++static int isequal(int c) ++{ ++ return c == '='; ++} ++ ++static field findField(const field *in, typeof(isspace) *isdelim, field *out) ++{ ++ field nxt = {}; ++ size_t off = 0; ++ ++ while (off < in->chars && isdelim(in->start[off])) ++ off++; ++ ++ if (off == in->chars) ++ return nxt; ++ ++ out->start = &in->start[off]; ++ out->chars = 0; ++ ++ while (off + out->chars < in->chars && !isdelim(out->start[out->chars])) ++ out->chars++; ++ ++ nxt.start = out->start + out->chars; ++ nxt.chars = in->chars - off - out->chars; ++ return nxt; ++} ++ ++static int fieldEquals(const field *in, const char *str) ++{ ++ return in->chars == strlen(str) && ++ strncmp(in->start, str, in->chars) == 0; ++} ++ ++/* Parse /proc/mounts to determine the subvolume prefix. */ ++static size_t subvolPrefix(const char *str) ++{ ++ FILE *file = NULL; ++ char *line = NULL; ++ size_t prfx = 0; ++ size_t size = 0; ++ ++ file = fopen(mounts, "r"); ++ if (!file) ++ return 0; ++ ++ for (ssize_t s; (s = getline(&line, &size, file)) >= 0; ) { ++ field nxt = { line, s }; ++ field dev = {}; ++ field path = {}; ++ field type = {}; ++ field opts = {}; ++ field opt = {}; ++ ++ nxt = findField(&nxt, isspace, &dev); ++ if (!nxt.start) ++ continue; ++ ++ nxt = findField(&nxt, isspace, &path); ++ if (!nxt.start) ++ continue; ++ ++ nxt = findField(&nxt, isspace, &type); ++ if (!nxt.start) ++ continue; ++ ++ nxt = findField(&nxt, isspace, &opts); ++ if (!nxt.start) ++ continue; ++ ++ if (!fieldEquals(&type, "btrfs")) ++ continue; ++ ++ /* We have found a btrfs mount point. */ ++ ++ nxt = opts; ++ while ((nxt = findField(&nxt, iscomma, &opt)).start) { ++ field key = {}; ++ field val = {}; ++ ++ opt = findField(&opt, isequal, &key); ++ if (!opt.start) ++ continue; ++ ++ opt = findField(&opt, isequal, &val); ++ if (!opt.start) ++ continue; ++ ++ if (!fieldEquals(&key, "subvol")) ++ continue; ++ ++ /* We have found a btrfs subvolume mount point. */ ++ ++ if (strncmp(val.start, str, val.chars)) ++ continue; ++ ++ if (val.start[val.chars - 1] != '/' && ++ str[val.chars] != '/') ++ continue; ++ ++ /* The subvolume mount point matches our input. */ ++ ++ if (prfx < val.chars) ++ prfx = val.chars; ++ } ++ } ++ ++ dbgPrintf("%s(): str: '%s', prfx: '%s'\n", __FUNCTION__, str, prfx); ++ ++ fclose(file); ++ free(line); ++ return prfx; ++} ++ + int suitableImage(struct singleEntry * entry, const char * bootPrefix, + int skipRemoved, int flags) { + struct singleLine * line; +@@ -2794,12 +2919,22 @@ struct singleLine * addLineTmpl(struct singleEntry * entry, + + /* but try to keep the rootspec from the template... sigh */ + if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { +- size_t rs = getRootSpecifier(tmplLine->elements[1].item); ++ const char *prfx = tmplLine->elements[1].item; ++ size_t rs = getRootSpecifier(prfx); ++ if (isinitrd(tmplLine->type)) { ++ for (struct singleLine *l = entry->lines; ++ rs == 0 && l; l = l->next) { ++ if (iskernel(l->type)) { ++ prfx = l->elements[1].item; ++ rs = getRootSpecifier(prfx); ++ } ++ } ++ } + if (rs > 0) { + free(newLine->elements[1].item); +- newLine->elements[1].item = sdupprintf("%.*s%s", (int) rs, +- tmplLine->elements[1].item, val); +- } ++ newLine->elements[1].item = sdupprintf("%.*s%s", ++ (int) rs, prfx, val); ++ } + } + } + +@@ -3738,7 +3873,7 @@ static size_t getRootSpecifier(const char *str) + rs++; + } + +- return rs; ++ return rs + subvolPrefix(str + rs); + } + + static char * getInitrdVal(struct grubConfig * config, +@@ -4253,6 +4388,9 @@ int main(int argc, const char ** argv) { + { "mbargs", 0, POPT_ARG_STRING, &newMBKernelArgs, 0, + _("default arguments for the new multiboot kernel or " + "new arguments for multiboot kernel being updated"), NULL }, ++ { "mounts", 0, POPT_ARG_STRING, &mounts, 0, ++ _("path to fake /proc/mounts file (for testing only)"), ++ _("mounts") }, + { "bad-image-okay", 0, 0, &badImageOkay, 0, + _("don't sanity check images in boot entries (for testing only)"), + NULL }, +-- +2.14.3 + diff --git a/0003-Add-tests-for-btrfs-support.patch b/0003-Add-tests-for-btrfs-support.patch new file mode 100644 index 0000000..d274bb9 --- /dev/null +++ b/0003-Add-tests-for-btrfs-support.patch @@ -0,0 +1,1871 @@ +From 20d92194d03750d5d839c501d0539f9258614aae Mon Sep 17 00:00:00 2001 +From: Gene Czarcinski +Date: Mon, 9 Jun 2014 21:11:37 -0400 +Subject: [PATCH 3/3] Add tests for btrfs support + +The tests performed are: +- add kernel with /boot on btrfs subvol (20) +- update kernel/add initrd with /boot on btrfs subvol (21) +- add kernel with rootfs on btrfs subvol and /boot a directory (22) +- update kernel/add initrd with rootfs on btrfs subvol and + /boot a directory (23) +- add kernel and initrd with /boot on btrfs subvol (24) +- add kernel and initrd with rootfs on btrfs subvol and /boot + a directory (25) +--- + 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 ++++++++++++++++++++++++++++++++++ + 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 + create mode 100644 test/grub2-support_files/g2.22-mounts + create mode 120000 test/grub2-support_files/g2.23-mounts + create mode 120000 test/grub2-support_files/g2.24-mounts + create mode 120000 test/grub2-support_files/g2.25-mounts + create mode 100644 test/grub2.20 + create mode 100644 test/grub2.21 + create mode 100644 test/grub2.22 + create mode 100644 test/grub2.23 + create mode 100644 test/grub2.24 + create mode 100644 test/grub2.25 + create mode 100644 test/results/add/g2-1.20 + create mode 100644 test/results/add/g2-1.21 + create mode 100644 test/results/add/g2-1.22 + create mode 100644 test/results/add/g2-1.23 + create mode 100644 test/results/add/g2-1.24 + create mode 100644 test/results/add/g2-1.25 + +diff --git a/test.sh b/test.sh +index 6379698..c35bfca 100755 +--- a/test.sh ++++ b/test.sh +@@ -629,6 +629,46 @@ if [ "$testgrub2" == "y" ]; then + --initrd /boot/initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img \ + --copy-default --title "Fedora 21 Rescue" --args=root=/fooooo \ + --remove-kernel=wtf --boot-filesystem=/boot/ ++ ++ testing="GRUB2 add kernel with boot on btrfs subvol" ++ grub2Test grub2.20 add/g2-1.20 --add-kernel=/boot/new-kernel.img \ ++ --title='title' \ ++ --boot-filesystem=/boot/ \ ++ --copy-default \ ++ --mounts='test/grub2-support_files/g2.20-mounts' ++ ++ testing="GRUB2 add initrd with boot on btrfs subvol" ++ grub2Test grub2.21 add/g2-1.21 --update-kernel=/boot/new-kernel.img \ ++ --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ ++ --mounts='test/grub2-support_files/g2.21-mounts' ++ ++ testing="GRUB2 add kernel with rootfs on btrfs subvol and boot directory" ++ grub2Test grub2.22 add/g2-1.22 --add-kernel=/boot/new-kernel.img \ ++ --title='title' \ ++ --boot-filesystem= \ ++ --copy-default \ ++ --mounts='test/grub2-support_files/g2.22-mounts' ++ ++ testing="GRUB2 add initrd with rootfs on btrfs subvol and boot directory" ++ grub2Test grub2.23 add/g2-1.23 --update-kernel=/boot/new-kernel.img \ ++ --initrd=/boot/new-initrd --boot-filesystem= \ ++ --mounts='test/grub2-support_files/g2.23-mounts' ++ ++ testing="GRUB2 add kernel and initrd with boot on btrfs subvol" ++ grub2Test grub2.24 add/g2-1.24 --add-kernel=/boot/new-kernel.img \ ++ --title='title' \ ++ --initrd=/boot/new-initrd \ ++ --boot-filesystem=/boot/ \ ++ --copy-default \ ++ --mounts='test/grub2-support_files/g2.24-mounts' ++ ++ testing="GRUB2 add kernel and initrd with rootfs on btrfs subvol and boot directory" ++ grub2Test grub2.25 add/g2-1.25 --add-kernel=/boot/new-kernel.img \ ++ --title='title' \ ++ --initrd=/boot/new-initrd \ ++ --boot-filesystem= \ ++ --copy-default \ ++ --mounts='test/grub2-support_files/g2.25-mounts' + fi + fi + +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 +--- /dev/null ++++ b/test/grub2-support_files/g2.20-mounts +@@ -0,0 +1,2 @@ ++/dev/sda / btrfs subvol=/root6,defaults 0 0 ++/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 +--- /dev/null ++++ b/test/grub2-support_files/g2.21-mounts +@@ -0,0 +1 @@ ++g2.20-mounts +\ 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 +--- /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 +--- /dev/null ++++ b/test/grub2-support_files/g2.23-mounts +@@ -0,0 +1 @@ ++g2.22-mounts +\ 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 +--- /dev/null ++++ b/test/grub2-support_files/g2.24-mounts +@@ -0,0 +1 @@ ++g2.20-mounts +\ 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 +--- /dev/null ++++ b/test/grub2-support_files/g2.25-mounts +@@ -0,0 +1 @@ ++g2.22-mounts +\ No newline at end of file +diff --git a/test/grub2.20 b/test/grub2.20 +new file mode 100644 +index 0000000..23b75fa +--- /dev/null ++++ b/test/grub2.20 +@@ -0,0 +1,126 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### END /etc/grub.d/30_os-prober ### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### END /etc/grub.d/41_custom ### +diff --git a/test/grub2.21 b/test/grub2.21 +new file mode 100644 +index 0000000..579c2f6 +--- /dev/null ++++ b/test/grub2.21 +@@ -0,0 +1,140 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### END /etc/grub.d/30_os-prober ### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### END /etc/grub.d/41_custom ### +diff --git a/test/grub2.22 b/test/grub2.22 +new file mode 100644 +index 0000000..9466bc3 +--- /dev/null ++++ b/test/grub2.22 +@@ -0,0 +1,128 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### END /etc/grub.d/41_custom ### +diff --git a/test/grub2.23 b/test/grub2.23 +new file mode 100644 +index 0000000..5cb240f +--- /dev/null ++++ b/test/grub2.23 +@@ -0,0 +1,143 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### END /etc/grub.d/41_custom ### +diff --git a/test/grub2.24 b/test/grub2.24 +new file mode 100644 +index 0000000..23b75fa +--- /dev/null ++++ b/test/grub2.24 +@@ -0,0 +1,126 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### END /etc/grub.d/30_os-prober ### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### END /etc/grub.d/41_custom ### +diff --git a/test/grub2.25 b/test/grub2.25 +new file mode 100644 +index 0000000..9466bc3 +--- /dev/null ++++ b/test/grub2.25 +@@ -0,0 +1,128 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### 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 +--- /dev/null ++++ b/test/results/add/g2-1.20 +@@ -0,0 +1,140 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### END /etc/grub.d/30_os-prober ### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### 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 +--- /dev/null ++++ b/test/results/add/g2-1.21 +@@ -0,0 +1,141 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/new-initrd ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### END /etc/grub.d/30_os-prober ### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### 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 +--- /dev/null ++++ b/test/results/add/g2-1.22 +@@ -0,0 +1,143 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### 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 +--- /dev/null ++++ b/test/results/add/g2-1.23 +@@ -0,0 +1,144 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/new-initrd ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### 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 +--- /dev/null ++++ b/test/results/add/g2-1.24 +@@ -0,0 +1,141 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/new-initrd ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ else ++ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ++ fi ++ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet ++ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### END /etc/grub.d/30_os-prober ### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### 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 +--- /dev/null ++++ b/test/results/add/g2-1.25 +@@ -0,0 +1,144 @@ ++# ++# DO NOT EDIT THIS FILE ++# ++# It is automatically generated by grub2-mkconfig using templates ++# from /etc/grub.d and settings from /etc/default/grub ++# ++ ++### BEGIN /etc/grub.d/00_header ### ++set pager=1 ++ ++if [ -s $prefix/grubenv ]; then ++ load_env ++fi ++if [ "${next_entry}" ] ; then ++ set default="${next_entry}" ++ set next_entry= ++ save_env next_entry ++ set boot_once=true ++else ++ set default="${saved_entry}" ++fi ++ ++if [ x"${feature_menuentry_id}" = xy ]; then ++ menuentry_id_option="--id" ++else ++ menuentry_id_option="" ++fi ++ ++export menuentry_id_option ++ ++if [ "${prev_saved_entry}" ]; then ++ set saved_entry="${prev_saved_entry}" ++ save_env saved_entry ++ set prev_saved_entry= ++ save_env prev_saved_entry ++ set boot_once=true ++fi ++ ++function savedefault { ++ if [ -z "${boot_once}" ]; then ++ saved_entry="${chosen}" ++ save_env saved_entry ++ fi ++} ++ ++function load_video { ++ if [ x$feature_all_video_module = xy ]; then ++ insmod all_video ++ else ++ insmod efi_gop ++ insmod efi_uga ++ insmod ieee1275_fb ++ insmod vbe ++ insmod vga ++ insmod video_bochs ++ insmod video_cirrus ++ fi ++} ++ ++terminal_output console ++if [ x$feature_timeout_style = xy ] ; then ++ set timeout_style=menu ++ set timeout=15 ++# Fallback normal timeout code in case the timeout_style feature is ++# unavailable. ++else ++ set timeout=15 ++fi ++### END /etc/grub.d/00_header ### ++ ++### BEGIN /etc/grub.d/10_linux ### ++menuentry 'title' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/new-initrd ++} ++menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { ++ load_video ++ set gfxpayload=keep ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img ++} ++menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { ++ load_video ++ insmod gzio ++ insmod part_msdos ++ insmod part_msdos ++ insmod btrfs ++ set root='hd0,msdos1' ++ if [ x$feature_platform_search_hint = xy ]; then ++ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ else ++ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb ++ fi ++ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet ++ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img ++} ++ ++### END /etc/grub.d/10_linux ### ++ ++### BEGIN /etc/grub.d/20_linux_xen ### ++ ++### END /etc/grub.d/20_linux_xen ### ++ ++### BEGIN /etc/grub.d/20_ppc_terminfo ### ++### END /etc/grub.d/20_ppc_terminfo ### ++ ++### BEGIN /etc/grub.d/30_os-prober ### ++### ++ ++### BEGIN /etc/grub.d/40_custom ### ++# This file provides an easy way to add custom menu entries. Simply type the ++# menu entries you want to add after this comment. Be careful not to change ++# the 'exec tail' line above. ++### END /etc/grub.d/40_custom ### ++ ++### BEGIN /etc/grub.d/41_custom ### ++if [ -f ${config_directory}/custom.cfg ]; then ++ source ${config_directory}/custom.cfg ++elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then ++ source $prefix/custom.cfg; ++fi ++### END /etc/grub.d/41_custom ### +-- +2.14.3 + diff --git a/grubby.spec b/grubby.spec index e70b911..2d3d492 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 9%{?dist} +Release: 10%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -10,6 +10,9 @@ URL: https://github.com/rhinstaller/grubby # Source0: %%{name}-%%{version}.tar.bz2 Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz 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 BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git-core @@ -62,6 +65,9 @@ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} %{_mandir}/man8/*.8* %changelog +* Sat Mar 03 2018 Nathaniel McCallum - 8.40-10 +- Add support for /boot on btrfs subvolumes + * Wed Feb 07 2018 Fedora Release Engineering - 8.40-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild From c8349748f208c796b8d7a41716704cd12bd0ed56 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 6 Apr 2018 15:49:17 +0000 Subject: [PATCH 002/132] 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 --- grubby.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 2d3d492..7e3fc34 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 10%{?dist} +Release: 11%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -21,6 +21,7 @@ BuildRequires: util-linux-ng %ifarch aarch64 i686 x86_64 %{power64} BuildRequires: grub2-tools-minimal Requires: grub2-tools-minimal +Requires: grub2-tools %endif %ifarch s390 s390x Requires: s390utils-base @@ -56,6 +57,11 @@ make test %install make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} +%postun +if [ "$1" = 0 ] ; then + grub2-switch-to-blscfg &>/dev/null || : +fi + %files %{!?_licensedir:%global license %%doc} %license COPYING @@ -65,6 +71,9 @@ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} %{_mandir}/man8/*.8* %changelog +* Fri Apr 06 2018 Javier Martinez Canillas - 8.40-11 +- Switch grub2 config to BLS configuration on %%postun + * Sat Mar 03 2018 Nathaniel McCallum - 8.40-10 - Add support for /boot on btrfs subvolumes From eedee250666ab8035b294509c4bcb84c7fc2873b Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 10 Apr 2018 15:37:31 +0200 Subject: [PATCH 003/132] 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 --- grubby.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index 7e3fc34..ebfb91d 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 11%{?dist} +Release: 12%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -59,7 +59,7 @@ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} %postun if [ "$1" = 0 ] ; then - grub2-switch-to-blscfg &>/dev/null || : + grub2-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || : fi %files @@ -71,6 +71,9 @@ fi %{_mandir}/man8/*.8* %changelog +* Tue Apr 10 2018 Javier Martinez Canillas - 8.40-12 +- Use .rpmsave as backup suffix when switching to BLS configuration + * Fri Apr 06 2018 Javier Martinez Canillas - 8.40-11 - Switch grub2 config to BLS configuration on %%postun From a631596958b535d2ed1defcb8648e43697a3cfba Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Date: Tue, 29 May 2018 15:21:54 +0200 Subject: [PATCH 004/132] Use Fedora standard linker flags - Resolves rhbz#1543502 Signed-off-by: Rafael dos Santos --- 0004-Use-system-LDFLAGS.patch | 25 +++++++++++++++++++++++++ grubby.spec | 6 +++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 0004-Use-system-LDFLAGS.patch diff --git a/0004-Use-system-LDFLAGS.patch b/0004-Use-system-LDFLAGS.patch new file mode 100644 index 0000000..f186b98 --- /dev/null +++ b/0004-Use-system-LDFLAGS.patch @@ -0,0 +1,25 @@ +From fbc4d4feef66df7224fde64adae95525e73bf141 Mon Sep 17 00:00:00 2001 +From: Rafael dos Santos +Date: Tue, 29 May 2018 15:15:24 +0200 +Subject: [PATCH] Use system LDFLAGS + +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index ac14404..f0d1372 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.0 + diff --git a/grubby.spec b/grubby.spec index ebfb91d..3faffa1 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -13,6 +13,7 @@ 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 BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git-core @@ -71,6 +72,9 @@ fi %{_mandir}/man8/*.8* %changelog +* Tue May 29 2018 Rafael dos Santos - 8.40-13 +- Use standard Fedora linker flags (rhbz#1543502) + * Tue Apr 10 2018 Javier Martinez Canillas - 8.40-12 - Use .rpmsave as backup suffix when switching to BLS configuration From 5d5938c58d713ff66e4af4cba6ca89017ac1b2ea Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 14 Jun 2018 10:25:05 -0400 Subject: [PATCH 005/132] Fix an old changelog entry rpmlint was complaining about Signed-off-by: Peter Jones --- grubby.spec | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/grubby.spec b/grubby.spec index 3faffa1..dede26f 100644 --- a/grubby.spec +++ b/grubby.spec @@ -330,16 +330,16 @@ fi * Thu Dec 08 2011 Adam Williamson - 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 - 8.3-1 - Fix new-kernel-pkg invocation of grubby for grub (patch from Mads Kiilerich) From b92599df6effc06bb486f022d45ed90dbfc847b9 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 14 Jun 2018 16:22:17 +0200 Subject: [PATCH 006/132] Switch zipl config to BLS configuration on %postun for s390x When grubby is not installed, the zipl configuration has to be changed to use the BLS configuration files. Signed-off-by: Javier Martinez Canillas --- grubby.spec | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/grubby.spec b/grubby.spec index dede26f..56b0d18 100644 --- a/grubby.spec +++ b/grubby.spec @@ -60,7 +60,14 @@ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} %postun if [ "$1" = 0 ] ; then - grub2-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || : + arch=$(uname -m) + if [[ $arch == "s390x" ]]; then + command=zipl-switch-to-blscfg + else + command=grub2-switch-to-blscfg + fi + + $command --backup-suffix=.rpmsave &>/dev/null || : fi %files @@ -72,8 +79,9 @@ fi %{_mandir}/man8/*.8* %changelog -* Tue May 29 2018 Rafael dos Santos - 8.40-13 -- Use standard Fedora linker flags (rhbz#1543502) +* Thu Jun 14 2018 Peter Jones - 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 - 8.40-12 - Use .rpmsave as backup suffix when switching to BLS configuration From a7316b242a8561fab2e83d3763b9f8f46bd834df Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 13 Jul 2018 04:33:50 +0000 Subject: [PATCH 007/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 56b0d18..c48f3aa 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 13%{?dist} +Release: 14%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -79,6 +79,9 @@ fi %{_mandir}/man8/*.8* %changelog +* Fri Jul 13 2018 Fedora Release Engineering - 8.40-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + * Thu Jun 14 2018 Peter Jones - 8.40-13 - Use standard Fedora linker flags (rhbz#1543502) (rdossant) - Switch zipl config to BLS configuration on %%postun for s390x (javierm) From 19db5c489a7e6cad6266305acf61b262e29cddc6 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 18 Jun 2018 11:14:35 +0200 Subject: [PATCH 008/132] 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 --- grubby-bls | 616 ++++++++++++++++++++++++++++++++++++++++++++++++++++ grubby.spec | 33 +-- 2 files changed, 635 insertions(+), 14 deletions(-) create mode 100755 grubby-bls diff --git a/grubby-bls b/grubby-bls new file mode 100755 index 0000000..d94415f --- /dev/null +++ b/grubby-bls @@ -0,0 +1,616 @@ +#!/bin/bash +# +# grubby wrapper to manage BootLoaderSpec files +# +# +# Copyright 2018 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 . + +readonly SCRIPTNAME="${0##*/}" + +CMDLINE_LINUX_DEBUG=" systemd.log_level=debug systemd.log_target=kmsg" +LINUX_DEBUG_VERSION_POSTFIX="_with_debugging" +LINUX_DEBUG_TITLE_POSTFIX=" with debugging" + +declare -a bls_file +declare -a bls_title +declare -a bls_version +declare -a bls_linux +declare -a bls_initrd +declare -a bls_options +declare -a bls_id + +[[ -f /etc/sysconfig/kernel ]] && . /etc/sysconfig/kernel +[[ -f /etc/os-release ]] && . /etc/os-release +read MACHINE_ID < /etc/machine-id +arch=$(uname -m) + +if [[ $arch = 's390' || $arch = 's390x' ]]; then + bootloader="zipl" +else + bootloader="grub2" +fi + +print_error() { + echo "$1" >&2 + exit 1 +} + +if [[ ${#} = 0 ]]; then + print_error "no action specified" +fi + +get_bls_value() { + local bls="$1" && shift + local key="$1" && shift + + echo "$(grep "^${key}[ \t]" "${bls}" | sed -e "s,^${key}[ \t]*,,")" +} + +set_bls_value() { + local bls="$1" && shift + local key="$1" && shift + local value="$1" && shift + + sed -i -e "s,^${key}.*,${key} ${value}," "${bls}" +} + +append_bls_value() { + local bls="$1" && shift + local key="$1" && shift + local value="$1" && shift + + 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)" + + count=$((count+1)) + done +} + +get_default_index() { + local default="" + local index="-1" + local title="" + local version="" + if [[ $bootloader = "grub2" ]]; then + default="$(grep '^saved_entry=' ${env} | sed -e 's/^saved_entry=//')" + else + default="$(grep '^default=' ${zipl_config} | sed -e 's/^default=//')" + fi + + if [[ -z $default ]]; then + index=0 + elif [[ $default =~ ^[0-9]+$ ]]; then + 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 + echo $i + return + fi + done +} + +display_default_value() { + case "$display_default" in + kernel) + echo "${bls_linux[$default_index]}" + exit 0 + ;; + index) + echo "$default_index" + exit 0 + ;; + title) + echo "${bls_title[$default_index]}" + exit 0 + ;; + esac +} + +param_to_indexes() { + local param="$1" + local indexes="" + + if [[ $param = "ALL" ]]; then + for i in ${!bls_file[@]}; do + indexes="$indexes $i" + done + echo -n $indexes + return + fi + + if [[ $param = "DEFAULT" ]]; then + echo -n $default_index + return + fi + + for i in ${!bls_file[@]}; do + if [[ $param = "${bls_linux[$i]}" ]]; then + indexes="$indexes $i" + fi + + if [[ $param = "TITLE=${bls_title[$i]}" ]]; then + indexes="$indexes $i" + fi + + if [[ $param = $i ]]; then + indexes="$indexes $i" + fi + done + + if [[ -n $indexes ]]; then + echo -n $indexes + return + fi + + echo -n "-1" +} + +display_info_values() { + local indexes=($(param_to_indexes "$1")) + + for i in ${indexes[*]}; do + echo "index=$i" + echo "kernel=${bls_linux[$i]}" + echo "args=\"${bls_options[$i]}\"" + echo "initrd=${bls_initrd[$i]}" + echo "title=${bls_title[$i]}" + done + exit 0 +} + +mkbls() { + local kernel=$1 && shift + local kernelver=$1 && shift + local datetime=$1 && shift + + local debugname="" + local flavor="" + + if [[ $kernelver == *\+* ]] ; then + local flavor=-"${kernelver##*+}" + if [[ $flavor == "-debug" ]]; then + local debugname="with debugging" + local debugid="-debug" + fi + fi + + cat < "${bls_target}" + fi + + if [[ -n $title ]]; then + set_bls_value "${bls_target}" "title" "${title}" + fi + + if [[ -n $options ]]; then + set_bls_value "${bls_target}" "options" "${options}" + fi + + if [[ -n $initrd ]]; then + set_bls_value "${bls_target}" "initrd" "${initrd}" + fi + + if [[ -n $extra_initrd ]]; then + append_bls_value "${bls_target}" "initrd" "${extra_initrd}" + fi + + if [[ $MAKEDEBUG = "yes" ]]; then + 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/\.${arch}/-debug.${arch}/")" + set_bls_value "${bls_debug}" "id" "${blsid}" + fi + + get_bls_values + + if [[ $make_default = "true" ]]; then + set_default_bls "TITLE=${title}" + fi + + exit 0 +} + +update_args() { + local args=$1 && shift + local remove_args=($1) && shift + local add_args=($1) && shift + + for arg in ${remove_args[*]}; do + args="$(echo $args | sed -e "s,$arg[^ ]*,,")" + 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 + done + + echo ${args} +} + +update_bls_fragment() { + local indexes=($(param_to_indexes "$1")) && shift + local remove_args=$1 && shift + local add_args=$1 && shift + local initrd=$1 && shift + + 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}" + fi + + if [[ -n $initrd ]]; then + set_bls_value "${bls_file[$i]}" "initrd" "${initrd}" + fi + done +} + +set_default_bls() { + local index=($(param_to_indexes "$1")) + + if [[ $bootloader = grub2 ]]; then + grub2-editenv "${env}" set saved_entry="${bls_title[$index]}" + else + 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}" + else + echo "default=${default}" >> "${zipl_config}" + fi + fi +} + +remove_var_prefix() { + if [[ -n $remove_kernel && $remove_kernel =~ ^/ ]]; then + remove_kernel="/${remove_kernel##*/}" + fi + + if [[ -n $initrd ]]; then + initrd="/${initrd##*/}" + fi + + if [[ -n $extra_initrd ]]; then + extra_initrd=" /${extra_initrd##*/}" + fi + + if [[ -n $kernel ]]; then + kernel="/${kernel##*/}" + fi + + if [[ -n $update_kernel && $update_kernel =~ ^/ ]]; then + update_kernel="/${update_kernel##*/}" + fi +} + +print_usage() +{ + cat <&2 + echo "Try '${SCRIPTNAME} --help' to list supported options" >&2 + echo + exit 1 + ;; + --) + shift + break + ;; + *) + echo + echo "${SCRIPTNAME}: invalid option \"${1}\"" >&2 + echo "Try '${SCRIPTNAME} --help' for more information" >&2 + echo + exit 1 + ;; + esac + shift +done + +if [[ -z $blsdir ]]; then + blsdir="/boot/loader/entries" +fi + +if [[ -z $env ]]; then + env="/boot/grub2/grubenv" +fi + +if [[ -z $zipl_config ]]; then + zipl_config="/etc/zipl.conf" +fi + +get_bls_values + +default_index="$(get_default_index)" + +if [[ -n $display_default ]]; then + display_default_value +fi + +if [[ -n $display_info ]]; then + display_info_values "${display_info}" +fi + +if [[ $bootloader = grub2 ]]; then + remove_var_prefix +fi + +if [[ -n $kernel ]]; then + if [[ $copy_default = "true" ]]; then + opts="${bls_options[$default_index]}" + if [[ -n $args ]]; then + opts="${opts} ${args}" + fi + else + opts="${args}" + fi + + add_bls_fragment "${kernel}" "${title}" "${opts}" "${initrd}" \ + "${extra_initrd}" +fi + +if [[ -n $remove_kernel ]]; then + remove_bls_fragment "${remove_kernel}" +fi + +if [[ -n $update_kernel ]]; then + update_bls_fragment "${update_kernel}" "${remove_args}" "${args}" "${initrd}" +fi + +if [[ -n $set_default ]]; then + set_default_bls "${set_default}" +fi + +exit 0 diff --git a/grubby.spec b/grubby.spec index c48f3aa..e623107 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 14%{?dist} +Release: 15%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -9,6 +9,7 @@ URL: https://github.com/rhinstaller/grubby # git archive --format=tar --prefix=grubby-%%{version}/ HEAD |bzip2 > grubby-%%{version}.tar.bz2 # Source0: %%{name}-%%{version}.tar.bz2 Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz +Source1: grubby-bls Patch1: drop-uboot-uImage-creation.patch Patch2: 0001-Change-return-type-in-getRootSpecifier.patch Patch3: 0002-Add-btrfs-subvolume-support-for-grub2.patch @@ -35,6 +36,8 @@ 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 @@ -58,27 +61,29 @@ make test %install make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} -%postun -if [ "$1" = 0 ] ; then - arch=$(uname -m) - if [[ $arch == "s390x" ]]; then - command=zipl-switch-to-blscfg - else - command=grub2-switch-to-blscfg - fi +rm %{buildroot}/sbin/installkernel +rm %{buildroot}/sbin/new-kernel-pkg +cp %{SOURCE1} %{buildroot}/sbin/grubby - $command --backup-suffix=.rpmsave &>/dev/null || : -fi +%package bls +Summary: Command line tool for updating BootLoaderSpec files +Obsoletes: %{name} < 8.40-15 +BuildArch: noarch -%files +%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 bls %{!?_licensedir:%global license %%doc} %license COPYING -/sbin/installkernel -/sbin/new-kernel-pkg /sbin/grubby %{_mandir}/man8/*.8* %changelog +* Fri Jul 13 2018 Javier Martinez Canillas - 8.40-15 +- Add a grubby-bls package that contains grubby-bls script and obsoletes grubby + * Fri Jul 13 2018 Fedora Release Engineering - 8.40-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild From 214bb840df1b638dc1167d9854a1b660522b22c8 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 10 Jul 2018 13:11:43 -0400 Subject: [PATCH 009/132] Move grubby-bls to grubby and obsolete the old grubby package Signed-off-by: Peter Jones --- 0004-Honor-sbindir.patch | 36 ++++++++++++++++++++++++++++++++++++ grubby.spec | 29 ++++++++++++----------------- 2 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 0004-Honor-sbindir.patch diff --git a/0004-Honor-sbindir.patch b/0004-Honor-sbindir.patch new file mode 100644 index 0000000..5a2c5cf --- /dev/null +++ b/0004-Honor-sbindir.patch @@ -0,0 +1,36 @@ +From a56df998177574ef2db332220c15f11bccd98f7e Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 18 Jul 2018 13:41:02 -0400 +Subject: [PATCH] Honor sbindir + +Signed-off-by: Peter Jones +--- + Makefile | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Makefile b/Makefile +index ac144046133..2b18dd6404b 100644 +--- a/Makefile ++++ b/Makefile +@@ -42,14 +42,14 @@ test: all + @./test.sh + + install: all +- mkdir -p $(DESTDIR)$(PREFIX)/sbin ++ mkdir -p $(DESTDIR)$(PREFIX)$(sbindir) + mkdir -p $(DESTDIR)/$(mandir)/man8 +- install -m 755 new-kernel-pkg $(DESTDIR)$(PREFIX)/sbin ++ install -m 755 new-kernel-pkg $(DESTDIR)$(PREFIX)$(sbindir) + install -m 644 new-kernel-pkg.8 $(DESTDIR)/$(mandir)/man8 +- install -m 755 installkernel $(DESTDIR)$(PREFIX)/sbin ++ install -m 755 installkernel $(DESTDIR)$(PREFIX)$(sbindir) + install -m 644 installkernel.8 $(DESTDIR)/$(mandir)/man8 + if [ -f grubby ]; then \ +- install -m 755 grubby $(DESTDIR)$(PREFIX)/sbin ; \ ++ install -m 755 grubby $(DESTDIR)$(PREFIX)$(sbindir) ; \ + install -m 644 grubby.8 $(DESTDIR)/$(mandir)/man8 ; \ + fi + +-- +2.17.1 + diff --git a/grubby.spec b/grubby.spec index e623107..d202663 100644 --- a/grubby.spec +++ b/grubby.spec @@ -4,6 +4,9 @@ Release: 15%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby +Obsoletes: %{name} <= 8.40-14 +Obsoletes: %{name}-bls <= 8.40-14 + # we only pull git snaps at the moment # git clone git@github.com:rhinstaller/grubby.git # git archive --format=tar --prefix=grubby-%%{version}/ HEAD |bzip2 > grubby-%%{version}.tar.bz2 @@ -15,6 +18,7 @@ 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 BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git-core @@ -59,30 +63,21 @@ make test %endif %install -make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} +make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} -rm %{buildroot}/sbin/installkernel -rm %{buildroot}/sbin/new-kernel-pkg -cp %{SOURCE1} %{buildroot}/sbin/grubby +rm %{buildroot}%{_sbindir}/installkernel +rm %{buildroot}%{_sbindir}/new-kernel-pkg +cp %{SOURCE1} %{buildroot}%{_sbindir}/grubby -%package bls -Summary: Command line tool for updating BootLoaderSpec files -Obsoletes: %{name} < 8.40-15 -BuildArch: noarch - -%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 bls +%files %{!?_licensedir:%global license %%doc} %license COPYING -/sbin/grubby +%{_sbindir}/grubby %{_mandir}/man8/*.8* %changelog -* Fri Jul 13 2018 Javier Martinez Canillas - 8.40-15 -- Add a grubby-bls package that contains grubby-bls script and obsoletes grubby +* Wed Jul 18 2018 Peter Jones - 8.40-15 +- Move grubby-bls to grubby and obsolete the old grubby package * Fri Jul 13 2018 Fedora Release Engineering - 8.40-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild From 87beb89e754e744ca850e34123585148920aae53 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 10 Jul 2018 13:11:43 -0400 Subject: [PATCH 010/132] Make this like the f28 package. We need to cary this in f29 until we have the anaconda patches in and get grubby out of the default install, so we'll have BLS configs and not need grubby to update them. Signed-off-by: Peter Jones --- .gitignore | 2 ++ grubby.in | 8 ++++++++ grubby.spec | 40 +++++++++++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 grubby.in diff --git a/.gitignore b/.gitignore index 7050abc..5e9e976 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ grubby-*.tar.bz2 clog *.rpm /8.40-1.tar.gz +.build*log +grubby-*/ diff --git a/grubby.in b/grubby.in new file mode 100644 index 0000000..f0036e9 --- /dev/null +++ b/grubby.in @@ -0,0 +1,8 @@ +#!/bin/bash +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 diff --git a/grubby.spec b/grubby.spec index d202663..3a4f7d0 100644 --- a/grubby.spec +++ b/grubby.spec @@ -4,15 +4,13 @@ Release: 15%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby -Obsoletes: %{name} <= 8.40-14 -Obsoletes: %{name}-bls <= 8.40-14 - # we only pull git snaps at the moment # git clone git@github.com:rhinstaller/grubby.git # git archive --format=tar --prefix=grubby-%%{version}/ HEAD |bzip2 > grubby-%%{version}.tar.bz2 # Source0: %%{name}-%%{version}.tar.bz2 Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz Source1: grubby-bls +Source2: grubby.in Patch1: drop-uboot-uImage-creation.patch Patch2: 0001-Change-return-type-in-getRootSpecifier.patch Patch3: 0002-Add-btrfs-subvolume-support-for-grub2.patch @@ -20,8 +18,9 @@ Patch4: 0003-Add-tests-for-btrfs-support.patch Patch5: 0004-Use-system-LDFLAGS.patch Patch6: 0004-Honor-sbindir.patch +BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel -BuildRequires: libblkid-devel git-core +BuildRequires: libblkid-devel git-core sed # for make test / getopt: BuildRequires: util-linux-ng %ifarch aarch64 i686 x86_64 %{power64} @@ -65,19 +64,42 @@ make test %install make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} -rm %{buildroot}%{_sbindir}/installkernel -rm %{buildroot}%{_sbindir}/new-kernel-pkg -cp %{SOURCE1} %{buildroot}%{_sbindir}/grubby +mkdir -p %{buildroot}%{_libexecdir}/grubby/ %{buildroot}%{_sbindir}/ +mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby +cp -v %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/ +sed -e "s,@@LIBEXECDIR@@,%{_libexecdir},g" %{SOURCE2} \ + > %{buildroot}%{_sbindir}/grubby + +%package bls +Summary: Command line tool for updating BootLoaderSpec files +Conflicts: %{name} <= 8.40-13 +BuildArch: noarch + +%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 +%{_libexecdir}/grubby/grubby +%{_sbindir}/grubby +%{_sbindir}/installkernel +%{_sbindir}/new-kernel-pkg +%{_mandir}/man8/*.8* + +%files bls +%{!?_licensedir:%global license %%doc} +%license COPYING +%dir %{_libexecdir}/grubby +%{_libexecdir}/grubby/grubby-bls %{_sbindir}/grubby %{_mandir}/man8/*.8* %changelog -* Wed Jul 18 2018 Peter Jones - 8.40-15 -- Move grubby-bls to grubby and obsolete the old grubby package +* Fri Jul 13 2018 Javier Martinez Canillas - 8.40-15 +- Add a grubby-bls package that conflicts with grubby * Fri Jul 13 2018 Fedora Release Engineering - 8.40-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild From 1f933303c9ce89c237b58ccc4ddb698308115bd7 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 24 Jul 2018 13:44:00 -0400 Subject: [PATCH 011/132] Fix permissions on /usr/sbin/grubby Signed-off-by: Peter Jones --- grubby.spec | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/grubby.spec b/grubby.spec index 3a4f7d0..4849d61 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 15%{?dist} +Release: 16%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -83,21 +83,24 @@ meant to only be used for legacy compatibility users with existing grubby users. %{!?_licensedir:%global license %%doc} %license COPYING %dir %{_libexecdir}/grubby -%{_libexecdir}/grubby/grubby -%{_sbindir}/grubby -%{_sbindir}/installkernel -%{_sbindir}/new-kernel-pkg +%attr(0755,root,root) %{_libexecdir}/grubby/grubby +%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 -%{_libexecdir}/grubby/grubby-bls -%{_sbindir}/grubby +%attr(0755,root,root) %{_libexecdir}/grubby/grubby-bls +%attr(0755,root,root) %{_sbindir}/grubby %{_mandir}/man8/*.8* %changelog +* Tue Jul 24 2018 Peter Jones - 8.40-16 +- Fix permissions on /usr/sbin/grubby + * Fri Jul 13 2018 Javier Martinez Canillas - 8.40-15 - Add a grubby-bls package that conflicts with grubby From 5e1de1e87d76b37c4acd0ba4102103ef74e3732f Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 25 Jul 2018 01:27:02 +0200 Subject: [PATCH 012/132] Fix grubby wrapper paths Resolves: rhbz#1607981 Signed-off-by: Javier Martinez Canillas --- grubby.spec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index 4849d61..99a010a 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 16%{?dist} +Release: 17%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -67,7 +67,7 @@ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} mkdir -p %{buildroot}%{_libexecdir}/grubby/ %{buildroot}%{_sbindir}/ mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby cp -v %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/ -sed -e "s,@@LIBEXECDIR@@,%{_libexecdir},g" %{SOURCE2} \ +sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \ > %{buildroot}%{_sbindir}/grubby %package bls @@ -98,6 +98,10 @@ meant to only be used for legacy compatibility users with existing grubby users. %{_mandir}/man8/*.8* %changelog +* Tue Jul 24 2018 Javier Martinez Canillas - 8.40-17 +- Fix grubby wrapper paths + Resolves: rhbz#1607981 + * Tue Jul 24 2018 Peter Jones - 8.40-16 - Fix permissions on /usr/sbin/grubby From 6a009b55ac7f453fd50feef38bfd628501c53585 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 6 Aug 2018 13:34:28 -0400 Subject: [PATCH 013/132] Make installkernel to use kernel-install scripts on BLS configuration Signed-off-by: Javier Martinez Canillas --- 0005-installkernel-use-kernel-install.patch | 48 +++++++++++++++++++++ grubby.spec | 16 +++++-- installkernel.in | 8 ++++ 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 0005-installkernel-use-kernel-install.patch create mode 100644 installkernel.in diff --git a/0005-installkernel-use-kernel-install.patch b/0005-installkernel-use-kernel-install.patch new file mode 100644 index 0000000..2ec577d --- /dev/null +++ b/0005-installkernel-use-kernel-install.patch @@ -0,0 +1,48 @@ +From f93a35be5bdec17044dd2a17980689d3cbf73d58 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 31 Jul 2018 17:43:53 +0200 +Subject: [PATCH] Make installkernel to use kernel-install scripts on BLS + configuration + +The kernel make install target executes the arch/$ARCH/boot/install.sh +that in turns executes the distro specific installkernel script. This +script always uses new-kernel-pkg to install the kernel images. + +But on a BootLoaderSpec setup, the kernel-install scripts must be used +instead. Check if the system uses a BLS setup, and call kernel-install +add in that case instead of new-kernel-pkg. + +Reported-by: Hans de Goede +Signed-off-by: Javier Martinez Canillas +--- + installkernel | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/installkernel b/installkernel +index b887929c179..68dcfac16d2 100755 +--- a/installkernel ++++ b/installkernel +@@ -20,6 +20,8 @@ + # Author(s): tyson@rwii.com + # + ++[[ -f /etc/default/grub ]] && . /etc/default/grub ++ + usage() { + echo "Usage: `basename $0` " >&2 + exit 1 +@@ -77,6 +79,11 @@ 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 [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] || [ ! -f /sbin/new-kernel-pkg ]; then ++ kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION ++ exit $? ++fi ++ + if [ -n "$cfgLoader" ] && [ -x /sbin/new-kernel-pkg ]; then + if [ -n "$(which dracut 2>/dev/null)" ]; then + new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install --kernel-name $KERNEL_NAME $KERNEL_VERSION +-- +2.17.1 + diff --git a/grubby.spec b/grubby.spec index 99a010a..673301b 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 17%{?dist} +Release: 18%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -11,16 +11,18 @@ URL: https://github.com/rhinstaller/grubby 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 BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel -BuildRequires: libblkid-devel git-core sed +BuildRequires: libblkid-devel git-core sed make # for make test / getopt: BuildRequires: util-linux-ng %ifarch aarch64 i686 x86_64 %{power64} @@ -64,11 +66,14 @@ make test %install make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} -mkdir -p %{buildroot}%{_libexecdir}/grubby/ %{buildroot}%{_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 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 %package bls Summary: Command line tool for updating BootLoaderSpec files @@ -84,6 +89,8 @@ meant to only be used for legacy compatibility users with existing grubby users. %license COPYING %dir %{_libexecdir}/grubby %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 @@ -98,6 +105,9 @@ meant to only be used for legacy compatibility users with existing grubby users. %{_mandir}/man8/*.8* %changelog +* Fri Aug 10 2018 Javier Martinez Canillas - 8.40-18 +- Make installkernel to use kernel-install scripts on BLS configuration + * Tue Jul 24 2018 Javier Martinez Canillas - 8.40-17 - Fix grubby wrapper paths Resolves: rhbz#1607981 diff --git a/installkernel.in b/installkernel.in new file mode 100644 index 0000000..87b81ee --- /dev/null +++ b/installkernel.in @@ -0,0 +1,8 @@ +#!/bin/bash +if [[ -x @@LIBEXECDIR@@/installkernel ]] ; then + exec @@LIBEXECDIR@@/installkernel "${@}" +elif [[ -x @@LIBEXECDIR@@/installkernel-bls ]] ; then + exec @@LIBEXECDIR@@/installkernel-bls "${@}" +fi +echo "installkernel is not installed correctly." >>/dev/stderr +exit 1 From c8647003fc319d766cc26b04bd3a61d57b037f10 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 23 Oct 2018 14:27:58 +0200 Subject: [PATCH 014/132] Provide the correct installkenrel and grubby-bls packaging for blscfg Resolves: rhbz#1619344 Signed-off-by: Peter Jones --- .gitignore | 6 +++--- grubby.spec | 47 ++++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 5e9e976..0449688 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -grubby-*.tar.bz2 +*.tar.bz2 +*.tar.gz clog *.rpm -/8.40-1.tar.gz .build*log -grubby-*/ +*/ diff --git a/grubby.spec b/grubby.spec index 673301b..8d1cd61 100644 --- a/grubby.spec +++ b/grubby.spec @@ -35,11 +35,9 @@ Requires: s390utils-base %endif %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. +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. %global debug_package %{nil} @@ -75,34 +73,41 @@ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \ > %{buildroot}%{_sbindir}/installkernel -%package bls -Summary: Command line tool for updating BootLoaderSpec files +%package deprecated +Summary: Legacy command line tool for updating bootloader configs Conflicts: %{name} <= 8.40-13 -BuildArch: noarch -%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. +%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) %{_sbindir}/grubby +%attr(0755,root,root) %{_sbindir}/installkernel +%{_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 * Fri Aug 10 2018 Javier Martinez Canillas - 8.40-18 From 656faab212e0a8577ec0820997e00582db614f70 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 23 Oct 2018 14:47:22 +0200 Subject: [PATCH 015/132] Re-enable debuginfo generation. So what's happened here is this: - we planned on not having the grubby binary in this package at all anymore - when we did test builds like that, find-debuginfo.sh broke - since it was completely inconsequential, we disabled building debuginfo - then we re-thought the package layout, and decided to build that binary anyway, but forgot to turn debuginfo back on - also we build the binary as -fPIE, which file(1) says is a "shared object" - brp-strip does not act on shared objects, so it didn't strip As a result, rpmdiff noticed our binary was not stripped. This patch re-enables debuginfo, which will cause our binary to get stripped, as well as to have the correct debuginfo packages in the output. Related: rhbz#1619344 Signed-off-by: Peter Jones --- grubby.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index 8d1cd61..cbd3860 100644 --- a/grubby.spec +++ b/grubby.spec @@ -39,8 +39,6 @@ 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. -%global debug_package %{nil} - %prep %setup -q -n grubby-%{version}-1 From e4c6ac24673a045f955cc5b5a2a0f3a8e10129b8 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 23 Oct 2018 14:52:47 +0200 Subject: [PATCH 016/132] Install installkernel-bls here as well, not just in the grub2 package, since s390x doesn't have grubby packages. Related: rhbz#1619344 Signed-off-by: Peter Jones --- grubby.spec | 3 ++ installkernel-bls | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 installkernel-bls diff --git a/grubby.spec b/grubby.spec index cbd3860..927385f 100644 --- a/grubby.spec +++ b/grubby.spec @@ -12,6 +12,7 @@ Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz Source1: grubby-bls Source2: grubby.in Source3: installkernel.in +Source4: installkernel-bls Patch1: drop-uboot-uImage-creation.patch Patch2: 0001-Change-return-type-in-getRootSpecifier.patch Patch3: 0002-Add-btrfs-subvolume-support-for-grub2.patch @@ -66,6 +67,7 @@ mkdir -p %{buildroot}%{_libexecdir}/{grubby,installkernel}/ %{buildroot}%{_sbind mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby mv -v %{buildroot}%{_sbindir}/installkernel %{buildroot}%{_libexecdir}/installkernel/installkernel cp -v %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/ +cp -v %{SOURCE4} %{buildroot}%{_libexecdir}/installkernel/ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \ > %{buildroot}%{_sbindir}/grubby sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \ @@ -92,6 +94,7 @@ current boot environment. %dir %{_libexecdir}/installkernel %attr(0755,root,root) %{_libexecdir}/grubby/grubby-bls %attr(0755,root,root) %{_sbindir}/grubby +%attr(0755,root,root) %{_libexecdir}/installkernel/installkernel-bls %attr(0755,root,root) %{_sbindir}/installkernel %{_mandir}/man8/[gi]*.8* diff --git a/installkernel-bls b/installkernel-bls new file mode 100755 index 0000000..d66c44a --- /dev/null +++ b/installkernel-bls @@ -0,0 +1,85 @@ +#! /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 . +# +# Author(s): tyson@rwii.com +# + +[[ -f /etc/default/grub ]] && . /etc/default/grub + +usage() { + echo "Usage: `basename $0` " >&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" ] && [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION + exit $? +fi From b8c8cdcf6c996a5255b768cf2033b4ee8dcf3701 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 5 Oct 2018 12:13:49 +0200 Subject: [PATCH 017/132] Make grubby-bls execute grub2-mkconfig on ppc64 When booting an ppc64 machine on bare-metal (PowerNV) the OPAL firmware interface is used. The firmware contains the Petitboot boot-loader that can be used to parse the BootLoaderSpec (BLS) snippets in a BLS setup. But machines could have an older version of Petitboot that doesn't have BLS support, so on ppc64 machines can't be assumed that just modifying the BLS files is enough for those changes to be reflected in the boot menu. Instead, grub2-mkconfig is executed so the BLS can be parsed and produce a grub config file that can be used by any Petitboot version. Resolves: rhbz#1636039 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/grubby-bls b/grubby-bls index d94415f..4a83cd6 100755 --- a/grubby-bls +++ b/grubby-bls @@ -234,6 +234,8 @@ remove_bls_fragment() { done get_bls_values + + update_grubcfg } add_bls_fragment() { @@ -308,6 +310,8 @@ add_bls_fragment() { set_default_bls "TITLE=${title}" fi + update_grubcfg + exit 0 } @@ -357,6 +361,8 @@ update_bls_fragment() { set_bls_value "${bls_file[$i]}" "initrd" "${initrd}" fi done + + update_grubcfg } set_default_bls() { @@ -397,6 +403,13 @@ remove_var_prefix() { fi } +update_grubcfg() +{ + if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then + grub2-mkconfig -o /boot/grub2/grub.cfg >& /dev/null + fi +} + print_usage() { cat < Date: Thu, 4 Oct 2018 17:35:33 +0200 Subject: [PATCH 018/132] grubby-bls should only check if kernel exists and not if was installed When a new BLS entry is added, the script checks if the kernel image exists and also if it was installed from a rpm package. But the latter isn't really needed, it should be valid to just copy a kernel image and add a BLS entry. Resolves: rhbz#1634740 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 4a83cd6..9cce5c4 100755 --- a/grubby-bls +++ b/grubby-bls @@ -159,7 +159,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 @@ -247,11 +247,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 From 28952a66c871a5cf71cede8c37827a718aa6a52e Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 4 Oct 2018 17:54:42 +0200 Subject: [PATCH 019/132] Use ! instead of , as sed delimiter in grubby-bls script The script uses sed to modify the options field in the BLS entries, but it is using a ',' character as the sed delimiter. It's total valid to have a kernel command line parameter that contains that character, for example: $ grubby --add-kernel=/boot/vmlinuz --args="console=ttyS0,115200n81" \ --initrd=/boot/initrd.img --make-default --title=install sed: -e expression #1, char 42: unknown option to `s' Fix this by using a different delimiter that won't be present in a cmdline. Resolves: rhbz#1634744 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grubby-bls b/grubby-bls index 9cce5c4..c992e2e 100755 --- a/grubby-bls +++ b/grubby-bls @@ -56,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() { @@ -64,7 +64,7 @@ set_bls_value() { local key="$1" && shift local value="$1" && shift - sed -i -e "s,^${key}.*,${key} ${value}," "${bls}" + sed -i -e "s!^${key}.*!${key} ${value}!" "${bls}" } append_bls_value() { @@ -322,7 +322,7 @@ update_args() { local add_args=($1) && shift for arg in ${remove_args[*]}; do - args="$(echo $args | sed -e "s,$arg[^ ]*,,")" + args="$(echo $args | sed -e "s!$arg[^ ]*!!")" done for arg in ${add_args[*]}; do @@ -331,7 +331,7 @@ update_args() { key=${arg%%=$value} exist=$(echo $args | grep "${key}=") if [[ -n $exist ]]; then - args="$(echo $args | sed -e "s,$key=[^ ]*,$key=$value,")" + args="$(echo $args | sed -e "s!$key=[^ ]*!$key=$value!")" else args="$args $key=$value" fi From 33ab171b289002c472b4461c03f8fe33bb0d7779 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 5 Oct 2018 14:31:13 +0200 Subject: [PATCH 020/132] Print information about the entry set as default by grubby-bls script This information can be useful for users to know what's the BLS entry that was set as the default. Resolves: rhbz#1636180 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grubby-bls b/grubby-bls index c992e2e..28da698 100755 --- a/grubby-bls +++ b/grubby-bls @@ -48,6 +48,10 @@ print_error() { exit 1 } +print_info() { + echo "$1" >&2 +} + if [[ ${#} = 0 ]]; then print_error "no action specified" fi @@ -380,6 +384,8 @@ set_default_bls() { echo "default=${default}" >> "${zipl_config}" fi fi + + print_info "The default is ${bls_file[$index]} with index $index and kernel ${bls_linux[$index]}" } remove_var_prefix() { From 4aa091811b4a110c9eb1d9611219347f44ed460e Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 23 Oct 2018 15:08:30 +0200 Subject: [PATCH 021/132] grubby-bls: make "id" be the filename, and include it in --info=ALL Related: rhbz#1638103 Signed-off-by: Peter Jones --- grubby-bls | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 28da698..0d65e29 100755 --- a/grubby-bls +++ b/grubby-bls @@ -89,7 +89,8 @@ get_bls_values() { 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)" + bls_id[$count]="${bls%.conf}" + bls_id[$count]="${bls_id[$count]##*/}" count=$((count+1)) done @@ -193,6 +194,7 @@ display_info_values() { echo "args=\"${bls_options[$i]}\"" echo "initrd=${bls_initrd[$i]}" echo "title=${bls_title[$i]}" + echo "id=\"${bls_id[$i]}\"" done exit 0 } From 0f5ce5a543498f0066e6bbedef5254ac485c91e6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 15 Oct 2018 12:42:51 -0400 Subject: [PATCH 022/132] Rename patches This is just "git format-patch -7" to normalize the names. Related: rhbz#1638103 --- ...remove-the-old-crufty-u-boot-support.patch | 21 +++--- ...ange-return-type-in-getRootSpecifier.patch | 8 +-- ...dd-btrfs-subvolume-support-for-grub2.patch | 10 +-- ... => 0004-Add-tests-for-btrfs-support.patch | 70 +++++++++---------- ...AGS.patch => 0005-Use-system-LDFLAGS.patch | 8 +-- ...-sbindir.patch => 0006-Honor-sbindir.patch | 6 +- ...el-to-use-kernel-install-scripts-on-.patch | 4 +- grubby.spec | 14 ++-- 8 files changed, 72 insertions(+), 69 deletions(-) rename drop-uboot-uImage-creation.patch => 0001-remove-the-old-crufty-u-boot-support.patch (95%) rename 0001-Change-return-type-in-getRootSpecifier.patch => 0002-Change-return-type-in-getRootSpecifier.patch (96%) rename 0002-Add-btrfs-subvolume-support-for-grub2.patch => 0003-Add-btrfs-subvolume-support-for-grub2.patch (96%) rename 0003-Add-tests-for-btrfs-support.patch => 0004-Add-tests-for-btrfs-support.patch (98%) rename 0004-Use-system-LDFLAGS.patch => 0005-Use-system-LDFLAGS.patch (78%) rename 0004-Honor-sbindir.patch => 0006-Honor-sbindir.patch (88%) rename 0005-installkernel-use-kernel-install.patch => 0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch (92%) diff --git a/drop-uboot-uImage-creation.patch b/0001-remove-the-old-crufty-u-boot-support.patch similarity index 95% rename from drop-uboot-uImage-creation.patch rename to 0001-remove-the-old-crufty-u-boot-support.patch index ee611f9..f6f5e97 100644 --- a/drop-uboot-uImage-creation.patch +++ b/0001-remove-the-old-crufty-u-boot-support.patch @@ -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 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 --- - 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 + diff --git a/0001-Change-return-type-in-getRootSpecifier.patch b/0002-Change-return-type-in-getRootSpecifier.patch similarity index 96% rename from 0001-Change-return-type-in-getRootSpecifier.patch rename to 0002-Change-return-type-in-getRootSpecifier.patch index 0a6808b..f2a1978 100644 --- a/0001-Change-return-type-in-getRootSpecifier.patch +++ b/0002-Change-return-type-in-getRootSpecifier.patch @@ -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 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 diff --git a/0002-Add-btrfs-subvolume-support-for-grub2.patch b/0003-Add-btrfs-subvolume-support-for-grub2.patch similarity index 96% rename from 0002-Add-btrfs-subvolume-support-for-grub2.patch rename to 0003-Add-btrfs-subvolume-support-for-grub2.patch index d460c5d..583c5de 100644 --- a/0002-Add-btrfs-subvolume-support-for-grub2.patch +++ b/0003-Add-btrfs-subvolume-support-for-grub2.patch @@ -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 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 diff --git a/0003-Add-tests-for-btrfs-support.patch b/0004-Add-tests-for-btrfs-support.patch similarity index 98% rename from 0003-Add-tests-for-btrfs-support.patch rename to 0004-Add-tests-for-btrfs-support.patch index d274bb9..f4b8ec8 100644 --- a/0003-Add-tests-for-btrfs-support.patch +++ b/0004-Add-tests-for-btrfs-support.patch @@ -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 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 diff --git a/0004-Use-system-LDFLAGS.patch b/0005-Use-system-LDFLAGS.patch similarity index 78% rename from 0004-Use-system-LDFLAGS.patch rename to 0005-Use-system-LDFLAGS.patch index f186b98..17954c4 100644 --- a/0004-Use-system-LDFLAGS.patch +++ b/0005-Use-system-LDFLAGS.patch @@ -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 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 diff --git a/0004-Honor-sbindir.patch b/0006-Honor-sbindir.patch similarity index 88% rename from 0004-Honor-sbindir.patch rename to 0006-Honor-sbindir.patch index 5a2c5cf..0d947cc 100644 --- a/0004-Honor-sbindir.patch +++ b/0006-Honor-sbindir.patch @@ -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 Date: Wed, 18 Jul 2018 13:41:02 -0400 -Subject: [PATCH] Honor sbindir +Subject: [PATCH 6/8] Honor sbindir Signed-off-by: Peter Jones --- @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 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 diff --git a/0005-installkernel-use-kernel-install.patch b/0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch similarity index 92% rename from 0005-installkernel-use-kernel-install.patch rename to 0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch index 2ec577d..727cab6 100644 --- a/0005-installkernel-use-kernel-install.patch +++ b/0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch @@ -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 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 diff --git a/grubby.spec b/grubby.spec index 927385f..9df4e4a 100644 --- a/grubby.spec +++ b/grubby.spec @@ -13,13 +13,13 @@ Source1: grubby-bls Source2: grubby.in Source3: installkernel.in Source4: installkernel-bls -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 +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 BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel From cf425061aaa266c26163307636618ff086833ed5 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 15 Oct 2018 14:56:02 +0200 Subject: [PATCH 023/132] grubby-bls: set saved_entry to id instead of title on set-default The grubby wrapper sets the saved_entry in grubenv to the entry title field since that's done by grubby. But for BLS the id is the filename without the .conf extension, this saved_entry is set to this when a new kernel is installed. So for consistency also use the entry id for the --set-default option. Related: rhbz#1638103 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 0d65e29..99a57bd 100755 --- a/grubby-bls +++ b/grubby-bls @@ -376,7 +376,7 @@ set_default_bls() { local index=($(param_to_indexes "$1")) 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 current="$(grep '^default=' ${zipl_config} | sed -e 's/^default=//')" From b40ea5be1811e801a36ac9241df876f0ca723fa7 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 15 Oct 2018 15:25:43 +0200 Subject: [PATCH 024/132] grubby-bls: check if entry exists before attempting to print its info The grubby --info option didn't check if an entry existed for a kernel and printed wrong information about it. Fix this and also for --update-kernel and --set-default options that have the same issue. Resolves: rhbz#1634712 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grubby-bls b/grubby-bls index 99a57bd..c9c608b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -188,6 +188,10 @@ param_to_indexes() { display_info_values() { local indexes=($(param_to_indexes "$1")) + if [[ $indexes = "-1" ]]; then + print_error "The param $1 is incorrect" + fi + for i in ${indexes[*]}; do echo "index=$i" echo "kernel=${bls_linux[$i]}" @@ -358,6 +362,10 @@ update_bls_fragment() { local add_args=$1 && shift local initrd=$1 && shift + if [[ $indexes = "-1" ]]; then + print_error "The param $1 is incorrect" + 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}")" @@ -375,6 +383,10 @@ update_bls_fragment() { 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]}" else From a5e56a6e7da34840a7ff64de1a16cef383c1ede8 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 23 Oct 2018 15:38:55 +0200 Subject: [PATCH 025/132] Make grubby-bls sort everything correctly, including spaces. Related: rhbz#1638103 --- 0008-Add-usr-libexec-rpm-sort.patch | 418 ++++++++++++++++++++++++++++ grubby-bls | 39 ++- grubby.spec | 6 +- 3 files changed, 448 insertions(+), 15 deletions(-) create mode 100644 0008-Add-usr-libexec-rpm-sort.patch diff --git a/0008-Add-usr-libexec-rpm-sort.patch b/0008-Add-usr-libexec-rpm-sort.patch new file mode 100644 index 0000000..b3e5faa --- /dev/null +++ b/0008-Add-usr-libexec-rpm-sort.patch @@ -0,0 +1,418 @@ +From b8a581014170c6a9bb8ffb799090401a57a4bbe6 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 12 Oct 2018 16:39:37 -0400 +Subject: [PATCH 8/8] Add /usr/libexec/rpm-sort + +Signed-off-by: Peter Jones +--- + 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 ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++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 + diff --git a/grubby-bls b/grubby-bls index c9c608b..6fa3fe4 100755 --- a/grubby-bls +++ b/grubby-bls @@ -76,21 +76,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]="${bls%.conf}" - bls_id[$count]="${bls_id[$count]##*/}" + 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 | 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 @@ -194,10 +205,10 @@ display_info_values() { for i in ${indexes[*]}; do echo "index=$i" - echo "kernel=${bls_linux[$i]}" + echo "kernel=\"${bls_linux[$i]}\"" echo "args=\"${bls_options[$i]}\"" - echo "initrd=${bls_initrd[$i]}" - echo "title=${bls_title[$i]}" + echo "initrd=\"${bls_initrd[$i]}\"" + echo "title=\"${bls_title[$i]}\"" echo "id=\"${bls_id[$i]}\"" done exit 0 @@ -239,7 +250,7 @@ remove_bls_fragment() { print_error "The param $1 is incorrect" fi - for i in ${indexes[*]}; do + for i in "${indexes[@]}"; do rm -f "${bls_file[$i]}" done diff --git a/grubby.spec b/grubby.spec index 9df4e4a..45d41c8 100644 --- a/grubby.spec +++ b/grubby.spec @@ -20,12 +20,14 @@ 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 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 @@ -34,6 +36,7 @@ Requires: grub2-tools %ifarch s390 s390x Requires: s390utils-base %endif +Requires: findutils %description This package provides a grubby compatibility script that manages @@ -61,7 +64,7 @@ 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 @@ -93,6 +96,7 @@ current boot environment. %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 From 84881fb39693dfaf400997f442ee2d39ab90942c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 16 Oct 2018 20:06:33 +0200 Subject: [PATCH 026/132] grubby-bls: make a copy of the cmdline if is modified for an entry The BLS entries use a global kernel command line parameters that's set as kernelopts variable in the grubenv file. But users may want to have custom parameters for some entries, so make a copy of the current kernelopts and set the "options" field value to the modified parameters. Resolves: rhbz#1629054 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 6fa3fe4..8708997 100755 --- a/grubby-bls +++ b/grubby-bls @@ -367,6 +367,17 @@ update_args() { echo ${args} } +get_bls_args() { + if [[ $bootloader = "grub2" && "${bls_options[$i]}" = "\$kernelopts" ]]; then + old_args=$(grub2-editenv list | grep kernelopts) + old_args="${old_args##kernelopts=}" + else + old_args="${bls_options[$i]}" + fi + + echo ${old_args} +} + update_bls_fragment() { local indexes=($(param_to_indexes "$1")) && shift local remove_args=$1 && shift @@ -379,7 +390,8 @@ update_bls_fragment() { 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}")" + local old_args="$(get_bls_args "$i")" + local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")" set_bls_value "${bls_file[$i]}" "options" "${new_args}" fi From 7d53b5e0a6615b5e0ab623c82ac0ae803a112f93 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 17 Oct 2018 20:36:08 +0200 Subject: [PATCH 027/132] grubby-bls: escape delimiter character before replacing the options field The ! character was used as the delimiter, but this doesn't work when the param uses this character, for example "memmap=1G!1G". Resolves: rhbz#1640017 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/grubby-bls b/grubby-bls index 8708997..6e0acb6 100755 --- a/grubby-bls +++ b/grubby-bls @@ -68,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() { @@ -343,7 +344,8 @@ 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') + args="$(echo $args | sed -e "s/$arg[^ ]*//")" done for arg in ${add_args[*]}; do @@ -352,7 +354,8 @@ update_args() { key=${arg%%=$value} exist=$(echo $args | grep "${key}=") if [[ -n $exist ]]; then - args="$(echo $args | sed -e "s!$key=[^ ]*!$key=$value!")" + value=$(echo $value | sed -e 's/\//\\\//g') + args="$(echo $args | sed -e "s/$key=[^ ]*/$key=$value/")" else args="$args $key=$value" fi From db3ffac800448ba587ce64ad60f30ad19b175fa4 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 19 Oct 2018 18:13:38 +0200 Subject: [PATCH 028/132] grubby-bls: use id instead of title to get the default entry The wrapper is using the title before to store the default entry, but we are now using the entry id for grub2, so make the wrapper query the id. Resolves: rhbz#1638103 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 6e0acb6..5ac7c6a 100755 --- a/grubby-bls +++ b/grubby-bls @@ -127,13 +127,13 @@ get_default_index() { # GRUB2 and zipl use different fields to set the default entry if [[ $bootloader = "grub2" ]]; then - title="$default" + id="$default" else version="$default" fi for i in ${!bls_file[@]}; do - if [[ $title = ${bls_title[$i]} || $version = ${bls_version[$i]} || + if [[ $title = ${bls_title[$i]} || $id = ${bls_id[$i]} || $i -eq $index ]]; then echo $i return From 1c345197a4eec04107aa61737a9a1254a97cd9a1 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 19 Oct 2018 20:51:29 +0200 Subject: [PATCH 029/132] grubby-bls: use ~debug instead of -debug as suffix to sort correctly For the debug BLS entries a -debug suffix was added so they are sorted after the kernel entries, but that only works with version sort and not rpm sort. So instead use ~debug prefix so rpm sort algorithm could sort it correctly. Related: rhbz#1638103 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/grubby-bls b/grubby-bls index 5ac7c6a..2eb27bb 100755 --- a/grubby-bls +++ b/grubby-bls @@ -317,13 +317,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 From 9a80bb6f8e2173b21bac55224e88b27f3f2b43c7 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 2 Nov 2018 00:51:22 +0100 Subject: [PATCH 030/132] grubby-bls: allow to add many BLS entries for the same kernel image The BLS files name convention used is ${MACHINE_ID}-${KERNEL_VERSION}.conf but this means that there can only be a single entry for a given kernel. Allow the grubby wrapper to add many entries for the same kernel image, since the old grubby tool was able to do that. To differentiate from the original BLS entry and to specify that it's a customized entry, add a [[:digit:]]~custom suffix after the kernel version number. This will also sort the custom entries before the original entry, that's also what the old grubby tool did. Resolves: rhbz#1634752 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/grubby-bls b/grubby-bls index 2eb27bb..1ad7a38 100755 --- a/grubby-bls +++ b/grubby-bls @@ -260,6 +260,35 @@ remove_bls_fragment() { 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() { local kernel="$1" && shift local title="$1" && shift @@ -288,6 +317,12 @@ 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 [[ -f "${kernel_dir}/bls.conf" ]]; then cp -aT "${kernel_dir}/bls.conf" "${bls_target}" || exit $? From 2ef6823a35f5ef75ee61f34074d2f36782c677d9 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 2 Nov 2018 00:44:51 +0100 Subject: [PATCH 031/132] grubby-bls: fix --default-* options for s390x On s390x the version field is used to set the default BLS entry. Resolves: rhbz#1644608 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 1ad7a38..cf9f593 100755 --- a/grubby-bls +++ b/grubby-bls @@ -133,8 +133,17 @@ get_default_index() { fi for i in ${!bls_file[@]}; do - if [[ $title = ${bls_title[$i]} || $id = ${bls_id[$i]} || - $i -eq $index ]]; then + if [[ $i -eq $index ]]; then + echo $i + return + fi + + if [[ $bootloader = "grub2" && $id = ${bls_id[$i]} ]]; then + echo $i + return + fi + + if [[ $bootloader = "zipl" && $version = ${bls_version[$i]} ]]; then echo $i return fi From 6ed71042bd6e23b9347ae04498795929169ff4fc Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 23 Oct 2018 16:02:50 +0200 Subject: [PATCH 032/132] A lot of BLS fixes - 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 Signed-off-by: Javier Martinez Canillas --- grubby.spec | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/grubby.spec b/grubby.spec index 45d41c8..e75d1d8 100644 --- a/grubby.spec +++ b/grubby.spec @@ -115,6 +115,43 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Oct 23 2018 Javier Martinez Canillas +- 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 + * Fri Aug 10 2018 Javier Martinez Canillas - 8.40-18 - Make installkernel to use kernel-install scripts on BLS configuration From 7babbb04df2c037c58c141e71e01824d246f9432 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 6 Nov 2018 11:47:22 +0100 Subject: [PATCH 033/132] grubby-bls: only compare using relative paths if /boot is a mount point The grub2 bootloader expects the BLS linux and initrd fields values to be set to a relative path to the root of the boot partition and the zipl tool expects these to be an absolute path to the kernel and initramfs images. So the grubby wrapper was removing the prefixes from the kernel and initrd paths before doing any comparision with the BLS fields. But this shouldn't be done if the /boot directory isn't a mount point. Resolves: rhbz#1642078 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- grubby.spec | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index cf9f593..ee28802 100755 --- a/grubby-bls +++ b/grubby-bls @@ -686,7 +686,7 @@ if [[ -n $display_info ]]; then display_info_values "${display_info}" fi -if [[ $bootloader = grub2 ]]; then +if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then remove_var_prefix fi diff --git a/grubby.spec b/grubby.spec index e75d1d8..a5ecffc 100644 --- a/grubby.spec +++ b/grubby.spec @@ -151,6 +151,8 @@ current boot environment. 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 - 8.40-18 - Make installkernel to use kernel-install scripts on BLS configuration From d72135ede950cffddbdf420067ce92551239289c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 6 Nov 2018 15:07:37 +0100 Subject: [PATCH 034/132] Move old grubby and new-kernel-pkg to grubby-deprecated and default to BLS Now that Anaconda defaults to a BootLoaderSpec setup on installation, the the grubby package should also install the grubby BLS wrapper by default. Signed-off-by: Javier Martinez Canillas --- grubby.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index a5ecffc..1b73e0a 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 18%{?dist} +Release: 19%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -115,7 +115,7 @@ current boot environment. %{_mandir}/man8/*.8* %changelog -* Tue Oct 23 2018 Javier Martinez Canillas +* Tue Nov 06 2018 Javier Martinez Canillas - 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) From f9d8ee1b6400945563f63bf88462e4b0abc998b7 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 12 Nov 2018 22:47:30 +0100 Subject: [PATCH 035/132] Switch to a BLS configuration on %%post By default the old grubby tool isn't installed anymore and it's part of the grubby-deprecated package. Instead the grubby wrapper that modifies BLS config files is installed for backward compatiblity with old grubby. So on postinstall the bootloader configuration has to be changed to BLS since non-BLS bootloader configuration won't be updated anymore without the old grubby tool and the new-kernel-pkg script. Signed-off-by: Javier Martinez Canillas --- grubby.spec | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index 1b73e0a..08dcb71 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 19%{?dist} +Release: 20%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -38,6 +38,8 @@ Requires: s390utils-base %endif Requires: findutils +Obsoletes: %{name}-bls + %description This package provides a grubby compatibility script that manages BootLoaderSpec files and is meant to only be used for legacy compatibility @@ -76,9 +78,21 @@ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \ > %{buildroot}%{_sbindir}/installkernel +%post +if [ "$1" = 2 ]; then + arch=$(uname -m) + if [[ $arch == "s390x" ]]; then + command=zipl-switch-to-blscfg + else + command=grub2-switch-to-blscfg + fi + + $command --backup-suffix=.rpmsave &>/dev/null || : +fi + %package deprecated Summary: Legacy command line tool for updating bootloader configs -Conflicts: %{name} <= 8.40-13 +Conflicts: %{name} <= 8.40-18 %description deprecated This package provides deprecated, legacy grubby. This is for temporary @@ -115,6 +129,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Nov 13 2018 Javier Martinez Canillas - 8.40-20 +- Switch to a BLS configuration on %%post + * Tue Nov 06 2018 Javier Martinez Canillas - 8.40-19 - Make the temporary config wrapper be what "grubby" contains, and put traditional grubby in grubby-deprecated (pjones) From 4925c9ded92d4725da2a2d8be8d913427a8cae5e Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 21 Nov 2018 10:43:48 +0100 Subject: [PATCH 036/132] installkernel-bls: remove unnecessary check for GRUB_ENABLE_BLSCFG=true A BLS configuration is the default and in this case the installkernel-bls script is used. For a non-BLS configuration the grubby-deprecated package installs an installkernel that uses the new-kernel-pkg script. So there is no need to check for GRUB_ENABLE_BLSCFG=true. Also, this check is wrong for s390x and was causing the installkernel-bls script to no call kernel-install on this platform. Resolves: rhbz#1647721 Signed-off-by: Javier Martinez Canillas --- installkernel-bls | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/installkernel-bls b/installkernel-bls index d66c44a..f2f607e 100755 --- a/installkernel-bls +++ b/installkernel-bls @@ -20,8 +20,6 @@ # Author(s): tyson@rwii.com # -[[ -f /etc/default/grub ]] && . /etc/default/grub - usage() { echo "Usage: `basename $0` " >&2 exit 1 @@ -79,7 +77,7 @@ 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" ] && [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then +if [ -n "$cfgLoader" ]; then kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION exit $? fi From 791d55400ba8919b84a3e9b43a01c40e240169ba Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 21 Nov 2018 10:44:33 +0100 Subject: [PATCH 037/132] grubby-bls: use title field instead of version for zipl default entry Most bootloaders use the BootLoaderSpec "title" field to name the entries in their boot menu. The zipl bootloader used the "version" field instead, since it was wrongly assumed that the zipl boot menu didn't support names that contained spaces, which are usually present in a BLS "title" field. But this is not the case, names with space characters are supported by the IPL and is just a constraint of the section heading in the zipl.conf file. To be consistent with all the other bootloaders, zipl now uses the "title" field to populate the boot menu entries from BLS files. So change grubby to use the "title" field to set the default entry of the "version" field. Related: rhbz#1645200 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grubby-bls b/grubby-bls index ee28802..71dcb31 100755 --- a/grubby-bls +++ b/grubby-bls @@ -129,7 +129,7 @@ get_default_index() { if [[ $bootloader = "grub2" ]]; then id="$default" else - version="$default" + title="$default" fi for i in ${!bls_file[@]}; do @@ -143,7 +143,7 @@ get_default_index() { return fi - if [[ $bootloader = "zipl" && $version = ${bls_version[$i]} ]]; then + if [[ $bootloader = "zipl" && $title = ${bls_title[$i]} ]]; then echo $i return fi @@ -459,7 +459,7 @@ set_default_bls() { if [[ $bootloader = grub2 ]]; then 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}" From 6cdfe45ecebc63eada09b31d09eb9506db573ffd Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 17 Nov 2018 00:03:02 +0100 Subject: [PATCH 038/132] grubby-bls: print the absolute kernel and initramfs images paths The BLS file "linux" and "initrd" fields expect a relative paths from the root of the partition that contains the kernel and initramfs. The grubby tool was printing the value of thse fields and not their full path. So if there is a partition and /boot is a mount point, he BLS would have: linux /vmlinuz-4.18.0-38.el8.x86_64 initrd /initramfs-4.18.0-38.el8.x86_64.img And grubby would print: kernel="/vmlinuz-4.18.0-38.el8.x86_64" initrd="/initramfs-4.18.0-38.el8.x86_64.img" But the old tool used to print the full paths of the images, so should be: kernel="/boot/vmlinuz-4.18.0-38.el8.x86_64" initrd="/boot/initramfs-4.18.0-38.el8.x86_64.img" Resolves: rhbz#1649778 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/grubby-bls b/grubby-bls index 71dcb31..add7b0a 100755 --- a/grubby-bls +++ b/grubby-bls @@ -206,8 +206,17 @@ param_to_indexes() { echo -n "-1" } +get_prefix() { + if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then + echo "/boot" + else + echo "" + fi +} + display_info_values() { local indexes=($(param_to_indexes "$1")) + local prefix=$(get_prefix) if [[ $indexes = "-1" ]]; then print_error "The param $1 is incorrect" @@ -215,9 +224,9 @@ display_info_values() { for i in ${indexes[*]}; do echo "index=$i" - echo "kernel=\"${bls_linux[$i]}\"" + echo "kernel=\"${prefix}${bls_linux[$i]}\"" echo "args=\"${bls_options[$i]}\"" - echo "initrd=\"${bls_initrd[$i]}\"" + echo "initrd=\"${prefix}${bls_initrd[$i]}\"" echo "title=\"${bls_title[$i]}\"" echo "id=\"${bls_id[$i]}\"" done @@ -231,6 +240,11 @@ mkbls() { local debugname="" local flavor="" + local prefix="" + + if [[ $(get_prefix) = "" ]]; then + prefix="/boot" + fi if [[ $kernelver == *\+* ]] ; then local flavor=-"${kernelver##*+}" @@ -244,7 +258,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 @@ -468,7 +482,7 @@ set_default_bls() { fi fi - print_info "The default is ${bls_file[$index]} with index $index and kernel ${bls_linux[$index]}" + print_info "The default is ${bls_file[$index]} with index $index and kernel $(get_prefix)${bls_linux[$index]}" } remove_var_prefix() { @@ -686,7 +700,7 @@ if [[ -n $display_info ]]; then display_info_values "${display_info}" fi -if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then +if [[ $(get_prefix) == "/boot" ]]; then remove_var_prefix fi From 695377d276cf0990c96d57263c608b97f4fe6644 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 17 Nov 2018 03:35:14 +0100 Subject: [PATCH 039/132] grubby-bls: make info print the root parameter if is present in cmdline The old grubby tool printed the root parameter separated from the other kernel command line arguments. Make the wrapper have the same behaviour. Resolves: rhbz#1649791 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index add7b0a..7b8bae7 100755 --- a/grubby-bls +++ b/grubby-bls @@ -223,9 +223,27 @@ display_info_values() { fi for i in ${indexes[*]}; do + local root="" + local args=${bls_options[$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=\"${bls_options[$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]}\"" From e777519e08a42b479304a651bc9d7765ea6f83b1 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 21 Nov 2018 10:49:56 +0100 Subject: [PATCH 040/132] Another batch of grubby-bls fixes - 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 Signed-off-by: Javier Martinez Canillas --- grubby.spec | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 08dcb71..3031a04 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 20%{?dist} +Release: 21%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -129,6 +129,16 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed Nov 21 2018 Javier Martinez Canillas - 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 - 8.40-20 - Switch to a BLS configuration on %%post From d1dd184403aff92db19c2114cba30746134b8925 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 1 Dec 2018 01:57:07 +0100 Subject: [PATCH 041/132] grubby-bls: also print the absolute path in the --default-kernel option The absolute path to the kernel and initramfs images is printed by the --info option, but it's not printed by the --default-kernel option. Resolves: rhbz#1649778 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 7b8bae7..e0614bd 100755 --- a/grubby-bls +++ b/grubby-bls @@ -151,9 +151,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) From 4b1d63cacdc07b6a8c7c3f65701e1cd7d7262252 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 22 Nov 2018 20:35:13 +0100 Subject: [PATCH 042/132] grubby-bls: allow to specify the same kernel param multiple times The kernel command line can contain parameters that are specified multiple times. This is supported by the old grubby tool but ins't supported by the grubby BLS wrapper. Allow the grubby wrapper to do the same. Resolves: rhbz#1652486 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/grubby-bls b/grubby-bls index e0614bd..c9bf226 100755 --- a/grubby-bls +++ b/grubby-bls @@ -421,27 +421,21 @@ 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[^ ]*//")" + if [[ $arg = *"="* ]]; then + arg=$(echo $arg | sed -e 's/\//\\\//g') + 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 - value=$(echo $value | sed -e 's/\//\\\//g') - 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%=*} + args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")" + done + + for arg in ${add_args[*]}; do + args="$args $arg" done echo ${args} From b84a214b99e1b6c7585e91fb291f15dfb1cd5da1 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 23 Nov 2018 01:22:56 +0100 Subject: [PATCH 043/132] grubby-bls: expand kernel options if these are environment variables The grub2 bootloader allows the BLS snippets fields to contain environment variables instead of constants. This is useful for example to define the kernel command line parameters only once in the grubenv file and set this variable in the BLS snippets. But this can be confusing for users when the information is printed by the grubby script, so expand the variables if they can be looked up in grubenv. Resolves: rhbz#1649785 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index c9bf226..1e6a9e5 100755 --- a/grubby-bls +++ b/grubby-bls @@ -216,6 +216,20 @@ get_prefix() { 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 +} + display_info_values() { local indexes=($(param_to_indexes "$1")) local prefix=$(get_prefix) @@ -226,9 +240,19 @@ display_info_values() { for i in ${indexes[*]}; do local root="" + local value="" local args=${bls_options[$i]} 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 + + local opts=(${args}) + for opt in ${opts[*]}; do if echo $opt | grep -q "^root="; then root="$(echo $opt | sed -e 's/root=//')" @@ -443,7 +467,7 @@ update_args() { get_bls_args() { if [[ $bootloader = "grub2" && "${bls_options[$i]}" = "\$kernelopts" ]]; then - old_args=$(grub2-editenv list | grep kernelopts) + old_args=$(grub2-editenv "${env}" list | grep kernelopts) old_args="${old_args##kernelopts=}" else old_args="${bls_options[$i]}" From f1aafa632f58a5f0506cb66caa9619d110ff1a9b Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 26 Nov 2018 18:06:24 +0100 Subject: [PATCH 044/132] grubby-bls: always generate the BLS snippets when adding new entries a BLS file is generated at build time and stored in /lib/modules/$kernel but this default BLS file assumes that /boot is a mount point and so the kernel and initrd paths are relative to the root of this boot partition. This is not the case if /boot is not a mount point or if the bootloader is zipl, since zipl expects the absolute path to be in the BLS snippet. The kernel-install scripts takes care of this and modifies the BLS file if needed, but grubby doesn't do that. So instead just generate the BLS always even if there is one for the kernel version of the added entry. Resolves: rhbz#1653365 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/grubby-bls b/grubby-bls index 1e6a9e5..5f5ca6a 100755 --- a/grubby-bls +++ b/grubby-bls @@ -391,16 +391,12 @@ add_bls_fragment() { fi kernel_dir="/lib/modules/${kernelver}" - if [[ -f "${kernel_dir}/bls.conf" ]]; then - cp -aT "${kernel_dir}/bls.conf" "${bls_target}" || exit $? + if [[ -d $kernel_dir ]]; then + datetime="$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" 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}" + datetime=0 fi + mkbls "${kernel}" "${kernelver}" "${datetime}" > "${bls_target}" if [[ -n $title ]]; then set_bls_value "${bls_target}" "title" "${title}" From 27cf1e739988359632c8f753718938e6ed473116 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 1 Dec 2018 02:09:53 +0100 Subject: [PATCH 045/132] Make the old grubby take precedence over grubby-bls if is installed Not all bootloaders used in Fedora have BLS support, for example extlinux doesn't. So when using extlinux the old grubby tool has to be installed. Currently the grubby-bls wrapper has precedence over the old grubby tool, which means that even if grubby-deprecated is installed, the wrapper will executed when calling grubby. Make the old grubby take precedence instead. Related: rhbz#1654841 Signed-off-by: Javier Martinez Canillas --- grubby.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grubby.in b/grubby.in index f0036e9..023e595 100644 --- a/grubby.in +++ b/grubby.in @@ -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 From 2ad4f485f11376b08e8da47e756cc37a9e0e4680 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 1 Dec 2018 02:17:14 +0100 Subject: [PATCH 046/132] Another set of mostly grubby-bls fixes - 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 Signed-off-by: Javier Martinez Canillas --- 0009-Improve-man-page-for-info-option.patch | 30 +++++++++++++++++++++ grubby.spec | 17 +++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 0009-Improve-man-page-for-info-option.patch diff --git a/0009-Improve-man-page-for-info-option.patch b/0009-Improve-man-page-for-info-option.patch new file mode 100644 index 0000000..742eb62 --- /dev/null +++ b/0009-Improve-man-page-for-info-option.patch @@ -0,0 +1,30 @@ +From 64f91f29b03639b0726f0c46f004a20f11379e22 Mon Sep 17 00:00:00 2001 +From: Jan Stodola +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 + diff --git a/grubby.spec b/grubby.spec index 3031a04..470d9f5 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 21%{?dist} +Release: 22%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -21,6 +21,7 @@ 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 BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel @@ -129,6 +130,20 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Fri Nov 30 2018 Javier Martinez Canillas - 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 - 8.40-21 - installkernel-bls: remove unnecessary check for GRUB_ENABLE_BLSCFG=true Resolves: rhbz#1647721 From 6b2ae0e3353026f7b305765c0e2edd65bf1a5e53 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 11 Dec 2018 16:21:45 +0100 Subject: [PATCH 047/132] grubby-bls: lookup default entry by either id or title on grub2 There is a grub2-set-default script that can be used to set the default entry. It can take an entry id, title or index as a parameter so grubby should be able to also lookup a default entry using the title on grub2. Related: rhbz#1654936 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 14 +------------- grubby.spec | 6 +++++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/grubby-bls b/grubby-bls index 5f5ca6a..708f830 100755 --- a/grubby-bls +++ b/grubby-bls @@ -125,25 +125,13 @@ get_default_index() { index="$default" fi - # GRUB2 and zipl use different fields to set the default entry - if [[ $bootloader = "grub2" ]]; then - id="$default" - else - title="$default" - fi - for i in ${!bls_file[@]}; do if [[ $i -eq $index ]]; then echo $i return fi - if [[ $bootloader = "grub2" && $id = ${bls_id[$i]} ]]; then - echo $i - return - fi - - if [[ $bootloader = "zipl" && $title = ${bls_title[$i]} ]]; then + if [[ $default = ${bls_id[$i]} || $default = ${bls_title[$i]} ]]; then echo $i return fi diff --git a/grubby.spec b/grubby.spec index 470d9f5..a9d4b74 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 22%{?dist} +Release: 23%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -130,6 +130,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Dec 11 2018 Javier Martinez Canillas - 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 - 8.40-22 - grubby-bls: also print the absolute path in the --default-kernel option Resolves: rhbz#1649778 From 290786e60680ff4af7eb03cb6126d9886884e0ab Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 14 Jan 2019 09:56:05 +0100 Subject: [PATCH 048/132] Correctly set LDFLAGS and make grubby-bls expand all options variables - 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 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 35 +++++++++++++++-------------------- grubby.spec | 11 +++++++++-- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/grubby-bls b/grubby-bls index 708f830..8f4b73c 100755 --- a/grubby-bls +++ b/grubby-bls @@ -218,6 +218,20 @@ expand_var() { echo $var } +get_bls_args() { + local args=${bls_options[$i]} + 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) @@ -229,15 +243,7 @@ display_info_values() { for i in ${indexes[*]}; do local root="" local value="" - local args=${bls_options[$i]} - 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 + local args="$(get_bls_args "$i")" local opts=(${args}) @@ -449,17 +455,6 @@ update_args() { echo ${args} } -get_bls_args() { - if [[ $bootloader = "grub2" && "${bls_options[$i]}" = "\$kernelopts" ]]; then - old_args=$(grub2-editenv "${env}" list | grep kernelopts) - old_args="${old_args##kernelopts=}" - else - old_args="${bls_options[$i]}" - fi - - echo ${old_args} -} - update_bls_fragment() { local indexes=($(param_to_indexes "$1")) && shift local remove_args=$1 && shift diff --git a/grubby.spec b/grubby.spec index a9d4b74..2623833 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 23%{?dist} +Release: 24%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -59,7 +59,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 @@ -130,6 +131,12 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Jan 14 2019 Javier Martinez Canillas - 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 - 8.40-23 - grubby-bls: lookup default entry by either id or title on grub2 Related: rhbz#1654936 From 9f336a65dd3597d6a5d304d39fae391c0171f20e Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 1 Feb 2019 01:38:17 +0000 Subject: [PATCH 049/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 2623833..88ebab8 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 24%{?dist} +Release: 25%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Fri Feb 01 2019 Fedora Release Engineering - 8.40-25 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + * Mon Jan 14 2019 Javier Martinez Canillas - 8.40-24 - Correctly set LDFLAGS to include hardened flags (pjones) Related: rhbz#1654936 From f742fa15b39e312cc4c686031f5b11d79301f620 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 2 Feb 2019 00:37:15 +0100 Subject: [PATCH 050/132] grubby-bls: show absolute path when printing error about incorrect param The error message is not printing the absolute path to the images, fix it. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 8f4b73c..92ea61b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -309,7 +309,7 @@ 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 @@ -456,13 +456,14 @@ update_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 if [[ $indexes = "-1" ]]; then - print_error "The param $1 is incorrect" + print_error "The param $(get_prefix)${param} is incorrect" fi for i in ${indexes[*]}; do From a77221432e6666fa1b529af89e4f267c6c525889 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 2 Feb 2019 00:59:16 +0100 Subject: [PATCH 051/132] grubby-bls: unset default entry if is the one being removed If the default entry is removed, this can't be set as the default anymore for zipl. Otherwise the zipl tool will fail since it won't exist an IPL section for the one set as the default. For grub2, if the saved_entry doesn't exist it will fallback to the first entry. But still the correct thing to do is to unset the default there. Resolves: rhbz#1668329 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grubby-bls b/grubby-bls index 92ea61b..2549880 100755 --- a/grubby-bls +++ b/grubby-bls @@ -305,6 +305,15 @@ 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")) @@ -313,6 +322,9 @@ remove_bls_fragment() { fi for i in "${indexes[@]}"; do + if [[ $default_index = $i ]]; then + unset_default_bls + fi rm -f "${bls_file[$i]}" done From ac9b25b31e3304a65e0490a2acc16d415838b4be Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 4 Feb 2019 00:13:56 +0100 Subject: [PATCH 052/132] Fix build errors with GCC9 and two more grubby-bls fixes - 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 Signed-off-by: Javier Martinez Canillas --- ...-about-possible-string-truncations-a.patch | 104 ++++++++++++++++++ grubby.spec | 8 +- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch diff --git a/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch b/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch new file mode 100644 index 0000000..24d3d30 --- /dev/null +++ b/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch @@ -0,0 +1,104 @@ +From 00241c65a5c0b4bb32a847a6abb5a86d0c704a8f Mon Sep 17 00:00:00 2001 +From: no one +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: no one +--- + 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 + diff --git a/grubby.spec b/grubby.spec index 88ebab8..52ab427 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 25%{?dist} +Release: 26%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -22,6 +22,7 @@ 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 BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel @@ -131,6 +132,11 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Feb 05 2019 Javier Martinez Canillas - 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 - 8.40-25 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild From 40d73389b42c5866517b47701dcb873dc9808c63 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 14 Feb 2019 10:33:36 +0100 Subject: [PATCH 053/132] grubby-bls: error if args or remove-args is used without update-kernel The --args and --remove-args options can only be used when the kernel to update is specified using the --update-kernel option. Print an error if the latter option is not provided. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 4 ++++ grubby.spec | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 2549880..c1ea4cf 100755 --- a/grubby-bls +++ b/grubby-bls @@ -706,6 +706,10 @@ while [ ${#} -gt 0 ]; do shift done +if [[ -z $update_kernel ]] && [[ -n $args || -n $remove_args ]]; then + print_error "no action specified" +fi + if [[ -z $blsdir ]]; then blsdir="/boot/loader/entries" fi diff --git a/grubby.spec b/grubby.spec index 52ab427..5606b2c 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 26%{?dist} +Release: 27%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -132,6 +132,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Thu Feb 14 2019 Javier Martinez Canillas - 8.40-27 +- grubby-bls: error if args or remove-args is used without update-kernel + * Tue Feb 05 2019 Javier Martinez Canillas - 8.40-26 - Fix GCC warnings about possible string truncations and buffer overflows - grubby-bls: unset default entry if is the one being removed From 6abeb6fc77bf8831ce74c7b3b8499259280ddf5a Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 28 Feb 2019 13:01:40 +0100 Subject: [PATCH 054/132] grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv Currently there's no way to update the kernelopts variable defined in the grubenv by using the grubby wrapper. Updating it with grub2-editenv - set is tedious and error prone so let's use --update-kernel=ALL option for it. This command currently iterates over all the BLS entries and update them individually, but makes more sense to update the kernelopts grubenv var and only update the BLS entries that don't have the $kernelopts var in their options field. If after an update one of these BLS entries have exactly the same params in their options field than the ones set in $kernelopts, set the options field to $kernelopts again since the parameters have converged again. That way the modified BLS entries will only have a custom options field while its value diverged from the $kernelopts defined in grubenv. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 32 ++++++++++++++++++++++++++++++-- grubby.spec | 5 ++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/grubby-bls b/grubby-bls index c1ea4cf..d4a543e 100755 --- a/grubby-bls +++ b/grubby-bls @@ -218,8 +218,20 @@ expand_var() { echo $var } +has_kernelopts() +{ + local args=${bls_options[$1]} + local opts=(${args}) + + for opt in ${opts[*]}; do + [[ $opt = "\$kernelopts" ]] && return 0 + done + + return 1 +} + get_bls_args() { - local args=${bls_options[$i]} + local args=${bls_options[$1]} local opts=(${args}) for opt in ${opts[*]}; do @@ -473,16 +485,32 @@ update_bls_fragment() { 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="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" + opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" + grub2-editenv "${env}" set kernelopts="${opts}" + 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}")" - set_bls_value "${bls_file[$i]}" "options" "${new_args}" + + if [[ $param != "ALL" || ! "$(has_kernelopts "$i")" ]]; then + set_bls_value "${bls_file[$i]}" "options" "${new_args}" + fi + + if [[ $bootloader = grub2 && ! "$(has_kernelopts "$i")" && $opts = $new_args ]]; then + set_bls_value "${bls_file[$i]}" "options" "\$kernelopts" + fi fi if [[ -n $initrd ]]; then diff --git a/grubby.spec b/grubby.spec index 5606b2c..9df01e6 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 27%{?dist} +Release: 28%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -132,6 +132,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Fri Mar 01 2019 Javier Martinez Canillas - 8.40-28 +- grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv + * Thu Feb 14 2019 Javier Martinez Canillas - 8.40-27 - grubby-bls: error if args or remove-args is used without update-kernel From 8213073fa48bef1927dcac4acee7945b30bd62d6 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 11 Mar 2019 11:05:27 +0100 Subject: [PATCH 055/132] Only switch to BLS config for s390x / zipl For platforms using GRUB, the switch to BLS should be done in the %post scriptlet for the grub2-tools package. So only switch to BLS for s390x. Related: rhbz#1652806 Signed-off-by: Javier Martinez Canillas --- grubby.spec | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/grubby.spec b/grubby.spec index 9df01e6..b4965c8 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 28%{?dist} +Release: 29%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -84,13 +84,8 @@ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \ %post if [ "$1" = 2 ]; then arch=$(uname -m) - if [[ $arch == "s390x" ]]; then - command=zipl-switch-to-blscfg - else - command=grub2-switch-to-blscfg - fi - - $command --backup-suffix=.rpmsave &>/dev/null || : + [[ $arch == "s390x" ]] && \ + zipl-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || : fi %package deprecated @@ -132,6 +127,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Mar 11 2019 Javier Martinez Canillas - 8.40-29 +- Only switch to BLS config for s390x / zipl + Related: rhbz#1652806 + * Fri Mar 01 2019 Javier Martinez Canillas - 8.40-28 - grubby-bls: make --update-kernel ALL to update kernelopts var in grubenv From dc24f2cedf3e1e58f61fcbc0d9b7e706371a6a0b Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 20 Mar 2019 17:15:00 +0100 Subject: [PATCH 056/132] grubby-bls: fix --add-kernel not working when using the --args option The script prints an error if --args option is used without --update-kernel but it's also valid to use it with the --add-kernel option. Resolves: rhbz#1691004 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- grubby.spec | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index d4a543e..3551896 100755 --- a/grubby-bls +++ b/grubby-bls @@ -734,7 +734,7 @@ while [ ${#} -gt 0 ]; do shift done -if [[ -z $update_kernel ]] && [[ -n $args || -n $remove_args ]]; then +if [[ -z $update_kernel && -z $kernel ]] && [[ -n $args || -n $remove_args ]]; then print_error "no action specified" fi diff --git a/grubby.spec b/grubby.spec index b4965c8..711c7bc 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 29%{?dist} +Release: 30%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -127,6 +127,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Thu Mar 21 2019 Javier Martinez Canillas - 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 - 8.40-29 - Only switch to BLS config for s390x / zipl Related: rhbz#1652806 From 73b809baaf4b3ee42bc78956d1fe17796d3ef09c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 3 May 2019 18:21:23 +0200 Subject: [PATCH 057/132] Use mountpoint command to check whether /boot is a mount point Using grep is wrong and fragile, so let's use the mountpoint command instead to make it more robust. Resolves: rhbz#1706091 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- grubby.spec | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 3551896..274107f 100755 --- a/grubby-bls +++ b/grubby-bls @@ -197,7 +197,7 @@ param_to_indexes() { } get_prefix() { - if [[ $bootloader = grub2 ]] && grep -q /boot /proc/mounts; then + if [[ $bootloader = grub2 ]] && mountpoint -q /boot; then echo "/boot" else echo "" diff --git a/grubby.spec b/grubby.spec index 711c7bc..8aae1b3 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 30%{?dist} +Release: 31%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -39,6 +39,7 @@ Requires: grub2-tools Requires: s390utils-base %endif Requires: findutils +Requires: util-linux Obsoletes: %{name}-bls @@ -127,6 +128,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Fri May 03 2019 Javier Martinez Canillas - 8.40-31 +- Use mountpoint command to check whether /boot is a mount point + Resolves: rhbz#1706091 + * Thu Mar 21 2019 Javier Martinez Canillas - 8.40-30 - grubby-bls: fix --add-kernel not working when using the --args option Resolves: rhbz#1691004 From 7b4b34aa740256cf0693b8289beceb8f94f80dd8 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 10 Jun 2019 17:42:02 +0200 Subject: [PATCH 058/132] Rebuild for RPM 4.15 Signed-off-by: Igor Gnatenko --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 8aae1b3..6c0b76e 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 31%{?dist} +Release: 32%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -128,6 +128,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Jun 10 15:42:02 CET 2019 Igor Gnatenko - 8.40-32 +- Rebuild for RPM 4.15 + * Fri May 03 2019 Javier Martinez Canillas - 8.40-31 - Use mountpoint command to check whether /boot is a mount point Resolves: rhbz#1706091 From 7c6e97e8098d6e9594c48b6306ab7809ce5109b0 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 11 Jun 2019 00:13:19 +0200 Subject: [PATCH 059/132] Rebuild for RPM 4.15 Signed-off-by: Igor Gnatenko --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 6c0b76e..5bd679c 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 32%{?dist} +Release: 33%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -128,6 +128,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Jun 10 22:13:19 CET 2019 Igor Gnatenko - 8.40-33 +- Rebuild for RPM 4.15 + * Mon Jun 10 15:42:02 CET 2019 Igor Gnatenko - 8.40-32 - Rebuild for RPM 4.15 From b50c79e71cfa820bb7e8286a96298bd06f57af00 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 17 Jun 2019 17:20:17 +0200 Subject: [PATCH 060/132] Add a kernel-install plugin to execute hook scripts in /etc/kernel/ The kernel hook scripts in /etc/kernel/postinst.d and /etc/kernel/prerm.d were executed by the new-kernel-pkg --rpmposttrans and --remove options. But with a BLS configuration the new-kernel-pkg script isn't executed and instead the kernel-install plugins are used. Add a kernel-install plugin that executes the hooks since packages like dkms and akmod make use of it. Resolves: rhbz#1696202 Signed-off-by: Javier Martinez Canillas --- 95-kernel-hooks.install | 33 +++++++++++++++++++++++++++++++++ grubby.spec | 9 ++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 95-kernel-hooks.install diff --git a/95-kernel-hooks.install b/95-kernel-hooks.install new file mode 100755 index 0000000..1313556 --- /dev/null +++ b/95-kernel-hooks.install @@ -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 diff --git a/grubby.spec b/grubby.spec index 5bd679c..6134415 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 33%{?dist} +Release: 34%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -13,6 +13,7 @@ Source1: grubby-bls Source2: grubby.in Source3: installkernel.in Source4: installkernel-bls +Source5: 95-kernel-hooks.install 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 @@ -81,6 +82,7 @@ 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} %post if [ "$1" = 2 ]; then @@ -113,6 +115,7 @@ current boot environment. %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 @@ -128,6 +131,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Jun 17 2019 Javier Martinez Canillas - 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 - 8.40-33 - Rebuild for RPM 4.15 From 4009bc7ed49e0e784cec57f8da4a5dd17ae461f3 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 25 Jul 2019 07:49:12 +0000 Subject: [PATCH 061/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 6134415..e0f13cc 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 34%{?dist} +Release: 35%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Thu Jul 25 2019 Fedora Release Engineering - 8.40-35 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + * Mon Jun 17 2019 Javier Martinez Canillas - 8.40-34 - Add a kernel-install plugin to execute hook scripts in /etc/kernel/ Resolves: rhbz#1696202 From 9baffd002dd7d118ae60ac8c2cc8067af5927dda Mon Sep 17 00:00:00 2001 From: Yuval Turgeman Date: Mon, 5 Aug 2019 20:01:52 +0200 Subject: [PATCH 062/132] grubby-bls: strip only /boot from paths If the /boot directory is a mount point, then the paths of the kernel and initramfs images paths in the BLS snippet have to be relative to the root of the boot partition. So the /boot prefix has to be stripped from paths in this case. But the function was wrongly stripping the entire path instead of only the /boot prefix, which prevented having kernels and initrds in subdirectories. Signed-off-by: Yuval Turgeman --- grubby-bls | 18 ++++++++++-------- grubby.spec | 5 ++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/grubby-bls b/grubby-bls index 274107f..90db0a5 100755 --- a/grubby-bls +++ b/grubby-bls @@ -544,24 +544,28 @@ set_default_bls() { } 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 } @@ -762,9 +766,7 @@ if [[ -n $display_info ]]; then display_info_values "${display_info}" fi -if [[ $(get_prefix) == "/boot" ]]; then - remove_var_prefix -fi +remove_var_prefix "$(get_prefix)" if [[ -n $kernel ]]; then if [[ $copy_default = "true" ]]; then diff --git a/grubby.spec b/grubby.spec index e0f13cc..152cc26 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 35%{?dist} +Release: 36%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Aug 06 2019 Yuval Turgeman - 8.40-36 +- grubby-bls: strip only /boot from paths + * Thu Jul 25 2019 Fedora Release Engineering - 8.40-35 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild From 77a8c0bcac0ed4d34b1410a41a99530252d7ed65 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 22 Nov 2019 14:59:58 +0100 Subject: [PATCH 063/132] grubby-bls: don't print rpm-sort error messages If there are no BLS snippets, an empty array of strings is passed to the rpm-sort tool and it will print an error that just confuses grubby users. Resolves: rhbz#1731924 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 90db0a5..8c423dd 100755 --- a/grubby-bls +++ b/grubby-bls @@ -92,7 +92,7 @@ get_bls_values() { bls="${bls%.conf}" bls="${bls##*/}" echo "${bls}" - done | /usr/libexec/grubby/rpm-sort -c rpmnvrcmp | tac)) || : + done | /usr/libexec/grubby/rpm-sort -c rpmnvrcmp 2>/dev/null | tac)) || : for bls in "${files[@]}" ; do blspath="${blsdir}/${bls}.conf" From 5dafc374ee5bd4283ed18e905c6e95dacbe0e9fb Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 22 Nov 2019 15:52:17 +0100 Subject: [PATCH 064/132] grubby-bls: remove -o option and support -c for ppc64le grub config Resolves: rhbz#1758598 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grubby-bls b/grubby-bls index 8c423dd..24790a8 100755 --- a/grubby-bls +++ b/grubby-bls @@ -572,7 +572,7 @@ remove_var_prefix() { update_grubcfg() { if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then - grub2-mkconfig -o /boot/grub2/grub.cfg >& /dev/null + grub2-mkconfig -o "${grub_config}" >& /dev/null fi } @@ -595,7 +595,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 @@ -611,9 +610,9 @@ 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:,\ bootloader-probe,debug,devtree,devtreedir:,elilo,efi,extlinux,grub,lilo,\ @@ -641,6 +640,7 @@ while [ ${#} -gt 0 ]; do bad_image=true ;; --config-file|-c) + grub_config="${2}" zipl_config="${2}" shift ;; @@ -678,10 +678,6 @@ while [ ${#} -gt 0 ]; do --make-default) make_default=true ;; - --output-file|-o) - output_file="${2}" - shift - ;; --remove-args) remove_args="${2}" shift @@ -754,6 +750,10 @@ if [[ -z $zipl_config ]]; then zipl_config="/etc/zipl.conf" fi +if [[ -z $grub_config ]]; then + grub_config="/boot/grub2/grub.cfg" +fi + get_bls_values default_index="$(get_default_index)" From 08153fc1d69f8766bfccd46134969b4f2fecc541 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 27 Nov 2019 17:08:03 +0100 Subject: [PATCH 065/132] grubby-bls: fix logic to check if the kernelopts var is defined in a BLS The logic to check if a kernelopts variable is defined in a BLS entry was wrong and caused grubby to expand the variables even when it was defined. Resolves: rhbz#1726514 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grubby-bls b/grubby-bls index 24790a8..06a021b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -224,10 +224,10 @@ has_kernelopts() local opts=(${args}) for opt in ${opts[*]}; do - [[ $opt = "\$kernelopts" ]] && return 0 + [[ $opt = "\$kernelopts" ]] && echo "true" done - return 1 + echo "false" } get_bls_args() { @@ -504,11 +504,11 @@ update_bls_fragment() { local old_args="$(get_bls_args "$i")" local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")" - if [[ $param != "ALL" || ! "$(has_kernelopts "$i")" ]]; then + if [[ $param != "ALL" || "$(has_kernelopts "$i")" = "false" ]]; then set_bls_value "${bls_file[$i]}" "options" "${new_args}" fi - if [[ $bootloader = grub2 && ! "$(has_kernelopts "$i")" && $opts = $new_args ]]; then + if [[ $bootloader = grub2 && "$(has_kernelopts "$i")" = "false" && $opts = $new_args ]]; then set_bls_value "${bls_file[$i]}" "options" "\$kernelopts" fi fi From 3ffa2d2706d76cf64c584cc3eabe89201f0ac8bc Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 28 Nov 2019 12:11:39 +0100 Subject: [PATCH 066/132] Fix logic that checks for kernelopts in BLS files and some cleanups 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 Signed-off-by: Javier Martinez Canillas --- grubby.spec | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 152cc26..b87c1bc 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 36%{?dist} +Release: 37%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,14 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Thu Nov 28 2019 Javier Martinez Canillas - 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 - 8.40-36 - grubby-bls: strip only /boot from paths From b5070e227834b2cfeb531a111972770c703ead23 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 29 Nov 2019 23:56:07 +0100 Subject: [PATCH 067/132] grubby-bls: don't update grubenv when generating grub.cfg for ppc64le Since PowerNV machines can have a Petitboot versions that still don't have BLS support, grubby re-generates the grub.cfg file on all ppc64le machines. But this has the side effect that the grubenv file is updated, which will overwrite any value that was set by grubby itself. To prevent that run the grub2-mkconfig with the --no-grubenv-update option. Related: rhbz#1726514 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- grubby.spec | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 06a021b..2c6cb3d 100755 --- a/grubby-bls +++ b/grubby-bls @@ -572,7 +572,7 @@ remove_var_prefix() { update_grubcfg() { if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then - grub2-mkconfig -o "${grub_config}" >& /dev/null + grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null fi } diff --git a/grubby.spec b/grubby.spec index b87c1bc..acb69a0 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 37%{?dist} +Release: 38%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Fri Nov 29 2019 Javier Martinez Canillas - 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 - 8.40-37 - grubby-bls: don't print rpm-sort error messages Resolves: rhbz#1731924 From 03b13cef758e336aedc910beac1e8d95433c2197 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 29 Jan 2020 03:36:54 +0000 Subject: [PATCH 068/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index acb69a0..698f578 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 38%{?dist} +Release: 39%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed Jan 29 2020 Fedora Release Engineering - 8.40-39 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + * Fri Nov 29 2019 Javier Martinez Canillas - 8.40-38 - grubby-bls: don't update grubenv when generating grub.cfg for ppc64le Related: rhbz#1726514 From 5f9558c222c0dfc8389f51892a3720791e55ed36 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 10 Feb 2020 19:30:45 +0100 Subject: [PATCH 069/132] Fix FTBFS and a couple of cleanups Fix FTBFS Resolves: rhbz#1799496 Fix wrong S-o-B tag in patch Fix warning about using unversioned Obsoletes Signed-off-by: Javier Martinez Canillas --- ...-about-possible-string-truncations-a.patch | 4 +- 0011-Fix-stringop-overflow-warning.patch | 72 +++++++++++++++++++ 0012-Fix-maybe-uninitialized-warning.patch | 35 +++++++++ grubby.spec | 12 +++- 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 0011-Fix-stringop-overflow-warning.patch create mode 100644 0012-Fix-maybe-uninitialized-warning.patch diff --git a/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch b/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch index 24d3d30..c4de866 100644 --- a/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch +++ b/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch @@ -1,5 +1,5 @@ From 00241c65a5c0b4bb32a847a6abb5a86d0c704a8f Mon Sep 17 00:00:00 2001 -From: no one +From: Javier Martinez Canillas Date: Tue, 5 Feb 2019 20:08:43 +0100 Subject: [PATCH] Fix GCC warnings about possible string truncations and buffer overflows @@ -10,7 +10,7 @@ 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: no one +Signed-off-by: Javier Martinez Canillas --- grubby.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/0011-Fix-stringop-overflow-warning.patch b/0011-Fix-stringop-overflow-warning.patch new file mode 100644 index 0000000..0fc4734 --- /dev/null +++ b/0011-Fix-stringop-overflow-warning.patch @@ -0,0 +1,72 @@ +From ed5e255c023c9b78120d9ff2246d6516f652d4b7 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +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 +--- + 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 + diff --git a/0012-Fix-maybe-uninitialized-warning.patch b/0012-Fix-maybe-uninitialized-warning.patch new file mode 100644 index 0000000..bcaa145 --- /dev/null +++ b/0012-Fix-maybe-uninitialized-warning.patch @@ -0,0 +1,35 @@ +From ee9f80190d4c458a09309fbd9a88d2756dc2d3fa Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +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 +--- + 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 + diff --git a/grubby.spec b/grubby.spec index 698f578..5011e98 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 39%{?dist} +Release: 40%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -24,6 +24,8 @@ 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 @@ -42,7 +44,7 @@ Requires: s390utils-base Requires: findutils Requires: util-linux -Obsoletes: %{name}-bls +Obsoletes: %{name}-bls < %{version}-%{release} %description This package provides a grubby compatibility script that manages @@ -131,6 +133,12 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Feb 10 2020 Javier Martinez Canillas - 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 - 8.40-39 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild From 8c7d86690790292be16d5eb0079a4564c828bd04 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 30 Mar 2020 10:54:20 +0200 Subject: [PATCH 070/132] Make grubby to also update GRUB_CMDLINE_LINUX in /etc/default/grub The grubby --update-kernel=ALL option is used to update the kernel command line parameters for all the boot entries. But the updated cmdline is lost if the grub2-mkconfig command is executed, since in that case the cmdline is changed with the value set by GRUB_CMDLINE_LINUX in /etc/default/grub. To prevent the cmdline set by users to be overridden by mistake, keep the value of GRUB_CMDLINE_LINUX in sync with the current cmdline. Related: rhbz#1287854 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 11 ++++++++++- grubby.spec | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 2c6cb3d..01ba96b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -492,7 +492,12 @@ update_bls_fragment() { fi if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then - local old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" + local old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" + 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}" + + old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" grub2-editenv "${env}" set kernelopts="${opts}" elif [[ $bootloader = grub2 ]]; then @@ -754,6 +759,10 @@ 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)" diff --git a/grubby.spec b/grubby.spec index 5011e98..1141389 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 40%{?dist} +Release: 41%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -133,6 +133,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Mar 30 2020 Javier Martinez Canillas - 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 - 8.40-40 - Fix FTBFS Resolves: rhbz#1799496 From f57406f3ab1185ccb3fc16321ae2205ff7725f8c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 29 Apr 2020 12:05:04 +0200 Subject: [PATCH 071/132] grubby-bls: fix corner case when a kernel param value contains a '=' If a kernel command line parameter has a '=' character, grubby fails to update the options field in the BLS snippet, for example: $ grubby --update-kernel=foo --args="bar=https://test?token=" sed: -e expression #1, char 30: unknown option to `s' Signed-off-by: Javier Martinez Canillas --- grubby-bls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 01ba96b..01b99bf 100755 --- a/grubby-bls +++ b/grubby-bls @@ -460,7 +460,7 @@ update_args() { for arg in ${remove_args[*]}; do if [[ $arg = *"="* ]]; then - arg=$(echo $arg | sed -e 's/\//\\\//g') + arg="$(echo $arg | sed -e 's/\//\\\//g')" args="$(echo $args | sed -E "s/(^|[[:space:]])$arg([[:space:]]|$)/ /")" else args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")" @@ -468,7 +468,7 @@ update_args() { done for arg in ${add_args[*]}; do - arg=${arg%=*} + arg="${arg%%=*}" args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")" done From 303821d0140dc0728b5b7c44d20d6878aee82ea2 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 29 Apr 2020 14:41:47 +0200 Subject: [PATCH 072/132] grubby-bls: update man page to match options in current wrapper script The man page of the old grubby tool is still shipped in the grubby package but instead there should be a man page that only documents the options for the wrapper grubby script that is used to manage the BLS config snippets. Current man page is confusing for users so let's add one that contains the options that are supported by the wrapper script but no unsupported ones. Signed-off-by: Javier Martinez Canillas --- grubby.8 | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++ grubby.spec | 7 ++- 2 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 grubby.8 diff --git a/grubby.8 b/grubby.8 new file mode 100644 index 0000000..143decd --- /dev/null +++ b/grubby.8 @@ -0,0 +1,170 @@ +.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. + +.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. + +.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 diff --git a/grubby.spec b/grubby.spec index 1141389..f4bfaed 100644 --- a/grubby.spec +++ b/grubby.spec @@ -14,6 +14,7 @@ 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 @@ -78,13 +79,15 @@ make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} libex 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/ -cp -v %{SOURCE4} %{buildroot}%{_libexecdir}/installkernel/ +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 0755 %{SOURCE6} %{buildroot}%{_mandir}/man8/ %post if [ "$1" = 2 ]; then From 670185c68251537e17c4976cd6a7f1baee025761 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 29 Apr 2020 18:33:46 +0200 Subject: [PATCH 073/132] Update man page to match current grubby script options and fix a bug Signed-off-by: Javier Martinez Canillas --- grubby.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index f4bfaed..a070b1a 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 41%{?dist} +Release: 42%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -136,6 +136,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed Apr 29 2020 Javier Martinez Canillas - 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 - 8.40-41 - Make grubby to also update GRUB_CMDLINE_LINUX in /etc/default/grub Related: rhbz#1287854 From 1621d288b6ddfc46533375e2254a4b0f3e2de7da Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 30 Apr 2020 23:07:06 +0200 Subject: [PATCH 074/132] grubby-bls: minor style cleanup Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 01b99bf..de75da6 100755 --- a/grubby-bls +++ b/grubby-bls @@ -492,7 +492,7 @@ update_bls_fragment() { fi if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then - local old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" + local old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" 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}" From b1eee22db83cc6d9847c03ac07e5cf5da81c2071 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 4 May 2020 14:57:52 +0200 Subject: [PATCH 075/132] grubby-bls: always escape the delimiter character used in sed commands The forward slash character is used as the delimiter for sed substitutions so this is escaped before calling sed. But this was only done before removing parameters from the kernel command and not when adding it. Use it for all the cases when the parameters are replaced in the update_args() function. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index de75da6..68cea40 100755 --- a/grubby-bls +++ b/grubby-bls @@ -459,8 +459,8 @@ update_args() { local add_args=($1) && shift for arg in ${remove_args[*]}; do + arg="$(echo $arg | sed -e 's/\//\\\//g')" if [[ $arg = *"="* ]]; then - arg="$(echo $arg | sed -e 's/\//\\\//g')" args="$(echo $args | sed -E "s/(^|[[:space:]])$arg([[:space:]]|$)/ /")" else args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")" @@ -469,6 +469,7 @@ update_args() { 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 From f24781c87b8226be5ec522f02a1833bda9504fe1 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 5 May 2020 11:40:57 +0200 Subject: [PATCH 076/132] grubby-bls: add a --no-etc-grub-update option The option makes grubby to not update the GRUB_CMDLINE_LINUX variable in the /etc/default/grub file when the --update-kernel=ALL option is used. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 21 +++++++++++++++------ grubby.8 | 11 ++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/grubby-bls b/grubby-bls index 68cea40..0306490 100755 --- a/grubby-bls +++ b/grubby-bls @@ -493,10 +493,14 @@ update_bls_fragment() { fi if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then - local old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" - 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}" + local old_args="" + + if [[ -z $no_etc_update ]]; then + old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" + 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 old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" @@ -609,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 @@ -620,7 +625,7 @@ 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,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} -- "$@")" @@ -715,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) diff --git a/grubby.8 b/grubby.8 index 143decd..9bcd247 100644 --- a/grubby.8 +++ b/grubby.8 @@ -145,7 +145,10 @@ for the entry. \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. +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 @@ -156,6 +159,12 @@ Configure \fBzipl\fR bootloader. 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), From b2ab29059a43cf3433a374da12438edb0bc0866c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 5 May 2020 12:22:37 +0200 Subject: [PATCH 077/132] grubby-bls: add a --no-etc-grub-update option and a fix for --args Signed-off-by: Javier Martinez Canillas --- grubby.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index a070b1a..c9751d4 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 42%{?dist} +Release: 43%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -136,6 +136,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue May 05 2020 Javier Martinez Canillas - 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 - 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 From 959c481fa9132f887d7896841772751ac45bf45d Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 6 May 2020 11:34:31 +0200 Subject: [PATCH 078/132] Fix installed man page file mode bits Signed-off-by: Javier Martinez Canillas --- grubby.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index c9751d4..4d9aedf 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 43%{?dist} +Release: 44%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -87,7 +87,7 @@ 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 0755 %{SOURCE6} %{buildroot}%{_mandir}/man8/ +install -m 0644 %{SOURCE6} %{buildroot}%{_mandir}/man8/ %post if [ "$1" = 2 ]; then @@ -136,6 +136,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed May 06 2020 Javier Martinez Canillas - 8.40-44 +- Fix installed man page file mode bits + * Tue May 05 2020 Javier Martinez Canillas - 8.40-43 - grubby-bls: always escape the delimiter character used in sed commands - grubby-bls: add a --no-etc-grub-update option From 770392fcd0cc5a587a244706b0788241f59cbcd5 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 7 May 2020 10:15:39 +0200 Subject: [PATCH 079/132] grubby-bls: only attempt to update cmdline if was already set Signed-off-by: Javier Martinez Canillas --- grubby-bls | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/grubby-bls b/grubby-bls index 0306490..5b428a0 100755 --- a/grubby-bls +++ b/grubby-bls @@ -495,16 +495,20 @@ update_bls_fragment() { if [[ $param = "ALL" && $bootloader = grub2 ]] && [[ -n $remove_args || -n $add_args ]]; then local old_args="" - if [[ -z $no_etc_update ]]; then + if [[ -z $no_etc_update ]] && [[ -e ${grub_etc_default} ]]; then old_args="$(source ${grub_etc_default}; echo ${GRUB_CMDLINE_LINUX})" - 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}" + 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=//")" - opts="$(update_args "${old_args}" "${remove_args}" "${add_args}")" - grub2-editenv "${env}" set kernelopts="${opts}" + 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 From 12e62c4f0a6b0582e9292f19ea7771efc09f9789 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 13 May 2020 18:44:59 +0200 Subject: [PATCH 080/132] grubby-bls: don't replace options with kernelopts if values are the same If the options field in a BLS file has the same value than the kernelopts variable in grubenv, the options is replaced with the kernelopts variable. This was done to keep the options in the BLS files in sync when possible, but having the kernel cmdline as a variable in the grubenv file was proven to be fragile. Instead, the kernel cmdline will be stored in the BLS files to make the configuration more robust. This will work even if the grubenv gets corrupted or is deleted. Since we want to get rid of the kernelopts variable, don't attempt to use that in the BLS snippets anymore. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 4 ---- grubby.spec | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/grubby-bls b/grubby-bls index 5b428a0..74dbe5b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -521,10 +521,6 @@ update_bls_fragment() { if [[ $param != "ALL" || "$(has_kernelopts "$i")" = "false" ]]; then set_bls_value "${bls_file[$i]}" "options" "${new_args}" fi - - if [[ $bootloader = grub2 && "$(has_kernelopts "$i")" = "false" && $opts = $new_args ]]; then - set_bls_value "${bls_file[$i]}" "options" "\$kernelopts" - fi fi if [[ -n $initrd ]]; then diff --git a/grubby.spec b/grubby.spec index 4d9aedf..bc3e307 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 44%{?dist} +Release: 45%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -136,6 +136,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed May 13 2020 Javier Martinez Canillas - 8.40-45 +- grubby-bls: don't replace options with kernelopts if values are the same + * Wed May 06 2020 Javier Martinez Canillas - 8.40-44 - Fix installed man page file mode bits From a5c9c3a1382095a37546188be8dd62167a744ceb Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 26 Jun 2020 09:38:06 +0200 Subject: [PATCH 081/132] fix build with rpm-4.16 and correct --extra-initrd option image path Signed-off-by: Javier Martinez Canillas --- 0013-Fix-build-with-rpm-4.16.patch | 28 ++++++++++++++++++++++++++++ grubby-bls | 6 +++--- grubby.spec | 7 ++++++- 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 0013-Fix-build-with-rpm-4.16.patch diff --git a/0013-Fix-build-with-rpm-4.16.patch b/0013-Fix-build-with-rpm-4.16.patch new file mode 100644 index 0000000..9c122b7 --- /dev/null +++ b/0013-Fix-build-with-rpm-4.16.patch @@ -0,0 +1,28 @@ +From 1afddd618629a97479560bedbdcfa11b2c492a0e Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Fri, 26 Jun 2020 10:02:51 +0200 +Subject: [PATCH] Fix build with rpm-4.16 + +rpmvercmp() was moved to librpmio, so link against this library instead. + +Signed-off-by: Javier Martinez Canillas +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 1ab58aeb039..a54b053a30b 100644 +--- a/Makefile ++++ b/Makefile +@@ -59,7 +59,7 @@ grubby:: $(OBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(grubby_LIBS) + + rpm-sort::rpm-sort.o +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpm ++ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpmio + + clean: + rm -f *.o grubby rpm-sort *~ +-- +2.26.2 + diff --git a/grubby-bls b/grubby-bls index 74dbe5b..def45dd 100755 --- a/grubby-bls +++ b/grubby-bls @@ -429,7 +429,7 @@ add_bls_fragment() { fi if [[ -n $extra_initrd ]]; then - append_bls_value "${bls_target}" "initrd" "${extra_initrd}" + append_bls_value "${bls_target}" "initrd" " ${extra_initrd}" fi if [[ $MAKEDEBUG = "yes" ]]; then @@ -567,7 +567,7 @@ remove_var_prefix() { fi if [[ -n $extra_initrd ]]; then - extra_initrd=" /${extra_initrd##${prefix}/}" + extra_initrd="/${extra_initrd##${prefix}/}" fi if [[ -n $kernel ]]; then @@ -683,7 +683,7 @@ while [ ${#} -gt 0 ]; do shift ;; --extra-initrd|-i) - extra_initrd=" /${2}" + extra_initrd="${2}" shift ;; --make-default) diff --git a/grubby.spec b/grubby.spec index bc3e307..e760734 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 45%{?dist} +Release: 46%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -27,6 +27,7 @@ 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 +Patch0013: 0013-Fix-build-with-rpm-4.16.patch BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel @@ -136,6 +137,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Fri Jun 26 2020 Javier Martinez Canillas - 8.40-46 +- fix build with rpm-4.16 +- grubby-bls: fix --extra-initrd option not adding the correct path + * Wed May 13 2020 Javier Martinez Canillas - 8.40-45 - grubby-bls: don't replace options with kernelopts if values are the same From 1ead121a0843cccac82a61cbf2ec8024988297a6 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 28 Jul 2020 00:24:28 +0000 Subject: [PATCH 082/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index e760734..d414522 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 46%{?dist} +Release: 47%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -137,6 +137,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Jul 28 2020 Fedora Release Engineering - 8.40-47 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Fri Jun 26 2020 Javier Martinez Canillas - 8.40-46 - fix build with rpm-4.16 - grubby-bls: fix --extra-initrd option not adding the correct path From 3498276978410fa78ac73abbc500c3494da46a68 Mon Sep 17 00:00:00 2001 From: Josh Boyer Date: Sat, 24 Oct 2020 12:33:50 +0000 Subject: [PATCH 083/132] Only require s390utils-core zipl appears to be the only thing grubby needs, and that is provided by s390utils-core. Change the Requires to that, which allows for a more minimal installation. --- grubby.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index d414522..6010697 100644 --- a/grubby.spec +++ b/grubby.spec @@ -41,7 +41,7 @@ Requires: grub2-tools-minimal Requires: grub2-tools %endif %ifarch s390 s390x -Requires: s390utils-base +Requires: s390utils-core %endif Requires: findutils Requires: util-linux From b91640a743834f0222671dfe8f77216ac3b5fff2 Mon Sep 17 00:00:00 2001 From: Josh Boyer Date: Sat, 24 Oct 2020 12:33:50 +0000 Subject: [PATCH 084/132] Only require s390utils-core zipl appears to be the only thing grubby needs, and that is provided by s390utils-core. Change the Requires to that, which allows for a more minimal installation. --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 6010697..ac3ed0c 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 47%{?dist} +Release: 48%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -137,6 +137,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Oct 26 2020 Josh Boyer - 8.40-48 +- Only require s390utils-core, not s390utils-base + * Tue Jul 28 2020 Fedora Release Engineering - 8.40-47 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From 536f42db1c6ed62afc08985f5cb65ce0df1f8447 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Tue, 24 Nov 2020 10:44:12 +0000 Subject: [PATCH 085/132] Add device tree kernel install option, minor cleanups --- 10-devicetree.install | 73 +++++++++++++++++++++++++++++++++++++++++++ grubby.spec | 29 ++++++++--------- 2 files changed, 86 insertions(+), 16 deletions(-) create mode 100755 10-devicetree.install diff --git a/10-devicetree.install b/10-devicetree.install new file mode 100755 index 0000000..3345391 --- /dev/null +++ b/10-devicetree.install @@ -0,0 +1,73 @@ +#!/bin/bash + +# set -x + +if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]] +then +COMMAND="$1" +KERNEL_VERSION="$2" +#BOOT_DIR_ABS="$3" +#KERNEL_IMAGE="$4" + +[ -f /etc/u-boot.conf ] && source /etc/u-boot.conf || true +[ -z "$FIRMWAREDT" ] || FirmwareDT=$FIRMWAREDT + +if [[ $FirmwareDT == "True" ]] +then + # if we want to use firmware DT we remove symlink to current kernel DT + if [ -h /boot/dtb ]; then + rm -f /boot/dtb + fi + exit 0 +fi + +# Setup a /boot/dtb -> /boot/dtb-$newest_kernel_version symlink so that +# u-boot can find the correct dtb to load. +# +# If invoked to 'add' a new kernel, find the newest based on `sort`ing +# the kernel versions dtb. If 'remove', then follow basically the same +# procedure but exclude the version currently being removed. +# +# The theory of operation here is that, while newer kernels may add new +# dtb nodes and fields, as upstreaming hw support for some particular +# device progresses, it should never make backward incompatible changes. +# So it should always be safe to use a newer dtb with an older kernel. + + list_dtb_versions() { + excluded_version="$1" + for dtbdir in /boot/dtb-*; do + dtbver=${dtbdir#*-} + if [ "$dtbver" != "$excluded_version" ]; then + echo $dtbver + fi + done + } + + setup_dtb_link() { + ver=`list_dtb_versions $1 | sort -r --sort=version | head -1` + if [ -h /boot/dtb ]; then + rm -f /boot/dtb + fi + ln -s dtb-$ver /boot/dtb + } + + ret=0 + case "$COMMAND" in + add) + # If we're adding a kernel we want that version + if [ -h /boot/dtb ]; then + rm -f /boot/dtb + fi + ln -s dtb-$KERNEL_VERSION /boot/dtb + ret=$? + ;; + remove) + setup_dtb_link $KERNEL_VERSION + ret=$? + ;; + esac + exit $ret +else + # Just exit on non ARM + exit 0 +fi diff --git a/grubby.spec b/grubby.spec index ac3ed0c..985b640 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 48%{?dist} +Release: 49%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -14,7 +14,9 @@ Source2: grubby.in Source3: installkernel.in Source4: installkernel-bls Source5: 95-kernel-hooks.install -Source6: grubby.8 +Source6: 10-devicetree.install +Source7: 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 @@ -31,7 +33,7 @@ Patch0013: 0013-Fix-build-with-rpm-4.16.patch BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel -BuildRequires: libblkid-devel git-core sed make +BuildRequires: libblkid-devel sed make # for make test / getopt: BuildRequires: util-linux-ng BuildRequires: rpm-devel @@ -46,6 +48,7 @@ Requires: s390utils-core Requires: findutils Requires: util-linux +Conflicts: uboot-tools < 2021.01-0.1.rc2 Obsoletes: %{name}-bls < %{version}-%{release} %description @@ -54,16 +57,7 @@ BootLoaderSpec files and is meant to only be used for legacy compatibility users with existing grubby users. %prep -%setup -q -n grubby-%{version}-1 - -git init -git config user.email "noone@example.com" -git config user.name "no one" -git add . -git commit -a -q -m "%{version} baseline" -git am %{patches} %{buildroot}%{_sbindir}/installkernel install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5} +install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE6} rm %{buildroot}%{_mandir}/man8/grubby.8* -install -m 0644 %{SOURCE6} %{buildroot}%{_mandir}/man8/ +install -m 0644 %{SOURCE7} %{buildroot}%{_mandir}/man8/ %post if [ "$1" = 2 ]; then @@ -112,7 +107,6 @@ 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 %dir %{_libexecdir}/installkernel @@ -121,11 +115,11 @@ current boot environment. %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/10-devicetree.install %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 @@ -137,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Fri Nov 20 2020 Peter Robinson - 8.40-49 +- Add device tree kernel install option + * Mon Oct 26 2020 Josh Boyer - 8.40-48 - Only require s390utils-core, not s390utils-base From fd57e031d4b1f411937273896d78f528f7023233 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 30 Dec 2020 17:27:35 +0100 Subject: [PATCH 086/132] Use make_build macro instead of plain make This will make it possible for buildroots to inject arguments to make by redefining the %__make macro. --- grubby.spec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index 985b640..80cfd91 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 49%{?dist} +Release: 50%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -61,7 +61,7 @@ users with existing grubby users. %build %set_build_flags -make %{?_smp_mflags} LDFLAGS="${LDFLAGS}" +%make_build LDFLAGS="${LDFLAGS}" %ifnarch aarch64 %{arm} %check @@ -131,6 +131,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed Dec 30 2020 Tom Stellard - 8.40-50 +- Use make_build macro instead of plain make +- https://docs.fedoraproject.org/en-US/packaging-guidelines/#_parallel_make + * Fri Nov 20 2020 Peter Robinson - 8.40-49 - Add device tree kernel install option From 786a133370716c3ec9de9051f706f1db3e3429fd Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 26 Jan 2021 13:00:54 +0000 Subject: [PATCH 087/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 80cfd91..1f7fd07 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 50%{?dist} +Release: 51%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Tue Jan 26 2021 Fedora Release Engineering - 8.40-51 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Wed Dec 30 2020 Tom Stellard - 8.40-50 - Use make_build macro instead of plain make - https://docs.fedoraproject.org/en-US/packaging-guidelines/#_parallel_make From 5d3963841da86836020e3658cc055d9f6c33655b Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 26 Apr 2021 18:43:51 +0200 Subject: [PATCH 088/132] grubby-bs: Fix changing kernel cmdline params not working on ppc64le Currently the grubby script re-generates a GRUB config file that contains menuentry commands for every /boot/loader/entries/*.conf file snippet. But this is only needed for ppc64le machines that have a Petitboot version that doesn't support parsing BLS snippets. Instead of generating a config on any ppc64le machine, restrict this for the case where is really needed. The /etc/grub.d/10_linux script already takes this into account and does not add menuentry commands unless is needed. But the grubby script didn't check this, causing changing kernel cmdline params to not work on ppc64le. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 29 +++++++++++++++++++++++++++-- grubby.spec | 5 ++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/grubby-bls b/grubby-bls index def45dd..aa1f3a2 100755 --- a/grubby-bls +++ b/grubby-bls @@ -581,8 +581,33 @@ remove_var_prefix() { update_grubcfg() { - if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then - grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null + # Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support + # so grub2-mkconfig has to be run to generate a config with menuentry commands. + if [ "${arch}" = "ppc64le" ] && [ -d /sys/firmware/opal ]; then + RUN_MKCONFIG="true" + petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" + + if test -e ${petitboot_path}; then + read -r -d '' petitboot_version < ${petitboot_path} + petitboot_version="$(echo ${petitboot_version//v})" + + if test -n ${petitboot_version}; then + major_version="$(echo ${petitboot_version} | cut -d . -f1)" + minor_version="$(echo ${petitboot_version} | cut -d . -f2)" + + re='^[0-9]+$' + if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] && + ([[ ${major_version} -gt 1 ]] || + [[ ${major_version} -eq 1 && + ${minor_version} -ge 8 ]]); then + RUN_MKCONFIG="false" + fi + fi + fi + fi + + if [[ $RUN_MKCONFIG = "true" ]]; then + grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null fi } diff --git a/grubby.spec b/grubby.spec index 1f7fd07..4f22e97 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 51%{?dist} +Release: 52%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Apr 26 2021 Javier Martinez Canillas - 8.40-52 +- grubby-bs: Fix changing kernel cmdline params not working on ppc64le + * Tue Jan 26 2021 Fedora Release Engineering - 8.40-51 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild From 2b59d1355d3c81a9a8b0f561e4368071823bddea Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 9 Jun 2021 23:38:54 +0200 Subject: [PATCH 089/132] grubby-bls: expand only the kernelopts variable The BLS snippets have the options field set to a kernelopts variable by default, which is set in GRUB's environemnt block to the kernel cmdline. When the kernel command line parameters are modified for all the entries, the value of this kernelopts variable is modified. But if the cmdline is modified for a single entry, then the kernelopts variable is expanded and the resulted modified value stored in the BLS snippet. The grubby tool expanded all the variables in the options field, but it's possible that some of these variables are managed by another tool. For example the tuned program adds a tuned variable that shouldn't be changed by the grubby tool. Otherwise it will mangle the tuned configuration set. To prevent this, let's make grubby to only expand the kernelopts variable. Signed-off-by: Javier Martinez Canillas --- grubby-bls | 2 +- grubby.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index aa1f3a2..97bb14c 100755 --- a/grubby-bls +++ b/grubby-bls @@ -235,7 +235,7 @@ get_bls_args() { local opts=(${args}) for opt in ${opts[*]}; do - if [[ $opt =~ ^\$ ]]; then + if [[ $opt = "\$kernelopts" ]]; then value="$(expand_var $opt)" args="$(echo ${args} | sed -e "s/${opt}/${value}/")" fi diff --git a/grubby.spec b/grubby.spec index 4f22e97..713aa0a 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 52%{?dist} +Release: 53%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed Jun 09 2021 Javier Martinez Canillas - 8.40-53 +- grubby-bls: expand only the kernelopts variable + * Mon Apr 26 2021 Javier Martinez Canillas - 8.40-52 - grubby-bs: Fix changing kernel cmdline params not working on ppc64le From e94425201f39687d28d78661857ef4f6249be27f Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 23 Jun 2021 07:56:20 +0200 Subject: [PATCH 090/132] Clarify package description The grubby script was meant to be a temporary solution to provide backward compatibility with existing grubby users. But it turned out that grubby is the recommended approach to modify the boot loader entries. Let's make clear in the package description that this is not only meant to be used for legacy compatibility purposes, which may discourage its usage. Resolves: rhbz#1913299 Signed-off-by: Javier Martinez Canillas --- grubby.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grubby.spec b/grubby.spec index 713aa0a..8b61884 100644 --- a/grubby.spec +++ b/grubby.spec @@ -53,8 +53,8 @@ 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. +BootLoaderSpec files and is meant to be backward compatible with +the previous grubby tool. %prep %autosetup -p1 -n grubby-%{version}-1 From 9ebc469d544a1f85cb90301e5d1bf7e289857b9c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 23 Jun 2021 08:22:38 +0200 Subject: [PATCH 091/132] Update man page to not mention the GRUB config in the ESP anymore After https://fedoraproject.org/wiki/Changes/UnifyGrubConfig the config in ESP is only used as a stub to load the actual GRUB config the in /boot dir. Don't mention this file in the grubby man page, since users shouldn't even be aware of that config file. Resolves: rhbz#1958458 Signed-off-by: Javier Martinez Canillas --- grubby.8 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/grubby.8 b/grubby.8 index 9bcd247..314c4f8 100644 --- a/grubby.8 +++ b/grubby.8 @@ -19,13 +19,10 @@ 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. +On BIOS-based Intel x86, PowerPC and UEFI-based platforms, \fBgrub2\fR is the +default bootloader and the configuration file is 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 From e69860d718b40413fb9212972500256a45ab42b2 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 23 Jun 2021 10:20:32 +0200 Subject: [PATCH 092/132] Man page and package description fixes Clarify package description Resolves: rhbz#1913299 Update man page to not mention the GRUB config in the ESP anymore Resolves: rhbz#1958458 Signed-off-by: Javier Martinez Canillas --- grubby.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 8b61884..5ea7955 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 53%{?dist} +Release: 54%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,12 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Wed Jun 23 2021 Javier Martinez Canillas - 8.40-54 +- Clarify package description + Resolves: rhbz#1913299 +- Update man page to not mention the GRUB config in the ESP anymore + Resolves: rhbz#1958458 + * Wed Jun 09 2021 Javier Martinez Canillas - 8.40-53 - grubby-bls: expand only the kernelopts variable From eaef784cc65b6d88763afc536e055b9369f0b0ef Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 22 Jul 2021 07:09:11 +0000 Subject: [PATCH 093/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 5ea7955..d7b5acf 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 54%{?dist} +Release: 55%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Thu Jul 22 2021 Fedora Release Engineering - 8.40-55 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + * Wed Jun 23 2021 Javier Martinez Canillas - 8.40-54 - Clarify package description Resolves: rhbz#1913299 From 0dd1a4fc40c59549418c31bf3ee5f9dfa0c85508 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jan 2022 11:50:18 +0000 Subject: [PATCH 094/132] - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index d7b5acf..17a4e4d 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 55%{?dist} +Release: 56%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Thu Jan 20 2022 Fedora Release Engineering - 8.40-56 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + * Thu Jul 22 2021 Fedora Release Engineering - 8.40-55 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild From dfdd26c908956c2300987429a80d899740f0b05a Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Mon, 7 Feb 2022 21:42:54 +0000 Subject: [PATCH 095/132] grubby-bls: wire up -h (help) Originally authored by Lukas Herbolt. --- grubby-bls | 4 ++-- grubby.spec | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/grubby-bls b/grubby-bls index 97bb14c..af0d82d 100755 --- a/grubby-bls +++ b/grubby-bls @@ -641,12 +641,12 @@ Usage: grubby [OPTION...] --no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub Help options: - -?, --help Show this help message + -h, --help Show this help message EOF } -OPTS="$(getopt -o c:i:b:? --long help,add-kernel:,args:,bad-image-okay,\ +OPTS="$(getopt -o hc: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,remove-args:,\ remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\ diff --git a/grubby.spec b/grubby.spec index 17a4e4d..06c849c 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 56%{?dist} +Release: 57%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -131,6 +131,9 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Feb 07 2022 Robbie Harwood - 8.40-57 +- grubby-bls: wire up -h (help) + * Thu Jan 20 2022 Fedora Release Engineering - 8.40-56 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild From 59ba93105a271b1c1047b2947befa9f1f4042d9d Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Thu, 10 Mar 2022 20:40:02 +0000 Subject: [PATCH 096/132] grubby-bls: wire up -h (help) Signed-off-by: Robbie Harwood --- grubby.spec | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/grubby.spec b/grubby.spec index 06c849c..e7dea0e 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 57%{?dist} +Release: 58%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -63,17 +63,10 @@ the previous grubby tool. %set_build_flags %make_build LDFLAGS="${LDFLAGS}" -%ifnarch aarch64 %{arm} -%check -make test -%endif - %install 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 install -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/grubby/ install -m 0755 %{SOURCE4} %{buildroot}%{_libexecdir}/installkernel/ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \ @@ -82,8 +75,9 @@ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \ > %{buildroot}%{_sbindir}/installkernel install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5} install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE6} -rm %{buildroot}%{_mandir}/man8/grubby.8* +rm %{buildroot}%{_mandir}/man8/{grubby,new-kernel-pkg}.8* install -m 0644 %{SOURCE7} %{buildroot}%{_mandir}/man8/ +rm %{buildroot}%{_sbindir}/new-kernel-pkg %post if [ "$1" = 2 ]; then @@ -92,20 +86,6 @@ if [ "$1" = 2 ]; then zipl-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || : fi -%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 %license COPYING %dir %{_libexecdir}/grubby @@ -119,17 +99,6 @@ current boot environment. %attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install %{_mandir}/man8/[gi]*.8* -%files deprecated -%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* - %changelog * Mon Feb 07 2022 Robbie Harwood - 8.40-57 - grubby-bls: wire up -h (help) From 1bc3038166287bb9607e3978130038a352952233 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 15 Mar 2022 16:06:36 -0400 Subject: [PATCH 097/132] Add missing changelog (Remove grubby-deprecated) Signed-off-by: Robbie Harwood --- grubby.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grubby.spec b/grubby.spec index e7dea0e..abaa15d 100644 --- a/grubby.spec +++ b/grubby.spec @@ -100,6 +100,9 @@ fi %{_mandir}/man8/[gi]*.8* %changelog +* Thu Mar 10 2022 Robbie Harwood - 8.40-58 +- Remove grubby-deprecated + * Mon Feb 07 2022 Robbie Harwood - 8.40-57 - grubby-bls: wire up -h (help) From 415ad451de22ef60820f2704d783a87b712af744 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Wed, 27 Apr 2022 15:28:15 +0000 Subject: [PATCH 098/132] Remove upstream and layers of indirection around -bls Signed-off-by: Robbie Harwood --- ...remove-the-old-crufty-u-boot-support.patch | 235 --- ...ange-return-type-in-getRootSpecifier.patch | 143 -- ...dd-btrfs-subvolume-support-for-grub2.patch | 209 -- 0004-Add-tests-for-btrfs-support.patch | 1871 ----------------- 0005-Use-system-LDFLAGS.patch | 25 - 0006-Honor-sbindir.patch | 36 - ...el-to-use-kernel-install-scripts-on-.patch | 48 - 0008-Add-usr-libexec-rpm-sort.patch | 418 ---- 0009-Improve-man-page-for-info-option.patch | 30 - ...-about-possible-string-truncations-a.patch | 104 - 0011-Fix-stringop-overflow-warning.patch | 72 - 0012-Fix-maybe-uninitialized-warning.patch | 35 - 0013-Fix-build-with-rpm-4.16.patch | 28 - COPYING | 340 +++ grubby.in | 8 - grubby.spec | 71 +- installkernel.in | 8 - rpm-sort.c | 355 ++++ sources | 1 - 19 files changed, 723 insertions(+), 3314 deletions(-) delete mode 100644 0001-remove-the-old-crufty-u-boot-support.patch delete mode 100644 0002-Change-return-type-in-getRootSpecifier.patch delete mode 100644 0003-Add-btrfs-subvolume-support-for-grub2.patch delete mode 100644 0004-Add-tests-for-btrfs-support.patch delete mode 100644 0005-Use-system-LDFLAGS.patch delete mode 100644 0006-Honor-sbindir.patch delete mode 100644 0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch delete mode 100644 0008-Add-usr-libexec-rpm-sort.patch delete mode 100644 0009-Improve-man-page-for-info-option.patch delete mode 100644 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch delete mode 100644 0011-Fix-stringop-overflow-warning.patch delete mode 100644 0012-Fix-maybe-uninitialized-warning.patch delete mode 100644 0013-Fix-build-with-rpm-4.16.patch create mode 100644 COPYING delete mode 100644 grubby.in delete mode 100644 installkernel.in create mode 100644 rpm-sort.c delete mode 100644 sources diff --git a/0001-remove-the-old-crufty-u-boot-support.patch b/0001-remove-the-old-crufty-u-boot-support.patch deleted file mode 100644 index f6f5e97..0000000 --- a/0001-remove-the-old-crufty-u-boot-support.patch +++ /dev/null @@ -1,235 +0,0 @@ -From aa4472dbc10f3d669e24ac07293d7ac19e606866 Mon Sep 17 00:00:00 2001 -From: Dennis Gilmore -Date: Wed, 30 Aug 2017 14:03:45 -0500 -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 -the no longer needed uboot file - -Signed-off-by: Dennis Gilmore ---- - 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 ---- a/new-kernel-pkg -+++ b/new-kernel-pkg -@@ -37,7 +37,6 @@ else - fi - - [ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel --[ -f /etc/sysconfig/uboot ] && . /etc/sysconfig/uboot - - cfgGrub2="" - cfgGrub2Efi="" -@@ -50,7 +49,6 @@ grubConfig="" - grub2Config="" - grub2EfiConfig="" - extlinuxConfig="" --ubootScript="/boot/boot.scr" - - ARCH=$(uname -m) - -@@ -84,13 +82,6 @@ elif [[ ${ARCH} =~ armv[5|7].*l ]] ; then - liloConfig="" - bootPrefix=/boot - extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) -- ubootDir=${UBOOT_DIR:-"/boot"} -- ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} -- ubootKList=${UBOOT_KLIST:-"klist.txt"} -- ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} -- ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} -- ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} -- ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} - mounted="" - liloFlag="" - isx86="" -@@ -382,53 +373,6 @@ remove() { - [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" - fi - -- if [ -n "$cfguBoot" ]; then -- [ -n "$verbose" ] && echo "removing $version from $ubootDir..." -- -- if [ -f $ubootDir/$ubootKList ]; then -- tmpKList=`mktemp $ubootDir/$ubootKList.XXXX` -- curversion=`tail -n1 $ubootDir/$ubootKList` -- sed "/$version$/d" $ubootDir/$ubootKList > $tmpKList -- newversion=`tail -n1 $tmpKList` -- if [ -f $ubootDir/uImage-$newversion ] && [ -f $ubootDir/uInitrd-$newversion ]; then -- if [ "$curversion" != "$newversion" ]; then -- cp -fp $ubootDir/uImage-$newversion $ubootDir/${ubootDefaultImage} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uImage-$newversion error, default kernel not replaced!" && exit -- fi -- cp -fp $ubootDir/uInitrd-$newversion $ubootDir/${ubootDefaultInitrd} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uInitrd-$newversion error, default Initrd not replaced!" && exit -- fi -- fi -- -- [ -n "$verbose" ] && echo "removing uImage-$version" -- if [ -f $ubootDir/uImage-$version ]; then -- rm -f $ubootDir/uImage-$version -- else -- [ -n "$verbose" ] && echo "uImage-$version did not exist!" -- fi -- -- [ -n "$verbose" ] && echo "removing uInitrd-$version" -- if [ -f $ubootDir/uInitrd-$version ]; then -- rm -f $ubootDir/uInitrd-$version -- else -- [ -n "$verbose" ] && echo "uInitrd-$version did not exist!" -- fi -- -- mv $tmpKList $ubootDir/$ubootKList -- [ -x /sbin/a-b-c ] && /sbin/a-b-c -- else -- [ -n "$verbose" ] && echo "uImage $newversion does not exist!" -- [ -f $tmpKList ] && rm -f $tmpKList -- fi -- else -- [ -n "$verbose" ] && echo "No previous kernel version. U-Boot images not removed!" -- fi -- else -- [ -n "$verbose" ] && echo "$ubootScript does not exist, not modifying $ubootDir" -- fi -- - if [ -n "$cfgExtlinux" ]; then - [ -n "$verbose" ] && echo "removing $version from $extlinuxConfig" - $grubby --extlinux -c $extlinuxConfig \ -@@ -530,36 +474,6 @@ update() { - [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" - fi - -- if [ -n "$cfguBoot" ]; then -- [ -n "$verbose" ] && echo "adding $version to $ubootDir..." -- -- [ -n "$verbose" ] && echo "creating uImage-$version" -- mkimage -A arm -O linux -T kernel -C none -a $ubootAddress \ -- -e $ubootAddress -n $version \ -- -d $kernelImage $ubootDir/uImage-$version -- -- [ -n "$verbose" ] && echo "creating uInitrd-$version" -- mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ -- -n initramfs -d $initrdfile $ubootDir/uInitrd-$version -- -- if [ -f $ubootDir/uImage-$version ] && [ -f $ubootDir/uInitrd-$version ]; then -- cp -fp $ubootDir/uImage-$version $ubootDir/${ubootDefaultImage} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uImage-$version error, kernel not installed!" && exit -- fi -- cp -fp $ubootDir/uInitrd-$version $ubootDir/${ubootDefaultInitrd} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uInitrd-$version error, kernel not installed!" && exit -- fi -- echo $version >> $ubootDir/$ubootKList -- [ -x /sbin/a-b-c ] && /sbin/a-b-c -- else -- [ -n "$verbose" ] && echo "cannot make $version the default" -- fi -- else -- [ -n "$verbose" ] && echo "$ubootScript does not exist, not setting up $ubootDir" -- fi -- - if [ -n "$cfgExtlinux" ]; then - [ -n "$verbose" ] && echo "updating $version from $extlinuxConfig" - ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \ -@@ -877,33 +791,6 @@ fi - [ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1; - [ -n "$extlinuxConfig" ] && [ -f "$extlinuxConfig" ] && cfgExtlinux=1; - --# if we have a U-Boot directory, but no boot script, check if the directory --# is mounted. If not, mount it, and then check if a boot script exists. --if [ -n "$ubootDir" ]; then -- if [ -f "$ubootScript" ]; then -- cfguBoot=1 -- else -- mountEntry=`mount | grep $ubootDir` -- if [ -z "$mountEntry" ]; then -- mount $ubootDevice $ubootDir -- mounted=1 -- fi -- [ -f "$ubootScript" ] && cfguBoot=1; -- fi --fi -- --# if we're using U-Boot, check if the default load address should change --if [ -n "$cfguBoot" -a -z "$UBOOT_IMGADDR" ]; then -- [[ $version =~ .([^.]*)$ ]] -- platform=${BASH_REMATCH[1]} -- # A few platforms use an alternate kernel load address -- if [ "$platform" = "omap" ]; then -- ubootAddress=0x80008000 -- elif [ "$platform" = "imx" ]; then -- ubootAddress=0x90008000 -- fi --fi -- - # if we have a lilo config on an x86 box, see if the default boot loader - # is lilo to determine if it should be run - if [ -n "$cfgLilo" -a -n "$isx86" ]; then -@@ -920,7 +807,4 @@ elif [ "$mode" == "--rpmposttrans" ]; then - rpmposttrans - fi - --# if we mounted the U-Boot directory, unmount it. --[ -n "$mounted" ] && umount $ubootDir -- - exit 0 -diff --git a/uboot b/uboot -deleted file mode 100644 -index 07d8671822f..00000000000 ---- a/uboot -+++ /dev/null -@@ -1,43 +0,0 @@ --# Settings for uBoot setup in /sbin/new-kernel-pkg --# --# Default values are provided below (as comments) --# --# WARNING: These values affect where grubby installs and removes --# uBoot kernel images. Changing these _after_ kernels have --# been installed may cause removing a kernel image to fail. -- --# directory where uBoot images and scripts are found --#UBOOT_DIR=/boot -- --# Override the load address when running mkimage on the kernel. --# OMAP such as Beagleboard and Pandaboard: Use 0x80008000 --# Tegra such as Trimslice: Use 0x00008000 --# IMX such as Efika mx51 smarttop: Use 0x90008000 --# Kirkwood such as Dreamplug, Guruplug, Sheevaplug: Use 0x00008000 --# If left undefined grubby will use defults for Tegra or OMAP depending --# upon the contents of /proc/cpuinfo. --#UBOOT_IMGADDR=0x0x00008000 -- --# name of the text file containing the list of installed kernel versions --# NOTE: The versions are in order of installation. The last entry should --# always be the default boot kernel version. --#UBOOT_KLIST=klist.txt -- --# device partition where uBoot images reside; mounted on $UBOOT_DIR --#UBOOT_DEVICE=mmcblk0p1 -- -- --# NOTE: Both of the following files are automatically overwritte --# when a kernel package is installed or removed. -- --# default kernel uImage file name --#UBOOT_UIMAGE=uImage -- --# default initrd uInitrd file name --#UBOOT_UINITRD=uInitrd -- --# defualt for platform shipping an onboard dtb. --#SHIPSDTB=no -- --# option to tell new-kernel-pkg a specific dtb file to load in extlinux.conf --#dtbfile=foo.dtb --- -2.17.1 - diff --git a/0002-Change-return-type-in-getRootSpecifier.patch b/0002-Change-return-type-in-getRootSpecifier.patch deleted file mode 100644 index f2a1978..0000000 --- a/0002-Change-return-type-in-getRootSpecifier.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 3afc4c0ed28d443bb71956b07fd45c8cfb07566f Mon Sep 17 00:00:00 2001 -From: Nathaniel McCallum -Date: Fri, 2 Mar 2018 14:59:32 -0500 -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, -it reduces some memory leaks since the return value was often never -freed. Second, it simplifies the caller who is usually only interested -in the length of the prefix. ---- - grubby.c | 54 +++++++++++++++++++++++++++--------------------------- - 1 file changed, 27 insertions(+), 27 deletions(-) - -diff --git a/grubby.c b/grubby.c -index d4ebb86168d..a062ef8e567 100644 ---- a/grubby.c -+++ b/grubby.c -@@ -675,7 +675,7 @@ static int lineWrite(FILE * out, struct singleLine * line, - struct configFileInfo * cfi); - static int getNextLine(char ** bufPtr, struct singleLine * line, - struct configFileInfo * cfi); --static char * getRootSpecifier(char * str); -+static size_t getRootSpecifier(const char *str); - static void requote(struct singleLine *line, struct configFileInfo * cfi); - static void insertElement(struct singleLine * line, - const char * item, int insertHere, -@@ -1840,7 +1840,7 @@ int suitableImage(struct singleEntry * entry, const char * bootPrefix, - char * fullName; - int i; - char * dev; -- char * rootspec; -+ size_t rs; - char * rootdev; - - if (skipRemoved && entry->skip) { -@@ -1866,12 +1866,11 @@ int suitableImage(struct singleEntry * entry, const char * bootPrefix, - - fullName = alloca(strlen(bootPrefix) + - strlen(line->elements[1].item) + 1); -- rootspec = getRootSpecifier(line->elements[1].item); -- int rootspec_offset = rootspec ? strlen(rootspec) : 0; -+ rs = getRootSpecifier(line->elements[1].item); - int hasslash = endswith(bootPrefix, '/') || -- beginswith(line->elements[1].item + rootspec_offset, '/'); -+ beginswith(line->elements[1].item + rs, '/'); - sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", -- line->elements[1].item + rootspec_offset); -+ line->elements[1].item + rs); - if (access(fullName, R_OK)) { - notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); - return 0; -@@ -1952,7 +1951,6 @@ struct singleEntry * findEntryByPath(struct grubConfig * config, - struct singleLine * line; - int i; - char * chptr; -- char * rootspec = NULL; - enum lineType_e checkType = LT_KERNEL; - - if (isdigit(*kernel)) { -@@ -2044,11 +2042,10 @@ struct singleEntry * findEntryByPath(struct grubConfig * config, - - if (line && line->type != LT_MENUENTRY && - line->numElements >= 2) { -- rootspec = getRootSpecifier(line->elements[1].item); -- if (!strcmp(line->elements[1].item + -- ((rootspec != NULL) ? strlen(rootspec) : 0), -- kernel + strlen(prefix))) -- break; -+ if (!strcmp(line->elements[1].item + -+ getRootSpecifier(line->elements[1].item), -+ kernel + strlen(prefix))) -+ break; - } - if(line->type == LT_MENUENTRY && - !strcmp(line->elements[1].item, kernel)) -@@ -2797,11 +2794,11 @@ struct singleLine * addLineTmpl(struct singleEntry * entry, - - /* but try to keep the rootspec from the template... sigh */ - if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { -- char * rootspec = getRootSpecifier(tmplLine->elements[1].item); -- if (rootspec != NULL) { -- free(newLine->elements[1].item); -- newLine->elements[1].item = -- sdupprintf("%s%s", rootspec, val); -+ size_t rs = getRootSpecifier(tmplLine->elements[1].item); -+ if (rs > 0) { -+ free(newLine->elements[1].item); -+ newLine->elements[1].item = sdupprintf("%.*s%s", (int) rs, -+ tmplLine->elements[1].item, val); - } - } - } -@@ -3729,15 +3726,19 @@ int checkForElilo(struct grubConfig * config) { - return 1; - } - --static char * getRootSpecifier(char * str) { -- char * idx, * rootspec = NULL; -+static size_t getRootSpecifier(const char *str) -+{ -+ size_t rs = 0; - - if (*str == '(') { -- idx = rootspec = strdup(str); -- while(*idx && (*idx != ')') && (!isspace(*idx))) idx++; -- *(++idx) = '\0'; -+ for (; str[rs] != ')' && !isspace(str[rs]); rs++) { -+ if (!str[rs]) -+ return rs; -+ } -+ rs++; - } -- return rootspec; -+ -+ return rs; - } - - static char * getInitrdVal(struct grubConfig * config, -@@ -4616,7 +4617,7 @@ int main(int argc, const char ** argv) { - if (displayDefault) { - struct singleLine * line; - struct singleEntry * entry; -- char * rootspec; -+ size_t rs; - - if (config->defaultImage == -1) return 0; - if (config->defaultImage == DEFAULT_SAVED_GRUB2 && -@@ -4629,9 +4630,8 @@ int main(int argc, const char ** argv) { - line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); - if (!line) return 0; - -- rootspec = getRootSpecifier(line->elements[1].item); -- printf("%s%s\n", bootPrefix, line->elements[1].item + -- ((rootspec != NULL) ? strlen(rootspec) : 0)); -+ rs = getRootSpecifier(line->elements[1].item); -+ printf("%s%s\n", bootPrefix, line->elements[1].item + rs); - - return 0; - --- -2.17.1 - diff --git a/0003-Add-btrfs-subvolume-support-for-grub2.patch b/0003-Add-btrfs-subvolume-support-for-grub2.patch deleted file mode 100644 index 583c5de..0000000 --- a/0003-Add-btrfs-subvolume-support-for-grub2.patch +++ /dev/null @@ -1,209 +0,0 @@ -From 112b6e5fc690b2a73b6ad8c92dc4645db08503b6 Mon Sep 17 00:00:00 2001 -From: Nathaniel McCallum -Date: Fri, 2 Mar 2018 08:40:18 -0500 -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 -filesystem, the caller can use the --mounts option to specify his own -mounts file. - -Btrfs subvolumes are already supported by grub2 and by grub2-mkconfig. - -Fixes #22 ---- - grubby.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 143 insertions(+), 5 deletions(-) - -diff --git a/grubby.c b/grubby.c -index a062ef8e567..96d252a0a83 100644 ---- a/grubby.c -+++ b/grubby.c -@@ -68,6 +68,8 @@ int isEfi = 0; - - char *saved_command_line = NULL; - -+const char *mounts = "/proc/mounts"; -+ - /* comments get lumped in with indention */ - struct lineElement { - char * item; -@@ -1834,6 +1836,129 @@ static int endswith(const char *s, char c) - return s[slen] == c; - } - -+typedef struct { -+ const char *start; -+ size_t chars; -+} field; -+ -+static int iscomma(int c) -+{ -+ return c == ','; -+} -+ -+static int isequal(int c) -+{ -+ return c == '='; -+} -+ -+static field findField(const field *in, typeof(isspace) *isdelim, field *out) -+{ -+ field nxt = {}; -+ size_t off = 0; -+ -+ while (off < in->chars && isdelim(in->start[off])) -+ off++; -+ -+ if (off == in->chars) -+ return nxt; -+ -+ out->start = &in->start[off]; -+ out->chars = 0; -+ -+ while (off + out->chars < in->chars && !isdelim(out->start[out->chars])) -+ out->chars++; -+ -+ nxt.start = out->start + out->chars; -+ nxt.chars = in->chars - off - out->chars; -+ return nxt; -+} -+ -+static int fieldEquals(const field *in, const char *str) -+{ -+ return in->chars == strlen(str) && -+ strncmp(in->start, str, in->chars) == 0; -+} -+ -+/* Parse /proc/mounts to determine the subvolume prefix. */ -+static size_t subvolPrefix(const char *str) -+{ -+ FILE *file = NULL; -+ char *line = NULL; -+ size_t prfx = 0; -+ size_t size = 0; -+ -+ file = fopen(mounts, "r"); -+ if (!file) -+ return 0; -+ -+ for (ssize_t s; (s = getline(&line, &size, file)) >= 0; ) { -+ field nxt = { line, s }; -+ field dev = {}; -+ field path = {}; -+ field type = {}; -+ field opts = {}; -+ field opt = {}; -+ -+ nxt = findField(&nxt, isspace, &dev); -+ if (!nxt.start) -+ continue; -+ -+ nxt = findField(&nxt, isspace, &path); -+ if (!nxt.start) -+ continue; -+ -+ nxt = findField(&nxt, isspace, &type); -+ if (!nxt.start) -+ continue; -+ -+ nxt = findField(&nxt, isspace, &opts); -+ if (!nxt.start) -+ continue; -+ -+ if (!fieldEquals(&type, "btrfs")) -+ continue; -+ -+ /* We have found a btrfs mount point. */ -+ -+ nxt = opts; -+ while ((nxt = findField(&nxt, iscomma, &opt)).start) { -+ field key = {}; -+ field val = {}; -+ -+ opt = findField(&opt, isequal, &key); -+ if (!opt.start) -+ continue; -+ -+ opt = findField(&opt, isequal, &val); -+ if (!opt.start) -+ continue; -+ -+ if (!fieldEquals(&key, "subvol")) -+ continue; -+ -+ /* We have found a btrfs subvolume mount point. */ -+ -+ if (strncmp(val.start, str, val.chars)) -+ continue; -+ -+ if (val.start[val.chars - 1] != '/' && -+ str[val.chars] != '/') -+ continue; -+ -+ /* The subvolume mount point matches our input. */ -+ -+ if (prfx < val.chars) -+ prfx = val.chars; -+ } -+ } -+ -+ dbgPrintf("%s(): str: '%s', prfx: '%s'\n", __FUNCTION__, str, prfx); -+ -+ fclose(file); -+ free(line); -+ return prfx; -+} -+ - int suitableImage(struct singleEntry * entry, const char * bootPrefix, - int skipRemoved, int flags) { - struct singleLine * line; -@@ -2794,12 +2919,22 @@ struct singleLine * addLineTmpl(struct singleEntry * entry, - - /* but try to keep the rootspec from the template... sigh */ - if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { -- size_t rs = getRootSpecifier(tmplLine->elements[1].item); -+ const char *prfx = tmplLine->elements[1].item; -+ size_t rs = getRootSpecifier(prfx); -+ if (isinitrd(tmplLine->type)) { -+ for (struct singleLine *l = entry->lines; -+ rs == 0 && l; l = l->next) { -+ if (iskernel(l->type)) { -+ prfx = l->elements[1].item; -+ rs = getRootSpecifier(prfx); -+ } -+ } -+ } - if (rs > 0) { - free(newLine->elements[1].item); -- newLine->elements[1].item = sdupprintf("%.*s%s", (int) rs, -- tmplLine->elements[1].item, val); -- } -+ newLine->elements[1].item = sdupprintf("%.*s%s", -+ (int) rs, prfx, val); -+ } - } - } - -@@ -3738,7 +3873,7 @@ static size_t getRootSpecifier(const char *str) - rs++; - } - -- return rs; -+ return rs + subvolPrefix(str + rs); - } - - static char * getInitrdVal(struct grubConfig * config, -@@ -4253,6 +4388,9 @@ int main(int argc, const char ** argv) { - { "mbargs", 0, POPT_ARG_STRING, &newMBKernelArgs, 0, - _("default arguments for the new multiboot kernel or " - "new arguments for multiboot kernel being updated"), NULL }, -+ { "mounts", 0, POPT_ARG_STRING, &mounts, 0, -+ _("path to fake /proc/mounts file (for testing only)"), -+ _("mounts") }, - { "bad-image-okay", 0, 0, &badImageOkay, 0, - _("don't sanity check images in boot entries (for testing only)"), - NULL }, --- -2.17.1 - diff --git a/0004-Add-tests-for-btrfs-support.patch b/0004-Add-tests-for-btrfs-support.patch deleted file mode 100644 index f4b8ec8..0000000 --- a/0004-Add-tests-for-btrfs-support.patch +++ /dev/null @@ -1,1871 +0,0 @@ -From e319f73ca691b9cc138def3a9c19f1cb6e581475 Mon Sep 17 00:00:00 2001 -From: Gene Czarcinski -Date: Mon, 9 Jun 2014 21:11:37 -0400 -Subject: [PATCH 4/8] Add tests for btrfs support - -The tests performed are: -- add kernel with /boot on btrfs subvol (20) -- update kernel/add initrd with /boot on btrfs subvol (21) -- add kernel with rootfs on btrfs subvol and /boot a directory (22) -- update kernel/add initrd with rootfs on btrfs subvol and - /boot a directory (23) -- add kernel and initrd with /boot on btrfs subvol (24) -- add kernel and initrd with rootfs on btrfs subvol and /boot - a directory (25) ---- - 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 ++++++++++++++++++++++++++ - 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 - create mode 100644 test/grub2-support_files/g2.22-mounts - create mode 120000 test/grub2-support_files/g2.23-mounts - create mode 120000 test/grub2-support_files/g2.24-mounts - create mode 120000 test/grub2-support_files/g2.25-mounts - create mode 100644 test/grub2.20 - create mode 100644 test/grub2.21 - create mode 100644 test/grub2.22 - create mode 100644 test/grub2.23 - create mode 100644 test/grub2.24 - create mode 100644 test/grub2.25 - create mode 100644 test/results/add/g2-1.20 - create mode 100644 test/results/add/g2-1.21 - create mode 100644 test/results/add/g2-1.22 - create mode 100644 test/results/add/g2-1.23 - create mode 100644 test/results/add/g2-1.24 - create mode 100644 test/results/add/g2-1.25 - -diff --git a/test.sh b/test.sh -index 6379698c6de..c35bfca1c89 100755 ---- a/test.sh -+++ b/test.sh -@@ -629,6 +629,46 @@ if [ "$testgrub2" == "y" ]; then - --initrd /boot/initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img \ - --copy-default --title "Fedora 21 Rescue" --args=root=/fooooo \ - --remove-kernel=wtf --boot-filesystem=/boot/ -+ -+ testing="GRUB2 add kernel with boot on btrfs subvol" -+ grub2Test grub2.20 add/g2-1.20 --add-kernel=/boot/new-kernel.img \ -+ --title='title' \ -+ --boot-filesystem=/boot/ \ -+ --copy-default \ -+ --mounts='test/grub2-support_files/g2.20-mounts' -+ -+ testing="GRUB2 add initrd with boot on btrfs subvol" -+ grub2Test grub2.21 add/g2-1.21 --update-kernel=/boot/new-kernel.img \ -+ --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ -+ --mounts='test/grub2-support_files/g2.21-mounts' -+ -+ testing="GRUB2 add kernel with rootfs on btrfs subvol and boot directory" -+ grub2Test grub2.22 add/g2-1.22 --add-kernel=/boot/new-kernel.img \ -+ --title='title' \ -+ --boot-filesystem= \ -+ --copy-default \ -+ --mounts='test/grub2-support_files/g2.22-mounts' -+ -+ testing="GRUB2 add initrd with rootfs on btrfs subvol and boot directory" -+ grub2Test grub2.23 add/g2-1.23 --update-kernel=/boot/new-kernel.img \ -+ --initrd=/boot/new-initrd --boot-filesystem= \ -+ --mounts='test/grub2-support_files/g2.23-mounts' -+ -+ testing="GRUB2 add kernel and initrd with boot on btrfs subvol" -+ grub2Test grub2.24 add/g2-1.24 --add-kernel=/boot/new-kernel.img \ -+ --title='title' \ -+ --initrd=/boot/new-initrd \ -+ --boot-filesystem=/boot/ \ -+ --copy-default \ -+ --mounts='test/grub2-support_files/g2.24-mounts' -+ -+ testing="GRUB2 add kernel and initrd with rootfs on btrfs subvol and boot directory" -+ grub2Test grub2.25 add/g2-1.25 --add-kernel=/boot/new-kernel.img \ -+ --title='title' \ -+ --initrd=/boot/new-initrd \ -+ --boot-filesystem= \ -+ --copy-default \ -+ --mounts='test/grub2-support_files/g2.25-mounts' - fi - fi - -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 ---- /dev/null -+++ b/test/grub2-support_files/g2.20-mounts -@@ -0,0 +1,2 @@ -+/dev/sda / btrfs subvol=/root6,defaults 0 0 -+/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 ---- /dev/null -+++ b/test/grub2-support_files/g2.21-mounts -@@ -0,0 +1 @@ -+g2.20-mounts -\ 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 ---- /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 ---- /dev/null -+++ b/test/grub2-support_files/g2.23-mounts -@@ -0,0 +1 @@ -+g2.22-mounts -\ 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 ---- /dev/null -+++ b/test/grub2-support_files/g2.24-mounts -@@ -0,0 +1 @@ -+g2.20-mounts -\ 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 ---- /dev/null -+++ b/test/grub2-support_files/g2.25-mounts -@@ -0,0 +1 @@ -+g2.22-mounts -\ No newline at end of file -diff --git a/test/grub2.20 b/test/grub2.20 -new file mode 100644 -index 00000000000..23b75fa8d3c ---- /dev/null -+++ b/test/grub2.20 -@@ -0,0 +1,126 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### END /etc/grub.d/30_os-prober ### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### END /etc/grub.d/41_custom ### -diff --git a/test/grub2.21 b/test/grub2.21 -new file mode 100644 -index 00000000000..579c2f6744a ---- /dev/null -+++ b/test/grub2.21 -@@ -0,0 +1,140 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### END /etc/grub.d/30_os-prober ### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### END /etc/grub.d/41_custom ### -diff --git a/test/grub2.22 b/test/grub2.22 -new file mode 100644 -index 00000000000..9466bc35153 ---- /dev/null -+++ b/test/grub2.22 -@@ -0,0 +1,128 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### END /etc/grub.d/41_custom ### -diff --git a/test/grub2.23 b/test/grub2.23 -new file mode 100644 -index 00000000000..5cb240fc1de ---- /dev/null -+++ b/test/grub2.23 -@@ -0,0 +1,143 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### END /etc/grub.d/41_custom ### -diff --git a/test/grub2.24 b/test/grub2.24 -new file mode 100644 -index 00000000000..23b75fa8d3c ---- /dev/null -+++ b/test/grub2.24 -@@ -0,0 +1,126 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### END /etc/grub.d/30_os-prober ### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### END /etc/grub.d/41_custom ### -diff --git a/test/grub2.25 b/test/grub2.25 -new file mode 100644 -index 00000000000..9466bc35153 ---- /dev/null -+++ b/test/grub2.25 -@@ -0,0 +1,128 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### 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 ---- /dev/null -+++ b/test/results/add/g2-1.20 -@@ -0,0 +1,140 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### END /etc/grub.d/30_os-prober ### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### 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 ---- /dev/null -+++ b/test/results/add/g2-1.21 -@@ -0,0 +1,141 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/new-initrd -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### END /etc/grub.d/30_os-prober ### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### 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 ---- /dev/null -+++ b/test/results/add/g2-1.22 -@@ -0,0 +1,143 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### 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 ---- /dev/null -+++ b/test/results/add/g2-1.23 -@@ -0,0 +1,144 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/new-initrd -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### 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 ---- /dev/null -+++ b/test/results/add/g2-1.24 -@@ -0,0 +1,141 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/new-kernel.img root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/new-initrd -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-81378818f7a24478b496ebef90e1dd69' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ else -+ search --no-floppy --fs-uuid --set=root 1bab15a4-93ce-4373-8d7d-b77f907fd0c6 -+ fi -+ linux16 /boot6/vmlinuz-0-rescue-81378818f7a24478b496ebef90e1dd69 root=UUID=1bab15a4-93ce-4373-8d7d-b77f907fd0c6 ro rootflags=subvol=root6 rhgb quiet -+ initrd16 /boot6/initramfs-0-rescue-81378818f7a24478b496ebef90e1dd69.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### END /etc/grub.d/30_os-prober ### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### 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 ---- /dev/null -+++ b/test/results/add/g2-1.25 -@@ -0,0 +1,144 @@ -+# -+# DO NOT EDIT THIS FILE -+# -+# It is automatically generated by grub2-mkconfig using templates -+# from /etc/grub.d and settings from /etc/default/grub -+# -+ -+### BEGIN /etc/grub.d/00_header ### -+set pager=1 -+ -+if [ -s $prefix/grubenv ]; then -+ load_env -+fi -+if [ "${next_entry}" ] ; then -+ set default="${next_entry}" -+ set next_entry= -+ save_env next_entry -+ set boot_once=true -+else -+ set default="${saved_entry}" -+fi -+ -+if [ x"${feature_menuentry_id}" = xy ]; then -+ menuentry_id_option="--id" -+else -+ menuentry_id_option="" -+fi -+ -+export menuentry_id_option -+ -+if [ "${prev_saved_entry}" ]; then -+ set saved_entry="${prev_saved_entry}" -+ save_env saved_entry -+ set prev_saved_entry= -+ save_env prev_saved_entry -+ set boot_once=true -+fi -+ -+function savedefault { -+ if [ -z "${boot_once}" ]; then -+ saved_entry="${chosen}" -+ save_env saved_entry -+ fi -+} -+ -+function load_video { -+ if [ x$feature_all_video_module = xy ]; then -+ insmod all_video -+ else -+ insmod efi_gop -+ insmod efi_uga -+ insmod ieee1275_fb -+ insmod vbe -+ insmod vga -+ insmod video_bochs -+ insmod video_cirrus -+ fi -+} -+ -+terminal_output console -+if [ x$feature_timeout_style = xy ] ; then -+ set timeout_style=menu -+ set timeout=15 -+# Fallback normal timeout code in case the timeout_style feature is -+# unavailable. -+else -+ set timeout=15 -+fi -+### END /etc/grub.d/00_header ### -+ -+### BEGIN /etc/grub.d/10_linux ### -+menuentry 'title' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/new-kernel.img root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/new-initrd -+} -+menuentry 'Fedora, with Linux 3.15.0-0.rc7.git2.1.fc21.x86_64' --class gnu-linux --class gnu --class os { -+ load_video -+ set gfxpayload=keep -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-3.15.0-0.rc7.git2.1.fc21.x86_64 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-3.15.0-0.rc7.git2.1.fc21.x86_64.img -+} -+menuentry 'Fedora, with Linux 0-rescue-20e7024f4e9c4b70b1042b91acd434c6' --class gnu-linux --class gnu --class os { -+ load_video -+ insmod gzio -+ insmod part_msdos -+ insmod part_msdos -+ insmod btrfs -+ set root='hd0,msdos1' -+ if [ x$feature_platform_search_hint = xy ]; then -+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' --hint='hd1,msdos3' 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ else -+ search --no-floppy --fs-uuid --set=root 54c6abc2-b1e7-4987-aa73-c79927be69eb -+ fi -+ linux16 /root4/boot/vmlinuz-0-rescue-20e7024f4e9c4b70b1042b91acd434c6 root=UUID=54c6abc2-b1e7-4987-aa73-c79927be69eb ro rootflags=subvol=root4 rhgb quiet -+ initrd16 /root4/boot/initramfs-0-rescue-20e7024f4e9c4b70b1042b91acd434c6.img -+} -+ -+### END /etc/grub.d/10_linux ### -+ -+### BEGIN /etc/grub.d/20_linux_xen ### -+ -+### END /etc/grub.d/20_linux_xen ### -+ -+### BEGIN /etc/grub.d/20_ppc_terminfo ### -+### END /etc/grub.d/20_ppc_terminfo ### -+ -+### BEGIN /etc/grub.d/30_os-prober ### -+### -+ -+### BEGIN /etc/grub.d/40_custom ### -+# This file provides an easy way to add custom menu entries. Simply type the -+# menu entries you want to add after this comment. Be careful not to change -+# the 'exec tail' line above. -+### END /etc/grub.d/40_custom ### -+ -+### BEGIN /etc/grub.d/41_custom ### -+if [ -f ${config_directory}/custom.cfg ]; then -+ source ${config_directory}/custom.cfg -+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then -+ source $prefix/custom.cfg; -+fi -+### END /etc/grub.d/41_custom ### --- -2.17.1 - diff --git a/0005-Use-system-LDFLAGS.patch b/0005-Use-system-LDFLAGS.patch deleted file mode 100644 index 17954c4..0000000 --- a/0005-Use-system-LDFLAGS.patch +++ /dev/null @@ -1,25 +0,0 @@ -From e08c858af4d2b09e62441560f3ccecc9e750c87a Mon Sep 17 00:00:00 2001 -From: Rafael dos Santos -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 - diff --git a/0006-Honor-sbindir.patch b/0006-Honor-sbindir.patch deleted file mode 100644 index 0d947cc..0000000 --- a/0006-Honor-sbindir.patch +++ /dev/null @@ -1,36 +0,0 @@ -From db200499551e386e7616c621fcbd69e350081664 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 18 Jul 2018 13:41:02 -0400 -Subject: [PATCH 6/8] Honor sbindir - -Signed-off-by: Peter Jones ---- - Makefile | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/Makefile b/Makefile -index f0d13720db5..cfa8e0d60ab 100644 ---- a/Makefile -+++ b/Makefile -@@ -42,14 +42,14 @@ test: all - @./test.sh - - install: all -- mkdir -p $(DESTDIR)$(PREFIX)/sbin -+ mkdir -p $(DESTDIR)$(PREFIX)$(sbindir) - mkdir -p $(DESTDIR)/$(mandir)/man8 -- install -m 755 new-kernel-pkg $(DESTDIR)$(PREFIX)/sbin -+ install -m 755 new-kernel-pkg $(DESTDIR)$(PREFIX)$(sbindir) - install -m 644 new-kernel-pkg.8 $(DESTDIR)/$(mandir)/man8 -- install -m 755 installkernel $(DESTDIR)$(PREFIX)/sbin -+ install -m 755 installkernel $(DESTDIR)$(PREFIX)$(sbindir) - install -m 644 installkernel.8 $(DESTDIR)/$(mandir)/man8 - if [ -f grubby ]; then \ -- install -m 755 grubby $(DESTDIR)$(PREFIX)/sbin ; \ -+ install -m 755 grubby $(DESTDIR)$(PREFIX)$(sbindir) ; \ - install -m 644 grubby.8 $(DESTDIR)/$(mandir)/man8 ; \ - fi - --- -2.17.1 - diff --git a/0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch b/0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch deleted file mode 100644 index 727cab6..0000000 --- a/0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch +++ /dev/null @@ -1,48 +0,0 @@ -From fa1bf7b54cb71fa193da16ffc404f8535d7d16ac Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 31 Jul 2018 17:43:53 +0200 -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 -that in turns executes the distro specific installkernel script. This -script always uses new-kernel-pkg to install the kernel images. - -But on a BootLoaderSpec setup, the kernel-install scripts must be used -instead. Check if the system uses a BLS setup, and call kernel-install -add in that case instead of new-kernel-pkg. - -Reported-by: Hans de Goede -Signed-off-by: Javier Martinez Canillas ---- - installkernel | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/installkernel b/installkernel -index b887929c179..68dcfac16d2 100755 ---- a/installkernel -+++ b/installkernel -@@ -20,6 +20,8 @@ - # Author(s): tyson@rwii.com - # - -+[[ -f /etc/default/grub ]] && . /etc/default/grub -+ - usage() { - echo "Usage: `basename $0` " >&2 - exit 1 -@@ -77,6 +79,11 @@ 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 [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] || [ ! -f /sbin/new-kernel-pkg ]; then -+ kernel-install add $KERNEL_VERSION $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION -+ exit $? -+fi -+ - if [ -n "$cfgLoader" ] && [ -x /sbin/new-kernel-pkg ]; then - if [ -n "$(which dracut 2>/dev/null)" ]; then - new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install --kernel-name $KERNEL_NAME $KERNEL_VERSION --- -2.17.1 - diff --git a/0008-Add-usr-libexec-rpm-sort.patch b/0008-Add-usr-libexec-rpm-sort.patch deleted file mode 100644 index b3e5faa..0000000 --- a/0008-Add-usr-libexec-rpm-sort.patch +++ /dev/null @@ -1,418 +0,0 @@ -From b8a581014170c6a9bb8ffb799090401a57a4bbe6 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 12 Oct 2018 16:39:37 -0400 -Subject: [PATCH 8/8] Add /usr/libexec/rpm-sort - -Signed-off-by: Peter Jones ---- - 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 -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+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 - diff --git a/0009-Improve-man-page-for-info-option.patch b/0009-Improve-man-page-for-info-option.patch deleted file mode 100644 index 742eb62..0000000 --- a/0009-Improve-man-page-for-info-option.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 64f91f29b03639b0726f0c46f004a20f11379e22 Mon Sep 17 00:00:00 2001 -From: Jan Stodola -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 - diff --git a/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch b/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch deleted file mode 100644 index c4de866..0000000 --- a/0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 00241c65a5c0b4bb32a847a6abb5a86d0c704a8f Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -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 ---- - 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 - diff --git a/0011-Fix-stringop-overflow-warning.patch b/0011-Fix-stringop-overflow-warning.patch deleted file mode 100644 index 0fc4734..0000000 --- a/0011-Fix-stringop-overflow-warning.patch +++ /dev/null @@ -1,72 +0,0 @@ -From ed5e255c023c9b78120d9ff2246d6516f652d4b7 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -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 ---- - 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 - diff --git a/0012-Fix-maybe-uninitialized-warning.patch b/0012-Fix-maybe-uninitialized-warning.patch deleted file mode 100644 index bcaa145..0000000 --- a/0012-Fix-maybe-uninitialized-warning.patch +++ /dev/null @@ -1,35 +0,0 @@ -From ee9f80190d4c458a09309fbd9a88d2756dc2d3fa Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -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 ---- - 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 - diff --git a/0013-Fix-build-with-rpm-4.16.patch b/0013-Fix-build-with-rpm-4.16.patch deleted file mode 100644 index 9c122b7..0000000 --- a/0013-Fix-build-with-rpm-4.16.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 1afddd618629a97479560bedbdcfa11b2c492a0e Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 26 Jun 2020 10:02:51 +0200 -Subject: [PATCH] Fix build with rpm-4.16 - -rpmvercmp() was moved to librpmio, so link against this library instead. - -Signed-off-by: Javier Martinez Canillas ---- - Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index 1ab58aeb039..a54b053a30b 100644 ---- a/Makefile -+++ b/Makefile -@@ -59,7 +59,7 @@ grubby:: $(OBJECTS) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(grubby_LIBS) - - rpm-sort::rpm-sort.o -- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpm -+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpmio - - clean: - rm -f *.o grubby rpm-sort *~ --- -2.26.2 - diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..f90922e --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/grubby.in b/grubby.in deleted file mode 100644 index 023e595..0000000 --- a/grubby.in +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -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 diff --git a/grubby.spec b/grubby.spec index abaa15d..b4c1faa 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,42 +1,27 @@ +# What? No. +%define __brp_mangle_shebangs %{nil} + Name: grubby Version: 8.40 -Release: 58%{?dist} +Release: 59%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ -URL: https://github.com/rhinstaller/grubby -# we only pull git snaps at the moment -# git clone git@github.com:rhinstaller/grubby.git -# git archive --format=tar --prefix=grubby-%%{version}/ HEAD |bzip2 > grubby-%%{version}.tar.bz2 -# Source0: %%{name}-%%{version}.tar.bz2 -Source0: https://github.com/rhboot/grubby/archive/%{version}-1.tar.gz Source1: grubby-bls -Source2: grubby.in -Source3: installkernel.in +Source2: rpm-sort.c +Source3: COPYING Source4: installkernel-bls Source5: 95-kernel-hooks.install Source6: 10-devicetree.install Source7: 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 -Patch0013: 0013-Fix-build-with-rpm-4.16.patch - BuildRequires: gcc -BuildRequires: pkgconfig glib2-devel popt-devel -BuildRequires: libblkid-devel sed make -# for make test / getopt: -BuildRequires: util-linux-ng +BuildRequires: glib2-devel +BuildRequires: libblkid-devel +BuildRequires: make +BuildRequires: pkgconfig +BuildRequires: popt-devel BuildRequires: rpm-devel +BuildRequires: sed %ifarch aarch64 i686 x86_64 %{power64} BuildRequires: grub2-tools-minimal Requires: grub2-tools-minimal @@ -57,27 +42,27 @@ BootLoaderSpec files and is meant to be backward compatible with the previous grubby tool. %prep -%autosetup -p1 -n grubby-%{version}-1 +# Make sure the license can be found in mock +cp %{SOURCE3} . || true %build %set_build_flags -%make_build LDFLAGS="${LDFLAGS}" +gcc ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -std=gnu99 -DVERSION='"8.4.0"' \ + -o rpm-sort %{SOURCE2} -lrpmio %install -make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} libexecdir=%{_libexecdir} +mkdir -p %{buildroot}%{_libexecdir}/grubby/ +install -D -m 0755 rpm-sort %{buildroot}%{_libexecdir}/grubby + +mkdir -p %{buildroot}%{_sbindir}/ +install -T -m 0755 %{SOURCE1} %{buildroot}%{_sbindir}/grubby +install -T -m 0755 %{SOURCE4} %{buildroot}%{_sbindir}/installkernel -mkdir -p %{buildroot}%{_libexecdir}/{grubby,installkernel}/ %{buildroot}%{_sbindir}/ -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} install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE6} -rm %{buildroot}%{_mandir}/man8/{grubby,new-kernel-pkg}.8* + +mkdir -p %{buildroot}%{_mandir}/man8 install -m 0644 %{SOURCE7} %{buildroot}%{_mandir}/man8/ -rm %{buildroot}%{_sbindir}/new-kernel-pkg %post if [ "$1" = 2 ]; then @@ -89,17 +74,17 @@ fi %files %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/10-devicetree.install %attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install -%{_mandir}/man8/[gi]*.8* +%{_mandir}/man8/grubby.8* %changelog +* Wed Apr 27 2022 Robbie Harwood - 8.40-59 +- Remove upstream and layers of indirection around -bls + * Thu Mar 10 2022 Robbie Harwood - 8.40-58 - Remove grubby-deprecated diff --git a/installkernel.in b/installkernel.in deleted file mode 100644 index 87b81ee..0000000 --- a/installkernel.in +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -if [[ -x @@LIBEXECDIR@@/installkernel ]] ; then - exec @@LIBEXECDIR@@/installkernel "${@}" -elif [[ -x @@LIBEXECDIR@@/installkernel-bls ]] ; then - exec @@LIBEXECDIR@@/installkernel-bls "${@}" -fi -echo "installkernel is not installed correctly." >>/dev/stderr -exit 1 diff --git a/rpm-sort.c b/rpm-sort.c new file mode 100644 index 0000000..f196356 --- /dev/null +++ b/rpm-sort.c @@ -0,0 +1,355 @@ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include + +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/sources b/sources deleted file mode 100644 index 0f5ce7f..0000000 --- a/sources +++ /dev/null @@ -1 +0,0 @@ -SHA512 (8.40-1.tar.gz) = 956ea6ccec2e7285fc8ebbf1d7659c4f41b1e9eda913d99a9712af9103144a13e66e93dce4c089b64ab370d1fed63656e922eafb88a0a39f843a6a6d166f72c5 From aaefddefe8fa964909ac5e2e9330cb21f615a4c3 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Wed, 27 Apr 2022 13:08:31 -0400 Subject: [PATCH 099/132] rpm-sort: fix missing include and sort Signed-off-by: Robbie Harwood --- rpm-sort.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rpm-sort.c b/rpm-sort.c index f196356..274bcb1 100644 --- a/rpm-sort.c +++ b/rpm-sort.c @@ -1,13 +1,14 @@ #define _GNU_SOURCE +#include +#include +#include +#include +#include #include #include +#include #include -#include -#include -#include -#include -#include typedef enum { RPMNVRCMP, From 79765ad0d78ac88d56f78bc0d10b8ef8746b7e17 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Wed, 27 Apr 2022 13:13:57 -0400 Subject: [PATCH 100/132] Stop building on ia32 Signed-off-by: Robbie Harwood --- grubby.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index b4c1faa..4938666 100644 --- a/grubby.spec +++ b/grubby.spec @@ -22,7 +22,7 @@ BuildRequires: pkgconfig BuildRequires: popt-devel BuildRequires: rpm-devel BuildRequires: sed -%ifarch aarch64 i686 x86_64 %{power64} +%ifarch aarch64 x86_64 %{power64} BuildRequires: grub2-tools-minimal Requires: grub2-tools-minimal Requires: grub2-tools @@ -33,6 +33,7 @@ Requires: s390utils-core Requires: findutils Requires: util-linux +ExcludeArch: %{ix86} Conflicts: uboot-tools < 2021.01-0.1.rc2 Obsoletes: %{name}-bls < %{version}-%{release} From 599a2e1a99114516f54179346f6654c9868bd20b Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 31 May 2022 17:23:49 +0000 Subject: [PATCH 101/132] Additionally write to /etc/kernel/cmdline Signed-off-by: Robbie Harwood --- grubby-bls | 13 +++++++++++++ grubby.spec | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index af0d82d..f70aceb 100755 --- a/grubby-bls +++ b/grubby-bls @@ -513,6 +513,19 @@ update_bls_fragment() { opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" fi + # systemd decide that what we needed was *another* place to configure this + # stuff (after our two, plus BLS). Two, actually, but configuration + # doesn't live in /usr. If we don't do this, kernel-install + # (90-loaderentry.install) will read arguments from /proc/cmdline (instead + # of our actual configuration...), causing future kernel installs to use + # the current kernel's arguments - which depending on when the system + # reboots, may or may not be what the user wanted... + if [[ $param = "ALL" && -e /etc/default/grub ]]; then + opts="$(source /etc/default/grub; echo ${GRUB_CMDLINE_LINUX})" + root="$(tr -s "$IFS" '\n' /etc/kernel/cmdline + fi + for i in ${indexes[*]}; do if [[ -n $remove_args || -n $add_args ]]; then local old_args="$(get_bls_args "$i")" diff --git a/grubby.spec b/grubby.spec index 4938666..8b319c8 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 59%{?dist} +Release: 60%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -83,6 +83,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Tue May 31 2022 Robbie Harwood - 8.40-60 +- Additionally write to /etc/kernel/cmdline + * Wed Apr 27 2022 Robbie Harwood - 8.40-59 - Remove upstream and layers of indirection around -bls From 78927fa5edbb8647aeab9ec864e2789829fb9649 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Wed, 22 Jun 2022 14:42:14 -0400 Subject: [PATCH 102/132] Revert "Additionally write to /etc/kernel/cmdline" This reverts commit 599a2e1a99114516f54179346f6654c9868bd20b. Signed-off-by: Robbie Harwood --- grubby-bls | 13 ------------- grubby.spec | 5 +---- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/grubby-bls b/grubby-bls index f70aceb..af0d82d 100755 --- a/grubby-bls +++ b/grubby-bls @@ -513,19 +513,6 @@ update_bls_fragment() { opts="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" fi - # systemd decide that what we needed was *another* place to configure this - # stuff (after our two, plus BLS). Two, actually, but configuration - # doesn't live in /usr. If we don't do this, kernel-install - # (90-loaderentry.install) will read arguments from /proc/cmdline (instead - # of our actual configuration...), causing future kernel installs to use - # the current kernel's arguments - which depending on when the system - # reboots, may or may not be what the user wanted... - if [[ $param = "ALL" && -e /etc/default/grub ]]; then - opts="$(source /etc/default/grub; echo ${GRUB_CMDLINE_LINUX})" - root="$(tr -s "$IFS" '\n' /etc/kernel/cmdline - fi - for i in ${indexes[*]}; do if [[ -n $remove_args || -n $add_args ]]; then local old_args="$(get_bls_args "$i")" diff --git a/grubby.spec b/grubby.spec index 8b319c8..4938666 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 60%{?dist} +Release: 59%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -83,9 +83,6 @@ fi %{_mandir}/man8/grubby.8* %changelog -* Tue May 31 2022 Robbie Harwood - 8.40-60 -- Additionally write to /etc/kernel/cmdline - * Wed Apr 27 2022 Robbie Harwood - 8.40-59 - Remove upstream and layers of indirection around -bls From 810b5eee5ab449318cc97f3706e0023a273d8a1b Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Wed, 22 Jun 2022 14:43:48 -0400 Subject: [PATCH 103/132] Update spec file for previous change Signed-off-by: Robbie Harwood --- grubby.spec | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 4938666..c2fdb2f 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 59%{?dist} +Release: 61%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -83,6 +83,12 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Wed Jun 22 2022 Robbie Harwood - 8.40-61 +- Revert previous change + +* Tue May 31 2022 Robbie Harwood - 8.40-60 +- Additionally write to /etc/kernel/cmdline + * Wed Apr 27 2022 Robbie Harwood - 8.40-59 - Remove upstream and layers of indirection around -bls From 29fb24f2057b0f4a9228f9faef65bb7198756424 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 19 Jul 2022 19:26:03 +0000 Subject: [PATCH 104/132] Clarify that grub files aren't used on s390x in man page Signed-off-by: Robbie Harwood --- grubby.8 | 3 ++- grubby.spec | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/grubby.8 b/grubby.8 index 314c4f8..e9a8e7b 100644 --- a/grubby.8 +++ b/grubby.8 @@ -145,7 +145,8 @@ 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. +unless the \fB-\-no-etc-grub-update\fR option is used or the file does not +exist (e.g., on s390x). .TP \fB-\-zipl\fR diff --git a/grubby.spec b/grubby.spec index c2fdb2f..995771b 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 61%{?dist} +Release: 62%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -83,6 +83,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Tue Jul 19 2022 Robbie Harwood - 8.40-62 +- Clarify that grub files aren't used on s390x in man page + * Wed Jun 22 2022 Robbie Harwood - 8.40-61 - Revert previous change From c8241463d75b15c35b23d3c7f785746cd19cac7a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 21 Jul 2022 13:06:10 +0000 Subject: [PATCH 105/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 995771b..a44afa7 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 62%{?dist} +Release: 63%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -83,6 +83,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Thu Jul 21 2022 Fedora Release Engineering - 8.40-63 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + * Tue Jul 19 2022 Robbie Harwood - 8.40-62 - Clarify that grub files aren't used on s390x in man page From 1faea2de0a46e339913c4e6a1598062d1fffe2e7 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 2 Aug 2022 20:09:04 +0000 Subject: [PATCH 106/132] Handle updating /etc/kernel/cmdline Signed-off-by: Robbie Harwood --- grubby-bls | 24 ++++++++++++++++++++++++ grubby.spec | 5 ++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index af0d82d..0571a0b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -502,6 +502,16 @@ update_bls_fragment() { opts="$(echo "$opts" | sed -e 's/\//\\\//g')" sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" fi + + if [[ -f /etc/kernel/cmdline ]]; then + sed -i "s/\(root=[^ ]*\) .*/\1 ${opts}/" /etc/kernel/cmdline + else + # grub2-mkconfig creates this. Do that now. + grub2-mkconfig -o /etc/grub2.cfg + fi + if [[ ! -f /etc/kernel/cmdline ]]; then + echo "No /etc/kernel/cmdline; please report a bug"; + fi fi old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" @@ -528,6 +538,20 @@ update_bls_fragment() { fi done + if [[ $param = "ALL" && $bootloader = zipl ]] && [[ -n $remove_args || -n $add_args ]]; then + if [[ ! -f /etc/kernel/cmdline ]]; then + # anaconda could pre-populate this file, but until then, most of + # the time we'll just want the most recent one. This is pretty + # close to the current almost-correct behavior of falling back to + # /proc/cmdline anyhow. + echo "$(get_bls_args -1)" > /etc/kernel/cmdline + fi + + read old_args < /etc/kernel/cmdline + local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")" + echo "$new_args" > /etc/kernel/cmdline + fi + update_grubcfg } diff --git a/grubby.spec b/grubby.spec index a44afa7..a6ef7ca 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 63%{?dist} +Release: 64%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -83,6 +83,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Tue Aug 02 2022 Robbie Harwood - 8.40-64 +- Handle updating /etc/kernel/cmdline + * Thu Jul 21 2022 Fedora Release Engineering - 8.40-63 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild From 74ff4810be5e83e60a65d1d5c769f2b5fb531cb7 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Wed, 17 Aug 2022 15:17:48 +0000 Subject: [PATCH 107/132] Mark package as obsoleting -deprecated Resolves: #2117817 Signed-off-by: Robbie Harwood --- grubby.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index a6ef7ca..9c17bff 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 64%{?dist} +Release: 65%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -36,6 +36,7 @@ Requires: util-linux ExcludeArch: %{ix86} Conflicts: uboot-tools < 2021.01-0.1.rc2 Obsoletes: %{name}-bls < %{version}-%{release} +Obsoletes: %{name}-deprecated < %{version}-%{release} %description This package provides a grubby compatibility script that manages @@ -83,6 +84,10 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Wed Aug 17 2022 Robbie Harwood - 8.40-65 +- Mark package as obsoleting -deprecated +- Resolves: #2117817 + * Tue Aug 02 2022 Robbie Harwood - 8.40-64 - Handle updating /etc/kernel/cmdline From 0da23ad751882023bb16a6784c5bd34f15b025d8 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Mon, 22 Aug 2022 21:47:49 +0000 Subject: [PATCH 108/132] Give up and just pull the config from BLS Suggested-by: Bojan Smojver Signed-off-by: Robbie Harwood --- grubby-bls | 12 +----------- grubby.spec | 6 +++++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/grubby-bls b/grubby-bls index 0571a0b..f09156b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -502,16 +502,6 @@ update_bls_fragment() { opts="$(echo "$opts" | sed -e 's/\//\\\//g')" sed -i -e "s/^GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" fi - - if [[ -f /etc/kernel/cmdline ]]; then - sed -i "s/\(root=[^ ]*\) .*/\1 ${opts}/" /etc/kernel/cmdline - else - # grub2-mkconfig creates this. Do that now. - grub2-mkconfig -o /etc/grub2.cfg - fi - if [[ ! -f /etc/kernel/cmdline ]]; then - echo "No /etc/kernel/cmdline; please report a bug"; - fi fi old_args="$(grub2-editenv "${env}" list | grep kernelopts | sed -e "s/kernelopts=//")" @@ -538,7 +528,7 @@ update_bls_fragment() { fi done - if [[ $param = "ALL" && $bootloader = zipl ]] && [[ -n $remove_args || -n $add_args ]]; then + if [[ $param = "ALL" ]] && [[ -n $remove_args || -n $add_args ]]; then if [[ ! -f /etc/kernel/cmdline ]]; then # anaconda could pre-populate this file, but until then, most of # the time we'll just want the most recent one. This is pretty diff --git a/grubby.spec b/grubby.spec index 9c17bff..1853265 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 65%{?dist} +Release: 66%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -84,6 +84,10 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Mon Aug 22 2022 Robbie Harwood - 8.40-66 +- Give up and just pull the config from BLS +- Suggested-by: Bojan Smojver + * Wed Aug 17 2022 Robbie Harwood - 8.40-65 - Mark package as obsoleting -deprecated - Resolves: #2117817 From 2f6207731e09a5901d49fde7944f48c73661820e Mon Sep 17 00:00:00 2001 From: Marta Lewandowska Date: Tue, 4 Oct 2022 13:08:06 +0000 Subject: [PATCH 109/132] Fix passing --args without copy-default Fix so that --args are not passed by default if copy-default is not used. Set root when --args are passed without copy-default. --- grubby-bls | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/grubby-bls b/grubby-bls index f09156b..f3650e3 100755 --- a/grubby-bls +++ b/grubby-bls @@ -827,13 +827,12 @@ fi remove_var_prefix "$(get_prefix)" if [[ -n $kernel ]]; then - if [[ $copy_default = "true" ]]; then - opts="${bls_options[$default_index]}" - if [[ -n $args ]]; then - opts="${opts} ${args}" - fi - else - opts="${args}" + opts="${bls_options[$default_index]}" + if [[ $copy_default != "true" ]]; then + opts=$(echo $opts | sed -e 's/ .*//') + fi + if [[ -n $args ]]; then + opts="${opts} ${args}" fi add_bls_fragment "${kernel}" "${title}" "${opts}" "${initrd}" \ From 9f3764d8d249f466554254a3f5946f95de374687 Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 4 Oct 2022 17:16:29 +0000 Subject: [PATCH 110/132] Apply Marta's copy-default args fix Signed-off-by: Robbie Harwood --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 1853265..ee362e6 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 66%{?dist} +Release: 67%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -84,6 +84,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Tue Oct 04 2022 Robbie Harwood - 8.40-67 +- Apply Marta's copy-default args fix + * Mon Aug 22 2022 Robbie Harwood - 8.40-66 - Give up and just pull the config from BLS - Suggested-by: Bojan Smojver From 68f872a10efca0a0553717a20f99460d9692865c Mon Sep 17 00:00:00 2001 From: Robbie Harwood Date: Tue, 1 Nov 2022 17:40:38 +0000 Subject: [PATCH 111/132] Drop custom rpm-sort See-also: https://github.com/rpm-software-management/rpm/pull/2249 Signed-off-by: Robbie Harwood --- grubby-bls | 2 +- grubby.spec | 15 +-- rpm-sort.c | 356 ---------------------------------------------------- 3 files changed, 7 insertions(+), 366 deletions(-) delete mode 100644 rpm-sort.c diff --git a/grubby-bls b/grubby-bls index f3650e3..cce0579 100755 --- a/grubby-bls +++ b/grubby-bls @@ -92,7 +92,7 @@ get_bls_values() { bls="${bls%.conf}" bls="${bls##*/}" echo "${bls}" - done | /usr/libexec/grubby/rpm-sort -c rpmnvrcmp 2>/dev/null | tac)) || : + done | sort -Vr 2>/dev/null)) || : for bls in "${files[@]}" ; do blspath="${blsdir}/${bls}.conf" diff --git a/grubby.spec b/grubby.spec index ee362e6..4ee7241 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,11 +3,11 @@ Name: grubby Version: 8.40 -Release: 67%{?dist} +Release: 68%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls -Source2: rpm-sort.c +# Source2: rpm-sort.c Source3: COPYING Source4: installkernel-bls Source5: 95-kernel-hooks.install @@ -49,13 +49,8 @@ cp %{SOURCE3} . || true %build %set_build_flags -gcc ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -std=gnu99 -DVERSION='"8.4.0"' \ - -o rpm-sort %{SOURCE2} -lrpmio %install -mkdir -p %{buildroot}%{_libexecdir}/grubby/ -install -D -m 0755 rpm-sort %{buildroot}%{_libexecdir}/grubby - mkdir -p %{buildroot}%{_sbindir}/ install -T -m 0755 %{SOURCE1} %{buildroot}%{_sbindir}/grubby install -T -m 0755 %{SOURCE4} %{buildroot}%{_sbindir}/installkernel @@ -75,8 +70,6 @@ fi %files %license COPYING -%dir %{_libexecdir}/grubby -%attr(0755,root,root) %{_libexecdir}/grubby/rpm-sort %attr(0755,root,root) %{_sbindir}/grubby %attr(0755,root,root) %{_sbindir}/installkernel %attr(0755,root,root) %{_prefix}/lib/kernel/install.d/10-devicetree.install @@ -84,6 +77,10 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Tue Nov 01 2022 Robbie Harwood - 8.40-68 +- Drop custom rpm-sort +- See-also: https://github.com/rpm-software-management/rpm/pull/2249 + * Tue Oct 04 2022 Robbie Harwood - 8.40-67 - Apply Marta's copy-default args fix diff --git a/rpm-sort.c b/rpm-sort.c deleted file mode 100644 index 274bcb1..0000000 --- a/rpm-sort.c +++ /dev/null @@ -1,356 +0,0 @@ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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; -} From d6967109223a4e10698fd8fc5a717637bce85d94 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 19 Jan 2023 11:35:50 +0000 Subject: [PATCH 112/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 4ee7241..44b20ad 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 68%{?dist} +Release: 69%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -77,6 +77,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Thu Jan 19 2023 Fedora Release Engineering - 8.40-69 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + * Tue Nov 01 2022 Robbie Harwood - 8.40-68 - Drop custom rpm-sort - See-also: https://github.com/rpm-software-management/rpm/pull/2249 From 8656bfd5651fe4ccf7a22e4a24129cfdf485946d Mon Sep 17 00:00:00 2001 From: Marta Lewandowska Date: Tue, 21 Feb 2023 19:33:02 +0100 Subject: [PATCH 113/132] Do not set root with not copying default --- grubby-bls | 15 +++++++++------ grubby.spec | 5 ++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/grubby-bls b/grubby-bls index cce0579..2d59de7 100755 --- a/grubby-bls +++ b/grubby-bls @@ -827,12 +827,15 @@ fi remove_var_prefix "$(get_prefix)" if [[ -n $kernel ]]; then - opts="${bls_options[$default_index]}" - if [[ $copy_default != "true" ]]; then - opts=$(echo $opts | sed -e 's/ .*//') - fi - if [[ -n $args ]]; then - opts="${opts} ${args}" + if [[ $copy_default = "true" ]]; then + opts="${bls_options[$default_index]}" + if [[ -n $args ]]; then + opts="${opts} ${args}" + fi + else + opts="${opts} ${args}" + remove_args="$kernelopts" + update_args "${opts}" "${remove_args}" "" fi add_bls_fragment "${kernel}" "${title}" "${opts}" "${initrd}" \ diff --git a/grubby.spec b/grubby.spec index 44b20ad..4ae304d 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 69%{?dist} +Release: 70%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -77,6 +77,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Tue Feb 21 2023 Marta Lewandowska - 8.40-70 +- remove root= when not copying default + * Thu Jan 19 2023 Fedora Release Engineering - 8.40-69 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild From 3d050aaf49cfd85b4cac6b48e461a147e85d4ff2 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jul 2023 05:39:58 +0000 Subject: [PATCH 114/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 4ae304d..a19523e 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 70%{?dist} +Release: 71%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls @@ -77,6 +77,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Thu Jul 20 2023 Fedora Release Engineering - 8.40-71 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + * Tue Feb 21 2023 Marta Lewandowska - 8.40-70 - remove root= when not copying default From aa9b1b454fd0c792226cefb65d744fadfaa8acda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 22 Jun 2023 11:33:14 -0600 Subject: [PATCH 115/132] Drop installkernel so that it can by provided by systemd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit systemd has kernel-install which supports being invoked as installkernel. After the file is removed from grubby, we can just provide a symlink installkernel → kernel-install. --- grubby.spec | 8 ++--- installkernel-bls | 83 ----------------------------------------------- 2 files changed, 4 insertions(+), 87 deletions(-) delete mode 100755 installkernel-bls diff --git a/grubby.spec b/grubby.spec index a19523e..af0bbdc 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,13 +3,12 @@ Name: grubby Version: 8.40 -Release: 71%{?dist} +Release: 72%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ Source1: grubby-bls # Source2: rpm-sort.c Source3: COPYING -Source4: installkernel-bls Source5: 95-kernel-hooks.install Source6: 10-devicetree.install Source7: grubby.8 @@ -53,7 +52,6 @@ cp %{SOURCE3} . || true %install mkdir -p %{buildroot}%{_sbindir}/ install -T -m 0755 %{SOURCE1} %{buildroot}%{_sbindir}/grubby -install -T -m 0755 %{SOURCE4} %{buildroot}%{_sbindir}/installkernel install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5} install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE6} @@ -71,12 +69,14 @@ fi %files %license COPYING %attr(0755,root,root) %{_sbindir}/grubby -%attr(0755,root,root) %{_sbindir}/installkernel %attr(0755,root,root) %{_prefix}/lib/kernel/install.d/10-devicetree.install %attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install %{_mandir}/man8/grubby.8* %changelog +* Mon Sep 11 2023 Zbigniew Jedrzejewski-Szmek - 8.40-72 +- Drop installkernel so that it can be provided by systemd + * Thu Jul 20 2023 Fedora Release Engineering - 8.40-71 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild diff --git a/installkernel-bls b/installkernel-bls deleted file mode 100755 index f2f607e..0000000 --- a/installkernel-bls +++ /dev/null @@ -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 . -# -# Author(s): tyson@rwii.com -# - -usage() { - echo "Usage: `basename $0` " >&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 From a73ecd5815d180cfd6a8adce7e23cf652462fa70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Such=C3=BD?= Date: Fri, 1 Dec 2023 08:13:01 +0000 Subject: [PATCH 116/132] Migrate to SPDX license This is part of https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_2 --- grubby.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index af0bbdc..a82fe14 100644 --- a/grubby.spec +++ b/grubby.spec @@ -5,7 +5,7 @@ Name: grubby Version: 8.40 Release: 72%{?dist} Summary: Command line tool for updating bootloader configs -License: GPLv2+ +License: GPL-2.0-or-later Source1: grubby-bls # Source2: rpm-sort.c Source3: COPYING From 893f94f4284445d5337ccd7c08aa265ef9d09f86 Mon Sep 17 00:00:00 2001 From: Marta Lewandowska Date: Wed, 10 Jan 2024 16:40:47 +0200 Subject: [PATCH 117/132] Don't overwrite vars that start with GRUB_CMDLINE_LINUX When updating args for ALL kernels, grubby clobbers all variables in /etc/default/grub that start with GRUB_CMDLINE_LINUX and renders that line multiple times, for each variable that exists. This breaks using recovery mode. Fix so this doesn't happen anymore. Signed-off-by: Marta Lewandowska --- grubby-bls | 2 +- grubby.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 2d59de7..ac82950 100755 --- a/grubby-bls +++ b/grubby-bls @@ -500,7 +500,7 @@ update_bls_fragment() { 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}" + sed -i -e "s/^GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\\\"${opts}\\\"/" "${grub_etc_default}" fi fi diff --git a/grubby.spec b/grubby.spec index a82fe14..f4bac16 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 72%{?dist} +Release: 73%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Wed Jan 10 2024 Marta Lewandowska - 8.40-73 +- Do not overwrite all vars that start with GRUB_CMDLINE_LINUX + * Mon Sep 11 2023 Zbigniew Jedrzejewski-Szmek - 8.40-72 - Drop installkernel so that it can be provided by systemd From 5318daa5c6383c3927ef85c81d28b3dfb0fdecd9 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 20 Jan 2024 21:34:21 +0000 Subject: [PATCH 118/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index f4bac16..a1c39e0 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 73%{?dist} +Release: 74%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Sat Jan 20 2024 Fedora Release Engineering - 8.40-74 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Wed Jan 10 2024 Marta Lewandowska - 8.40-73 - Do not overwrite all vars that start with GRUB_CMDLINE_LINUX From 758f62e580bc1732088a3a1ceb2847312ab020c4 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 24 Jan 2024 21:05:49 +0000 Subject: [PATCH 119/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index a1c39e0..421a493 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 74%{?dist} +Release: 75%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Wed Jan 24 2024 Fedora Release Engineering - 8.40-75 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Sat Jan 20 2024 Fedora Release Engineering - 8.40-74 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 197adec183a9b0c645c99384c69346efc84cf1fe Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 10 Apr 2024 14:38:27 +0000 Subject: [PATCH 120/132] Fix small typo in --args help message --- grubby-bls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index ac82950..1182a4a 100755 --- a/grubby-bls +++ b/grubby-bls @@ -630,7 +630,7 @@ print_usage() cat < Date: Thu, 18 Jul 2024 08:39:45 +0000 Subject: [PATCH 121/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 421a493..8478d3e 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 75%{?dist} +Release: 76%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Thu Jul 18 2024 Fedora Release Engineering - 8.40-76 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + * Wed Jan 24 2024 Fedora Release Engineering - 8.40-75 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 014744456dc40ad11344facea8b575cbcdb039ea Mon Sep 17 00:00:00 2001 From: Leo Sandoval Date: Mon, 25 Nov 2024 13:47:35 -0600 Subject: [PATCH 122/132] On grub cfg updates, run grub2-mkconfig for Xen systems Signed-off-by: Leo Sandoval --- grubby-bls | 9 +++++++++ grubby.spec | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 1182a4a..c7cb264 100755 --- a/grubby-bls +++ b/grubby-bls @@ -620,6 +620,15 @@ update_grubcfg() fi fi + # PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support, + # also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from + # 10_linux. So grub2-mkconfig has to run for both Xen Dom0 and DomU. + if [[ -e /sys/hypervisor/type ]] && grep -q "^xen$" /sys/hypervisor/type; then + if [ ! -e /sys/hypervisor/guest_type ] || ! grep -q "^HVM$" /sys/hypervisor/guest_type; then + RUN_MKCONFIG=true + fi + fi + if [[ $RUN_MKCONFIG = "true" ]]; then grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null fi diff --git a/grubby.spec b/grubby.spec index 8478d3e..5ee8ddc 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 76%{?dist} +Release: 77%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Mon Nov 25 2024 Leo Sandoval - 8.40-77 +- On grub cfg updates, run grub2-mkconfig for Xen systems + * Thu Jul 18 2024 Fedora Release Engineering - 8.40-76 - Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild From a94c545ae243d8050eec603e6df38c84e2f5f5ca Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Thu, 21 Mar 2024 17:09:57 +0200 Subject: [PATCH 123/132] Add riscv64 support Signed-off-by: David Abdurachmanov --- 10-devicetree.install | 2 +- grubby.spec | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/10-devicetree.install b/10-devicetree.install index 3345391..fdea5ec 100755 --- a/10-devicetree.install +++ b/10-devicetree.install @@ -2,7 +2,7 @@ # set -x -if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]] +if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 || "$(uname -m)" == riscv64 ]] then COMMAND="$1" KERNEL_VERSION="$2" diff --git a/grubby.spec b/grubby.spec index 5ee8ddc..63b5b6f 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 77%{?dist} +Release: 78%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -21,7 +21,7 @@ BuildRequires: pkgconfig BuildRequires: popt-devel BuildRequires: rpm-devel BuildRequires: sed -%ifarch aarch64 x86_64 %{power64} +%ifarch aarch64 x86_64 %{power64} riscv64 BuildRequires: grub2-tools-minimal Requires: grub2-tools-minimal Requires: grub2-tools @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Mon Dec 02 2024 David Abdurachmanov - 8.40-78 +- Add riscv64 support + * Mon Nov 25 2024 Leo Sandoval - 8.40-77 - On grub cfg updates, run grub2-mkconfig for Xen systems From 410b6c7592b831b18d5b2e18ccd28422c309c539 Mon Sep 17 00:00:00 2001 From: Leo Sandoval Date: Mon, 25 Nov 2024 13:07:52 -0600 Subject: [PATCH 124/132] grubby-bls: in s390* systems, run zipl on grub cfg update event Signed-off-by: Leo Sandoval --- grubby-bls | 6 +++++- grubby.spec | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index c7cb264..8d26a06 100755 --- a/grubby-bls +++ b/grubby-bls @@ -630,7 +630,11 @@ update_grubcfg() fi if [[ $RUN_MKCONFIG = "true" ]]; then - grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null + if [[ $bootloader = "zipl" ]]; then + zipl + else + grub2-mkconfig --no-grubenv-update -o "${grub_config}" &> /dev/null + fi fi } diff --git a/grubby.spec b/grubby.spec index 63b5b6f..bf11b1c 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 78%{?dist} +Release: 79%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Fri Dec 06 2024 Leo Sandoval - 8.40-79 +- grubby-bls: in s390* systems, run zipl on grub cfg update event + * Mon Dec 02 2024 David Abdurachmanov - 8.40-78 - Add riscv64 support From 6f82f6bf089e69d8ab59531766de0a79a4a21319 Mon Sep 17 00:00:00 2001 From: Leo Sandoval Date: Tue, 3 Dec 2024 17:54:14 -0600 Subject: [PATCH 125/132] grubby-bls: on PPC systems, remove petiboot's version checks Signed-off-by: Leo Sandoval --- grubby-bls | 23 ++--------------------- grubby.spec | 5 ++++- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/grubby-bls b/grubby-bls index 8d26a06..8fbaa27 100755 --- a/grubby-bls +++ b/grubby-bls @@ -595,29 +595,10 @@ remove_var_prefix() { update_grubcfg() { - # Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support - # so grub2-mkconfig has to be run to generate a config with menuentry commands. + # Older ppc64le OPAL firmware don't have BLS support so grub2-mkconfig has to be run + # to generate a config with menuentry commands. if [ "${arch}" = "ppc64le" ] && [ -d /sys/firmware/opal ]; then RUN_MKCONFIG="true" - petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" - - if test -e ${petitboot_path}; then - read -r -d '' petitboot_version < ${petitboot_path} - petitboot_version="$(echo ${petitboot_version//v})" - - if test -n ${petitboot_version}; then - major_version="$(echo ${petitboot_version} | cut -d . -f1)" - minor_version="$(echo ${petitboot_version} | cut -d . -f2)" - - re='^[0-9]+$' - if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] && - ([[ ${major_version} -gt 1 ]] || - [[ ${major_version} -eq 1 && - ${minor_version} -ge 8 ]]); then - RUN_MKCONFIG="false" - fi - fi - fi fi # PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support, diff --git a/grubby.spec b/grubby.spec index bf11b1c..dab4aa7 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 79%{?dist} +Release: 80%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Fri Dec 06 2024 Leo Sandoval - 8.40-80 +- grubby-bls: on PPC systems, remove petiboot's version checks + * Fri Dec 06 2024 Leo Sandoval - 8.40-79 - grubby-bls: in s390* systems, run zipl on grub cfg update event From 50760fed68aefd7a29bfc818a7dc8bf2168e3539 Mon Sep 17 00:00:00 2001 From: Martin Hicks Date: Wed, 24 Jul 2024 12:00:45 -0400 Subject: [PATCH 126/132] Allow custom filenames to exceed 10 9 sorts after 10, so "next" was always 10 and would overwrite previous 10~custom.conf files Signed-off-by: Martin Hicks --- grubby-bls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grubby-bls b/grubby-bls index 8fbaa27..526cf6c 100755 --- a/grubby-bls +++ b/grubby-bls @@ -356,7 +356,7 @@ get_custom_bls_filename() { prefix="${bls_target%%${arch}}" prefix="${prefix%.*}" - last=($(for bls in ${prefix}.*~custom*.conf ; do + last=($(for bls in $(ls ${prefix}.*~custom*.conf 2>/dev/null | sort -V); do if ! [[ -e "${bls}" ]] ; then continue fi From beb5f2b8a8856c22ef76566eea54c7bb0b3721cf Mon Sep 17 00:00:00 2001 From: Martin Hicks Date: Fri, 26 Jul 2024 08:22:44 -0400 Subject: [PATCH 127/132] Add 'custom' file entries at first gap Don't add a the next custom file after the last existing entry. This could result in a growing custom number with a large gap at the beginning. Fill the custom entries starting from 0. Signed-off-by: Martin Hicks Signed-off-by: Nicolas Frayer --- grubby-bls | 30 +++++++++++++++++------------- grubby.spec | 5 ++++- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/grubby-bls b/grubby-bls index 526cf6c..2785583 100755 --- a/grubby-bls +++ b/grubby-bls @@ -356,22 +356,26 @@ get_custom_bls_filename() { prefix="${bls_target%%${arch}}" prefix="${prefix%.*}" - last=($(for bls in $(ls ${prefix}.*~custom*.conf 2>/dev/null | sort -V); do - if ! [[ -e "${bls}" ]] ; then - continue - fi - bls="${bls##${prefix}.}" - bls="${bls%%~custom*}" - echo "${bls}" - done | tail -n1)) || : + first_gap=$( + first=0 + for bls_entry in $(ls "${prefix}".*~custom*.conf 2>/dev/null | sort -V); do + if [[ -e ${bls_entry} ]]; then + bls_entry="${bls_entry##"${prefix}".}" + bls_entry="${bls_entry%%~custom*}" + if [[ "${bls_entry}" = "${first}" ]]; then + first=$((first+1)) + else + break + fi + fi + done + echo "${first}") || : - if [[ -z $last ]]; then - last="0" - else - last=$((last+1)) + if [[ -z "$first_gap" ]]; then + first_gap="0" fi - echo "${bls_target}" | sed -e "s!${prefix}!${prefix}.${last}~custom!" + echo "${bls_target}" | sed -e "s!${prefix}!${prefix}.${first_gap}~custom!" } add_bls_fragment() { diff --git a/grubby.spec b/grubby.spec index dab4aa7..d7efabe 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 80%{?dist} +Release: 81%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Mon Jan 06 2025 Nicolas Frayer - 8.40-81 +- Fixups to custom kernel targets + * Fri Dec 06 2024 Leo Sandoval - 8.40-80 - grubby-bls: on PPC systems, remove petiboot's version checks From 06113ecc4c8825b2b4788514f51b9f39afb3fbbf Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 17 Jan 2025 05:15:43 +0000 Subject: [PATCH 128/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index d7efabe..9813791 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 81%{?dist} +Release: 82%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Fri Jan 17 2025 Fedora Release Engineering - 8.40-82 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + * Mon Jan 06 2025 Nicolas Frayer - 8.40-81 - Fixups to custom kernel targets From 7d63bffff90403fdb8e33c0a30562e0d73cafeeb Mon Sep 17 00:00:00 2001 From: Leo Sandoval Date: Thu, 20 Mar 2025 11:28:33 -0600 Subject: [PATCH 129/132] grubby-bls: in s390* systems, run zipl on grub cfg update event Change takes into account s390* systems as target for zipl execution. Reformat better archs/scenarios when either zipl or grub2-mkconfig must be run. Signed-off-by: Leo Sandoval --- grubby-bls | 20 +++++++++++--------- grubby.spec | 6 +++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/grubby-bls b/grubby-bls index 2785583..555fd13 100755 --- a/grubby-bls +++ b/grubby-bls @@ -599,17 +599,19 @@ remove_var_prefix() { update_grubcfg() { - # Older ppc64le OPAL firmware don't have BLS support so grub2-mkconfig has to be run - # to generate a config with menuentry commands. - if [ "${arch}" = "ppc64le" ] && [ -d /sys/firmware/opal ]; then + # Turn on RUN_MKCONFIG on different archs/scenarios + if [[ "${arch}" = 's390' ]] || [[ "${arch}" = 's390x' ]]; then + # On s390/s390x systems, run mkconfig/zipl RUN_MKCONFIG="true" - fi - - # PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support, - # also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from - # 10_linux. So grub2-mkconfig has to run for both Xen Dom0 and DomU. - if [[ -e /sys/hypervisor/type ]] && grep -q "^xen$" /sys/hypervisor/type; then + elif [[ "${arch}" = "ppc64le" ]] && [[ -d /sys/firmware/opal ]]; then + # Older ppc64le OPAL firmware don't have BLS support so grub2-mkconfig has to be run + # to generate a config with menuentry commands. + RUN_MKCONFIG="true" + elif [[ -e /sys/hypervisor/type ]] && grep -q "^xen$" /sys/hypervisor/type; then if [ ! -e /sys/hypervisor/guest_type ] || ! grep -q "^HVM$" /sys/hypervisor/guest_type; then + # PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support, + # also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from + # 10_linux. So grub2-mkconfig has to run for both Xen Dom0 and DomU. RUN_MKCONFIG=true fi fi diff --git a/grubby.spec b/grubby.spec index 9813791..1ffa529 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 82%{?dist} +Release: 83%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,10 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Thu Mar 20 2025 Leo Sandoval - 8.40-83 +- grubby-bls: in s390* systems, run zipl on grub cfg update event + Fixes previous commit and formats better the conditions that trigger grub cfg updates + * Fri Jan 17 2025 Fedora Release Engineering - 8.40-82 - Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild From 0eb1bed0a54ae1c41514e636f4016560cd355cdf Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 24 Jul 2025 16:39:20 +0000 Subject: [PATCH 130/132] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild --- grubby.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grubby.spec b/grubby.spec index 1ffa529..6abb3ed 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 83%{?dist} +Release: 84%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Thu Jul 24 2025 Fedora Release Engineering - 8.40-84 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + * Thu Mar 20 2025 Leo Sandoval - 8.40-83 - grubby-bls: in s390* systems, run zipl on grub cfg update event Fixes previous commit and formats better the conditions that trigger grub cfg updates From 6095bc576b3aa216400f1cc133ade107d4830ea7 Mon Sep 17 00:00:00 2001 From: Leo Sandoval Date: Wed, 30 Jul 2025 12:16:29 -0600 Subject: [PATCH 131/132] Update cfg when setting a default kernel Signed-off-by: Raju Cheerla Signed-off-by: Leo Sandoval --- grubby-bls | 2 +- grubby.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grubby-bls b/grubby-bls index 555fd13..11b69b1 100755 --- a/grubby-bls +++ b/grubby-bls @@ -567,7 +567,7 @@ set_default_bls() { echo "default=${default}" >> "${zipl_config}" fi fi - + update_grubcfg print_info "The default is ${bls_file[$index]} with index $index and kernel $(get_prefix)${bls_linux[$index]}" } diff --git a/grubby.spec b/grubby.spec index 6abb3ed..a7ec5c4 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 84%{?dist} +Release: 85%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -74,6 +74,9 @@ fi %{_mandir}/man8/grubby.8* %changelog +* Wed Jul 30 2025 Leo Sandoval - 8.40-85 +- Update cfg when setting a default kernel + * Thu Jul 24 2025 Fedora Release Engineering - 8.40-84 - Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild From 482a2825c47c4fd28a18beb279a3e826461bf878 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Wed, 10 Dec 2025 07:50:55 +0100 Subject: [PATCH 132/132] spec: own `/etc/sysconfig/kernel` `grubby` reads the `/etc/sysconfig/kernel` file which isn't owned by the package, nor created by it. This leads to all image build tooling having to take special care to write this file [1] [2] so produced deliverables automatically update their kernels. This commit moves the creation of this file to the `grubby` package so things work 'out of the box' instead of needing to do out-of-package configuration by third parties. [1]: https://pagure.io/fedora-kiwi-descriptions/blob/f43/f/root/etc/sysconfig [2]: https://github.com/osbuild/images/blob/a8fafe8d9b9f7fa0d4e7316b15452acd63c6941d/data/distrodefs/fedora/imagetypes.yaml#L1027-L1028 Signed-off-by: Simon de Vlieger --- grubby.spec | 10 +++++++++- kernel.sysconfig | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 kernel.sysconfig diff --git a/grubby.spec b/grubby.spec index a7ec5c4..87b8787 100644 --- a/grubby.spec +++ b/grubby.spec @@ -3,7 +3,7 @@ Name: grubby Version: 8.40 -Release: 85%{?dist} +Release: 86%{?dist} Summary: Command line tool for updating bootloader configs License: GPL-2.0-or-later Source1: grubby-bls @@ -12,6 +12,7 @@ Source3: COPYING Source5: 95-kernel-hooks.install Source6: 10-devicetree.install Source7: grubby.8 +Source8: kernel.sysconfig BuildRequires: gcc BuildRequires: glib2-devel @@ -59,6 +60,9 @@ install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE6} mkdir -p %{buildroot}%{_mandir}/man8 install -m 0644 %{SOURCE7} %{buildroot}%{_mandir}/man8/ +mkdir -p %{buildroot}%{_sysconfdir}/sysconfig +install -m 0644 %{SOURCE8} %{buildroot}%{_sysconfdir}/sysconfig/kernel + %post if [ "$1" = 2 ]; then arch=$(uname -m) @@ -72,8 +76,12 @@ fi %attr(0755,root,root) %{_prefix}/lib/kernel/install.d/10-devicetree.install %attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install %{_mandir}/man8/grubby.8* +%config(noreplace) %{_sysconfdir}/sysconfig/kernel %changelog +* Wed Dec 10 2025 Simon de Vlieger - 8.40-86 +- Own `/etc/sysconfig/kernel` which is used for `grubby` configuration + * Wed Jul 30 2025 Leo Sandoval - 8.40-85 - Update cfg when setting a default kernel diff --git a/kernel.sysconfig b/kernel.sysconfig new file mode 100644 index 0000000..8da1970 --- /dev/null +++ b/kernel.sysconfig @@ -0,0 +1,6 @@ +# UPDATEDEFAULT specifies if kernel-install should make +# new kernels the default +UPDATEDEFAULT=yes + +# DEFAULTKERNEL specifies the default kernel package type +DEFAULTKERNEL=kernel-core