--- trunk/grubby/grubby.c 2012/02/17 23:46:24 1696 +++ trunk/grubby/grubby.c 2012/02/18 00:35:46 1715 @@ -156,8 +156,30 @@ { NULL, 0, 0 }, }; +const char *grubFindConfig(struct configFileInfo *cfi) { + static const char *configFiles[] = { + "/etc/grub.conf", + "/boot/grub/grub.conf", + "/boot/grub/menu.lst", + NULL + }; + static int i = -1; + + if (i == -1) { + for (i = 0; configFiles[i] != NULL; i++) { + dbgPrintf("Checking \"%s\": ", configFiles[i]); + if (!access(configFiles[i], R_OK)) { + dbgPrintf("found\n"); + return configFiles[i]; + } + dbgPrintf("not found\n"); + } + } + return configFiles[i]; +} + struct configFileInfo grubConfigType = { - .defaultConfig = "/boot/grub/grub.conf", + .findConfig = grubFindConfig, .keywords = grubKeywords, .defaultIsIndex = 1, .defaultSupportSaved = 1, @@ -190,6 +212,7 @@ NULL }; static int i = -1; + static const char *grub_cfg = "/boot/grub/grub.cfg"; if (i == -1) { for (i = 0; configFiles[i] != NULL; i++) { @@ -198,9 +221,18 @@ dbgPrintf("found\n"); return configFiles[i]; } - dbgPrintf("not found\n"); } } + + /* Ubuntu renames grub2 to grub, so check for the grub.d directory + * that isn't in grub1, and if it exists, return the config file path + * that they use. */ + if (configFiles[i] == NULL && !access("/etc/grub.d/", R_OK)) { + dbgPrintf("found\n"); + return grub_cfg; + } + + dbgPrintf("not found\n"); return configFiles[i]; } @@ -2584,7 +2616,7 @@ } int checkForGrub2(struct grubConfig * config) { - if (!access("/boot/grub2", R_OK)) + if (!access("/etc/grub.d/", R_OK)) return 2; return 1; @@ -3380,8 +3412,9 @@ gr2c = checkForGrub2(gconfig); } - if (!access(grubConfigType.defaultConfig, F_OK)) { - gconfig = readConfig(grubConfigType.defaultConfig, &grubConfigType); + const char *grubconfig = grubFindConfig(&grubConfigType); + if (!access(grubconfig, F_OK)) { + gconfig = readConfig(grubconfig, &grubConfigType); if (!gconfig) grc = 1; else