This series include the grubby side of the boottool work we've been doing for autotest(.github.com).
Some are new versions of previous RFCs, and some are brand new. Feel free to comment/apply selectively.
Series summary: [PATCH 01/10] Support systems that do not have /boot as a separate [PATCH 02/10] Fix for grub on SuSE systems: lba and boot information [PATCH 03/10] Fix for grub on SuSE systems: test lba and boot info [PATCH 04/10] Fix grub detection on SuSE systems: config file order [PATCH 05/10] ppc64/yaboot: add support for probing the currently [PATCH 06/10] ia64/elilo: add support for probing the currently [PATCH 07/10] test.sh: revert bash 4 only syntax change [PATCH 08/10] test.sh: enable the use of MALLOC_PERTURB_ [PATCH 09/10] Add --set-default-index feature [PATCH 10/10] grubby.8: fixes for the grubby man page
Diff stat: grubby.8 | 13 +- grubby.c | 405 +++++++++++++++++++++-- test.sh | 13 +- test/grub.12 | 32 ++ test/grub.12-support_files/boot/grub/device.map | 1 + test/grub.12-support_files/etc/SuSE-release | 3 + test/grub.12-support_files/etc/grub.conf | 2 + test/results/info/g12.1 | 8 + 8 files changed, 446 insertions(+), 31 deletions(-)
While testing grubby on systems with a root (/) filesystem that includes the /boot directory, it was noticed that grubby displayed the prefix (/boot) twice.
This patch prevents printing the prefix twice on kernel and initrd lines.
Signed-off-by: Cleber Rosa crosa@redhat.com --- grubby.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c index 601ba8d..bf5fb37 100644 --- a/grubby.c +++ b/grubby.c @@ -1861,7 +1861,10 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { return; }
- printf("kernel=%s%s\n", prefix, line->elements[1].item); + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("kernel=%s\n", line->elements[1].item); + else + printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (line->numElements >= 3) { printf("args=""); @@ -1920,7 +1923,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { line = getLineByType(LT_INITRD, entry->lines);
if (line && line->numElements >= 2) { - printf("initrd=%s", prefix); + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("initrd="); + else + printf("initrd=%s", prefix); + for (i = 1; i < line->numElements; i++) printf("%s%s", line->elements[i].item, line->elements[i].indent); printf("\n");
On 03/20/2012 02:55 PM, Cleber Rosa wrote:
While testing grubby on systems with a root (/) filesystem that includes the /boot directory, it was noticed that grubby displayed the prefix (/boot) twice.
This patch prevents printing the prefix twice on kernel and initrd lines.
Signed-off-by: Cleber Rosa crosa@redhat.com
This needs a test case as well.
grubby.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c index 601ba8d..bf5fb37 100644 --- a/grubby.c +++ b/grubby.c @@ -1861,7 +1861,10 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { return; }
- printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("kernel=%s\n", line->elements[1].item);
else
printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (line->numElements >= 3) { printf("args="");
@@ -1920,7 +1923,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { line = getLineByType(LT_INITRD, entry->lines);
if (line && line->numElements >= 2) {
- printf("initrd=%s", prefix);
- if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("initrd=");
- else
printf("initrd=%s", prefix);
- for (i = 1; i < line->numElements; i++) printf("%s%s", line->elements[i].item, line->elements[i].indent); printf("\n");
On 03/20/2012 05:18 PM, Peter Jones wrote:
On 03/20/2012 02:55 PM, Cleber Rosa wrote:
While testing grubby on systems with a root (/) filesystem that includes the /boot directory, it was noticed that grubby displayed the prefix (/boot) twice.
This patch prevents printing the prefix twice on kernel and initrd lines.
Signed-off-by: Cleber Rosacrosa@redhat.com
This needs a test case as well.
Actually, test/grub.12 is a file that captures the configuration of such a system. Without this patch, the "GRUB lba and root information on SuSE systems" test fails (showing /boot twice), so I considered this patch was already covered by a test.
If you think we need another, more explicit and separate test, please let me know.
Thanks! CR.
grubby.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c index 601ba8d..bf5fb37 100644 --- a/grubby.c +++ b/grubby.c @@ -1861,7 +1861,10 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { return; }
- printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("kernel=%s\n", line->elements[1].item);
else
printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (line->numElements>= 3) { printf("args="");
@@ -1920,7 +1923,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { line = getLineByType(LT_INITRD, entry->lines);
if (line&& line->numElements>= 2) {
- printf("initrd=%s", prefix);
- if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("initrd=");
- else
printf("initrd=%s", prefix);
- for (i = 1; i< line->numElements; i++) printf("%s%s", line->elements[i].item, line->elements[i].indent); printf("\n");
On 03/21/2012 02:18 PM, Cleber Rosa wrote:
On 03/20/2012 05:18 PM, Peter Jones wrote:
On 03/20/2012 02:55 PM, Cleber Rosa wrote:
While testing grubby on systems with a root (/) filesystem that includes the /boot directory, it was noticed that grubby displayed the prefix (/boot) twice.
This patch prevents printing the prefix twice on kernel and initrd lines.
Signed-off-by: Cleber Rosacrosa@redhat.com
This needs a test case as well.
Actually, test/grub.12 is a file that captures the configuration of such a system. Without this patch, the "GRUB lba and root information on SuSE systems" test fails (showing /boot twice), so I considered this patch was already covered by a test.
If you think we need another, more explicit and separate test, please let me know.
Huh? There are no currently checked-in tests that fail. If you're seeing a failure, then it's being caused by some environmental condition. In that case, it needs to be fixed so that it behaves the same on both environments, but that probably also still does reflect a test suite problem that needs to be independently addressed.
Thanks! CR.
grubby.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c index 601ba8d..bf5fb37 100644 --- a/grubby.c +++ b/grubby.c @@ -1861,7 +1861,10 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { return; }
- printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("kernel=%s\n", line->elements[1].item);
else
printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (line->numElements>= 3) { printf("args="");
@@ -1920,7 +1923,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { line = getLineByType(LT_INITRD, entry->lines);
if (line&& line->numElements>= 2) {
- printf("initrd=%s", prefix);
- if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("initrd=");
- else
printf("initrd=%s", prefix);
for (i = 1; i< line->numElements; i++) printf("%s%s", line->elements[i].item, line->elements[i].indent); printf("\n");
On 03/22/2012 11:24 AM, Peter Jones wrote:
On 03/21/2012 02:18 PM, Cleber Rosa wrote:
On 03/20/2012 05:18 PM, Peter Jones wrote:
On 03/20/2012 02:55 PM, Cleber Rosa wrote:
While testing grubby on systems with a root (/) filesystem that includes the /boot directory, it was noticed that grubby displayed the prefix (/boot) twice.
This patch prevents printing the prefix twice on kernel and initrd lines.
Signed-off-by: Cleber Rosacrosa@redhat.com
This needs a test case as well.
Actually, test/grub.12 is a file that captures the configuration of such a system. Without this patch, the "GRUB lba and root information on SuSE systems" test fails (showing /boot twice), so I considered this patch was already covered by a test.
If you think we need another, more explicit and separate test, please let me know.
Huh? There are no currently checked-in tests that fail. If you're seeing a failure, then it's being caused by some environmental condition. In that case, it needs to be fixed so that it behaves the same on both environments, but that probably also still does reflect a test suite problem that needs to be independently addressed.
Indeed there were no failures *before* this patch series, because there was no configuration file with a kernel or initrd line that includes /boot being tested like that.
So, to make it more clear: patch [01/10] fixes a problem with a configuration file (test/grub.12) included in patch [03/10]. This happened to be found while testing the feature provided by patch [02/10], but does not depend on it. I moved the fix to the top of the patch series, so that the test on patch [03/10] does not fail.
Thanks! CR.
grubby.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c index 601ba8d..bf5fb37 100644 --- a/grubby.c +++ b/grubby.c @@ -1861,7 +1861,10 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { return; }
- printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("kernel=%s\n", line->elements[1].item);
else
printf("kernel=%s%s\n", prefix, line->elements[1].item);
if (line->numElements>= 3) { printf("args="");
@@ -1920,7 +1923,11 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { line = getLineByType(LT_INITRD, entry->lines);
if (line&& line->numElements>= 2) {
- printf("initrd=%s", prefix);
- if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
printf("initrd=");
- else
printf("initrd=%s", prefix);
for (i = 1; i< line->numElements; i++) printf("%s%s", line->elements[i].item, line->elements[i].indent); printf("\n");
This patch adds code that gets lba and boot device information on SuSE systems, which is done by looking at the commands that were used to install grub on that system, and match information with grub's device.map file.
Changes from v1: * Fixes for issues pointed by Peter Jones pjones@redhat.com * Add support for specifying paths for SuSE configuration files on environment variables, to make it possible to test this
Signed-off-by: Cleber Rosa crosa@redhat.com --- grubby.c | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 293 insertions(+), 7 deletions(-)
diff --git a/grubby.c b/grubby.c index bf5fb37..cd57b4f 100644 --- a/grubby.c +++ b/grubby.c @@ -1945,6 +1945,267 @@ void displayEntry(struct singleEntry * entry, const char * prefix, int index) { } }
+int isSuseSystem(void) { + const char * path; + const static char default_path[] = "/etc/SuSE-release"; + + if ((path = getenv("GRUBBY_SUSE_RELEASE")) == NULL) + path = default_path; + + if (!access(path, R_OK)) + return 1; + return 0; +} + +int isSuseGrubConf(const char * path) { + FILE * grubConf; + char * line = NULL; + size_t len = 0, res = 0; + + grubConf = fopen(path, "r"); + if (!grubConf) { + dbgPrintf("Could not open SuSE configuration file '%s'\n", path); + return 0; + } + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (!strncmp(line, "setup", 5)) { + fclose(grubConf); + free(line); + return 1; + } + } + + dbgPrintf("SuSE configuration file '%s' does not appear to be valid\n", + path); + + fclose(grubConf); + free(line); + return 0; +} + +int suseGrubConfGetLba(const char * path, int * lbaPtr) { + FILE * grubConf; + char * line = NULL; + size_t res = 0, len = 0; + + if (!path) return 1; + if (!lbaPtr) return 1; + + grubConf = fopen(path, "r"); + if (!grubConf) return 1; + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + if (!strncmp(line, "setup", 5)) { + if (strstr(line, "--force-lba")) { + *lbaPtr = 1; + } else { + *lbaPtr = 0; + } + dbgPrintf("lba: %i\n", *lbaPtr); + break; + } + } + + free(line); + fclose(grubConf); + return 0; +} + +int suseGrubConfGetInstallDevice(const char * path, char ** devicePtr) { + FILE * grubConf; + char * line = NULL; + size_t res = 0, len = 0; + char * lastParamPtr = NULL; + char * secLastParamPtr = NULL; + char installDeviceNumber = '\0'; + char * bounds = NULL; + + if (!path) return 1; + if (!devicePtr) return 1; + + grubConf = fopen(path, "r"); + if (!grubConf) return 1; + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (strncmp(line, "setup", 5)) + continue; + + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + lastParamPtr = bounds = line + res; + + /* Last parameter in grub may be an optional IMAGE_DEVICE */ + while (!isspace(*lastParamPtr)) + lastParamPtr--; + lastParamPtr++; + + secLastParamPtr = lastParamPtr - 2; + dbgPrintf("lastParamPtr: %s\n", lastParamPtr); + + if (lastParamPtr + 3 > bounds) { + dbgPrintf("lastParamPtr going over boundary"); + fclose(grubConf); + free(line); + return 1; + } + if (!strncmp(lastParamPtr, "(hd", 3)) + lastParamPtr += 3; + dbgPrintf("lastParamPtr: %c\n", *lastParamPtr); + + /* + * Second last parameter will decide wether last parameter is + * an IMAGE_DEVICE or INSTALL_DEVICE + */ + while (!isspace(*secLastParamPtr)) + secLastParamPtr--; + secLastParamPtr++; + + if (secLastParamPtr + 3 > bounds) { + dbgPrintf("secLastParamPtr going over boundary"); + fclose(grubConf); + free(line); + return 1; + } + dbgPrintf("secLastParamPtr: %s\n", secLastParamPtr); + if (!strncmp(secLastParamPtr, "(hd", 3)) { + secLastParamPtr += 3; + dbgPrintf("secLastParamPtr: %c\n", *secLastParamPtr); + installDeviceNumber = *secLastParamPtr; + } else { + installDeviceNumber = *lastParamPtr; + } + + *devicePtr = malloc(6); + snprintf(*devicePtr, 6, "(hd%c)", installDeviceNumber); + dbgPrintf("installDeviceNumber: %c\n", installDeviceNumber); + fclose(grubConf); + free(line); + return 0; + } + + free(line); + fclose(grubConf); + return 1; +} + +int grubGetBootFromDeviceMap(const char * device, + char ** bootPtr) { + FILE * deviceMap; + char * line = NULL; + size_t res = 0, len = 0; + char * devicePtr; + char * bounds = NULL; + const char * path; + const static char default_path[] = "/boot/grub/device.map"; + + if (!device) return 1; + if (!bootPtr) return 1; + + if ((path = getenv("GRUBBY_GRUB_DEVICE_MAP")) == NULL) + path = default_path; + + dbgPrintf("opening grub device.map file from: %s\n", path); + deviceMap = fopen(path, "r"); + if (!deviceMap) + return 1; + + while ((res = getline(&line, &len, deviceMap)) != -1) { + if (!strncmp(line, "#", 1)) + continue; + + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + devicePtr = line; + bounds = line + res; + + while ((isspace(*line) && ((devicePtr + 1) <= bounds))) + devicePtr++; + dbgPrintf("device: %s\n", devicePtr); + + if (!strncmp(devicePtr, device, strlen(device))) { + devicePtr += strlen(device); + while (isspace(*devicePtr) && ((devicePtr + 1) <= bounds)) + devicePtr++; + + *bootPtr = strdup(devicePtr); + break; + } + } + + free(line); + fclose(deviceMap); + return 0; +} + +int suseGrubConfGetBoot(const char * path, char ** bootPtr) { + char * grubDevice; + + if (suseGrubConfGetInstallDevice(path, &grubDevice)) + dbgPrintf("error looking for grub installation device\n"); + else + dbgPrintf("grubby installation device: %s\n", grubDevice); + + if (grubGetBootFromDeviceMap(grubDevice, bootPtr)) + dbgPrintf("error looking for grub boot device\n"); + else + dbgPrintf("grubby boot device: %s\n", *bootPtr); + + free(grubDevice); + return 0; +} + +int parseSuseGrubConf(int * lbaPtr, char ** bootPtr) { + /* + * This SuSE grub configuration file at this location is not your average + * grub configuration file, but instead the grub commands used to setup + * grub on that system. + */ + const char * path; + const static char default_path[] = "/etc/grub.conf"; + + if ((path = getenv("GRUBBY_SUSE_GRUB_CONF")) == NULL) + path = default_path; + + if (!isSuseGrubConf(path)) return 1; + + if (lbaPtr) { + *lbaPtr = 0; + if (suseGrubConfGetLba(path, lbaPtr)) + return 1; + } + + if (bootPtr) { + *bootPtr = NULL; + suseGrubConfGetBoot(path, bootPtr); + } + + return 0; +} + int parseSysconfigGrub(int * lbaPtr, char ** bootPtr) { FILE * in; char buf[1024]; @@ -1993,12 +2254,25 @@ int parseSysconfigGrub(int * lbaPtr, char ** bootPtr) { }
void dumpSysconfigGrub(void) { - char * boot; + char * boot = NULL; int lba;
- if (!parseSysconfigGrub(&lba, &boot)) { - if (lba) printf("lba\n"); - if (boot) printf("boot=%s\n", boot); + if (!isSuseSystem()) { + if (parseSysconfigGrub(&lba, &boot)) { + free(boot); + return; + } + } else { + if (parseSuseGrubConf(&lba, &boot)) { + free(boot); + return; + } + } + + if (lba) printf("lba\n"); + if (boot) { + printf("boot=%s\n", boot); + free(boot); } }
@@ -2819,9 +3093,14 @@ int checkForGrub(struct grubConfig * config) { int fd; unsigned char bootSect[512]; char * boot; + int onSuse;
- if (parseSysconfigGrub(NULL, &boot)) - return 0; + onSuse = isSuseSystem(); + if (!onSuse) { + if (parseSysconfigGrub(NULL, &boot)) return 0; + } else { + if (parseSuseGrubConf(NULL, &boot)) return 0; + }
/* assume grub is not installed -- not an error condition */ if (!boot) @@ -2840,7 +3119,14 @@ int checkForGrub(struct grubConfig * config) { } close(fd);
- return checkDeviceBootloader(boot, bootSect); + if (!onSuse) + return checkDeviceBootloader(boot, bootSect); + else + /* + * The more elaborate checks do not work on SuSE. The checks done + * seem to be reasonble (at least for now), so just return success + */ + return 2; }
int checkForExtLinux(struct grubConfig * config) {
This adds a test for the code that fetches the lba and boot info on SuSE systems. To properly test it, it's necessary to ship more files than other existing tests.
Signed-off-by: Cleber Rosa crosa@redhat.com --- test.sh | 6 ++++ test/grub.12 | 32 +++++++++++++++++++++++ test/grub.12-support_files/boot/grub/device.map | 1 + test/grub.12-support_files/etc/SuSE-release | 3 ++ test/grub.12-support_files/etc/grub.conf | 2 + test/results/info/g12.1 | 8 +++++ 6 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 test/grub.12 create mode 100644 test/grub.12-support_files/boot/grub/device.map create mode 100644 test/grub.12-support_files/etc/SuSE-release create mode 100644 test/grub.12-support_files/etc/grub.conf create mode 100644 test/results/info/g12.1
diff --git a/test.sh b/test.sh index 1678782..2b46082 100755 --- a/test.sh +++ b/test.sh @@ -305,6 +305,12 @@ grubTest grub.11 updargs/g11.2 --boot-filesystem=/ \ --update-kernel=/vmlinuz-2.4.7-2smp \ --args "ro root=LABEL=/ single"
+testing="GRUB lba and root information on SuSE systems" +GRUBBY_SUSE_RELEASE=test/grub.12-support_files/etc/SuSE-release \ + GRUBBY_SUSE_GRUB_CONF=test/grub.12-support_files/etc/grub.conf \ + GRUBBY_GRUB_DEVICE_MAP=test/grub.12-support_files/boot/grub/device.map \ + grubTest grub.12 info/g12.1 --info=0 + testing="LILO update kernel argument handling" liloTest lilo.1 updargs/l1.1 --update-kernel=/boot/vmlinuz-2.4.18-4 \ --args="root=/dev/md1" diff --git a/test/grub.12 b/test/grub.12 new file mode 100644 index 0000000..3cd2819 --- /dev/null +++ b/test/grub.12 @@ -0,0 +1,32 @@ +# Modified by YaST2. Last modification on Thu Mar 8 16:06:03 BRT 2012 +# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader +# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader + +default 0 +timeout 8 +##YaST - generic_mbr +##YaST - activate + +###Don't change this comment - YaST2 identifier: Original name: linux### +title Desktop -- openSUSE 12.1 - 3.1.9-1.4 + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-desktop root=/dev/vda2 resume=/dev/vda1 splash=silent quiet showopts vga=0x314 + initrd /boot/initrd-3.1.9-1.4-desktop + +###Don't change this comment - YaST2 identifier: Original name: failsafe### +title Failsafe -- openSUSE 12.1 - 3.1.9-1.4 (desktop) + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-desktop root=/dev/vda2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x314 + initrd /boot/initrd-3.1.9-1.4-desktop + +###Don't change this comment - YaST2 identifier: Original name: linux### +title openSUSE 12.1 - 3.1.9-1.4 + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-default root=/dev/vda2 resume=/dev/vda1 splash=silent quiet showopts vga=0x314 + initrd /boot/initrd-3.1.9-1.4-default + +###Don't change this comment - YaST2 identifier: Original name: failsafe### +title Failsafe -- openSUSE 12.1 - 3.1.9-1.4 (default) + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-default root=/dev/vda2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x314 + initrd /boot/initrd-3.1.9-1.4-default diff --git a/test/grub.12-support_files/boot/grub/device.map b/test/grub.12-support_files/boot/grub/device.map new file mode 100644 index 0000000..e2b208c --- /dev/null +++ b/test/grub.12-support_files/boot/grub/device.map @@ -0,0 +1 @@ +(hd0) /dev/vda diff --git a/test/grub.12-support_files/etc/SuSE-release b/test/grub.12-support_files/etc/SuSE-release new file mode 100644 index 0000000..ddd0acd --- /dev/null +++ b/test/grub.12-support_files/etc/SuSE-release @@ -0,0 +1,3 @@ +openSUSE 12.1 (x86_64) +VERSION = 12.1 +CODENAME = Asparagus diff --git a/test/grub.12-support_files/etc/grub.conf b/test/grub.12-support_files/etc/grub.conf new file mode 100644 index 0000000..9af4c20 --- /dev/null +++ b/test/grub.12-support_files/etc/grub.conf @@ -0,0 +1,2 @@ +setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,1) +quit diff --git a/test/results/info/g12.1 b/test/results/info/g12.1 new file mode 100644 index 0000000..25d7ab6 --- /dev/null +++ b/test/results/info/g12.1 @@ -0,0 +1,8 @@ +lba +boot=/dev/vda +index=0 +kernel=/boot/vmlinuz-3.1.9-1.4-desktop +args="resume=/dev/vda1 splash=silent quiet showopts vga=0x314" +root=/dev/vda2 +initrd=/boot/initrd-3.1.9-1.4-desktop +title=Desktop -- openSUSE 12.1 - 3.1.9-1.4
SuSE sytems ship with a /etc/grub.conf that is not your regular grub configuration file, but instead a sequence of grub commands. Example:
setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,1) quit
Because of that, the parsing of the config fails. So, try to first use the grub config file at /boot/grub/menu.lst.
Signed-off-by: Cleber Rosa crosa@redhat.com --- grubby.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/grubby.c b/grubby.c index cd57b4f..b9da724 100644 --- a/grubby.c +++ b/grubby.c @@ -164,8 +164,8 @@ struct keywordTypes grubKeywords[] = {
const char *grubFindConfig(struct configFileInfo *cfi) { static const char *configFiles[] = { - "/etc/grub.conf", "/boot/grub/menu.lst", + "/etc/grub.conf", NULL }; static int i = -1;
Changes from v1: * Settled on simplistic check for yaboot, but left comment on how to do an installation check.
Signed-off-by: Cleber Rosa crosa@redhat.com --- grubby.c | 38 +++++++++++++++++++++++++++++++++----- 1 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/grubby.c b/grubby.c index b9da724..f366c42 100644 --- a/grubby.c +++ b/grubby.c @@ -3159,6 +3159,23 @@ int checkForExtLinux(struct grubConfig * config) { return checkDeviceBootloader(boot, bootSect); }
+int checkForYaboot(struct grubConfig * config) { + /* + * This is a simplistic check that we consider good enough for own puporses + * + * If we were to properly check if yaboot is *installed* we'd need to: + * 1) get the system boot device (LT_BOOT) + * 2) considering it's a raw filesystem, check if the yaboot binary matches + * the content on the boot device + * 3) if not, copy the binary to a temporary file and run "addnote" on it + * 4) check again if binary and boot device contents match + */ + if (!access("/etc/yaboot.conf", R_OK)) + return 2; + + return 1; +} + static char * getRootSpecifier(char * str) { char * idx, * rootspec = NULL;
@@ -3646,9 +3663,9 @@ int main(int argc, const char ** argv) { { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0, _("filestystem which contains /boot directory (for testing only)"), _("bootfs") }, -#if defined(__i386__) || defined(__x86_64__) +#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0, - _("check if lilo is installed on lilo.conf boot sector") }, + _("check which bootloader is installed on boot sector") }, #endif { "config-file", 'c', POPT_ARG_STRING, &grubConfig, 0, _("path to grub config file to update ("-" for stdin)"), @@ -3888,8 +3905,8 @@ int main(int argc, const char ** argv) { }
if (bootloaderProbe) { - int lrc = 0, grc = 0, gr2c = 0, erc = 0; - struct grubConfig * lconfig, * gconfig; + int lrc = 0, grc = 0, gr2c = 0, erc = 0, yrc = 0; + struct grubConfig * lconfig, * gconfig, * yconfig;
const char *grub2config = grub2FindConfig(&grub2ConfigType); if (grub2config) { @@ -3925,12 +3942,23 @@ int main(int argc, const char ** argv) { erc = checkForExtLinux(lconfig); }
- if (lrc == 1 || grc == 1 || gr2c == 1) return 1; + + if (!access(yabootConfigType.defaultConfig, F_OK)) { + yconfig = readConfig(yabootConfigType.defaultConfig, + &yabootConfigType); + if (!yconfig) + yrc = 1; + else + yrc = checkForYaboot(lconfig); + } + + if (lrc == 1 || grc == 1 || gr2c == 1 || yrc == 1) return 1;
if (lrc == 2) printf("lilo\n"); if (gr2c == 2) printf("grub2\n"); if (grc == 2) printf("grub\n"); if (erc == 2) printf("extlinux\n"); + if (yrc == 2) printf("yaboot\n");
return 0; }
Signed-off-by: Cleber Rosa crosa@redhat.com --- grubby.c | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/grubby.c b/grubby.c index f366c42..ccb11b0 100644 --- a/grubby.c +++ b/grubby.c @@ -3176,6 +3176,13 @@ int checkForYaboot(struct grubConfig * config) { return 1; }
+int checkForElilo(struct grubConfig * config) { + if (!access("/etc/elilo.conf", R_OK)) + return 2; + + return 1; +} + static char * getRootSpecifier(char * str) { char * idx, * rootspec = NULL;
@@ -3663,7 +3670,7 @@ int main(int argc, const char ** argv) { { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0, _("filestystem which contains /boot directory (for testing only)"), _("bootfs") }, -#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) +#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) || defined (__ia64__) { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0, _("check which bootloader is installed on boot sector") }, #endif @@ -3905,8 +3912,8 @@ int main(int argc, const char ** argv) { }
if (bootloaderProbe) { - int lrc = 0, grc = 0, gr2c = 0, erc = 0, yrc = 0; - struct grubConfig * lconfig, * gconfig, * yconfig; + int lrc = 0, grc = 0, gr2c = 0, extrc = 0, yrc = 0, erc = 0; + struct grubConfig * lconfig, * gconfig, * yconfig, * econfig;
const char *grub2config = grub2FindConfig(&grub2ConfigType); if (grub2config) { @@ -3934,12 +3941,21 @@ int main(int argc, const char ** argv) { lrc = checkForLilo(lconfig); }
+ if (!access(eliloConfigType.defaultConfig, F_OK)) { + econfig = readConfig(eliloConfigType.defaultConfig, + &eliloConfigType); + if (!econfig) + erc = 1; + else + erc = checkForElilo(econfig); + } + if (!access(extlinuxConfigType.defaultConfig, F_OK)) { lconfig = readConfig(extlinuxConfigType.defaultConfig, &extlinuxConfigType); if (!lconfig) - erc = 1; + extrc = 1; else - erc = checkForExtLinux(lconfig); + extrc = checkForExtLinux(lconfig); }
@@ -3952,13 +3968,16 @@ int main(int argc, const char ** argv) { yrc = checkForYaboot(lconfig); }
- if (lrc == 1 || grc == 1 || gr2c == 1 || yrc == 1) return 1; + if (lrc == 1 || grc == 1 || gr2c == 1 || extrc == 1 || yrc == 1 || + erc == 1) + return 1;
if (lrc == 2) printf("lilo\n"); if (gr2c == 2) printf("grub2\n"); if (grc == 2) printf("grub\n"); - if (erc == 2) printf("extlinux\n"); + if (extrc == 2) printf("extlinux\n"); if (yrc == 2) printf("yaboot\n"); + if (erc == 2) printf("elilo\n");
return 0; }
The "|&" syntax is bash version 4 specific, and thus fails on systems running older versions. This change was introduced by commit af5a11b0051e53a33e20ecac0b8d73da8d33348c.
Tested on RHEL 5 system with bash-3.2-32.el5.
Signed-off-by: Cleber Rosa crosa@redhat.com --- test.sh | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test.sh b/test.sh index 2b46082..56c3cb1 100755 --- a/test.sh +++ b/test.sh @@ -82,13 +82,13 @@ oneDisplayTest() {
echo "$testing ... $mode $cfg $correct" runme=( ./grubby "$mode" $BIO -c "$cfg" "$@" ) - if "${runme[@]}" |& cmp "$correct" > /dev/null; then + if "${runme[@]}" 2>&1 | cmp "$correct" > /dev/null; then (( pass++ )) if $opt_verbose; then echo ------------------------------------------------------------- echo -n "PASS: " printf "%q " "${runme[@]}"; echo - "${runme[@]}" |& diff -U30 "$cfg" - + "${runme[@]}" 2>&1 | diff -U30 "$cfg" - echo fi else @@ -96,7 +96,7 @@ oneDisplayTest() { echo ------------------------------------------------------------- echo -n "FAIL: " printf "%q " "${runme[@]}"; echo - "${runme[@]}" |& diff -U30 "$correct" - + "${runme[@]}" 2>&1 | diff -U30 "$correct" - echo fi }
MALLOC_CHECK_ is already set, so MALLOC_PERTURB_ makes a nice complement to it.
For more info on MALLOC_PERTURB_: http://udrepper.livejournal.com/11429.html
Signed-off-by: Cleber Rosa crosa@redhat.com --- test.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test.sh b/test.sh index 56c3cb1..2f167f0 100755 --- a/test.sh +++ b/test.sh @@ -126,6 +126,7 @@ while true; do done
export MALLOC_CHECK_=2 +export MALLOC_PERTURB_=1
testing="Parse/write comparison" for n in test/*.[0-9]*; do
This pairs with --default-index, allowing the user to specify the entry to make the default using and index rather than a kernel.
Signed-off-by: Cleber Rosa crosa@redhat.com --- grubby.8 | 11 ++++++++--- grubby.c | 29 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/grubby.8 b/grubby.8 index fe60892..43c141d 100644 --- a/grubby.8 +++ b/grubby.8 @@ -11,9 +11,10 @@ grubby - command line tool for configuring grub, lilo, and elilo [--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR] [--make-default] [-o path] [--version] [--remove-kernel=\fIkernel-path\fR] [--remove-args=\fIargs\fR] - [--set-default=\fIkernel-path\fR] [--title=entry-title] - [--add-multiboot=\fImultiboot-path\fR] [--mbargs=\fIargs\fR] - [--remove-multiboot=\fImultiboot-path\fR] [--remove-mbargs=\fIargs\fR] + [--set-default=\fIkernel-path\fR] [--set-default-index=\fientry-index\fR] + [--title=entry-title] [--add-multiboot=\fImultiboot-path\fR] + [--mbargs=\fIargs\fR] [--remove-multiboot=\fImultiboot-path\fR] + [--remove-mbargs=\fIargs\fR]
.SH DESCRIPTION \fBgrubby\fR is a command line tool for updating and displaying information @@ -154,6 +155,10 @@ 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 (\fBlilo\fR label) for the entry. If \fIentry-title\fR is longer then maximum diff --git a/grubby.c b/grubby.c index ccb11b0..b8380bf 100644 --- a/grubby.c +++ b/grubby.c @@ -1774,13 +1774,19 @@ void markRemovedImage(struct grubConfig * cfg, const char * image,
void setDefaultImage(struct grubConfig * config, int hasNew, const char * defaultKernelPath, int newIsDefault, - const char * prefix, int flags) { + const char * prefix, int flags, int index) { struct singleEntry * entry, * entry2, * newDefault; int i, j;
if (newIsDefault) { config->defaultImage = 0; return; + } else if ((index >= 0) && config->cfi->defaultIsIndex) { + if (findEntryByIndex(config, index)) + config->defaultImage = index; + else + config->defaultImage = -1; + return; } else if (defaultKernelPath) { i = 0; if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { @@ -3653,6 +3659,7 @@ int main(int argc, const char ** argv) { int displayDefault = 0; int displayDefaultIndex = 0; int displayDefaultTitle = 0; + int defaultIndex = -1; struct poptOption options[] = { { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, _("add an entry for the specified kernel"), _("kernel-path") }, @@ -3725,6 +3732,9 @@ int main(int argc, const char ** argv) { { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, _("make the first entry referencing the specified kernel " "the default"), _("kernel-path") }, + { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0, + _("make the given entry index the default entry"), + _("entry-index") }, { "silo", 0, POPT_ARG_NONE, &configureSilo, 0, _("configure silo bootloader") }, { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, @@ -3833,8 +3843,9 @@ int main(int argc, const char ** argv) { }
if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || - newKernelPath || removeKernelPath || makeDefault || - defaultKernel || displayDefaultIndex || displayDefaultTitle)) { + newKernelPath || removeKernelPath || makeDefault || + defaultKernel || displayDefaultIndex || displayDefaultTitle || + (defaultIndex >= 0))) { fprintf(stderr, _("grubby: --bootloader-probe may not be used with " "specified option")); return 1; @@ -3876,6 +3887,11 @@ int main(int argc, const char ** argv) { makeDefault = 1; defaultKernel = NULL; } + else if (defaultKernel && (defaultIndex >= 0)) { + fprintf(stderr, _("grubby: --set-default and --set-default-index " + "may not be used together\n")); + return 1; + }
if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { fprintf(stderr, _("grubby: output file must be specified if stdin " @@ -3884,8 +3900,9 @@ int main(int argc, const char ** argv) { }
if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel - && !kernelInfo && !bootloaderProbe && !updateKernelPath - && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) { + && !kernelInfo && !bootloaderProbe && !updateKernelPath + && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle + && (defaultIndex == -1)) { fprintf(stderr, _("grubby: no action specified\n")); return 1; } @@ -4044,7 +4061,7 @@ int main(int argc, const char ** argv) { markRemovedImage(config, removeKernelPath, bootPrefix); markRemovedImage(config, removeMBKernel, bootPrefix); setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, - bootPrefix, flags); + bootPrefix, flags, defaultIndex); setFallbackImage(config, newKernelPath != NULL); if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;
On 03/20/2012 02:55 PM, Cleber Rosa wrote:
This pairs with --default-index, allowing the user to specify the entry to make the default using and index rather than a kernel.
Signed-off-by: Cleber Rosa crosa@redhat.com
This needs test cases as well.
grubby.8 | 11 ++++++++--- grubby.c | 29 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/grubby.8 b/grubby.8 index fe60892..43c141d 100644 --- a/grubby.8 +++ b/grubby.8 @@ -11,9 +11,10 @@ grubby - command line tool for configuring grub, lilo, and elilo [--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR] [--make-default] [-o path] [--version] [--remove-kernel=\fIkernel-path\fR] [--remove-args=\fIargs\fR]
[--set-default=\fIkernel-path\fR] [--title=entry-title]
[--add-multiboot=\fImultiboot-path\fR] [--mbargs=\fIargs\fR]
[--remove-multiboot=\fImultiboot-path\fR] [--remove-mbargs=\fIargs\fR]
[--set-default=\fIkernel-path\fR] [--set-default-index=\fientry-index\fR]
[--title=entry-title] [--add-multiboot=\fImultiboot-path\fR]
[--mbargs=\fIargs\fR] [--remove-multiboot=\fImultiboot-path\fR]
[--remove-mbargs=\fIargs\fR]
.SH DESCRIPTION \fBgrubby\fR is a command line tool for updating and displaying information @@ -154,6 +155,10 @@ 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 (\fBlilo\fR label) for the entry. If \fIentry-title\fR is longer then maximum diff --git a/grubby.c b/grubby.c index ccb11b0..b8380bf 100644 --- a/grubby.c +++ b/grubby.c @@ -1774,13 +1774,19 @@ void markRemovedImage(struct grubConfig * cfg, const char * image,
void setDefaultImage(struct grubConfig * config, int hasNew, const char * defaultKernelPath, int newIsDefault,
const char * prefix, int flags) {
const char * prefix, int flags, int index) {
struct singleEntry * entry, * entry2, * newDefault; int i, j;
if (newIsDefault) { config->defaultImage = 0; return;
} else if ((index >= 0) && config->cfi->defaultIsIndex) {
if (findEntryByIndex(config, index))
config->defaultImage = index;
else
config->defaultImage = -1;
return; } else if (defaultKernelPath) { i = 0; if (findEntryByPath(config, defaultKernelPath, prefix, &i)) {
@@ -3653,6 +3659,7 @@ int main(int argc, const char ** argv) { int displayDefault = 0; int displayDefaultIndex = 0; int displayDefaultTitle = 0;
- int defaultIndex = -1; struct poptOption options[] = { { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, _("add an entry for the specified kernel"), _("kernel-path") },
@@ -3725,6 +3732,9 @@ int main(int argc, const char ** argv) { { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, _("make the first entry referencing the specified kernel " "the default"), _("kernel-path") },
- { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0,
_("make the given entry index the default entry"),
{ "silo", 0, POPT_ARG_NONE, &configureSilo, 0, _("configure silo bootloader") }, { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0,_("entry-index") },
@@ -3833,8 +3843,9 @@ int main(int argc, const char ** argv) { }
if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||
newKernelPath || removeKernelPath || makeDefault ||
defaultKernel || displayDefaultIndex || displayDefaultTitle)) {
newKernelPath || removeKernelPath || makeDefault ||
defaultKernel || displayDefaultIndex || displayDefaultTitle ||
fprintf(stderr, _("grubby: --bootloader-probe may not be used with " "specified option")); return 1;(defaultIndex >= 0))) {
@@ -3876,6 +3887,11 @@ int main(int argc, const char ** argv) { makeDefault = 1; defaultKernel = NULL; }
else if (defaultKernel && (defaultIndex >= 0)) {
fprintf(stderr, _("grubby: --set-default and --set-default-index "
"may not be used together\n"));
return 1;
}
if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { fprintf(stderr, _("grubby: output file must be specified if stdin "
@@ -3884,8 +3900,9 @@ int main(int argc, const char ** argv) { }
if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel
- && !kernelInfo && !bootloaderProbe && !updateKernelPath
&& !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) {
- && !kernelInfo && !bootloaderProbe && !updateKernelPath
- && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle
- && (defaultIndex == -1)) { fprintf(stderr, _("grubby: no action specified\n")); return 1; }
@@ -4044,7 +4061,7 @@ int main(int argc, const char ** argv) { markRemovedImage(config, removeKernelPath, bootPrefix); markRemovedImage(config, removeMBKernel, bootPrefix); setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault,
bootPrefix, flags);
setFallbackImage(config, newKernelPath != NULL); if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;bootPrefix, flags, defaultIndex);
On 03/20/2012 05:18 PM, Peter Jones wrote:
On 03/20/2012 02:55 PM, Cleber Rosa wrote:
This pairs with --default-index, allowing the user to specify the entry to make the default using and index rather than a kernel.
Signed-off-by: Cleber Rosacrosa@redhat.com
This needs test cases as well.
Sure!
grubby.8 | 11 ++++++++--- grubby.c | 29 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/grubby.8 b/grubby.8 index fe60892..43c141d 100644 --- a/grubby.8 +++ b/grubby.8 @@ -11,9 +11,10 @@ grubby - command line tool for configuring grub, lilo, and elilo [--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR] [--make-default] [-o path] [--version] [--remove-kernel=\fIkernel-path\fR] [--remove-args=\fIargs\fR]
[--set-default=\fIkernel-path\fR] [--title=entry-title]
[--add-multiboot=\fImultiboot-path\fR] [--mbargs=\fIargs\fR]
[--remove-multiboot=\fImultiboot-path\fR] [--remove-mbargs=\fIargs\fR]
[--set-default=\fIkernel-path\fR] [--set-default-index=\fientry-index\fR]
[--title=entry-title] [--add-multiboot=\fImultiboot-path\fR]
[--mbargs=\fIargs\fR] [--remove-multiboot=\fImultiboot-path\fR]
[--remove-mbargs=\fIargs\fR]
.SH DESCRIPTION \fBgrubby\fR is a command line tool for updating and displaying information
@@ -154,6 +155,10 @@ 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 (\fBlilo\fR label) for the entry. If \fIentry-title\fR is longer then maximum diff --git a/grubby.c b/grubby.c index ccb11b0..b8380bf 100644 --- a/grubby.c +++ b/grubby.c @@ -1774,13 +1774,19 @@ void markRemovedImage(struct grubConfig * cfg, const char * image,
void setDefaultImage(struct grubConfig * config, int hasNew, const char * defaultKernelPath, int newIsDefault,
const char * prefix, int flags) {
const char * prefix, int flags, int index) {
struct singleEntry * entry, * entry2, * newDefault; int i, j;
if (newIsDefault) { config->defaultImage = 0; return;
} else if ((index>= 0)&& config->cfi->defaultIsIndex) {
if (findEntryByIndex(config, index))
config->defaultImage = index;
else
config->defaultImage = -1;
return;
^ BTW, I followed the same logic employed when setting the default entry based on a kernel path that can not be found, that is, set defaultImage to -1 and return immediately. This effectively means that a previously set default will be removed. If you have any comments on this, please let me know.
} else if (defaultKernelPath) {
i = 0; if (findEntryByPath(config, defaultKernelPath, prefix,&i)) { @@ -3653,6 +3659,7 @@ int main(int argc, const char ** argv) { int displayDefault = 0; int displayDefaultIndex = 0; int displayDefaultTitle = 0;
- int defaultIndex = -1; struct poptOption options[] = { { "add-kernel", 0, POPT_ARG_STRING,&newKernelPath, 0, _("add an entry for the specified kernel"), _("kernel-path") },
@@ -3725,6 +3732,9 @@ int main(int argc, const char ** argv) { { "set-default", 0, POPT_ARG_STRING,&defaultKernel, 0, _("make the first entry referencing the specified kernel " "the default"), _("kernel-path") },
- { "set-default-index", 0, POPT_ARG_INT,&defaultIndex, 0,
_("make the given entry index the default entry"),
{ "silo", 0, POPT_ARG_NONE,&configureSilo, 0, _("configure silo bootloader") }, { "title", 0, POPT_ARG_STRING,&newKernelTitle, 0,_("entry-index") },
@@ -3833,8 +3843,9 @@ int main(int argc, const char ** argv) { }
if (bootloaderProbe&& (displayDefault || kernelInfo || newKernelVersion ||
newKernelPath || removeKernelPath || makeDefault ||
defaultKernel || displayDefaultIndex || displayDefaultTitle)) {
newKernelPath || removeKernelPath || makeDefault ||
defaultKernel || displayDefaultIndex || displayDefaultTitle ||
fprintf(stderr, _("grubby: --bootloader-probe may not be used with " "specified option")); return 1;(defaultIndex>= 0))) {
@@ -3876,6 +3887,11 @@ int main(int argc, const char ** argv) { makeDefault = 1; defaultKernel = NULL; }
else if (defaultKernel&& (defaultIndex>= 0)) {
fprintf(stderr, _("grubby: --set-default and --set-default-index "
"may not be used together\n"));
return 1;
}
if (grubConfig&& !strcmp(grubConfig, "-")&& !outputFile) { fprintf(stderr, _("grubby: output file must be specified if stdin "
@@ -3884,8 +3900,9 @@ int main(int argc, const char ** argv) { }
if (!removeKernelPath&& !newKernelPath&& !displayDefault&& !defaultKernel
- && !kernelInfo&& !bootloaderProbe&& !updateKernelPath
-&& !removeMBKernel&& !displayDefaultIndex&& !displayDefaultTitle) {
- && !kernelInfo&& !bootloaderProbe&& !updateKernelPath
- && !removeMBKernel&& !displayDefaultIndex&& !displayDefaultTitle
- && (defaultIndex == -1)) { fprintf(stderr, _("grubby: no action specified\n")); return 1; }
@@ -4044,7 +4061,7 @@ int main(int argc, const char ** argv) { markRemovedImage(config, removeKernelPath, bootPrefix); markRemovedImage(config, removeMBKernel, bootPrefix); setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault,
bootPrefix, flags);
setFallbackImage(config, newKernelPath != NULL); if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;bootPrefix, flags, defaultIndex);
Signed-off-by: Cleber Rosa crosa@redhat.com --- grubby.8 | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/grubby.8 b/grubby.8 index 43c141d..d79e60e 100644 --- a/grubby.8 +++ b/grubby.8 @@ -1,6 +1,6 @@ .TH GRUBBY 8 "Tue Jan 18 2005" .SH NAME -grubby - command line tool for configuring grub, lilo, and elilo +grubby - command line tool for configuring grub, lilo, elilo, yaboot and zipl
.SH SYNOPSIS \fBgrubby\fR [--add-kernel=\fIkernel-path\fR] [--args=\fIargs\fR]
anaconda-devel@lists.stg.fedoraproject.org