diff options
Diffstat (limited to 'loader')
-rw-r--r-- | loader/Makefile.am | 4 | ||||
-rw-r--r-- | loader/driverdisk.c | 53 | ||||
-rw-r--r-- | loader/hardware.c | 17 | ||||
-rw-r--r-- | loader/hdinstall.c | 36 | ||||
-rw-r--r-- | loader/kickstart.c | 53 | ||||
-rw-r--r-- | loader/loader.c | 59 | ||||
-rw-r--r-- | loader/modules.c | 33 | ||||
-rw-r--r-- | loader/net.c | 96 | ||||
-rw-r--r-- | loader/nfsinstall.c | 32 | ||||
-rw-r--r-- | loader/urlinstall.c | 36 |
10 files changed, 225 insertions, 194 deletions
diff --git a/loader/Makefile.am b/loader/Makefile.am index 8d0fdced1..e5d1b7faf 100644 --- a/loader/Makefile.am +++ b/loader/Makefile.am @@ -39,10 +39,10 @@ endif COMMON_CFLAGS = -DUSE_LOGDEV -DVERSION='"$(PACKAGE_VERSION)"' -loader_CFLAGS = $(COMMON_CFLAGS) $(LIBNM_GLIB_CFLAGS) \ +loader_CFLAGS = $(COMMON_CFLAGS) $(GLIB_CFLAGS) $(LIBNM_GLIB_CFLAGS) \ $(LIBCURL_CFLAGS) \ -DINCLUDE_LOCAL -DINCLUDE_NETWORK -loader_LDADD = $(NEWT_LIBS) $(POPT_LIBS) $(LIBNL_LIBS) \ +loader_LDADD = $(NEWT_LIBS) $(GLIB_LIBS) $(LIBNL_LIBS) \ $(LIBNM_GLIB_LIBS) $(CHECKISOMD5_LIBS) \ $(LIBCURL_LIBS) \ $(ISCSI_LIBS) $(top_srcdir)/isys/libisys.la diff --git a/loader/driverdisk.c b/loader/driverdisk.c index e5d8f9022..8c8cc93dc 100644 --- a/loader/driverdisk.c +++ b/loader/driverdisk.c @@ -23,12 +23,12 @@ #include <errno.h> #include <fcntl.h> #include <newt.h> -#include <popt.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> +#include <glib.h> #include "copy.h" #include "loader.h" @@ -554,34 +554,42 @@ static void getDDFromDev(struct loaderData_s * loaderData, char * dev); void useKickstartDD(struct loaderData_s * loaderData, int argc, char ** argv) { - char * fstype = NULL; char * dev = NULL; - char * src = NULL; - char * biospart = NULL, * p = NULL; - int usebiosdev = 0; - - poptContext optCon; - int rc; - struct poptOption ksDDOptions[] = { + gchar *fstype = NULL, *src = NULL; + gint usebiosdev = 0; + gchar **remaining = NULL; + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry ksDDOptions[] = { /* The --type option is deprecated and now has no effect. */ - { "type", '\0', POPT_ARG_STRING, &fstype, 0, NULL, NULL }, - { "source", '\0', POPT_ARG_STRING, &src, 0, NULL, NULL }, - { "biospart", '\0', POPT_ARG_NONE, &usebiosdev, 0, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0 } + { "type", 0, 0, G_OPTION_ARG_STRING, &fstype, NULL, NULL }, + { "source", 0, 0, G_OPTION_ARG_STRING, &src, NULL, NULL }, + { "biospart", 0, 0, G_OPTION_ARG_INT, &usebiosdev, NULL, NULL }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, + NULL, NULL }, + { NULL }, }; - optCon = poptGetContext(NULL, argc, (const char **) argv, ksDDOptions, 0); - if ((rc = poptGetNextOpt(optCon)) < -1) { + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, ksDDOptions, NULL); + + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { newtWinMessage(_("Kickstart Error"), _("OK"), _("The following invalid argument was specified for " - "the kickstart driver disk command: %s:%s"), - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); + "the kickstart driver disk command: %s"), + optErr->message); + g_error_free(optErr); + g_option_context_free(optCon); + g_strfreev(remaining); return; } - dev = (char *) poptGetArg(optCon); + g_option_context_free(optCon); + + if ((remaining != NULL) && (g_strv_length(remaining) == 1)) { + dev = remaining[0]; + } if (!dev && !src) { logMessage(ERROR, "bad arguments to kickstart driver disk command"); @@ -606,10 +614,13 @@ void useKickstartDD(struct loaderData_s * loaderData, } if (dev) { - return getDDFromDev(loaderData, dev); + getDDFromDev(loaderData, dev); } else { - return getDDFromSource(loaderData, src); + getDDFromSource(loaderData, src); } + + g_strfreev(remaining); + return; } static void getDDFromDev(struct loaderData_s * loaderData, char * dev) { diff --git a/loader/hardware.c b/loader/hardware.c index e9be27933..1f329055d 100644 --- a/loader/hardware.c +++ b/loader/hardware.c @@ -25,13 +25,13 @@ #include <errno.h> #include <fcntl.h> -#include <popt.h> #include <string.h> #include <strings.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <sys/wait.h> +#include <glib.h> #include "loader.h" #include "hardware.h" @@ -115,8 +115,9 @@ static int detectHardware() { int earlyModuleLoad(int justProbe) { int fd, len, i; char buf[1024], *cmdLine; - int argc; - char ** argv; + gint argc = 0; + gchar **argv = NULL; + GError *optErr = NULL; /* FIXME: reparsing /proc/cmdline to avoid major loader changes. * should probably be done in loader.c:parseCmdline() like everything @@ -126,13 +127,15 @@ int earlyModuleLoad(int justProbe) { len = read(fd, buf, sizeof(buf) - 1); close(fd); if (len <= 0) return 1; - + buf[len] = '\0'; cmdLine = buf; - - if (poptParseArgvString(cmdLine, &argc, (const char ***) &argv)) + + if (!g_shell_parse_argv(cmdLine, &argc, &argv, &optErr)) { + g_error_free(optErr); return 1; - + } + for (i=0; i < argc; i++) { if (!strncasecmp(argv[i], "driverload=", 11)) { logMessage(INFO, "loading %s early", argv[i] + 11); diff --git a/loader/hdinstall.c b/loader/hdinstall.c index a4396df9f..c523f1c5c 100644 --- a/loader/hdinstall.c +++ b/loader/hdinstall.c @@ -27,11 +27,11 @@ #include <errno.h> #include <fcntl.h> #include <newt.h> -#include <popt.h> #include <stdlib.h> #include <string.h> #include <sys/mount.h> #include <unistd.h> +#include <glib.h> #include "driverdisk.h" #include "hdinstall.h" @@ -353,30 +353,34 @@ char * mountHardDrive(struct installMethod * method, void setKickstartHD(struct loaderData_s * loaderData, int argc, char ** argv) { - char *biospart = NULL, *partition = NULL, *dir = NULL, *p; - poptContext optCon; - int rc; - - struct poptOption ksHDOptions[] = { - { "biospart", '\0', POPT_ARG_STRING, &biospart, 0, NULL, NULL }, - { "partition", '\0', POPT_ARG_STRING, &partition, 0, NULL, NULL }, - { "dir", '\0', POPT_ARG_STRING, &dir, 0, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0 } + char *p; + gchar *biospart = NULL, *partition = NULL, *dir = NULL; + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry ksHDOptions[] = { + { "biospart", 0, 0, G_OPTION_ARG_STRING, &biospart, NULL, NULL }, + { "partition", 0, 0, G_OPTION_ARG_STRING, &partition, NULL, NULL }, + { "dir", 0, 0, G_OPTION_ARG_STRING, &dir, NULL, NULL }, + { NULL }, }; - logMessage(INFO, "kickstartFromHD"); - optCon = poptGetContext(NULL, argc, (const char **) argv, ksHDOptions, 0); - if ((rc = poptGetNextOpt(optCon)) < -1) { + + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, ksHDOptions, NULL); + + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { startNewt(); newtWinMessage(_("Kickstart Error"), _("OK"), _("Bad argument to HD kickstart method " - "command %s: %s"), - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); + "command: %s"), optErr->message); + g_error_free(optErr); + g_option_context_free(optCon); return; } + g_option_context_free(optCon); + if (biospart) { char * dev; diff --git a/loader/kickstart.c b/loader/kickstart.c index 764df5d69..494045dd4 100644 --- a/loader/kickstart.c +++ b/loader/kickstart.c @@ -28,11 +28,11 @@ #include <errno.h> #include <fcntl.h> #include <newt.h> -#include <popt.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> +#include <glib.h> #include "loader.h" #include "loadermisc.h" @@ -120,8 +120,9 @@ int ksReadCommands(char * cmdFile) { char * start, * end, * chptr; char oldch; int line = 0; - char ** argv; - int argc; + gint argc = 0; + gchar **argv = NULL; + GError *optErr = NULL; int inSection = 0; /* in a section such as %post, %pre or %packages */ struct ksCommandNames * cmd; int commandsAlloced = 5; @@ -179,11 +180,15 @@ int ksReadCommands(char * cmdFile) { /* JKFIXME: this should be handled better, but at least we * won't segfault now */ } else { - if (poptParseArgvString(start, &argc, - (const char ***) &argv) || !argc) { - newtWinMessage(_("Kickstart Error"), _("OK"), - _("Error in %s on line %d of kickstart file %s."), - argv[0], line, cmdFile); + if (!g_shell_parse_argv(start, &argc, &argv, &optErr) && argc) { + newtWinMessage(_("Kickstart Error"), _("OK"), + _("Error in %s on line %d of kickstart " + "file %s."), argv[0], line, cmdFile); + g_error_free(optErr); + } else if (!argc) { + newtWinMessage(_("Kickstart Error"), _("OK"), + _("Missing options on line %d of kickstart " + "file %s."), line, cmdFile); } else { for (cmd = ksTable; cmd->name; cmd++) if (!strcmp(cmd->name, argv[0])) break; @@ -478,29 +483,31 @@ static void setHalt(struct loaderData_s * loaderData, int argc, static void setShutdown(struct loaderData_s * loaderData, int argc, char ** argv) { - poptContext optCon; - int reboot = 0, halt = 0, poweroff = 0; - int rc; - - struct poptOption ksOptions[] = { - { "eject", 'e', POPT_ARG_NONE, NULL, 0, NULL, NULL }, - { "reboot", 'r', POPT_ARG_NONE, &reboot, 0, NULL, NULL }, - { "halt", 'h', POPT_ARG_NONE, &halt, 0, NULL, NULL }, - { "poweroff", 'p', POPT_ARG_NONE, &poweroff, 0, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0 } + gint eject = 0, reboot = 0, halt = 0, poweroff = 0; + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry ksOptions[] = { + { "eject", 'e', 0, G_OPTION_ARG_INT, &eject, NULL, NULL }, + { "reboot", 'r', 0, G_OPTION_ARG_INT, &reboot, NULL, NULL }, + { "halt", 'h', 0, G_OPTION_ARG_INT, &halt, NULL, NULL }, + { "poweroff", 'p', 0, G_OPTION_ARG_INT, &poweroff, NULL, NULL }, + { NULL }, }; - optCon = poptGetContext(NULL, argc, (const char **) argv, ksOptions, 0); - if ((rc = poptGetNextOpt(optCon)) < -1) { + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, ksOptions, NULL); + + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { startNewt(); newtWinMessage(_("Kickstart Error"), _("OK"), _("Bad argument to shutdown kickstart method " - "command %s: %s"), - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); + "command: %s"), optErr->message); + g_error_free(optErr); + g_option_context_free(optCon); return; } + g_option_context_free(optCon); if (FL_NOKILL(flags)) { flags |= LOADER_FLAGS_HALT; diff --git a/loader/loader.c b/loader/loader.c index 89edee257..12e46c514 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -33,7 +33,6 @@ #include <execinfo.h> #include <fcntl.h> #include <newt.h> -#include <popt.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -56,6 +55,7 @@ #include <linux/vt.h> #include <curl/curl.h> +#include <glib.h> #ifdef USE_MTRACE #include <mcheck.h> @@ -902,8 +902,9 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, int fd; char buf[1024]; int len; - char ** argv; - int argc; + gint argc = 0; + gchar **argv = NULL; + GError *optErr = NULL; int numExtraArgs = 0; int i; char *front, *stage2param = NULL; @@ -928,8 +929,10 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, logMessage(INFO, "kernel command line: %s", cmdLine); - if (poptParseArgvString(cmdLine, &argc, (const char ***) &argv)) + if (!g_shell_parse_argv(cmdLine, &argc, &argv, &optErr)) { + g_error_free(optErr); return; + } for (i=0; i < argc; i++) { if (!strcasecmp(argv[i], "askmethod")) @@ -1823,19 +1826,21 @@ int main(int argc, char ** argv) { struct loaderData_s loaderData; char *path; - char * cmdLine = NULL; - char * ksFile = NULL; - int testing = 0; - int mediacheck = 0; - char * virtpcon = NULL; - poptContext optCon; - struct poptOption optionTable[] = { - { "cmdline", '\0', POPT_ARG_STRING, &cmdLine, 0, NULL, NULL }, - { "ksfile", '\0', POPT_ARG_STRING, &ksFile, 0, NULL, NULL }, - { "test", '\0', POPT_ARG_NONE, &testing, 0, NULL, NULL }, - { "mediacheck", '\0', POPT_ARG_NONE, &mediacheck, 0, NULL, NULL}, - { "virtpconsole", '\0', POPT_ARG_STRING, &virtpcon, 0, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0 } + + gchar *cmdLine = NULL, *ksFile = NULL, *virtpcon = NULL; + gboolean testing = FALSE, mediacheck = FALSE; + gchar **remaining = NULL; + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry optionTable[] = { + { "cmdline", 0, 0, G_OPTION_ARG_STRING, &cmdLine, NULL, NULL }, + { "ksfile", 0, 0, G_OPTION_ARG_STRING, &ksFile, NULL, NULL }, + { "test", 0, 0, G_OPTION_ARG_NONE, &testing, NULL, NULL }, + { "mediacheck", 0, 0, G_OPTION_ARG_NONE, &mediacheck, NULL, NULL }, + { "virtpconsole", 0, 0, G_OPTION_ARG_STRING, &virtpcon, NULL, NULL }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, + NULL, NULL }, + { NULL }, }; /* get init PID if we have it */ @@ -1865,20 +1870,26 @@ int main(int argc, char ** argv) { rc = anaconda_trace_init(); /* now we parse command line options */ - optCon = poptGetContext(NULL, argc, (const char **) argv, optionTable, 0); + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, optionTable, NULL); - if ((rc = poptGetNextOpt(optCon)) < -1) { - fprintf(stderr, "bad option %s: %s\n", - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { + fprintf(stderr, "bad option: %s\n", optErr->message); + g_error_free(optErr); + g_option_context_free(optCon); doExit(1); } - if ((arg = (char *) poptGetArg(optCon))) { - fprintf(stderr, "unexpected argument: %s\n", arg); + g_option_context_free(optCon); + + if (remaining) { + fprintf(stderr, "unexpected argument: %s\n", remaining[0]); + g_strfreev(remaining); doExit(1); } + g_strfreev(remaining); + if (!testing && !access("/var/run/loader.run", R_OK)) { printf(_("loader has already been run. Starting shell.\n")); execl("/bin/sh", "-/bin/sh", NULL); diff --git a/loader/modules.c b/loader/modules.c index a174dc11b..07f781a24 100644 --- a/loader/modules.c +++ b/loader/modules.c @@ -29,7 +29,6 @@ #include <errno.h> #include <fcntl.h> #include <newt.h> -#include <popt.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -363,27 +362,35 @@ void loadKickstartModule(struct loaderData_s * loaderData, int argc, char **argv) { gchar *opts = NULL; gchar *module = NULL; - gchar **args = NULL; - poptContext optCon; + gchar **args = NULL, **remaining = NULL; gboolean rc; - struct poptOption ksDeviceOptions[] = { - { "opts", '\0', POPT_ARG_STRING, &opts, 0, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0 } + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry ksDeviceOptions[] = { + { "opts", 0, 0, G_OPTION_ARG_STRING, &opts, NULL, NULL }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, + NULL, NULL }, + { NULL }, }; - optCon = poptGetContext(NULL, argc, (const char **) argv, - ksDeviceOptions, 0); - if ((rc = poptGetNextOpt(optCon)) < -1) { + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, ksDeviceOptions, NULL); + + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { startNewt(); newtWinMessage(_("Kickstart Error"), _("OK"), _("Bad argument to device kickstart method " - "command %s: %s"), - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); + "command: %s"), optErr->message); + g_error_free(optErr); + g_option_context_free(optCon); return; } - module = (gchar *) poptGetArg(optCon); + g_option_context_free(optCon); + + if ((remaining != NULL) && (g_strv_length(remaining) == 1)) { + module = remaining[0]; + } if (!module) { startNewt(); diff --git a/loader/net.c b/loader/net.c index 9280dc73a..4f49d8f44 100644 --- a/loader/net.c +++ b/loader/net.c @@ -28,7 +28,6 @@ #include <sys/utsname.h> #include <arpa/inet.h> #include <errno.h> -#include <popt.h> #include <resolv.h> #include <net/if.h> #include <newt.h> @@ -1526,72 +1525,53 @@ int writeEnabledNetInfo(iface_t *iface) { void setKickstartNetwork(struct loaderData_s * loaderData, int argc, char ** argv) { - char * arg, * bootProto = NULL, * device = NULL, *ethtool = NULL, * class = NULL; - char * essid = NULL, * wepkey = NULL, * onboot = NULL; - int mtu = 1500, noipv4 = 0, noipv6 = 0, dhcpTimeout = -1, noDns = 0, noksdev = 0; - int rc; - poptContext optCon; iface_t iface; - - struct poptOption ksOptions[] = { - { "bootproto", '\0', POPT_ARG_STRING, &bootProto, 0, NULL, NULL }, - { "device", '\0', POPT_ARG_STRING, &device, 0, NULL, NULL }, - { "dhcpclass", '\0', POPT_ARG_STRING, &class, 0, NULL, NULL }, - { "gateway", '\0', POPT_ARG_STRING, NULL, 'g', NULL, NULL }, - { "ip", '\0', POPT_ARG_STRING, NULL, 'i', NULL, NULL }, - { "mtu", '\0', POPT_ARG_INT, &mtu, 0, NULL, NULL }, - { "nameserver", '\0', POPT_ARG_STRING, NULL, 'n', NULL, NULL }, - { "netmask", '\0', POPT_ARG_STRING, NULL, 'm', NULL, NULL }, - { "noipv4", '\0', POPT_ARG_NONE, &noipv4, 0, NULL, NULL }, - { "noipv6", '\0', POPT_ARG_NONE, &noipv6, 0, NULL, NULL }, - { "nodns", '\0', POPT_ARG_NONE, &noDns, 0, NULL, NULL }, - { "hostname", '\0', POPT_ARG_STRING, NULL, 'h', NULL, NULL}, - { "ethtool", '\0', POPT_ARG_STRING, ðtool, 0, NULL, NULL }, - { "essid", '\0', POPT_ARG_STRING, &essid, 0, NULL, NULL }, - { "wepkey", '\0', POPT_ARG_STRING, &wepkey, 0, NULL, NULL }, - { "onboot", '\0', POPT_ARG_STRING, &onboot, 0, NULL, NULL }, - { "notksdevice", '\0', POPT_ARG_NONE, &noksdev, 0, NULL, NULL }, - { "dhcptimeout", '\0', POPT_ARG_INT, &dhcpTimeout, 0, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0 } + gchar *bootProto = NULL, *device = NULL, *class = NULL, *ethtool = NULL; + gchar *essid = NULL, *wepkey = NULL, *onboot = NULL; + gint mtu = 1500, dhcpTimeout = -1; + gboolean noipv4 = FALSE, noipv6 = FALSE, noDns = FALSE, noksdev = FALSE; + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry ksOptions[] = { + { "bootproto", 0, 0, G_OPTION_ARG_STRING, &bootProto, NULL, NULL }, + { "device", 0, 0, G_OPTION_ARG_STRING, &device, NULL, NULL }, + { "dhcpclass", 0, 0, G_OPTION_ARG_STRING, &class, NULL, NULL }, + { "gateway", 'g', 0, G_OPTION_ARG_STRING, &loaderData->gateway, + NULL, NULL }, + { "ip", 'i', 0, G_OPTION_ARG_STRING, &loaderData->ipv4, NULL, NULL }, + { "mtu", 0, 0, G_OPTION_ARG_INT, &mtu, NULL, NULL }, + { "nameserver", 'n', 0, G_OPTION_ARG_STRING, &loaderData->dns, + NULL, NULL }, + { "netmask", 'm', 0, G_OPTION_ARG_STRING, &loaderData->netmask, + NULL, NULL }, + { "noipv4", 0, 0, G_OPTION_ARG_NONE, &noipv4, NULL, NULL }, + { "noipv6", 0, 0, G_OPTION_ARG_NONE, &noipv6, NULL, NULL }, + { "nodns", 0, 0, G_OPTION_ARG_NONE, &noDns, NULL, NULL }, + { "hostname", 'h', 0, G_OPTION_ARG_STRING, &loaderData->hostname, + NULL, NULL }, + { "ethtool", 0, 0, G_OPTION_ARG_STRING, ðtool, NULL, NULL }, + { "essid", 0, 0, G_OPTION_ARG_STRING, &essid, NULL, NULL }, + { "wepkey", 0, 0, G_OPTION_ARG_STRING, &wepkey, NULL, NULL }, + { "onboot", 0, 0, G_OPTION_ARG_STRING, &onboot, NULL, NULL }, + { "notksdevice", 0, 0, G_OPTION_ARG_NONE, &noksdev, NULL, NULL }, + { "dhcptimeout", 0, 0, G_OPTION_ARG_INT, &dhcpTimeout, NULL, NULL }, + { NULL }, }; iface_init_iface_t(&iface); - optCon = poptGetContext(NULL, argc, (const char **) argv, - ksOptions, 0); - while ((rc = poptGetNextOpt(optCon)) >= 0) { - arg = (char *) poptGetOptArg(optCon); + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, ksOptions, NULL); - switch (rc) { - case 'g': - loaderData->gateway = strdup(arg); - break; - case 'i': - loaderData->ipv4 = strdup(arg); - break; - case 'n': - loaderData->dns = strdup(arg); - break; - case 'm': - loaderData->netmask = strdup(arg); - break; - case 'h': - if (loaderData->hostname) - free(loaderData->hostname); - loaderData->hostname = strdup(arg); - break; - } - } - - if (rc < -1) { + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { newtWinMessage(_("Kickstart Error"), _("OK"), - _("Bad argument to kickstart network command %s: %s"), - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); - } else { - poptFreeContext(optCon); + _("Bad argument to kickstart network command: %s"), + optErr->message); + g_error_free(optErr); } + g_option_context_free(optCon); + /* if they've specified dhcp/bootp use dhcp for the interface */ if (bootProto && (!strncmp(bootProto, "dhcp", 4) || !strncmp(bootProto, "bootp", 4))) { diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c index e405df976..cabad46ba 100644 --- a/loader/nfsinstall.c +++ b/loader/nfsinstall.c @@ -25,7 +25,6 @@ #include <fcntl.h> #include <newt.h> -#include <popt.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -369,29 +368,34 @@ char * mountNfsImage(struct installMethod * method, void setKickstartNfs(struct loaderData_s * loaderData, int argc, char ** argv) { - char * host = NULL, * dir = NULL, * mountOpts = NULL; char *substr = NULL; - poptContext optCon; - int rc; - struct poptOption ksNfsOptions[] = { - { "server", '\0', POPT_ARG_STRING, &host, 0, NULL, NULL }, - { "dir", '\0', POPT_ARG_STRING, &dir, 0, NULL, NULL }, - { "opts", '\0', POPT_ARG_STRING, &mountOpts, 0, NULL, NULL}, - { 0, 0, 0, 0, 0, 0, 0 } + gchar *host = NULL, *dir = NULL, *mountOpts = NULL; + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry ksNfsOptions[] = { + { "server", 0, 0, G_OPTION_ARG_STRING, &host, NULL, NULL }, + { "dir", 0, 0, G_OPTION_ARG_STRING, &dir, NULL, NULL }, + { "opts", 0, 0, G_OPTION_ARG_STRING, &mountOpts, NULL, NULL }, + { NULL }, }; logMessage(INFO, "kickstartFromNfs"); - optCon = poptGetContext(NULL, argc, (const char **) argv, ksNfsOptions, 0); - if ((rc = poptGetNextOpt(optCon)) < -1) { + + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, ksNfsOptions, NULL); + + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { startNewt(); newtWinMessage(_("Kickstart Error"), _("OK"), _("Bad argument to NFS kickstart method " - "command %s: %s"), - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); + "command: %s"), optErr->message); + g_error_free(optErr); + g_option_context_free(optCon); return; } + g_option_context_free(optCon); + if (!host || !dir) { logMessage(ERROR, "host and directory for nfs kickstart not specified"); return; diff --git a/loader/urlinstall.c b/loader/urlinstall.c index b03efce7a..8279ec9f6 100644 --- a/loader/urlinstall.c +++ b/loader/urlinstall.c @@ -24,12 +24,12 @@ */ #include <newt.h> -#include <popt.h> #include <stdlib.h> #include <string.h> #include <sys/mount.h> #include <unistd.h> #include <errno.h> +#include <glib.h> #include "../isys/iface.h" @@ -382,29 +382,33 @@ int kickstartFromUrl(char * url, struct loaderData_s * loaderData) { void setKickstartUrl(struct loaderData_s * loaderData, int argc, char ** argv) { - - char *url = NULL, *substr = NULL; - char *proxy = NULL; - poptContext optCon; - int rc; - struct poptOption ksUrlOptions[] = { - { "url", '\0', POPT_ARG_STRING, &url, 0, NULL, NULL }, - { "proxy", '\0', POPT_ARG_STRING, &proxy, 0, NULL, NULL }, - { 0, 0, 0, 0, 0, 0, 0 } + char *substr = NULL; + gchar *url = NULL, *proxy = NULL; + GOptionContext *optCon = g_option_context_new(NULL); + GError *optErr = NULL; + GOptionEntry ksUrlOptions[] = { + { "url", 0, 0, G_OPTION_ARG_STRING, &url, NULL, NULL }, + { "proxy", 0, 0, G_OPTION_ARG_STRING, &proxy, NULL, NULL }, + { NULL }, }; logMessage(INFO, "kickstartFromUrl"); - optCon = poptGetContext(NULL, argc, (const char **) argv, ksUrlOptions, 0); - if ((rc = poptGetNextOpt(optCon)) < -1) { + + g_option_context_set_help_enabled(optCon, FALSE); + g_option_context_add_main_entries(optCon, ksUrlOptions, NULL); + + if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) { startNewt(); newtWinMessage(_("Kickstart Error"), _("OK"), - _("Bad argument to Url kickstart method " - "command %s: %s"), - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(rc)); + _("Bad argument to URL kickstart method " + "command: %s"), optErr->message); + g_error_free(optErr); + g_option_context_free(optCon); return; } + g_option_context_free(optCon); + if (!url) { newtWinMessage(_("Kickstart Error"), _("OK"), _("Must supply a --url argument to Url kickstart method.")); |