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 1868 by niro, Mon Jul 2 13:22:30 2012 UTC
# Line 1310  static int writeConfig(struct grubConfig Line 1310  static int writeConfig(struct grubConfig
1310    
1311      /* most likely the symlink is relative, so change our      /* most likely the symlink is relative, so change our
1312         directory to the dir of the symlink */         directory to the dir of the symlink */
1313              rc = chdir(dirname(outName));      char *dir = strdupa(outName);
1314                rc = chdir(dirname(dir));
1315        free(dir);
1316      do {      do {
1317   buf = alloca(len + 1);   buf = alloca(len + 1);
1318   rc = readlink(basename(outName), buf, len);   rc = readlink(basename(outName), buf, len);
# Line 1867  void markRemovedImage(struct grubConfig Line 1869  void markRemovedImage(struct grubConfig
1869    
1870  void setDefaultImage(struct grubConfig * config, int hasNew,  void setDefaultImage(struct grubConfig * config, int hasNew,
1871       const char * defaultKernelPath, int newIsDefault,       const char * defaultKernelPath, int newIsDefault,
1872       const char * prefix, int flags) {       const char * prefix, int flags, int index) {
1873      struct singleEntry * entry, * entry2, * newDefault;      struct singleEntry * entry, * entry2, * newDefault;
1874      int i, j;      int i, j;
1875    
1876      if (newIsDefault) {      if (newIsDefault) {
1877   config->defaultImage = 0;   config->defaultImage = 0;
1878   return;   return;
1879        } else if ((index >= 0) && config->cfi->defaultIsIndex) {
1880     if (findEntryByIndex(config, index))
1881        config->defaultImage = index;
1882     else
1883        config->defaultImage = -1;
1884     return;
1885      } else if (defaultKernelPath) {      } else if (defaultKernelPath) {
1886   i = 0;   i = 0;
1887   if (findEntryByPath(config, defaultKernelPath, prefix, &i)) {   if (findEntryByPath(config, defaultKernelPath, prefix, &i)) {
# Line 3740  int main(int argc, const char ** argv) { Line 3748  int main(int argc, const char ** argv) {
3748      int displayDefault = 0;      int displayDefault = 0;
3749      int displayDefaultIndex = 0;      int displayDefaultIndex = 0;
3750      int displayDefaultTitle = 0;      int displayDefaultTitle = 0;
3751        int defaultIndex = -1;
3752      struct poptOption options[] = {      struct poptOption options[] = {
3753   { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0,   { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0,
3754      _("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 3821  int main(int argc, const char ** argv) {
3821   { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0,   { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0,
3822      _("make the first entry referencing the specified kernel "      _("make the first entry referencing the specified kernel "
3823        "the default"), _("kernel-path") },        "the default"), _("kernel-path") },
3824     { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0,
3825        _("make the given entry index the default entry"),
3826        _("entry-index") },
3827   { "silo", 0, POPT_ARG_NONE, &configureSilo, 0,   { "silo", 0, POPT_ARG_NONE, &configureSilo, 0,
3828      _("configure silo bootloader") },      _("configure silo bootloader") },
3829   { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0,   { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0,
# Line 3920  int main(int argc, const char ** argv) { Line 3932  int main(int argc, const char ** argv) {
3932      }      }
3933    
3934      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||
3935    newKernelPath || removeKernelPath || makeDefault ||      newKernelPath || removeKernelPath || makeDefault ||
3936    defaultKernel || displayDefaultIndex || displayDefaultTitle)) {      defaultKernel || displayDefaultIndex || displayDefaultTitle ||
3937        (defaultIndex >= 0))) {
3938   fprintf(stderr, _("grubby: --bootloader-probe may not be used with "   fprintf(stderr, _("grubby: --bootloader-probe may not be used with "
3939    "specified option"));    "specified option"));
3940   return 1;   return 1;
# Line 3963  int main(int argc, const char ** argv) { Line 3976  int main(int argc, const char ** argv) {
3976   makeDefault = 1;   makeDefault = 1;
3977   defaultKernel = NULL;   defaultKernel = NULL;
3978      }      }
3979        else if (defaultKernel && (defaultIndex >= 0)) {
3980     fprintf(stderr, _("grubby: --set-default and --set-default-index "
3981      "may not be used together\n"));
3982     return 1;
3983        }
3984    
3985      if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) {      if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) {
3986   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 3989  int main(int argc, const char ** argv) {
3989      }      }
3990    
3991      if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel      if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel
3992   && !kernelInfo && !bootloaderProbe && !updateKernelPath   && !kernelInfo && !bootloaderProbe && !updateKernelPath
3993          && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) {   && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle
3994     && (defaultIndex == -1)) {
3995   fprintf(stderr, _("grubby: no action specified\n"));   fprintf(stderr, _("grubby: no action specified\n"));
3996   return 1;   return 1;
3997      }      }
# Line 4052  int main(int argc, const char ** argv) { Line 4071  int main(int argc, const char ** argv) {
4071      if (!yconfig)      if (!yconfig)
4072   yrc = 1;   yrc = 1;
4073      else      else
4074   yrc = checkForYaboot(lconfig);   yrc = checkForYaboot(yconfig);
4075   }   }
4076    
4077   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 4150  int main(int argc, const char ** argv) {
4150      markRemovedImage(config, removeKernelPath, bootPrefix);      markRemovedImage(config, removeKernelPath, bootPrefix);
4151      markRemovedImage(config, removeMBKernel, bootPrefix);      markRemovedImage(config, removeMBKernel, bootPrefix);
4152      setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault,      setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault,
4153      bootPrefix, flags);      bootPrefix, flags, defaultIndex);
4154      setFallbackImage(config, newKernelPath != NULL);      setFallbackImage(config, newKernelPath != NULL);
4155      if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs,      if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs,
4156                      removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;                      removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1;

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