Magellan Linux

Diff of /tags/grubby-8_36/grubby.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1855 by niro, Mon Jul 2 13:13:03 2012 UTC revision 1931 by niro, Mon Oct 1 12:06:26 2012 UTC
# Line 205  struct keywordTypes grub2Keywords[] = { Line 205  struct keywordTypes grub2Keywords[] = {
205      { "default",    LT_DEFAULT,     ' ' },      { "default",    LT_DEFAULT,     ' ' },
206      { "fallback",   LT_FALLBACK,    ' ' },      { "fallback",   LT_FALLBACK,    ' ' },
207      { "linux",      LT_KERNEL,      ' ' },      { "linux",      LT_KERNEL,      ' ' },
208        { "linuxefi",   LT_KERNEL,      ' ' },
209      { "initrd",     LT_INITRD,      ' ', ' ' },      { "initrd",     LT_INITRD,      ' ', ' ' },
210        { "initrdefi",  LT_INITRD,      ' ', ' ' },
211      { "module",     LT_MBMODULE,    ' ' },      { "module",     LT_MBMODULE,    ' ' },
212      { "kernel",     LT_HYPER,       ' ' },      { "kernel",     LT_HYPER,       ' ' },
213      { NULL, 0, 0 },      { NULL, 0, 0 },
# Line 1310  static int writeConfig(struct grubConfig Line 1312  static int writeConfig(struct grubConfig
1312    
1313      /* most likely the symlink is relative, so change our      /* most likely the symlink is relative, so change our
1314         directory to the dir of the symlink */         directory to the dir of the symlink */
1315              rc = chdir(dirname(outName));      char *dir = strdupa(outName);
1316                rc = chdir(dirname(dir));
1317        free(dir);
1318      do {      do {
1319   buf = alloca(len + 1);   buf = alloca(len + 1);
1320   rc = readlink(basename(outName), buf, len);   rc = readlink(basename(outName), buf, len);
# Line 1867  void markRemovedImage(struct grubConfig Line 1871  void markRemovedImage(struct grubConfig
1871    
1872  void setDefaultImage(struct grubConfig * config, int hasNew,  void setDefaultImage(struct grubConfig * config, int hasNew,
1873       const char * defaultKernelPath, int newIsDefault,       const char * defaultKernelPath, int newIsDefault,
1874       const char * prefix, int flags) {       const char * prefix, int flags, int index) {
1875      struct singleEntry * entry, * entry2, * newDefault;      struct singleEntry * entry, * entry2, * newDefault;
1876      int i, j;      int i, j;
1877    
1878      if (newIsDefault) {      if (newIsDefault) {
1879   config->defaultImage = 0;   config->defaultImage = 0;
1880   return;   return;
1881        } else if ((index >= 0) && config->cfi->defaultIsIndex) {
1882     if (findEntryByIndex(config, index))
1883        config->defaultImage = index;
1884     else
1885        config->defaultImage = -1;
1886     return;
1887      } else if (defaultKernelPath) {      } else if (defaultKernelPath) {
1888   i = 0;   i = 0;
1889   if (findEntryByPath(config, defaultKernelPath, prefix, &i)) {   if (findEntryByPath(config, defaultKernelPath, prefix, &i)) {
# Line 3740  int main(int argc, const char ** argv) { Line 3750  int main(int argc, const char ** argv) {
3750      int displayDefault = 0;      int displayDefault = 0;
3751      int displayDefaultIndex = 0;      int displayDefaultIndex = 0;
3752      int displayDefaultTitle = 0;      int displayDefaultTitle = 0;
3753        int defaultIndex = -1;
3754      struct poptOption options[] = {      struct poptOption options[] = {
3755   { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0,   { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0,
3756      _("add an entry for the specified kernel"), _("kernel-path") },      _("add an entry for the specified kernel"), _("kernel-path") },
# Line 3812  int main(int argc, const char ** argv) { Line 3823  int main(int argc, const char ** argv) {
3823   { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0,   { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0,
3824      _("make the first entry referencing the specified kernel "      _("make the first entry referencing the specified kernel "
3825        "the default"), _("kernel-path") },        "the default"), _("kernel-path") },
3826     { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0,
3827        _("make the given entry index the default entry"),
3828        _("entry-index") },
3829   { "silo", 0, POPT_ARG_NONE, &configureSilo, 0,   { "silo", 0, POPT_ARG_NONE, &configureSilo, 0,
3830      _("configure silo bootloader") },      _("configure silo bootloader") },
3831   { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0,   { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0,
# Line 3920  int main(int argc, const char ** argv) { Line 3934  int main(int argc, const char ** argv) {
3934      }      }
3935    
3936      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||
3937    newKernelPath || removeKernelPath || makeDefault ||      newKernelPath || removeKernelPath || makeDefault ||
3938    defaultKernel || displayDefaultIndex || displayDefaultTitle)) {      defaultKernel || displayDefaultIndex || displayDefaultTitle ||
3939        (defaultIndex >= 0))) {
3940   fprintf(stderr, _("grubby: --bootloader-probe may not be used with "   fprintf(stderr, _("grubby: --bootloader-probe may not be used with "
3941    "specified option"));    "specified option"));
3942   return 1;   return 1;
# Line 3963  int main(int argc, const char ** argv) { Line 3978  int main(int argc, const char ** argv) {
3978   makeDefault = 1;   makeDefault = 1;
3979   defaultKernel = NULL;   defaultKernel = NULL;
3980      }      }
3981        else if (defaultKernel && (defaultIndex >= 0)) {
3982     fprintf(stderr, _("grubby: --set-default and --set-default-index "
3983      "may not be used together\n"));
3984     return 1;
3985        }
3986    
3987      if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) {      if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) {
3988   fprintf(stderr, _("grubby: output file must be specified if stdin "   fprintf(stderr, _("grubby: output file must be specified if stdin "
# Line 3971  int main(int argc, const char ** argv) { Line 3991  int main(int argc, const char ** argv) {
3991      }      }
3992    
3993      if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel      if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel
3994   && !kernelInfo && !bootloaderProbe && !updateKernelPath   && !kernelInfo && !bootloaderProbe && !updateKernelPath
3995          && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) {   && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle
3996     && (defaultIndex == -1)) {
3997   fprintf(stderr, _("grubby: no action specified\n"));   fprintf(stderr, _("grubby: no action specified\n"));
3998   return 1;   return 1;
3999      }      }
# Line 4052  int main(int argc, const char ** argv) { Line 4073  int main(int argc, const char ** argv) {
4073      if (!yconfig)      if (!yconfig)
4074   yrc = 1;   yrc = 1;
4075      else      else
4076   yrc = checkForYaboot(lconfig);   yrc = checkForYaboot(yconfig);
4077   }   }
4078    
4079   if (lrc == 1 || grc == 1 || gr2c == 1 || extrc == 1 || yrc == 1 ||   if (lrc == 1 || grc == 1 || gr2c == 1 || extrc == 1 || yrc == 1 ||
# Line 4131  int main(int argc, const char ** argv) { Line 4152  int main(int argc, const char ** argv) {
4152      markRemovedImage(config, removeKernelPath, bootPrefix);      markRemovedImage(config, removeKernelPath, bootPrefix);
4153      markRemovedImage(config, removeMBKernel, bootPrefix);      markRemovedImage(config, removeMBKernel, bootPrefix);
4154      setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault,      setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault,
4155      bootPrefix, flags);      bootPrefix, flags, defaultIndex);
4156      setFallbackImage(config, newKernelPath != NULL);      setFallbackImage(config, newKernelPath != NULL);
4157      if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs,      if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs,
4158                      removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;                      removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;

Legend:
Removed from v.1855  
changed lines
  Added in v.1931