Magellan Linux

Diff of /trunk/grubby/grubby.c

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

revision 2957 by niro, Wed Jun 29 14:06:18 2016 UTC revision 2971 by niro, Thu Jun 30 10:06:57 2016 UTC
# Line 582  struct keywordTypes extlinuxKeywords[] = Line 582  struct keywordTypes extlinuxKeywords[] =
582      { "initrd",    LT_INITRD,      ' ', ',' },      { "initrd",    LT_INITRD,      ' ', ',' },
583      { "append",    LT_KERNELARGS,  ' ' },      { "append",    LT_KERNELARGS,  ' ' },
584      { "prompt",     LT_UNKNOWN,     ' ' },      { "prompt",     LT_UNKNOWN,     ' ' },
585        { "fdt",        LT_DEVTREE,     ' ' },
586      { NULL,    0, 0 },      { NULL,    0, 0 },
587  };  };
588  int useextlinuxmenu;  int useextlinuxmenu;
# Line 2120  struct singleEntry * findTemplate(struct Line 2121  struct singleEntry * findTemplate(struct
2121   } else {   } else {
2122      entry = findEntryByTitle(cfg, defTitle, &index);      entry = findEntryByTitle(cfg, defTitle, &index);
2123   }   }
2124   if (entry)   if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
2125      cfg->defaultImage = index;      cfg->defaultImage = index;
2126        if (indexPtr)
2127     *indexPtr = index;
2128        return entry;
2129     }
2130      }      }
2131   }   }
2132      } else if (cfg->defaultImage > -1) {      } else if (cfg->defaultImage > -1) {
# Line 2366  void displayEntry(struct singleEntry * e Line 2371  void displayEntry(struct singleEntry * e
2371      } else {      } else {
2372   char * title;   char * title;
2373   line = getLineByType(LT_MENUENTRY, entry->lines);   line = getLineByType(LT_MENUENTRY, entry->lines);
2374   title = grub2ExtractTitle(line);   if (line) {
2375   if (title)      title = grub2ExtractTitle(line);
2376      printf("title=%s\n", title);      if (title)
2377     printf("title=%s\n", title);
2378     }
2379      }      }
2380    
2381      for (j = 0, line = entry->lines; line; line = line->next) {      for (j = 0, line = entry->lines; line; line = line->next) {
# Line 3305  int updateImage(struct grubConfig * cfg, Line 3312  int updateImage(struct grubConfig * cfg,
3312  }  }
3313    
3314  int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,  int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel,
3315   const char * image, const char * prefix, const char * initrd) {   const char * image, const char * prefix, const char * initrd,
3316     const char * title) {
3317      struct singleEntry * entry;      struct singleEntry * entry;
3318      struct singleLine * line, * kernelLine, *endLine = NULL;      struct singleLine * line, * kernelLine, *endLine = NULL;
3319      int index = 0;      int index = 0;
# Line 3316  int addMBInitrd(struct grubConfig * cfg, Line 3324  int addMBInitrd(struct grubConfig * cfg,
3324          kernelLine = getLineByType(LT_MBMODULE, entry->lines);          kernelLine = getLineByType(LT_MBMODULE, entry->lines);
3325          if (!kernelLine) continue;          if (!kernelLine) continue;
3326    
3327     /* if title is supplied, the entry's title must match it. */
3328     if (title) {
3329        char *linetitle;
3330    
3331        line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
3332        if (!line)
3333     continue;
3334    
3335        linetitle = extractTitle(line);
3336        if (!linetitle)
3337     continue;
3338        if (strcmp(title, linetitle)) {
3339     free(linetitle);
3340     continue;
3341        }
3342        free(linetitle);
3343     }
3344    
3345          if (prefix) {          if (prefix) {
3346              int prefixLen = strlen(prefix);              int prefixLen = strlen(prefix);
3347              if (!strncmp(initrd, prefix, prefixLen))              if (!strncmp(initrd, prefix, prefixLen))
# Line 3341  int addMBInitrd(struct grubConfig * cfg, Line 3367  int addMBInitrd(struct grubConfig * cfg,
3367  }  }
3368    
3369  int updateInitrd(struct grubConfig * cfg, const char * image,  int updateInitrd(struct grubConfig * cfg, const char * image,
3370                   const char * prefix, const char * initrd) {                   const char * prefix, const char * initrd, const char * title) {
3371      struct singleEntry * entry;      struct singleEntry * entry;
3372      struct singleLine * line, * kernelLine, *endLine = NULL;      struct singleLine * line, * kernelLine, *endLine = NULL;
3373      int index = 0;      int index = 0;
# Line 3352  int updateInitrd(struct grubConfig * cfg Line 3378  int updateInitrd(struct grubConfig * cfg
3378          kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);          kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
3379          if (!kernelLine) continue;          if (!kernelLine) continue;
3380    
3381     /* if title is supplied, the entry's title must match it. */
3382     if (title) {
3383        char *linetitle;
3384    
3385        line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines);
3386        if (!line)
3387     continue;
3388    
3389        linetitle = extractTitle(line);
3390        if (!linetitle)
3391     continue;
3392        if (strcmp(title, linetitle)) {
3393     free(linetitle);
3394     continue;
3395        }
3396        free(linetitle);
3397     }
3398    
3399          line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines);          line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines);
3400          if (line)          if (line)
3401              removeLine(entry, line);              removeLine(entry, line);
# Line 4410  int main(int argc, const char ** argv) { Line 4454  int main(int argc, const char ** argv) {
4454      if (newKernelPath && !newKernelTitle) {      if (newKernelPath && !newKernelTitle) {
4455   fprintf(stderr, _("grubby: kernel title must be specified\n"));   fprintf(stderr, _("grubby: kernel title must be specified\n"));
4456   return 1;   return 1;
4457      } else if (!newKernelPath && (newKernelTitle  || copyDefault ||      } else if (!newKernelPath && (copyDefault ||
4458    (newKernelInitrd && !updateKernelPath)||    (newKernelInitrd && !updateKernelPath)||
4459    makeDefault || extraInitrdCount > 0)) {    makeDefault || extraInitrdCount > 0)) {
4460   fprintf(stderr, _("grubby: kernel path expected\n"));   fprintf(stderr, _("grubby: kernel path expected\n"));
# Line 4632  int main(int argc, const char ** argv) { Line 4676  int main(int argc, const char ** argv) {
4676      if (updateKernelPath && newKernelInitrd) {      if (updateKernelPath && newKernelInitrd) {
4677      if (newMBKernel) {      if (newMBKernel) {
4678      if (addMBInitrd(config, newMBKernel, updateKernelPath,      if (addMBInitrd(config, newMBKernel, updateKernelPath,
4679   bootPrefix, newKernelInitrd))   bootPrefix, newKernelInitrd,
4680     newKernelTitle))
4681      return 1;      return 1;
4682      } else {      } else {
4683      if (updateInitrd(config, updateKernelPath, bootPrefix,      if (updateInitrd(config, updateKernelPath, bootPrefix,
4684   newKernelInitrd))   newKernelInitrd, newKernelTitle))
4685   return 1;   return 1;
4686      }      }
4687      }      }

Legend:
Removed from v.2957  
changed lines
  Added in v.2971