Magellan Linux

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

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

revision 2685 by niro, Wed Jul 16 10:38:09 2014 UTC revision 2959 by niro, Wed Jun 29 14:07:33 2016 UTC
# Line 60  int debug = 0; /* Currently just for tem Line 60  int debug = 0; /* Currently just for tem
60    
61  int isEfi = 0;  int isEfi = 0;
62    
63    #if defined(__aarch64__)
64    #define isEfiOnly 1
65    #else
66    #define isEfiOnly 0
67    #endif
68    
69  char *saved_command_line = NULL;  char *saved_command_line = NULL;
70    
71  /* comments get lumped in with indention */  /* comments get lumped in with indention */
# Line 155  struct configFileInfo { Line 161  struct configFileInfo {
161      int defaultIsVariable;      int defaultIsVariable;
162      int defaultSupportSaved;      int defaultSupportSaved;
163      int defaultIsSaved;      int defaultIsSaved;
164        int defaultIsUnquoted;
165      enum lineType_e entryStart;      enum lineType_e entryStart;
166      enum lineType_e entryEnd;      enum lineType_e entryEnd;
167      int needsBootPrefix;      int needsBootPrefix;
# Line 630  struct configFileInfo extlinuxConfigType Line 637  struct configFileInfo extlinuxConfigType
637      .needsBootPrefix = 1,      .needsBootPrefix = 1,
638      .maxTitleLength = 255,      .maxTitleLength = 255,
639      .mbAllowExtraInitRds = 1,      .mbAllowExtraInitRds = 1,
640        .defaultIsUnquoted = 1,
641  };  };
642    
643  struct grubConfig {  struct grubConfig {
# Line 721  static enum lineType_e preferredLineType Line 729  static enum lineType_e preferredLineType
729      if (isEfi && cfi == &grub2ConfigType) {      if (isEfi && cfi == &grub2ConfigType) {
730   switch (type) {   switch (type) {
731   case LT_KERNEL:   case LT_KERNEL:
732      return LT_KERNEL_EFI;      return isEfiOnly ? LT_KERNEL : LT_KERNEL_EFI;
733   case LT_INITRD:   case LT_INITRD:
734      return LT_INITRD_EFI;      return isEfiOnly ? LT_INITRD : LT_INITRD_EFI;
735   default:   default:
736      return type;      return type;
737   }   }
# Line 1185  static struct grubConfig * readConfig(co Line 1193  static struct grubConfig * readConfig(co
1193   cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;   cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;
1194   defaultLine = line;   defaultLine = line;
1195      }      }
  } else if (line->type == LT_DEFAULT && line->numElements == 2) {  
     cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;  
     defaultLine = line;  
1196    
1197          } else if (iskernel(line->type)) {          } else if (iskernel(line->type)) {
1198      /* if by some freak chance this is multiboot and the "module"      /* if by some freak chance this is multiboot and the "module"
1199       * lines came earlier in the template, make sure to use LT_HYPER       * lines came earlier in the template, make sure to use LT_HYPER
1200       * instead of LT_KERNEL now       * instead of LT_KERNEL now
1201       */       */
1202      if (entry->multiboot)      if (entry && entry->multiboot)
1203   line->type = LT_HYPER;   line->type = LT_HYPER;
1204    
1205          } else if (line->type == LT_MBMODULE) {          } else if (line->type == LT_MBMODULE) {
# Line 1220  static struct grubConfig * readConfig(co Line 1225  static struct grubConfig * readConfig(co
1225      cfg->fallbackImage = strtol(line->elements[1].item, &end, 10);      cfg->fallbackImage = strtol(line->elements[1].item, &end, 10);
1226      if (*end) cfg->fallbackImage = -1;      if (*end) cfg->fallbackImage = -1;
1227    
1228   } else if (line->type == LT_TITLE && line->numElements > 1) {   } else if ((line->type == LT_DEFAULT && cfi->defaultIsUnquoted) ||
1229      /* make the title a single argument (undoing our parsing) */                  (line->type == LT_TITLE && line->numElements > 1)) {
1230        /* make the title/default a single argument (undoing our parsing) */
1231      len = 0;      len = 0;
1232      for (int i = 1; i < line->numElements; i++) {      for (int i = 1; i < line->numElements; i++) {
1233   len += strlen(line->elements[i].item);   len += strlen(line->elements[i].item);
# Line 1328  static struct grubConfig * readConfig(co Line 1334  static struct grubConfig * readConfig(co
1334      }      }
1335   }   }
1336    
1337     if (line->type == LT_DEFAULT && line->numElements == 2) {
1338        cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;
1339        defaultLine = line;
1340     }
1341    
1342   /* If we find a generic config option which should live at the   /* If we find a generic config option which should live at the
1343     top of the file, move it there. Old versions of grubby were     top of the file, move it there. Old versions of grubby were
1344     probably responsible for putting new images in the wrong     probably responsible for putting new images in the wrong
# Line 1949  struct singleEntry * findEntryByPath(str Line 1960  struct singleEntry * findEntryByPath(str
1960   }   }
1961    
1962   indexVars[i + 1] = -1;   indexVars[i + 1] = -1;
1963    
1964   i = 0;   i = 0;
1965   if (index) {   if (index) {
1966      while (i < *index) i++;      while (i < *index) {
1967      if (indexVars[i] == -1) return NULL;   i++;
1968     if (indexVars[i] == -1) return NULL;
1969        }
1970   }   }
1971    
1972   entry = findEntryByIndex(config, indexVars[i]);   entry = findEntryByIndex(config, indexVars[i]);
# Line 2107  struct singleEntry * findTemplate(struct Line 2120  struct singleEntry * findTemplate(struct
2120   } else {   } else {
2121      entry = findEntryByTitle(cfg, defTitle, &index);      entry = findEntryByTitle(cfg, defTitle, &index);
2122   }   }
2123   if (entry)   if (entry && suitableImage(entry, prefix, skipRemoved, flags)) {
2124      cfg->defaultImage = index;      cfg->defaultImage = index;
2125        if (indexPtr)
2126     *indexPtr = index;
2127        return entry;
2128     }
2129      }      }
2130   }   }
2131      } else if (cfg->defaultImage > -1) {      } else if (cfg->defaultImage > -1) {
# Line 2265  void displayEntry(struct singleEntry * e Line 2282  void displayEntry(struct singleEntry * e
2282      struct singleLine * line;      struct singleLine * line;
2283      char * root = NULL;      char * root = NULL;
2284      int i;      int i;
2285        int j;
2286    
2287      printf("index=%d\n", index);      printf("index=%d\n", index);
2288    
# Line 2356  void displayEntry(struct singleEntry * e Line 2374  void displayEntry(struct singleEntry * e
2374   if (title)   if (title)
2375      printf("title=%s\n", title);      printf("title=%s\n", title);
2376      }      }
2377    
2378        for (j = 0, line = entry->lines; line; line = line->next) {
2379     if ((line->type & LT_MBMODULE) && line->numElements >= 2) {
2380        if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
2381     printf("mbmodule%d=", j);
2382        else
2383     printf("mbmodule%d=%s", j, prefix);
2384    
2385        for (i = 1; i < line->numElements; i++)
2386     printf("%s%s", line->elements[i].item, line->elements[i].indent);
2387        printf("\n");
2388        j++;
2389     }
2390        }
2391  }  }
2392    
2393  int isSuseSystem(void) {  int isSuseSystem(void) {
# Line 3284  int addMBInitrd(struct grubConfig * cfg, Line 3316  int addMBInitrd(struct grubConfig * cfg,
3316    
3317      if (!image) return 0;      if (!image) return 0;
3318    
3319      for (; (entry = findEntryByPath(cfg, newMBKernel, prefix, &index)); index++) {      for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) {
3320          kernelLine = getLineByType(LT_MBMODULE, entry->lines);          kernelLine = getLineByType(LT_MBMODULE, entry->lines);
3321          if (!kernelLine) continue;          if (!kernelLine) continue;
3322    
# Line 4027  int addNewKernel(struct grubConfig * con Line 4059  int addNewKernel(struct grubConfig * con
4059   }   }
4060      }      }
4061    
4062        struct singleLine *endLine = NULL;
4063        endLine = getLineByType(LT_ENTRY_END, new->lines);
4064        if (endLine) {
4065        removeLine(new, endLine);
4066        needs |= NEED_END;
4067        }
4068    
4069      /* add the remainder of the lines, i.e. those that either      /* add the remainder of the lines, i.e. those that either
4070       * weren't present in the template, or in the case of no template,       * weren't present in the template, or in the case of no template,
4071       * all the lines following the entryStart.       * all the lines following the entryStart.
# Line 4085  int addNewKernel(struct grubConfig * con Line 4124  int addNewKernel(struct grubConfig * con
4124   config->secondaryIndent, NULL);   config->secondaryIndent, NULL);
4125   needs &= ~NEED_END;   needs &= ~NEED_END;
4126      }      }
4127    
4128      if (needs) {      if (needs) {
4129   printf(_("grubby: needs=%d, aborting\n"), needs);   printf(_("grubby: needs=%d, aborting\n"), needs);
4130   abort();   abort();

Legend:
Removed from v.2685  
changed lines
  Added in v.2959