205 |
{ "default", LT_DEFAULT, ' ' }, |
{ "default", LT_DEFAULT, ' ' }, |
206 |
{ "fallback", LT_FALLBACK, ' ' }, |
{ "fallback", LT_FALLBACK, ' ' }, |
207 |
{ "linux", LT_KERNEL, ' ' }, |
{ "linux", LT_KERNEL, ' ' }, |
208 |
|
{ "linuxefi", LT_KERNEL, ' ' }, |
209 |
{ "initrd", LT_INITRD, ' ', ' ' }, |
{ "initrd", LT_INITRD, ' ', ' ' }, |
210 |
|
{ "initrdefi", LT_INITRD, ' ', ' ' }, |
211 |
{ "module", LT_MBMODULE, ' ' }, |
{ "module", LT_MBMODULE, ' ' }, |
212 |
{ "kernel", LT_HYPER, ' ' }, |
{ "kernel", LT_HYPER, ' ' }, |
213 |
{ NULL, 0, 0 }, |
{ NULL, 0, 0 }, |
1312 |
|
|
1313 |
/* most likely the symlink is relative, so change our |
/* most likely the symlink is relative, so change our |
1314 |
directory to the dir of the symlink */ |
directory to the dir of the symlink */ |
1315 |
rc = chdir(dirname(outName)); |
char *dir = strdupa(outName); |
1316 |
|
rc = chdir(dirname(dir)); |
1317 |
|
free(dir); |
1318 |
do { |
do { |
1319 |
buf = alloca(len + 1); |
buf = alloca(len + 1); |
1320 |
rc = readlink(basename(outName), buf, len); |
rc = readlink(basename(outName), buf, len); |
1871 |
|
|
1872 |
void setDefaultImage(struct grubConfig * config, int hasNew, |
void setDefaultImage(struct grubConfig * config, int hasNew, |
1873 |
const char * defaultKernelPath, int newIsDefault, |
const char * defaultKernelPath, int newIsDefault, |
1874 |
const char * prefix, int flags) { |
const char * prefix, int flags, int index) { |
1875 |
struct singleEntry * entry, * entry2, * newDefault; |
struct singleEntry * entry, * entry2, * newDefault; |
1876 |
int i, j; |
int i, j; |
1877 |
|
|
1878 |
if (newIsDefault) { |
if (newIsDefault) { |
1879 |
config->defaultImage = 0; |
config->defaultImage = 0; |
1880 |
return; |
return; |
1881 |
|
} else if ((index >= 0) && config->cfi->defaultIsIndex) { |
1882 |
|
if (findEntryByIndex(config, index)) |
1883 |
|
config->defaultImage = index; |
1884 |
|
else |
1885 |
|
config->defaultImage = -1; |
1886 |
|
return; |
1887 |
} else if (defaultKernelPath) { |
} else if (defaultKernelPath) { |
1888 |
i = 0; |
i = 0; |
1889 |
if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { |
if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { |
3273 |
return 1; |
return 1; |
3274 |
} |
} |
3275 |
|
|
3276 |
|
int checkForElilo(struct grubConfig * config) { |
3277 |
|
if (!access("/etc/elilo.conf", R_OK)) |
3278 |
|
return 2; |
3279 |
|
|
3280 |
|
return 1; |
3281 |
|
} |
3282 |
|
|
3283 |
static char * getRootSpecifier(char * str) { |
static char * getRootSpecifier(char * str) { |
3284 |
char * idx, * rootspec = NULL; |
char * idx, * rootspec = NULL; |
3285 |
|
|
3750 |
int displayDefault = 0; |
int displayDefault = 0; |
3751 |
int displayDefaultIndex = 0; |
int displayDefaultIndex = 0; |
3752 |
int displayDefaultTitle = 0; |
int displayDefaultTitle = 0; |
3753 |
|
int defaultIndex = -1; |
3754 |
struct poptOption options[] = { |
struct poptOption options[] = { |
3755 |
{ "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, |
{ "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, |
3756 |
_("add an entry for the specified kernel"), _("kernel-path") }, |
_("add an entry for the specified kernel"), _("kernel-path") }, |
3768 |
{ "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0, |
{ "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0, |
3769 |
_("filestystem which contains /boot directory (for testing only)"), |
_("filestystem which contains /boot directory (for testing only)"), |
3770 |
_("bootfs") }, |
_("bootfs") }, |
3771 |
#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) |
#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) || defined (__ia64__) |
3772 |
{ "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0, |
{ "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0, |
3773 |
_("check which bootloader is installed on boot sector") }, |
_("check which bootloader is installed on boot sector") }, |
3774 |
#endif |
#endif |
3823 |
{ "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, |
{ "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, |
3824 |
_("make the first entry referencing the specified kernel " |
_("make the first entry referencing the specified kernel " |
3825 |
"the default"), _("kernel-path") }, |
"the default"), _("kernel-path") }, |
3826 |
|
{ "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0, |
3827 |
|
_("make the given entry index the default entry"), |
3828 |
|
_("entry-index") }, |
3829 |
{ "silo", 0, POPT_ARG_NONE, &configureSilo, 0, |
{ "silo", 0, POPT_ARG_NONE, &configureSilo, 0, |
3830 |
_("configure silo bootloader") }, |
_("configure silo bootloader") }, |
3831 |
{ "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, |
{ "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, |
3934 |
} |
} |
3935 |
|
|
3936 |
if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || |
if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion || |
3937 |
newKernelPath || removeKernelPath || makeDefault || |
newKernelPath || removeKernelPath || makeDefault || |
3938 |
defaultKernel || displayDefaultIndex || displayDefaultTitle)) { |
defaultKernel || displayDefaultIndex || displayDefaultTitle || |
3939 |
|
(defaultIndex >= 0))) { |
3940 |
fprintf(stderr, _("grubby: --bootloader-probe may not be used with " |
fprintf(stderr, _("grubby: --bootloader-probe may not be used with " |
3941 |
"specified option")); |
"specified option")); |
3942 |
return 1; |
return 1; |
3978 |
makeDefault = 1; |
makeDefault = 1; |
3979 |
defaultKernel = NULL; |
defaultKernel = NULL; |
3980 |
} |
} |
3981 |
|
else if (defaultKernel && (defaultIndex >= 0)) { |
3982 |
|
fprintf(stderr, _("grubby: --set-default and --set-default-index " |
3983 |
|
"may not be used together\n")); |
3984 |
|
return 1; |
3985 |
|
} |
3986 |
|
|
3987 |
if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { |
if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { |
3988 |
fprintf(stderr, _("grubby: output file must be specified if stdin " |
fprintf(stderr, _("grubby: output file must be specified if stdin " |
3991 |
} |
} |
3992 |
|
|
3993 |
if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel |
if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel |
3994 |
&& !kernelInfo && !bootloaderProbe && !updateKernelPath |
&& !kernelInfo && !bootloaderProbe && !updateKernelPath |
3995 |
&& !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle) { |
&& !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle |
3996 |
|
&& (defaultIndex == -1)) { |
3997 |
fprintf(stderr, _("grubby: no action specified\n")); |
fprintf(stderr, _("grubby: no action specified\n")); |
3998 |
return 1; |
return 1; |
3999 |
} |
} |
4020 |
} |
} |
4021 |
|
|
4022 |
if (bootloaderProbe) { |
if (bootloaderProbe) { |
4023 |
int lrc = 0, grc = 0, gr2c = 0, erc = 0, yrc = 0; |
int lrc = 0, grc = 0, gr2c = 0, extrc = 0, yrc = 0, erc = 0; |
4024 |
struct grubConfig * lconfig, * gconfig, * yconfig; |
struct grubConfig * lconfig, * gconfig, * yconfig, * econfig; |
4025 |
|
|
4026 |
const char *grub2config = grub2FindConfig(&grub2ConfigType); |
const char *grub2config = grub2FindConfig(&grub2ConfigType); |
4027 |
if (grub2config) { |
if (grub2config) { |
4049 |
lrc = checkForLilo(lconfig); |
lrc = checkForLilo(lconfig); |
4050 |
} |
} |
4051 |
|
|
4052 |
|
if (!access(eliloConfigType.defaultConfig, F_OK)) { |
4053 |
|
econfig = readConfig(eliloConfigType.defaultConfig, |
4054 |
|
&eliloConfigType); |
4055 |
|
if (!econfig) |
4056 |
|
erc = 1; |
4057 |
|
else |
4058 |
|
erc = checkForElilo(econfig); |
4059 |
|
} |
4060 |
|
|
4061 |
if (!access(extlinuxConfigType.defaultConfig, F_OK)) { |
if (!access(extlinuxConfigType.defaultConfig, F_OK)) { |
4062 |
lconfig = readConfig(extlinuxConfigType.defaultConfig, &extlinuxConfigType); |
lconfig = readConfig(extlinuxConfigType.defaultConfig, &extlinuxConfigType); |
4063 |
if (!lconfig) |
if (!lconfig) |
4064 |
erc = 1; |
extrc = 1; |
4065 |
else |
else |
4066 |
erc = checkForExtLinux(lconfig); |
extrc = checkForExtLinux(lconfig); |
4067 |
} |
} |
4068 |
|
|
4069 |
|
|
4073 |
if (!yconfig) |
if (!yconfig) |
4074 |
yrc = 1; |
yrc = 1; |
4075 |
else |
else |
4076 |
yrc = checkForYaboot(lconfig); |
yrc = checkForYaboot(yconfig); |
4077 |
} |
} |
4078 |
|
|
4079 |
if (lrc == 1 || grc == 1 || gr2c == 1 || yrc == 1) return 1; |
if (lrc == 1 || grc == 1 || gr2c == 1 || extrc == 1 || yrc == 1 || |
4080 |
|
erc == 1) |
4081 |
|
return 1; |
4082 |
|
|
4083 |
if (lrc == 2) printf("lilo\n"); |
if (lrc == 2) printf("lilo\n"); |
4084 |
if (gr2c == 2) printf("grub2\n"); |
if (gr2c == 2) printf("grub2\n"); |
4085 |
if (grc == 2) printf("grub\n"); |
if (grc == 2) printf("grub\n"); |
4086 |
if (erc == 2) printf("extlinux\n"); |
if (extrc == 2) printf("extlinux\n"); |
4087 |
if (yrc == 2) printf("yaboot\n"); |
if (yrc == 2) printf("yaboot\n"); |
4088 |
|
if (erc == 2) printf("elilo\n"); |
4089 |
|
|
4090 |
return 0; |
return 0; |
4091 |
} |
} |
4152 |
markRemovedImage(config, removeKernelPath, bootPrefix); |
markRemovedImage(config, removeKernelPath, bootPrefix); |
4153 |
markRemovedImage(config, removeMBKernel, bootPrefix); |
markRemovedImage(config, removeMBKernel, bootPrefix); |
4154 |
setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, |
setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, |
4155 |
bootPrefix, flags); |
bootPrefix, flags, defaultIndex); |
4156 |
setFallbackImage(config, newKernelPath != NULL); |
setFallbackImage(config, newKernelPath != NULL); |
4157 |
if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, |
if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, |
4158 |
removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; |
removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; |