--- trunk/grubby/grubby.c 2012/07/02 13:09:12 1850 +++ trunk/grubby/grubby.c 2012/07/02 13:12:32 1854 @@ -164,9 +164,9 @@ const char *grubFindConfig(struct configFileInfo *cfi) { static const char *configFiles[] = { - "/etc/grub.conf", "/boot/grub/grub.conf", "/boot/grub/menu.lst", + "/etc/grub.conf", NULL }; static int i = -1; @@ -2350,13 +2350,13 @@ char * boot = NULL; int lba; - if (!isSuseSystem()) { - if (parseSysconfigGrub(&lba, &boot)) { + if (isSuseSystem()) { + if (parseSuseGrubConf(&lba, &boot)) { free(boot); return; } } else { - if (parseSuseGrubConf(&lba, &boot)) { + if (parseSysconfigGrub(&lba, &boot)) { free(boot); return; } @@ -3179,13 +3179,15 @@ int fd; unsigned char bootSect[512]; char * boot; - int onSuse; + int onSuse = isSuseSystem(); + - onSuse = isSuseSystem(); - if (!onSuse) { - if (parseSysconfigGrub(NULL, &boot)) return 0; + if (onSuse) { + if (parseSuseGrubConf(NULL, &boot)) + return 0; } else { - if (parseSuseGrubConf(NULL, &boot)) return 0; + if (parseSysconfigGrub(NULL, &boot)) + return 0; } /* assume grub is not installed -- not an error condition */ @@ -3205,14 +3207,13 @@ } close(fd); - 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 - */ + /* The more elaborate checks do not work on SuSE. The checks done + * seem to be reasonble (at least for now), so just return success + */ + if (onSuse) return 2; + + return checkDeviceBootloader(boot, bootSect); } int checkForExtLinux(struct grubConfig * config) { @@ -3245,6 +3246,30 @@ 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; +} + +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; @@ -3732,9 +3757,9 @@ { "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__) || defined (__ia64__) { "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)"), @@ -3974,8 +3999,8 @@ } if (bootloaderProbe) { - int lrc = 0, grc = 0, gr2c = 0, erc = 0; - struct grubConfig * lconfig, * gconfig; + 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) { @@ -4003,20 +4028,43 @@ 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); } - 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 || 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; }