Add --set-default-index feature
This pairs with --default-index, allowing the user to specify the
entry to make the default using and index rather than a kernel. Signed-off-by: Cleber Rosa <crosa@redhat.com> --- grubby.8 | 11 ++++++++--- grubby.c | 29 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/grubby.8 b/grubby.8 index fe60892..43c141d 100644 --- a/grubby.8 +++ b/grubby.8 @@ -11,9 +11,10 @@ grubby - command line tool for configuring grub, lilo, and elilo [--info=fIkernel-pathfR] [--initrd=fIinitrd-pathfR] [--make-default] [-o path] [--version] [--remove-kernel=fIkernel-pathfR] [--remove-args=fIargsfR] - [--set-default=fIkernel-pathfR] [--title=entry-title] - [--add-multiboot=fImultiboot-pathfR] [--mbargs=fIargsfR] - [--remove-multiboot=fImultiboot-pathfR] [--remove-mbargs=fIargsfR] + [--set-default=fIkernel-pathfR] [--set-default-index=fientry-indexfR] + [--title=entry-title] [--add-multiboot=fImultiboot-pathfR] + [--mbargs=fIargsfR] [--remove-multiboot=fImultiboot-pathfR] + [--remove-mbargs=fIargsfR] .SH DESCRIPTION fBgrubbyfR is a command line tool for updating and displaying information @@ -154,6 +155,10 @@ The first entry which boots the specified kernel is made the default boot entry. .TP +fB--set-default-indexfR=fIentry-indexfR +Makes the given entry number the default boot entry. + +.TP fB--titlefR=fIentry-titlefR When a new kernel entry is added fIentry-titlefR is used as the title (fBlilofR label) for the entry. If fIentry-titlefR is longer then maximum diff --git a/grubby.c b/grubby.c index ccb11b0..b8380bf 100644 --- a/grubby.c +++ b/grubby.c @@ -1774,13 +1774,19 @@ void markRemovedImage(struct grubConfig * cfg, const char * image, void setDefaultImage(struct grubConfig * config, int hasNew, const char * defaultKernelPath, int newIsDefault, - const char * prefix, int flags) { + const char * prefix, int flags, int index) { struct singleEntry * entry, * entry2, * newDefault; int i, j; if (newIsDefault) { config->defaultImage = 0; return; + } else if ((index >= 0) && config->cfi->defaultIsIndex) { + if (findEntryByIndex(config, index)) + config->defaultImage = index; + else + config->defaultImage = -1; + return; } else if (defaultKernelPath) { i = 0; if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { @@ -3653,6 +3659,7 @@ int main(int argc, const char ** argv) { int displayDefault = 0; int displayDefaultIndex = 0; int displayDefaultTitle = 0; + int defaultIndex = -1; struct poptOption options[] = { { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, _("add an entry for the specified kernel"), _("kernel-path") }, @@ -3725,6 +3732,9 @@ int main(int argc, const char ** argv) { { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, _("make the first entry referencing the specified kernel " "the default"), _("kernel-path") }, + { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0, + _("make the given entry index the default entry"), + _("entry-index") }, { "silo", 0, POPT_ARG_NONE, &configureSilo, 0, _("configure silo bootloader") }, { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, @@ -3833,8 +3843,9 @@ int main(int argc, const char ** argv) { } if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || - newKernelPath || removeKernelPath || makeDefault || - defaultKernel || displayDefaultIndex || displayDefaultTitle)) { + newKernelPath || removeKernelPath || makeDefault || + defaultKernel || displayDefaultIndex || displayDefaultTitle || + (defaultIndex >= 0))) { fprintf(stderr, _("grubby: --bootloader-probe may not be used with " "specified option")); return 1; @@ -3876,6 +3887,11 @@ int main(int argc, const char ** argv) { makeDefault = 1; defaultKernel = NULL; } + else if (defaultKernel && (defaultIndex >= 0)) { + fprintf(stderr, _("grubby: --set-default and --set-default-index " + "may not be used together ")); + return 1; + } if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { fprintf(stderr, _("grubby: output file must be specified if stdin " @@ -3884,8 +3900,9 @@ int main(int argc, const char ** argv) { } if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel - && !kernelInfo && !bootloaderProbe && !updateKernelPath - && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) { + && !kernelInfo && !bootloaderProbe && !updateKernelPath + && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle + && (defaultIndex == -1)) { fprintf(stderr, _("grubby: no action specified ")); return 1; } @@ -4044,7 +4061,7 @@ int main(int argc, const char ** argv) { markRemovedImage(config, removeKernelPath, bootPrefix); markRemovedImage(config, removeMBKernel, bootPrefix); setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, - bootPrefix, flags); + bootPrefix, flags, defaultIndex); setFallbackImage(config, newKernelPath != NULL); if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; -- 1.7.6.5 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Add --set-default-index feature
On 03/20/2012 02:55 PM, Cleber Rosa wrote:
> This pairs with --default-index, allowing the user to specify the > entry to make the default using and index rather than a kernel. > > Signed-off-by: Cleber Rosa <crosa@redhat.com> This needs test cases as well. > --- > grubby.8 | 11 ++++++++--- > grubby.c | 29 +++++++++++++++++++++++------ > 2 files changed, 31 insertions(+), 9 deletions(-) > > diff --git a/grubby.8 b/grubby.8 > index fe60892..43c141d 100644 > --- a/grubby.8 > +++ b/grubby.8 > @@ -11,9 +11,10 @@ grubby - command line tool for configuring grub, lilo, and elilo > [--info=fIkernel-pathfR] [--initrd=fIinitrd-pathfR] > [--make-default] [-o path] [--version] > [--remove-kernel=fIkernel-pathfR] [--remove-args=fIargsfR] > - [--set-default=fIkernel-pathfR] [--title=entry-title] > - [--add-multiboot=fImultiboot-pathfR] [--mbargs=fIargsfR] > - [--remove-multiboot=fImultiboot-pathfR] [--remove-mbargs=fIargsfR] > + [--set-default=fIkernel-pathfR] [--set-default-index=fientry-indexfR] > + [--title=entry-title] [--add-multiboot=fImultiboot-pathfR] > + [--mbargs=fIargsfR] [--remove-multiboot=fImultiboot-pathfR] > + [--remove-mbargs=fIargsfR] > > .SH DESCRIPTION > fBgrubbyfR is a command line tool for updating and displaying information > @@ -154,6 +155,10 @@ The first entry which boots the specified kernel is made the default > boot entry. > > .TP > +fB--set-default-indexfR=fIentry-indexfR > +Makes the given entry number the default boot entry. > + > +.TP > fB--titlefR=fIentry-titlefR > When a new kernel entry is added fIentry-titlefR is used as the title > (fBlilofR label) for the entry. If fIentry-titlefR is longer then maximum > diff --git a/grubby.c b/grubby.c > index ccb11b0..b8380bf 100644 > --- a/grubby.c > +++ b/grubby.c > @@ -1774,13 +1774,19 @@ void markRemovedImage(struct grubConfig * cfg, const char * image, > > void setDefaultImage(struct grubConfig * config, int hasNew, > const char * defaultKernelPath, int newIsDefault, > - const char * prefix, int flags) { > + const char * prefix, int flags, int index) { > struct singleEntry * entry, * entry2, * newDefault; > int i, j; > > if (newIsDefault) { > config->defaultImage = 0; > return; > + } else if ((index >= 0) && config->cfi->defaultIsIndex) { > + if (findEntryByIndex(config, index)) > + config->defaultImage = index; > + else > + config->defaultImage = -1; > + return; > } else if (defaultKernelPath) { > i = 0; > if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { > @@ -3653,6 +3659,7 @@ int main(int argc, const char ** argv) { > int displayDefault = 0; > int displayDefaultIndex = 0; > int displayDefaultTitle = 0; > + int defaultIndex = -1; > struct poptOption options[] = { > { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, > _("add an entry for the specified kernel"), _("kernel-path") }, > @@ -3725,6 +3732,9 @@ int main(int argc, const char ** argv) { > { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, > _("make the first entry referencing the specified kernel " > "the default"), _("kernel-path") }, > + { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0, > + _("make the given entry index the default entry"), > + _("entry-index") }, > { "silo", 0, POPT_ARG_NONE, &configureSilo, 0, > _("configure silo bootloader") }, > { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, > @@ -3833,8 +3843,9 @@ int main(int argc, const char ** argv) { > } > > if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || > - newKernelPath || removeKernelPath || makeDefault || > - defaultKernel || displayDefaultIndex || displayDefaultTitle)) { > + newKernelPath || removeKernelPath || makeDefault || > + defaultKernel || displayDefaultIndex || displayDefaultTitle || > + (defaultIndex >= 0))) { > fprintf(stderr, _("grubby: --bootloader-probe may not be used with " > "specified option")); > return 1; > @@ -3876,6 +3887,11 @@ int main(int argc, const char ** argv) { > makeDefault = 1; > defaultKernel = NULL; > } > + else if (defaultKernel && (defaultIndex >= 0)) { > + fprintf(stderr, _("grubby: --set-default and --set-default-index " > + "may not be used together ")); > + return 1; > + } > > if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { > fprintf(stderr, _("grubby: output file must be specified if stdin " > @@ -3884,8 +3900,9 @@ int main(int argc, const char ** argv) { > } > > if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel > - && !kernelInfo && !bootloaderProbe && !updateKernelPath > - && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) { > + && !kernelInfo && !bootloaderProbe && !updateKernelPath > + && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle > + && (defaultIndex == -1)) { > fprintf(stderr, _("grubby: no action specified ")); > return 1; > } > @@ -4044,7 +4061,7 @@ int main(int argc, const char ** argv) { > markRemovedImage(config, removeKernelPath, bootPrefix); > markRemovedImage(config, removeMBKernel, bootPrefix); > setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, > - bootPrefix, flags); > + bootPrefix, flags, defaultIndex); > setFallbackImage(config, newKernelPath != NULL); > if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, > removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; -- Peter I number the Linux folks among my personal heroes. -- Donald Knuth 01234567890123456789012345678901234567890123456789 012345678901234567890123456789 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Add --set-default-index feature
On 03/20/2012 05:18 PM, Peter Jones wrote:
On 03/20/2012 02:55 PM, Cleber Rosa wrote: This pairs with --default-index, allowing the user to specify the entry to make the default using and index rather than a kernel. Signed-off-by: Cleber Rosa<crosa@redhat.com> This needs test cases as well. Sure! --- grubby.8 | 11 ++++++++--- grubby.c | 29 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/grubby.8 b/grubby.8 index fe60892..43c141d 100644 --- a/grubby.8 +++ b/grubby.8 @@ -11,9 +11,10 @@ grubby - command line tool for configuring grub, lilo, and elilo [--info=fIkernel-pathfR] [--initrd=fIinitrd-pathfR] [--make-default] [-o path] [--version] [--remove-kernel=fIkernel-pathfR] [--remove-args=fIargsfR] - [--set-default=fIkernel-pathfR] [--title=entry-title] - [--add-multiboot=fImultiboot-pathfR] [--mbargs=fIargsfR] - [--remove-multiboot=fImultiboot-pathfR] [--remove-mbargs=fIargsfR] + [--set-default=fIkernel-pathfR] [--set-default-index=fientry-indexfR] + [--title=entry-title] [--add-multiboot=fImultiboot-pathfR] + [--mbargs=fIargsfR] [--remove-multiboot=fImultiboot-pathfR] + [--remove-mbargs=fIargsfR] .SH DESCRIPTION fBgrubbyfR is a command line tool for updating and displaying information @@ -154,6 +155,10 @@ The first entry which boots the specified kernel is made the default boot entry. .TP +fB--set-default-indexfR=fIentry-indexfR +Makes the given entry number the default boot entry. + +.TP fB--titlefR=fIentry-titlefR When a new kernel entry is added fIentry-titlefR is used as the title (fBlilofR label) for the entry. If fIentry-titlefR is longer then maximum diff --git a/grubby.c b/grubby.c index ccb11b0..b8380bf 100644 --- a/grubby.c +++ b/grubby.c @@ -1774,13 +1774,19 @@ void markRemovedImage(struct grubConfig * cfg, const char * image, void setDefaultImage(struct grubConfig * config, int hasNew, const char * defaultKernelPath, int newIsDefault, - const char * prefix, int flags) { + const char * prefix, int flags, int index) { struct singleEntry * entry, * entry2, * newDefault; int i, j; if (newIsDefault) { config->defaultImage = 0; return; + } else if ((index>= 0)&& config->cfi->defaultIsIndex) { + if (findEntryByIndex(config, index)) + config->defaultImage = index; + else + config->defaultImage = -1; + return; ^ BTW, I followed the same logic employed when setting the default entry based on a kernel path that can not be found, that is, set defaultImage to -1 and return immediately. This effectively means that a previously set default will be removed. If you have any comments on this, please let me know. } else if (defaultKernelPath) { i = 0; if (findEntryByPath(config, defaultKernelPath, prefix,&i)) { @@ -3653,6 +3659,7 @@ int main(int argc, const char ** argv) { int displayDefault = 0; int displayDefaultIndex = 0; int displayDefaultTitle = 0; + int defaultIndex = -1; struct poptOption options[] = { { "add-kernel", 0, POPT_ARG_STRING,&newKernelPath, 0, _("add an entry for the specified kernel"), _("kernel-path") }, @@ -3725,6 +3732,9 @@ int main(int argc, const char ** argv) { { "set-default", 0, POPT_ARG_STRING,&defaultKernel, 0, _("make the first entry referencing the specified kernel " "the default"), _("kernel-path") }, + { "set-default-index", 0, POPT_ARG_INT,&defaultIndex, 0, + _("make the given entry index the default entry"), + _("entry-index") }, { "silo", 0, POPT_ARG_NONE,&configureSilo, 0, _("configure silo bootloader") }, { "title", 0, POPT_ARG_STRING,&newKernelTitle, 0, @@ -3833,8 +3843,9 @@ int main(int argc, const char ** argv) { } if (bootloaderProbe&& (displayDefault || kernelInfo || newKernelVersion || - newKernelPath || removeKernelPath || makeDefault || - defaultKernel || displayDefaultIndex || displayDefaultTitle)) { + newKernelPath || removeKernelPath || makeDefault || + defaultKernel || displayDefaultIndex || displayDefaultTitle || + (defaultIndex>= 0))) { fprintf(stderr, _("grubby: --bootloader-probe may not be used with " "specified option")); return 1; @@ -3876,6 +3887,11 @@ int main(int argc, const char ** argv) { makeDefault = 1; defaultKernel = NULL; } + else if (defaultKernel&& (defaultIndex>= 0)) { + fprintf(stderr, _("grubby: --set-default and --set-default-index " + "may not be used together ")); + return 1; + } if (grubConfig&& !strcmp(grubConfig, "-")&& !outputFile) { fprintf(stderr, _("grubby: output file must be specified if stdin " @@ -3884,8 +3900,9 @@ int main(int argc, const char ** argv) { } if (!removeKernelPath&& !newKernelPath&& !displayDefault&& !defaultKernel - && !kernelInfo&& !bootloaderProbe&& !updateKernelPath -&& !removeMBKernel&& !displayDefaultIndex&& !displayDefaultTitle) { + && !kernelInfo&& !bootloaderProbe&& !updateKernelPath + && !removeMBKernel&& !displayDefaultIndex&& !displayDefaultTitle + && (defaultIndex == -1)) { fprintf(stderr, _("grubby: no action specified ")); return 1; } @@ -4044,7 +4061,7 @@ int main(int argc, const char ** argv) { markRemovedImage(config, removeKernelPath, bootPrefix); markRemovedImage(config, removeMBKernel, bootPrefix); setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, - bootPrefix, flags); + bootPrefix, flags, defaultIndex); setFallbackImage(config, newKernelPath != NULL); if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Add --set-default-index feature
This pairs with --default-index, allowing the user to specify the
entry to make the default using and index rather than a kernel. Signed-off-by: Cleber Rosa <crosa@redhat.com> --- grubby.8 | 11 ++++++++--- grubby.c | 29 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/grubby.8 b/grubby.8 index fe60892..43c141d 100644 --- a/grubby.8 +++ b/grubby.8 @@ -11,9 +11,10 @@ grubby - command line tool for configuring grub, lilo, and elilo [--info=fIkernel-pathfR] [--initrd=fIinitrd-pathfR] [--make-default] [-o path] [--version] [--remove-kernel=fIkernel-pathfR] [--remove-args=fIargsfR] - [--set-default=fIkernel-pathfR] [--title=entry-title] - [--add-multiboot=fImultiboot-pathfR] [--mbargs=fIargsfR] - [--remove-multiboot=fImultiboot-pathfR] [--remove-mbargs=fIargsfR] + [--set-default=fIkernel-pathfR] [--set-default-index=fientry-indexfR] + [--title=entry-title] [--add-multiboot=fImultiboot-pathfR] + [--mbargs=fIargsfR] [--remove-multiboot=fImultiboot-pathfR] + [--remove-mbargs=fIargsfR] .SH DESCRIPTION fBgrubbyfR is a command line tool for updating and displaying information @@ -154,6 +155,10 @@ The first entry which boots the specified kernel is made the default boot entry. .TP +fB--set-default-indexfR=fIentry-indexfR +Makes the given entry number the default boot entry. + +.TP fB--titlefR=fIentry-titlefR When a new kernel entry is added fIentry-titlefR is used as the title (fBlilofR label) for the entry. If fIentry-titlefR is longer then maximum diff --git a/grubby.c b/grubby.c index 5992e67..c14d3b0 100644 --- a/grubby.c +++ b/grubby.c @@ -1877,13 +1877,19 @@ void markRemovedImage(struct grubConfig * cfg, const char * image, void setDefaultImage(struct grubConfig * config, int hasNew, const char * defaultKernelPath, int newIsDefault, - const char * prefix, int flags) { + const char * prefix, int flags, int index) { struct singleEntry * entry, * entry2, * newDefault; int i, j; if (newIsDefault) { config->defaultImage = 0; return; + } else if ((index >= 0) && config->cfi->defaultIsIndex) { + if (findEntryByIndex(config, index)) + config->defaultImage = index; + else + config->defaultImage = -1; + return; } else if (defaultKernelPath) { i = 0; if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { @@ -3749,6 +3755,7 @@ int main(int argc, const char ** argv) { int displayDefault = 0; int displayDefaultIndex = 0; int displayDefaultTitle = 0; + int defaultIndex = -1; struct poptOption options[] = { { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, _("add an entry for the specified kernel"), _("kernel-path") }, @@ -3821,6 +3828,9 @@ int main(int argc, const char ** argv) { { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, _("make the first entry referencing the specified kernel " "the default"), _("kernel-path") }, + { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0, + _("make the given entry index the default entry"), + _("entry-index") }, { "silo", 0, POPT_ARG_NONE, &configureSilo, 0, _("configure silo bootloader") }, { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, @@ -3929,8 +3939,9 @@ int main(int argc, const char ** argv) { } if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || - newKernelPath || removeKernelPath || makeDefault || - defaultKernel || displayDefaultIndex || displayDefaultTitle)) { + newKernelPath || removeKernelPath || makeDefault || + defaultKernel || displayDefaultIndex || displayDefaultTitle || + (defaultIndex >= 0))) { fprintf(stderr, _("grubby: --bootloader-probe may not be used with " "specified option")); return 1; @@ -3972,6 +3983,11 @@ int main(int argc, const char ** argv) { makeDefault = 1; defaultKernel = NULL; } + else if (defaultKernel && (defaultIndex >= 0)) { + fprintf(stderr, _("grubby: --set-default and --set-default-index " + "may not be used together ")); + return 1; + } if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { fprintf(stderr, _("grubby: output file must be specified if stdin " @@ -3980,8 +3996,9 @@ int main(int argc, const char ** argv) { } if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel - && !kernelInfo && !bootloaderProbe && !updateKernelPath - && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) { + && !kernelInfo && !bootloaderProbe && !updateKernelPath + && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle + && (defaultIndex == -1)) { fprintf(stderr, _("grubby: no action specified ")); return 1; } @@ -4140,7 +4157,7 @@ int main(int argc, const char ** argv) { markRemovedImage(config, removeKernelPath, bootPrefix); markRemovedImage(config, removeMBKernel, bootPrefix); setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, - bootPrefix, flags); + bootPrefix, flags, defaultIndex); setFallbackImage(config, newKernelPath != NULL); if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; -- 1.7.6.5 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
| All times are GMT. The time now is 07:38 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.