Magellan Linux

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

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

revision 1720 by niro, Sat Feb 18 00:51:28 2012 UTC revision 1721 by niro, Sat Feb 18 00:52:28 2012 UTC
# Line 3161  int main(int argc, const char ** argv) { Line 3161  int main(int argc, const char ** argv) {
3161      int copyDefault = 0, makeDefault = 0;      int copyDefault = 0, makeDefault = 0;
3162      int displayDefault = 0;      int displayDefault = 0;
3163      int displayDefaultIndex = 0;      int displayDefaultIndex = 0;
3164        int displayDefaultTitle = 0;
3165      struct poptOption options[] = {      struct poptOption options[] = {
3166   { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0,   { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0,
3167      _("add an entry for the specified kernel"), _("kernel-path") },      _("add an entry for the specified kernel"), _("kernel-path") },
# Line 3195  int main(int argc, const char ** argv) { Line 3196  int main(int argc, const char ** argv) {
3196      _("display the path of the default kernel") },      _("display the path of the default kernel") },
3197   { "default-index", 0, 0, &displayDefaultIndex, 0,   { "default-index", 0, 0, &displayDefaultIndex, 0,
3198      _("display the index of the default kernel") },      _("display the index of the default kernel") },
3199     { "default-title", 0, 0, &displayDefaultTitle, 0,
3200        _("display the title of the default kernel") },
3201   { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,   { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,
3202      _("configure elilo bootloader") },      _("configure elilo bootloader") },
3203   { "extlinux", 0, POPT_ARG_NONE, &configureExtLinux, 0,   { "extlinux", 0, POPT_ARG_NONE, &configureExtLinux, 0,
# Line 3338  int main(int argc, const char ** argv) { Line 3341  int main(int argc, const char ** argv) {
3341    
3342      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||
3343    newKernelPath || removeKernelPath || makeDefault ||    newKernelPath || removeKernelPath || makeDefault ||
3344    defaultKernel || displayDefaultIndex)) {    defaultKernel || displayDefaultIndex || displayDefaultTitle)) {
3345   fprintf(stderr, _("grubby: --bootloader-probe may not be used with "   fprintf(stderr, _("grubby: --bootloader-probe may not be used with "
3346    "specified option"));    "specified option"));
3347   return 1;   return 1;
# Line 3389  int main(int argc, const char ** argv) { Line 3392  int main(int argc, const char ** argv) {
3392    
3393      if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel      if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel
3394   && !kernelInfo && !bootloaderProbe && !updateKernelPath   && !kernelInfo && !bootloaderProbe && !updateKernelPath
3395          && !removeMBKernel && !displayDefaultIndex) {          && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) {
3396   fprintf(stderr, _("grubby: no action specified\n"));   fprintf(stderr, _("grubby: no action specified\n"));
3397   return 1;   return 1;
3398      }      }
# Line 3485  int main(int argc, const char ** argv) { Line 3488  int main(int argc, const char ** argv) {
3488    
3489   return 0;   return 0;
3490    
3491        } else if (displayDefaultTitle) {
3492     struct singleLine * line;
3493     struct singleEntry * entry;
3494    
3495     if (config->defaultImage == -1) return 0;
3496     entry = findEntryByIndex(config, config->defaultImage);
3497     if (!entry) return 0;
3498    
3499     if (!configureGrub2) {
3500      line = getLineByType(LT_TITLE, entry->lines);
3501      if (!line) return 0;
3502      printf("%s\n", line->elements[1].item);
3503    
3504     } else {
3505      int i;
3506      size_t len;
3507      char * start;
3508      char * tmp;
3509    
3510      dbgPrintf("This is GRUB2, default title is embeded in menuentry\n");
3511      line = getLineByType(LT_MENUENTRY, entry->lines);
3512      if (!line) return 0;
3513    
3514      for (i = 0; i < line->numElements; i++) {
3515    
3516        if (!strcmp(line->elements[i].item, "menuentry"))
3517          continue;
3518    
3519        if (*line->elements[i].item == '\'')
3520          start = line->elements[i].item + 1;
3521        else
3522          start = line->elements[i].item;
3523    
3524        len = strlen(start);
3525        if (*(start + len - 1) == '\'') {
3526          tmp = strdup(start);
3527          *(tmp + len - 1) = '\0';
3528          printf("%s", tmp);
3529          free(tmp);
3530          break;
3531        } else {
3532          printf("%s ", start);
3533        }
3534      }
3535      printf("\n");
3536     }
3537     return 0;
3538    
3539      } else if (displayDefaultIndex) {      } else if (displayDefaultIndex) {
3540          if (config->defaultImage == -1) return 0;          if (config->defaultImage == -1) return 0;
3541          printf("%i\n", config->defaultImage);          printf("%i\n", config->defaultImage);

Legend:
Removed from v.1720  
changed lines
  Added in v.1721