package init

This commit is contained in:
chengquan 2019-12-30 14:36:43 +08:00
parent 63f77e78c0
commit 461affd01f
28 changed files with 2729 additions and 39 deletions

View File

@ -0,0 +1,143 @@
From c1c46d21182974181f5b4c2ed0a02288b4bfd880 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccallum@redhat.com>
Date: Fri, 2 Mar 2018 14:59:32 -0500
Subject: [PATCH 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

View File

@ -0,0 +1,209 @@
From 5dec033b19bb5b07a0a136a7357e16c8ca9f5dd6 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccallum@redhat.com>
Date: Fri, 2 Mar 2018 08:40:18 -0500
Subject: [PATCH 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

View File

@ -0,0 +1,25 @@
From fbc4d4feef66df7224fde64adae95525e73bf141 Mon Sep 17 00:00:00 2001
From: Rafael dos Santos <rdossant@redhat.com>
Date: Tue, 29 May 2018 15:15:24 +0200
Subject: [PATCH] Use system LDFLAGS
---
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

36
0004-Honor-sbindir.patch Normal file
View File

@ -0,0 +1,36 @@
From a56df998177574ef2db332220c15f11bccd98f7e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 18 Jul 2018 13:41:02 -0400
Subject: [PATCH] Honor sbindir
Signed-off-by: Peter Jones <pjones@redhat.com>
---
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

View File

@ -0,0 +1,48 @@
From f93a35be5bdec17044dd2a17980689d3cbf73d58 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 31 Jul 2018 17:43:53 +0200
Subject: [PATCH] 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 <hdegoede@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
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` <kernel_version> <bootimage> <mapfile>" >&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

BIN
8.40-1.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,182 @@
From d220ed2d9db1a2f9e2fde3195727a871c393e8cc Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 12:34:30 -0400
Subject: [PATCH 07/60] Add a bunch of tests for various
--default-{kernel,title,index}.
... and fix some failures where we see them.
Related: rhbz#1184014
(though I can't actually replicate his failure.)
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 50 ++++++++++++++++++++++++-----------------
test.sh | 10 +++++++++
test/results/defaultkernel/g.1 | 1 +
test/results/defaultkernel/l1.1 | 1 +
test/results/defaultkernel/z.1 | 1 +
test/results/defaulttitle/z.1 | 1 +
6 files changed, 44 insertions(+), 20 deletions(-)
create mode 100644 test/results/defaultkernel/g.1
create mode 100644 test/results/defaultkernel/l1.1
create mode 100644 test/results/defaultkernel/z.1
create mode 100644 test/results/defaulttitle/z.1
diff --git a/grubby.c b/grubby.c
index 649597e..0bb4869 100644
--- a/grubby.c
+++ b/grubby.c
@@ -428,7 +428,7 @@ char *grub2ExtractTitle(struct singleLine * line) {
/* bail out if line does not start with menuentry */
if (strcmp(line->elements[0].item, "menuentry"))
- return NULL;
+ return NULL;
i = 1;
current = line->elements[i].item;
@@ -437,10 +437,12 @@ char *grub2ExtractTitle(struct singleLine * line) {
/* if second word is quoted, strip the quotes and return single word */
if (isquote(*current) && isquote(current[current_len - 1])) {
char *tmp;
-
- tmp = strdup(current);
- *(tmp + current_len - 1) = '\0';
- return ++tmp;
+
+ tmp = strdup(current+1);
+ if (!tmp)
+ return NULL;
+ tmp[strlen(tmp)-1] = '\0';
+ return tmp;
}
/* if no quotes, return second word verbatim */
@@ -453,11 +455,11 @@ char *grub2ExtractTitle(struct singleLine * line) {
char * result;
/* need to ensure that ' does not match " as we search */
char quote_char = *current;
-
+
resultMaxSize = sizeOfSingleLine(line);
result = malloc(resultMaxSize);
snprintf(result, resultMaxSize, "%s", ++current);
-
+
i++;
for (; i < line->numElements; ++i) {
current = line->elements[i].item;
@@ -4648,27 +4650,35 @@ int main(int argc, const char ** argv) {
struct singleLine * line;
struct singleEntry * entry;
- if (config->defaultImage == -1) return 0;
+ if (config->defaultImage == -1)
+ return 0;
if (config->defaultImage == DEFAULT_SAVED_GRUB2 &&
cfi->defaultIsSaved)
config->defaultImage = 0;
entry = findEntryByIndex(config, config->defaultImage);
- if (!entry) return 0;
+ if (!entry)
+ return 0;
if (!configureGrub2) {
- line = getLineByType(LT_TITLE, entry->lines);
- if (!line) return 0;
- printf("%s\n", line->elements[1].item);
-
+ char *title;
+ line = getLineByType(LT_TITLE, entry->lines);
+ if (!line)
+ return 0;
+ title = extractTitle(config, line);
+ if (!title)
+ return 0;
+ printf("%s\n", title);
+ free(title);
} else {
- char * title;
+ char * title;
- dbgPrintf("This is GRUB2, default title is embeded in menuentry\n");
- line = getLineByType(LT_MENUENTRY, entry->lines);
- if (!line) return 0;
- title = grub2ExtractTitle(line);
- if (title)
- printf("%s\n", title);
+ dbgPrintf("This is GRUB2, default title is embeded in menuentry\n");
+ line = getLineByType(LT_MENUENTRY, entry->lines);
+ if (!line)
+ return 0;
+ title = grub2ExtractTitle(line);
+ if (title)
+ printf("%s\n", title);
}
return 0;
diff --git a/test.sh b/test.sh
index 6379698..96e0087 100755
--- a/test.sh
+++ b/test.sh
@@ -298,6 +298,9 @@ grubDisplayTest grub.9 defaulttitle/g.9 --default-title
grubDisplayTest grub.10 defaulttitle/g.10 --default-title
grubDisplayTest grub.11 defaulttitle/g.11 --default-title
+testing="GRUB display default kernel"
+grubDisplayTest grub.1 defaultkernel/g.1 --default-kernel
+
testing="LILO default directive"
liloTest lilo.1 default/l1.1 --set-default=/boot/vmlinuz-2.4.18-4
liloTest lilo.1 default/l1.2 --remove-kernel=/boot/vmlinuz-2.4.18-4smp
@@ -305,10 +308,17 @@ liloTest lilo.1 default/l1.3 --add-kernel /boot/kernel --title label \
--copy-default
liloTest lilo.1 default/l1.4 --add-kernel /boot/kernel --title label \
--copy-default --make-default
+liloDisplayTest lilo.1 defaultkernel/l1.1 --default-kernel
testing="Z/IPL default directive"
ziplTest zipl.1 default/z1.1 --add-kernel /boot/new-kernel --title test
ziplTest zipl.1 default/z1.2 --add-kernel /boot/new-kernel --title test --make-default
+testing="Z/IPL display default index"
+ziplDisplayTest zipl.1 defaultindex/0 --default-index
+testing="Z/IPL display default title"
+ziplDisplayTest zipl.1 defaulttitle/z.1 --default-title
+testing="Z/IPL display default kernel"
+ziplDisplayTest zipl.1 defaultkernel/z.1 --default-kernel
testing="GRUB fallback directive"
grubTest grub.5 fallback/g5.1 --remove-kernel=/boot/vmlinuz-2.4.7-ac3 \
diff --git a/test/results/defaultkernel/g.1 b/test/results/defaultkernel/g.1
new file mode 100644
index 0000000..2c3ac11
--- /dev/null
+++ b/test/results/defaultkernel/g.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.7-2
diff --git a/test/results/defaultkernel/l1.1 b/test/results/defaultkernel/l1.1
new file mode 100644
index 0000000..fd22b1b
--- /dev/null
+++ b/test/results/defaultkernel/l1.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.18-4smp
diff --git a/test/results/defaultkernel/z.1 b/test/results/defaultkernel/z.1
new file mode 100644
index 0000000..2c62e98
--- /dev/null
+++ b/test/results/defaultkernel/z.1
@@ -0,0 +1 @@
+/boot/vmlinuz-2.4.9-37
diff --git a/test/results/defaulttitle/z.1 b/test/results/defaulttitle/z.1
new file mode 100644
index 0000000..a08e1f3
--- /dev/null
+++ b/test/results/defaulttitle/z.1
@@ -0,0 +1 @@
+linux
--
1.8.3.1

View File

@ -0,0 +1,123 @@
From b9a37e249bf279ceb0b63ad4676f03d11796cfc9 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 26 Oct 2015 14:22:39 -0400
Subject: [PATCH 18/60] Always do the "rungrubby --debug" after the normal
kernel on install.
This way the during an update, the right kernel is picked as "default"
for the command line arguments.
Related: rhbz#1212128
Signed-off-by: Peter Jones <pjones@redhat.com>
---
new-kernel-pkg | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 9f56c47..9574dbb 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -243,8 +243,8 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby for grub 0.97"
fi
@@ -257,8 +257,8 @@ install() {
${mbargs:+--mbargs=\"$mbargs\"} \
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby for grub 2"
fi
@@ -272,8 +272,8 @@ install() {
${mbargs:+--mbargs=\"$mbargs\"} \
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby for grub 2 with UEFI"
fi
@@ -288,8 +288,8 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$version\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
if [ -n "$runLilo" ]; then
[ -n "$verbose" ] && echo "running $lilo"
if [ ! -x $lilo ] ; then
@@ -313,8 +313,8 @@ install() {
--args=\"root=$rootdevice $kernargs \$debugargs\" \
--remove-kernel=\"TITLE=$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS} $makedefault
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby for extlinux"
fi
@@ -480,8 +480,8 @@ update() {
${mbkernel:+--add-multiboot=\"$mbkernel\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"
fi
@@ -493,8 +493,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby"
fi
@@ -506,8 +506,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby"
fi
@@ -519,8 +519,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
if [ -n "$runLilo" ]; then
[ -n "$verbose" ] && echo "running $lilo"
@@ -571,8 +571,8 @@ update() {
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
- rungrubby --debug ${ARGS}
rungrubby ${ARGS}
+ rungrubby --debug ${ARGS}
else
[ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby"
fi
--
1.8.3.1

View File

@ -0,0 +1,78 @@
From d9406b061cef40bd42ed813e13bd02b3a285adae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@fedoraproject.org>
Date: Fri, 23 Jun 2017 23:56:50 +0200
Subject: [PATCH 44/60] Be more thorough about flushing our config file
when
writing.
Add missing fclose() at the end of writeConfig
Use fflush(out) + fsync(fileno(out) on temporary file
fsync() the destination directory after rename
---
grubby.c | 40 ++++++++++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/grubby.c b/grubby.c
index 345195c..951abb7 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1591,6 +1591,7 @@ static int writeConfig(struct grubConfig * cfg, char * outName,
int needs = MAIN_DEFAULT;
struct stat sb;
int i;
+ int rc = 0;
if (!strcmp(outName, "-")) {
out = stdout;
@@ -1694,15 +1695,42 @@ static int writeConfig(struct grubConfig * cfg, char * outName,
}
if (tmpOutName) {
- if (rename(tmpOutName, outName)) {
- fprintf(stderr, _("grubby: error moving %s to %s: %s\n"),
- tmpOutName, outName, strerror(errno));
- unlink(outName);
- return 1;
+ /* write userspace buffers */
+ if (fflush(out))
+ rc = 1;
+
+ /* purge the write-back cache with fsync() */
+ if (fsync(fileno(out)))
+ rc = 1;
+
+ if (fclose(out))
+ rc = 1;
+
+ if (rc == 0 && rename(tmpOutName, outName)) {
+ unlink(tmpOutName);
+ rc = 1;
+ }
+
+ /* fsync() the destination directory after rename */
+ if (rc == 0) {
+ int dirfd;
+
+ dirfd = open(dirname(strdupa(outName)), O_RDONLY);
+ if (dirfd < 0)
+ rc = 1;
+ else if (fsync(dirfd))
+ rc = 1;
+
+ if (dirfd >= 0)
+ close(dirfd);
}
+
+ if (rc == 1)
+ fprintf(stderr,
+ _("grubby: error flushing data: %m\n"));
}
- return 0;
+ return rc;
}
static int numEntries(struct grubConfig *cfg) {
--
2.19.1

View File

@ -0,0 +1,39 @@
From 90e25125a8e26560a8e0fe27462ea639ad0b309b Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Fri, 15 Mar 2019 10:14:42 +0100
Subject: [PATCH 59/60] Check that pointers are not NULL before
dereferencing
them
The coverity scan complains that the argValueMatch() function derefences
the chptra and chptrb pointers when these may be NULL. That's not really
true since the function first checks if both aren't NULL and then only
dereferences one when the other is NULL.
But still this confuses coverity, so to make it happy let's just check
if the pointer isn't NULL before derefencing them.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grubby.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index 1de7b52..522d4d5 100644
--- a/grubby.c
+++ b/grubby.c
@@ -3340,9 +3340,9 @@ static int argValueMatch(const char *one, const char *two)
if (!chptra && !chptrb)
return 0;
- else if (!chptra)
+ else if (!chptra && chptrb)
return *chptrb - 0;
- else if (!chptrb)
+ else if (!chptrb && chptra)
return 0 - *chptra;
else
return strcmp(chptra, chptrb);
--
2.19.1

View File

@ -0,0 +1,85 @@
From 7713f8e23e326dcf1258a715e2554a4bf53dec59 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 16:26:59 -0400
Subject: [PATCH 11/60] Don't leak from one extractTitle() call.
Found by coverity.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/grubby.c b/grubby.c
index 0bb4869..70477ba 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1510,13 +1510,14 @@ static struct grubConfig * readConfig(const char * inName,
return cfg;
}
-static void writeDefault(FILE * out, char * indent,
+static void writeDefault(FILE * out, char * indent,
char * separator, struct grubConfig * cfg) {
struct singleEntry * entry;
struct singleLine * line;
int i;
- if (!cfg->defaultImage && cfg->flags == GRUB_CONFIG_NO_DEFAULT) return;
+ if (!cfg->defaultImage && cfg->flags == GRUB_CONFIG_NO_DEFAULT)
+ return;
if (cfg->defaultImage == DEFAULT_SAVED)
fprintf(out, "%sdefault%ssaved\n", indent, separator);
@@ -1540,34 +1541,40 @@ static void writeDefault(FILE * out, char * indent,
fprintf(out, "%sset default=\"%d\"\n", indent,
cfg->defaultImage);
} else {
- fprintf(out, "%sdefault%s%d\n", indent, separator,
+ fprintf(out, "%sdefault%s%d\n", indent, separator,
cfg->defaultImage);
}
} else {
int image = cfg->defaultImage;
entry = cfg->entries;
- while (entry && entry->skip) entry = entry->next;
+ while (entry && entry->skip)
+ entry = entry->next;
i = 0;
while (entry && i < image) {
entry = entry->next;
- while (entry && entry->skip) entry = entry->next;
+ while (entry && entry->skip)
+ entry = entry->next;
i++;
}
- if (!entry) return;
+ if (!entry)
+ return;
line = getLineByType(LT_TITLE, entry->lines);
if (line && line->numElements >= 2)
- fprintf(out, "%sdefault%s%s\n", indent, separator,
+ fprintf(out, "%sdefault%s%s\n", indent, separator,
line->elements[1].item);
- else if (line && (line->numElements == 1) &&
+ else if (line && (line->numElements == 1) &&
cfg->cfi->titleBracketed) {
- fprintf(out, "%sdefault%s%s\n", indent, separator,
- extractTitle(cfg, line));
+ char *title = extractTitle(cfg, line);
+ if (title) {
+ fprintf(out, "%sdefault%s%s\n", indent, separator, title);
+ free(title);
+ }
}
}
}
--
1.8.3.1

52
Drop-SEGV-handler.patch Normal file
View File

@ -0,0 +1,52 @@
From d1309f34c347bea393582b5d927db1c7c577198c Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Thu, 27 Feb 2014 10:35:59 +0100
Subject: [PATCH 06/60] Drop SEGV handler
The generated tracebacks are mostly useless without debuginfo (which is likely
not present if the crash is not anticipated) and prevent ABRT from doing a
better job.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
grubby.c | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/grubby.c b/grubby.c
index 440c627..649597e 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4211,21 +4211,6 @@ int addNewKernel(struct grubConfig * config, struct singleEntry * template,
return 0;
}
-static void traceback(int signum)
-{
- void *array[40];
- size_t size;
-
- signal(SIGSEGV, SIG_DFL);
- memset(array, '\0', sizeof (array));
- size = backtrace(array, 40);
-
- fprintf(stderr, "grubby received SIGSEGV! Backtrace (%ld):\n",
- (unsigned long)size);
- backtrace_symbols_fd(array, size, STDERR_FILENO);
- exit(1);
-}
-
int main(int argc, const char ** argv) {
poptContext optCon;
const char * grubConfig = NULL;
@@ -4368,8 +4353,6 @@ int main(int argc, const char ** argv) {
useextlinuxmenu=0;
- signal(SIGSEGV, traceback);
-
int i = 0;
for (int j = 1; j < argc; j++)
i += strlen(argv[j]) + 1;
--
1.8.3.1

View File

@ -0,0 +1,28 @@
From 191c79fe21c51ee893e40e2f53c03175286fdb0f Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 2 Jul 2015 12:44:51 -0400
Subject: [PATCH 08/60] Emit better systemd debug settings on debug entries.
Resolves: rhbz#1212128
Signed-off-by: Peter Jones <pjones@redhat.com>
---
new-kernel-pkg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 1cdbbb9..1f6ab39 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -121,7 +121,7 @@ mbkernel="$HYPERVISOR"
mbargs="$HYPERVISOR_ARGS"
adddracutargs=""
addplymouthinitrd=""
-DEBUGARG="systemd.debug"
+DEBUGARG="systemd.log_level=debug systemd.log_target=kmsg"
usage() {
echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
--
1.8.3.1

View File

@ -0,0 +1,108 @@
From 9a2fc457659cc2baee7d13ed6b0f8c864ae605d9 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 5 Feb 2019 17:29:11 +0100
Subject: [PATCH 58/60] Fix GCC warnings about possible string
truncations and
buffer overflows
Building with -Werror=stringop-truncation and -Werror=stringop-overflow
leads to GCC complaining about possible string truncation and overflows.
Fix this by using memcpy(), explicitly calculating the buffers lenghts
and set a NUL byte terminator after copying the buffers.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grubby.c | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/grubby.c b/grubby.c
index 1d3e924..1de7b52 100644
--- a/grubby.c
+++ b/grubby.c
@@ -463,20 +463,28 @@ 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 (current[current_len-1] != quote_char) {
- 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;
}
@@ -1300,6 +1308,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"))
@@ -1314,13 +1323,18 @@ static struct grubConfig * readConfig(const char * inName,
len = strlen(title);
if (title[len-1] == quote_char) {
- 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;
@@ -4589,10 +4603,18 @@ 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.19.1

View File

@ -0,0 +1,64 @@
From a6843cb0fc122a3bd8a7e4067c3783ef4ce69f33 Mon Sep 17 00:00:00 2001
From: marcosfrm <marcosfrm@users.noreply.github.com>
Date: Tue, 6 Oct 2015 08:29:02 -0300
Subject: [PATCH 16/60] Fix dracut cmdline options and conditionalize them to
--add-dracut-args
By default initramfs generated by dracut is HostOnly and has vconsole.conf and locale.conf included. Instead of killing this import section, conditionalize it to --add-dracut-args.
Reference: http://git.kernel.org/cgit/boot/dracut/dracut.git/tree/modules.d/10i18n/parse-i18n.sh
---
new-kernel-pkg | 37 +++++++++++++++----------------------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 90652da..997fb1f 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -825,28 +825,21 @@ if [[ ${ARCH} =~ armv[5|7].*l ]]; then
fi
[ -n "$verbose" ] && echo "devtreedir is $devtreedir"
-# add dracut i18n, keyboard and plymouth kernel args if requested
-if [ -n "$dracut" -o -n "$adddracutargs" ]; then
- if [ -r /etc/vconsole.conf ]; then
- . /etc/vconsole.conf
- elif [ -r /etc/sysconfig/keyboard ]; then
- . /etc/sysconfig/keyboard
- fi
-
- if [ -r /etc/locale.conf ]; then
- . /etc/locale.conf
- elif [ -r /etc/sysconfig/i18n ]; then
- . /etc/sysconfig/i18n
- fi
-
- for i in SYSFONT SYSFONTACM UNIMAP LANG KEYTABLE; do
- val=$(eval echo \$$i)
- [ -n "$val" ] && kernargs="$kernargs $i=$val"
- done
-
- if [ -n "$KEYBOARDTYPE" -a "$KEYBOARDTYPE" != "pc" ]; then
- kernargs="$kernargs KEYBOARDTYPE=$KEYBOARDTYPE"
- fi
+# add dracut kernel args if requested
+if [ -n "$dracut" -a -n "$adddracutargs" ]; then
+ [ -r /etc/vconsole.conf ] && . /etc/vconsole.conf
+ [ -r /etc/locale.conf ] && . /etc/locale.conf
+
+ while read opt rd_opt; do
+ [ -n "${!opt}" ] && kernargs="$kernargs $rd_opt=\"${!opt}\""
+ done <<< 'KEYMAP rd.vconsole.keymap
+ FONT rd.vconsole.font
+ FONT_MAP rd.vconsole.font.map
+ FONT_UNIMAP rd.vconsole.font.unimap
+ UNICODE rd.vconsole.font.unicode
+ EXT_KEYMAP rd.vconsole.keymap.ext
+ LANG rd.locale.LANG
+ LC_ALL rd.locale.LC_ALL'
fi
# set this as the default if we have the package and it matches
--
1.8.3.1

View File

@ -0,0 +1,170 @@
From 46cab02a27010d74144a6342efc2b34961bb2e69 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 27 Sep 2017 11:28:00 -0400
Subject: [PATCH 45/60] Fix incorrect test case and --remove-args with a
value.
Currently we have this test case:
grubTest grub.3 updargs/g3.4 --update-kernel=ALL
--remove-args="hdd=foobar"
This fails to notice that the actual argument in grub.3 is hdd=ide-scsi,
and removes it anyway, and the data in g3.4 supports that behavior.
This is clearly wrong, and so this patch introduces updargs/g3.5, which
leaves hdd=ide-scsi intact, and fixes the code so that it won't modify
the command line in that case.
Resolves: rhbz#1476273
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 73 ++++++++++++++++++++++++++++++++++++++++-------
test.sh | 2 +-
test/results/updargs/g3.5 | 16 +++++++++++
3 files changed, 79 insertions(+), 12 deletions(-)
create mode 100644 test/results/updargs/g3.5
diff --git a/grubby.c b/grubby.c
index 951abb7..c2fab23 100644
--- a/grubby.c
+++ b/grubby.c
@@ -3270,20 +3270,68 @@ static void removeElement(struct singleLine * line, int removeHere) {
line->numElements--;
}
-int argMatch(const char * one, const char * two) {
+static int argNameMatch(const char *one, const char *two)
+{
char * first, * second;
- char * chptr;
+ char *chptra, *chptrb;
+ int rc;
first = strcpy(alloca(strlen(one) + 1), one);
second = strcpy(alloca(strlen(two) + 1), two);
- chptr = strchr(first, '=');
- if (chptr) *chptr = '\0';
+ chptra = strchr(first, '=');
+ if (chptra)
+ *chptra = '\0';
+
+ chptrb = strchr(second, '=');
+ if (chptrb)
+ *chptrb = '\0';
+
+ rc = strcmp(first, second);
+
+ if (chptra)
+ *chptra = '=';
+ if (chptrb)
+ *chptrb = '=';
+
+ return rc;
+}
+
+static int argHasValue(const char *arg)
+{
+ char *chptr;
+
+ chptr = strchr(arg, '=');
- chptr = strchr(second, '=');
- if (chptr) *chptr = '\0';
+ if (chptr)
+ return 1;
+ return 0;
+}
- return strcmp(first, second);
+static int argValueMatch(const char *one, const char *two)
+{
+ char *first, *second;
+ char *chptra, *chptrb;
+
+ first = strcpy(alloca(strlen(one) + 1), one);
+ second = strcpy(alloca(strlen(two) + 1), two);
+
+ chptra = strchr(first, '=');
+ if (chptra)
+ chptra += 1;
+
+ chptrb = strchr(second, '=');
+ if (chptrb)
+ chptrb += 1;
+
+ if (!chptra && !chptrb)
+ return 0;
+ else if (!chptra)
+ return *chptrb - 0;
+ else if (!chptrb)
+ return 0 - *chptra;
+ else
+ return strcmp(chptra, chptrb);
}
int updateActualImage(struct grubConfig * cfg, const char * image,
@@ -3419,7 +3467,7 @@ int updateActualImage(struct grubConfig * cfg, const char * image,
}
if (usedElements[i])
continue;
- if (!argMatch(line->elements[i].item, *arg)) {
+ if (!argNameMatch(line->elements[i].item, *arg)) {
usedElements[i]=1;
break;
}
@@ -3470,9 +3518,12 @@ int updateActualImage(struct grubConfig * cfg, const char * image,
!strcmp(line->elements[i].item, "--"))
/* reached the end of hyper args, stop here */
break;
- if (!argMatch(line->elements[i].item, *arg)) {
- removeElement(line, i);
- break;
+ if (!argNameMatch(line->elements[i].item, *arg)) {
+ if (!argHasValue(*arg) ||
+ !argValueMatch(line->elements[i].item, *arg)) {
+ removeElement(line, i);
+ break;
+ }
}
}
/* handle removing LT_ROOT line too */
diff --git a/test.sh b/test.sh
index a6da290..5d59216 100755
--- a/test.sh
+++ b/test.sh
@@ -381,7 +381,7 @@ grubTest grub.3 updargs/g3.2 --update-kernel=DEFAULT \
--args "root=/dev/hdd1 hdd=notide-scsi"
grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd"
grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=ide-scsi"
-grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=foobar"
+grubTest grub.3 updargs/g3.5 --update-kernel=ALL --remove-args="hdd=foobar"
grubTest grub.3 updargs/g3.7 --update-kernel=ALL \
--remove-args="hdd root ro"
grubTest grub.7 updargs/g7.2 --boot-filesystem=/ \
diff --git a/test/results/updargs/g3.5 b/test/results/updargs/g3.5
new file mode 100644
index 0000000..7d50bb8
--- /dev/null
+++ b/test/results/updargs/g3.5
@@ -0,0 +1,16 @@
+#boot=/dev/hda
+timeout=10
+splashimage=(hd0,1)/grub/splash.xpm.gz
+title Red Hat Linux (2.4.7-2smp)
+ root (hd0,1)
+ kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi
+ initrd /initrd-2.4.7-2smp.img
+title Red Hat Linux-up (2.4.7-2)
+ root (hd0,1)
+ kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi
+ initrd /initrd-2.4.7-2.img
+title DOS
+ rootnoverify (hd0,0)
+ chainloader +1
+
+
--
2.19.1

View File

@ -0,0 +1,22 @@
From c091abfca6c51079478431539b56df0e0d0346b1 Mon Sep 17 00:00:00 2001
From: zhangguangzhi <zhangguangzhi3@huawei.com>
Date: Wed, 18 Sep 2019 03:27:22 -0400
Subject: [PATCH] fix test error g2-1.15
diff --git a/test/results/add/g2-1.15 b/test/results/add/g2-1.15
index b67c373..ee5f868 100644
--- a/test/results/add/g2-1.15
+++ b/test/results/add/g2-1.15
@@ -82,7 +82,7 @@ menuentry 'Fedora 21 Rescue' --class fedora --class gnu-linux --class gnu --clas
search --no-floppy --fs-uuid --set=root 6169b46f-0257-4319-b2e4-caaed2a8e06b
fi
linuxefi /vmlinuz-0-rescue-5a94251776a14678911d4ae0949500f5 root=/fooooo ro rd.lvm.lv=fedora_uefi/root rd.lvm.lv=fedora_uefi/swap rhgb quiet
- initrdefi /initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img
+ initrd /initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img
}
menuentry 'Fedora, with Linux 3.15.0-0.rc5.git2.10.fc21.x86_64' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.15.0-0.rc5.git2.10.fc21.x86_64-advanced-a14e3dcb-ade3-42f7-832f-d9f66b5ae6a3' {
load_video
--
2.19.1

View File

@ -0,0 +1,51 @@
From ee49b7b71d017097be5b4a0f32bff83379b0a86e Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Mon, 18 Mar 2019 12:53:23 +0100
Subject: [PATCH 60/60] Print default image even if isn't a suitable one
The grubby --default-kernel option only prints the default kernel if
this
is a suitable one. That is if its associated kernel cmdline root param
is
the same than the partition currently mounted as the filesystem root.
But the grubby --set-default option doesn't have that restriction, it is
able to set a kernel as the default even if its root is for a different
partition. So make the --default-kernel option to also print the kernel
in this case. Still check if is a suitable image so --debug can tell it.
Resolves: rhbz#1323842
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grubby.c | 4 +++-
test/results/debug/g2.1 | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index 522d4d5..c3249bf 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4887,7 +4887,9 @@ int main(int argc, const char ** argv) {
config->defaultImage = 0;
entry = findEntryByIndex(config, config->defaultImage);
if (!entry) return 0;
- if (!suitableImage(entry, bootPrefix, 0, flags)) return 0;
+
+ /* check if is a suitable image but still print it */
+ suitableImage(entry, bootPrefix, 0, flags);
line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
if (!line) return 0;
diff --git a/test/results/debug/g2.1 b/test/results/debug/g2.1
index f5187f5..d579b59 100644
--- a/test/results/debug/g2.1
+++ b/test/results/debug/g2.1
@@ -12,3 +12,4 @@ DBG: linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root
DBG: echo 'Loading initial ramdisk ...'
DBG: initrd /initramfs-2.6.38.8-32.fc15.x86_64.img
DBG: }
+/boot/vmlinuz-2.6.38.8-32.fc15.x86_64
--
2.19.1

View File

@ -1,39 +0,0 @@
# grubby
#### 介绍
{**以下是码云平台说明,您可以替换此简介**
码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -0,0 +1,30 @@
From 99727547fcab701f95e560f190e760540faef6f4 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 13 Apr 2015 13:57:33 -0700
Subject: [PATCH 01/60] Set envFile from --env when bootloader is not specified
---
grubby.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index d4ebb86..53fe925 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4423,9 +4423,11 @@ int main(int argc, const char ** argv) {
}
if (!cfi) {
- if (grub2FindConfig(&grub2ConfigType))
+ if (grub2FindConfig(&grub2ConfigType)) {
cfi = &grub2ConfigType;
- else
+ if (envPath)
+ cfi->envFile = envPath;
+ } else
#ifdef __ia64__
cfi = &eliloConfigType;
#elif __powerpc__
--
1.8.3.1

View File

@ -0,0 +1,232 @@
From 3689d4cebedf115e41c192bf034b6f86fcb80acb Mon Sep 17 00:00:00 2001
From: Dennis Gilmore <dennis@ausil.us>
Date: Wed, 30 Aug 2017 14:03:45 -0500
Subject: [PATCH] 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 <dennis@ausil.us>
---
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
--- 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=""
@@ -386,53 +377,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 \
@@ -534,36 +478,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 \
@@ -874,33 +788,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 07d8671..0000000
--- 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

View File

@ -0,0 +1,28 @@
From 3cab2afc418f3363152708ab8bfaeb5380fa1385 Mon Sep 17 00:00:00 2001
From: Luo Chunsheng <luochunsheng@huawei.com>
Date: Tue, 16 Apr 2019 05:02:46 -0400
Subject: [PATCH] Currently we have this test case: grubDisplayTest grub.1
defaultkernel/g.1 --default-kernel when no boot partition, it outputs without
"/boot" Prefix, then don't match defaultkernel/g.1, so add test option
"--boot-filesystem=/boot" to fix make test fail.
---
test.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test.sh b/test.sh
index 5d59216..6896985 100755
--- a/test.sh
+++ b/test.sh
@@ -299,7 +299,7 @@ grubDisplayTest grub.10 defaulttitle/g.10 --default-title
grubDisplayTest grub.11 defaulttitle/g.11 --default-title
testing="GRUB display default kernel"
-grubDisplayTest grub.1 defaultkernel/g.1 --default-kernel
+grubDisplayTest grub.1 defaultkernel/g.1 --boot-filesystem=/boot --default-kernel
testing="LILO default directive"
liloTest lilo.1 default/l1.1 --set-default=/boot/vmlinuz-2.4.18-4
--
1.8.3.1

View File

@ -0,0 +1,60 @@
From 171aaa84047acc3b1ed99cd7c1d8c7a5b0394b10 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 31 Jan 2018 13:06:48 -0500
Subject: [PATCH 46/60] grubby: Make sure configure$BOOTLOADER variables
are
set correctly.
When we've chosen a bootloader because it's default for a platform, and
we've already determined it's not overridden by the command line, set
the configure$BOOTLOADER variable to 1 so that our checks for which
bootloader are selected work correctly.
Resolves: rhbz#1340893
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grubby.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/grubby.c b/grubby.c
index c2fab23..1d3e924 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4659,22 +4659,27 @@ int main(int argc, const char ** argv) {
if (!cfi) {
if (grub2FindConfig(&grub2ConfigType)) {
cfi = &grub2ConfigType;
+ configureGrub2 = 1;
if (envPath)
cfi->envFile = envPath;
- } else
+ } else {
#ifdef __ia64__
cfi = &eliloConfigType;
- #elif __powerpc__
+ configureLilo = 1;
+ #elif defined(__powerpc__)
cfi = &yabootConfigType;
- #elif __sparc__
+ configureYaboot = 1;
+ #elif defined(__sparc__)
cfi = &siloConfigType;
- #elif __s390__
+ configureSilo = 1;
+ #elif defined(__s390__) || defined(__s390x__)
cfi = &ziplConfigType;
- #elif __s390x__
- cfi = &ziplConfigtype;
+ configureZipl = 1
#else
cfi = &grubConfigType;
+ configureGrub = 1;
#endif
+ }
}
if (!grubConfig) {
--
2.19.1

616
grubby-bls Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
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 <<EOF
title ${NAME} (${kernelver}) ${VERSION}${debugname}
version ${kernelver}${debugid}
linux ${kernel}
initrd /initramfs-${kernelver}.img
options \$kernelopts
id ${ID}-${datetime}-${kernelver}${debugid}
grub_users \$grub_users
grub_arg --unrestricted
grub_class kernel${flavor}
EOF
}
remove_bls_fragment() {
local indexes=($(param_to_indexes "$1"))
if [[ $indexes = "-1" ]]; then
print_error "The param $1 is incorrect"
fi
for i in ${indexes[*]}; do
rm -f "${bls_file[$i]}"
done
get_bls_values
}
add_bls_fragment() {
local kernel="$1" && shift
local title="$1" && shift
local options="$1" && shift
local initrd="$1" && shift
local extra_initrd="$1" && shift
if [[ $kernel = *"vmlinuz-"* ]]; then
kernelver="${kernel##*/vmlinuz-}"
else
kernelver="${kernel##*/}"
fi
if [[ ! -d "/lib/modules/${kernelver}" || ! -f "/boot/vmlinuz-${kernelver}" ]] &&
[[ $bad_image != "true" ]]; then
print_error "The ${kernelver} kernel isn't installed in the machine"
fi
if [[ -z $title ]]; then
print_error "The kernel title must be specified"
fi
if [[ ! -d $blsdir ]]; then
install -m 700 -d "${blsdir}"
fi
bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
kernel_dir="/lib/modules/${kernelver}"
if [[ -f "${kernel_dir}/bls.conf" ]]; then
cp -aT "${kernel_dir}/bls.conf" "${bls_target}" || exit $?
else
if [[ -d $kernel_dir ]]; then
datetime="$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")"
else
datetime=0
fi
mkbls "${kernel}" "${kernelver}" "${datetime}" > "${bls_target}"
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 <<EOF
Usage: grubby [OPTION...]
--add-kernel=kernel-path add an entry for the specified kernel
--args=args default arguments for the new kernel or new arguments for kernel being updated)
--bad-image-okay don't sanity check images in boot entries (for testing only)
-c, --config-file=path path to grub config file to update ("-" for stdin)
--copy-default use the default boot entry as a template for the new entry being added; if the default is not a linux image, or if the kernel referenced by the default image does not exist, the
first linux entry whose kernel does exist is used as the template
--default-kernel display the path of the default kernel
--default-index display the index of the default kernel
--default-title display the title of the default kernel
--env=path path for environment data
--grub2 configure grub2 bootloader
--info=kernel-path display boot information for specified kernel
--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
--set-default-index=entry-index make the given entry index the default entry
--title=entry-title title to use for the new kernel entry
--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
Help options:
-?, --help Show this help message
EOF
}
OPTS="$(getopt -o c:i:o:b:? --long help,add-kernel:,args:,bad-image-okay,\
config-file:,copy-default,default-kernel,default-index,default-title,env:,\
grub2,info:,initrd:,extra-initrd:,make-default,output-file:,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,\
output-file:,remove-mbargs:,remove-multiboot:,silo,yaboot -n ${SCRIPTNAME} -- "$@")"
[[ $? = 0 ]] || exit 1
eval set -- "$OPTS"
while [ ${#} -gt 0 ]; do
case "$1" in
--help|-h)
print_usage
exit 0
;;
--add-kernel)
kernel="${2}"
shift
;;
--args)
args="${2}"
shift
;;
--bad-image-okay)
bad_image=true
;;
--config-file|-c)
zipl_config="${2}"
shift
;;
--copy-default)
copy_default=true
;;
--default-kernel)
display_default="kernel"
;;
--default-index)
display_default="index"
;;
--default-title)
display_default="title"
;;
--env)
env="${2}"
shift
;;
--grub2)
bootloader="grub2"
;;
--info)
display_info="${2}"
shift
;;
--initrd)
initrd="${2}"
shift
;;
--extra-initrd|-i)
extra_initrd=" /${2}"
shift
;;
--make-default)
make_default=true
;;
--output-file|-o)
output_file="${2}"
shift
;;
--remove-args)
remove_args="${2}"
shift
;;
--remove-kernel)
remove_kernel="${2}"
shift
;;
--set-default)
set_default="${2}"
shift
;;
--set-default-index)
set_default="${2}"
shift
;;
--title)
title="${2}"
shift
;;
--update-kernel)
update_kernel="${2}"
shift
;;
--zipl)
bootloader="zipl"
;;
--bls-directory|-b)
blsdir="${2}"
shift
;;
--add-kernel|--add-multiboot|--mbargs|--mounts|--boot-filesystem|\
--bootloader-probe|--debug|--devtree|--devtreedir|--elilo|--efi|\
--extlinux|--grub|--lilo|--output-file|--remove-mbargs|--silo|\
--remove-multiboot|--slilo|--yaboot)
echo
echo "${SCRIPTNAME}: the option \"${1}\" was deprecated" >&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

View File

@ -0,0 +1,162 @@
From 03433c27cbbeee9f8c83f5365b5ba1ef8c285d8b Mon Sep 17 00:00:00 2001
From: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Date: Tue, 16 Jun 2015 10:43:21 -0700
Subject: [PATCH 04/60] grubby: properly handle mixed ' and " and nested quotes
The SLES12 grub2.cfg file on ppc64le by default contains a line like:
submenu "Bootable snapshot #$snapshot_num" {
menuentry "If OK, run 'snapper rollback $snapshot_num' reboot." { true; }
}
On any grubby (tested with 8.40) invocation that updates the config
file, the combination of nested quotes and mixed quotes leads to a
generated file content like:
submenu "Bootable snapshot #$snapshot_num" {
menuentry 'If OK, run snapper rollback $snapshot_num' rollback $snapshot_num' and reboot." { true; }
}
which includes both a change from " to ', but also improperly quoted
strings and trailing characters relative to the string. This actually
leads to a failure to boot from the disk by default when using grubby
(e.g., Autotest) on SLES12 ppc64le. Whether SLES12 should be adding an
entry like this by default or not is probably open to debate, but grubby
should be able to hand this input file.
To fix the issue, three changes were necessary:
1) grub2ExtractTitle needs to check that if the second element starts
with a quote, that the matching element found ends with the same
quote-type (' vs. ")
2) lineWrite needs to output the right kind of quote based upon if the
string to be outputted itself contains quotes. This is not currently
possible in the code, because quotes are stripped out normally by
readConfig, but with the change in 3), that only happens now for the
quotes that actually delineate a string.
3) readConfig needs to check that when it is extracting titles and
determining extras, it uses matching quotes.
With these changes, a simple grubby --set-default=SLES12 (for example),
now produces:
submenu "Bootable snapshot #$snapshot_num" {
menuentry "If OK, run 'snapper rollback $snapshot_num' and reboot." { true; }
}
as expected.
Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
grubby.c | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/grubby.c b/grubby.c
index 53fe925..440c627 100644
--- a/grubby.c
+++ b/grubby.c
@@ -451,6 +451,8 @@ char *grub2ExtractTitle(struct singleLine * line) {
* whose last character is also quote (assuming it's the closing one) */
int resultMaxSize;
char * result;
+ /* need to ensure that ' does not match " as we search */
+ char quote_char = *current;
resultMaxSize = sizeOfSingleLine(line);
result = malloc(resultMaxSize);
@@ -464,7 +466,7 @@ char *grub2ExtractTitle(struct singleLine * line) {
current_indent_len = strlen(current_indent);
strncat(result, current_indent, current_indent_len);
- if (!isquote(current[current_len-1])) {
+ if (current[current_len-1] != quote_char) {
strncat(result, current, current_len);
} else {
strncat(result, current, current_len - 1);
@@ -928,10 +930,23 @@ static int lineWrite(FILE * out, struct singleLine * line,
/* Need to handle this, because we strip the quotes from
* menuentry when read it. */
if (line->type == LT_MENUENTRY && i == 1) {
- if(!isquote(*line->elements[i].item))
- fprintf(out, "\'%s\'", line->elements[i].item);
- else
+ if(!isquote(*line->elements[i].item)) {
+ int substring = 0;
+ /* If the line contains nested quotes, we did not strip
+ * the "interna" quotes and we must use the right quotes
+ * again when writing the updated file. */
+ for (int j = i; j < line->numElements; j++) {
+ if (strchr(line->elements[i].item, '\'') != NULL) {
+ substring = 1;
+ fprintf(out, "\"%s\"", line->elements[i].item);
+ break;
+ }
+ }
+ if (!substring)
+ fprintf(out, "\'%s\'", line->elements[i].item);
+ } else {
fprintf(out, "%s", line->elements[i].item);
+ }
fprintf(out, "%s", line->elements[i].indent);
continue;
@@ -1267,6 +1282,8 @@ static struct grubConfig * readConfig(const char * inName,
len = 0;
char *extras;
char *title;
+ /* initially unseen value */
+ char quote_char = '\0';
for (int i = 1; i < line->numElements; i++) {
len += strlen(line->elements[i].item);
@@ -1283,13 +1300,16 @@ static struct grubConfig * readConfig(const char * inName,
for (int i = 0; i < line->numElements; i++) {
if (!strcmp(line->elements[i].item, "menuentry"))
continue;
- if (isquote(*line->elements[i].item))
+ if (isquote(*line->elements[i].item) && quote_char == '\0') {
+ /* ensure we properly pair off quotes */
+ quote_char = *line->elements[i].item;
title = line->elements[i].item + 1;
- else
+ } else {
title = line->elements[i].item;
+ }
len = strlen(title);
- if (isquote(title[len-1])) {
+ if (title[len-1] == quote_char) {
strncat(buf, title,len-1);
break;
} else {
@@ -1300,6 +1320,7 @@ static struct grubConfig * readConfig(const char * inName,
/* get extras */
int count = 0;
+ quote_char = '\0';
for (int i = 0; i < line->numElements; i++) {
if (count >= 2) {
strcat(extras, line->elements[i].item);
@@ -1310,12 +1331,15 @@ static struct grubConfig * readConfig(const char * inName,
continue;
/* count ' or ", there should be two in menuentry line. */
- if (isquote(*line->elements[i].item))
+ if (isquote(*line->elements[i].item) && quote_char == '\0') {
+ /* ensure we properly pair off quotes */
+ quote_char = *line->elements[i].item;
count++;
+ }
len = strlen(line->elements[i].item);
- if (isquote(line->elements[i].item[len -1]))
+ if (line->elements[i].item[len -1] == quote_char)
count++;
/* ok, we get the final ' or ", others are extras. */
--
1.8.3.1

8
grubby.in Normal file
View File

@ -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

122
grubby.spec Normal file
View File

@ -0,0 +1,122 @@
Name: grubby
Version: 8.40
Release: 23
Summary: Update and display information about the configuration files
License: GPLv2+
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-Use-system-LDFLAGS.patch
Patch5: 0004-Honor-sbindir.patch
Patch6: 0005-installkernel-use-kernel-install.patch
Patch6001: Set-envFile-from-env-when-bootloader-is-not-specifie.patch
Patch6002: grubby-properly-handle-mixed-and-and-nested-quotes.patch
Patch6003: Drop-SEGV-handler.patch
Patch6004: Add-a-bunch-of-tests-for-various-default-kernel-titl.patch
Patch6005: Emit-better-systemd-debug-settings-on-debug-entries.patch
Patch6006: Don-t-leak-from-one-extractTitle-call.patch
Patch6007: Fix-dracut-cmdline-options-and-conditionalize-them-t.patch
Patch6008: Always-do-the-rungrubby-debug-after-the-normal-kerne.patch
Patch6009: Be-more-thorough-about-flushing-our-config-file-when.patch
Patch6010: Fix-incorrect-test-case-and-remove-args-with-a-value.patch
Patch6011: grubby-Make-sure-configure-BOOTLOADER-variables-are-.patch
Patch6012: Fix-GCC-warnings-about-possible-string-truncations-a.patch
Patch6013: Check-that-pointers-are-not-NULL-before-dereferencin.patch
Patch6014: Print-default-image-even-if-isn-t-a-suitable-one.patch
Patch9001: fix-make-test-fail-when-no-boot-partition.patch
Patch9002: Fix-make-test-fail-for-g2-1.15.patch
BuildRequires: gcc pkgconfig glib2-devel popt-devel
BuildRequires: libblkid-devel git-core sed make
BuildRequires: util-linux-ng
%ifarch aarch64 i686 x86_64
BuildRequires: grub2-tools-minimal
Requires: grub2-tools
%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.
%package bls
Summary: a command line tool for updating bootloader configs
Conflicts: %{name} <= 8.40-13
BuildArch: noarch
%description bls
the package provides a grubby wrapper that manages BootLoaderSpec files and is
meant to only be used for legacy compatibility users with existing grubby users.
%package_help
%prep
%autosetup -n %{name}-%{version}-1 -p1
%build
%make_build
%check
make test
%install
%make_install mandir=%{_mandir} sbindir=%{_sbindir}
mkdir -p %{buildroot}%{_libexecdir}/{grubby,installkernel}/ %{buildroot}%{_sbindir}/
mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby
mv -v %{buildroot}%{_sbindir}/installkernel %{buildroot}%{_libexecdir}/installkernel/installkernel
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
%pre
%preun
%post
%postun
%files
%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
%files bls
%dir %{_libexecdir}/grubby
%attr(0755,root,root) %{_libexecdir}/grubby/grubby-bls
%attr(0755,root,root) %{_sbindir}/grubby
%files help
%defattr(-,root,root)
%{_mandir}/man8/*.8*
%changelog
* Mon Dec 30 2019 openEuler Buildteam <buildteam@openeuler.org> - 8.40-23
- Modify patch info
* Sat Nov 30 2019 openEuler Buildteam <buildteam@openeuler.org> - 8.40-22
- add package bls to fix kernel package installation error
* Thu Sep 26 2019 openEuler Buildteam <buildteam@openeuler.org> - 8.40-21
- Modify patch info
* Mon Sep 23 2019 openEuler Buildteam <buildteam@openeuler.org> - 8.40-20
- Modify Requires
* Wed Sep 18 2019 openEuler Buildteam <buildteam@openeuler.org> - 8.40-19
- Package init

8
installkernel.in Normal file
View File

@ -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