]> git.ozlabs.org Git - petitboot/commitdiff
Move --dry-run option to discover server
authorJeremy Kerr <jk@ozlabs.org>
Thu, 7 Mar 2013 02:22:42 +0000 (10:22 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 15 Apr 2013 07:42:27 +0000 (15:42 +0800)
Now that the server does the booting, we should move the --dry-run
argument to the server.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/device-handler.c
discover/device-handler.h
discover/pb-discover.c
ui/ncurses/generic-main.c
ui/ncurses/nc-cui.c
ui/ncurses/nc-cui.h
ui/twin/main-generic.c
ui/twin/pbt-client.c
ui/twin/pbt-client.h
ui/twin/pbt-main.c
ui/twin/pbt-main.h

index 6a27f15780a5a4ae290e2ddf6d1b95f789dadb02..12bd5aed63a20ee56b45cd12e19f7d98a12c1901 100644 (file)
@@ -23,6 +23,7 @@
 
 struct device_handler {
        struct discover_server *server;
 
 struct device_handler {
        struct discover_server *server;
+       int dry_run;
 
        struct device **devices;
        unsigned int n_devices;
 
        struct device **devices;
        unsigned int n_devices;
@@ -407,7 +408,8 @@ int device_handler_event(struct device_handler *handler,
        return handlers[event->type][event->action](handler, event);
 }
 
        return handlers[event->type][event->action](handler, event);
 }
 
-struct device_handler *device_handler_init(struct discover_server *server)
+struct device_handler *device_handler_init(struct discover_server *server,
+               int dry_run)
 {
        struct device_handler *handler;
 
 {
        struct device_handler *handler;
 
@@ -415,6 +417,7 @@ struct device_handler *device_handler_init(struct discover_server *server)
        handler->devices = NULL;
        handler->n_devices = 0;
        handler->server = server;
        handler->devices = NULL;
        handler->n_devices = 0;
        handler->server = server;
+       handler->dry_run = dry_run;
 
        list_init(&handler->contexts);
 
 
        list_init(&handler->contexts);
 
@@ -455,5 +458,5 @@ void device_handler_boot(struct device_handler *handler,
 
        opt = find_boot_option_by_id(handler, cmd->option_id);
 
 
        opt = find_boot_option_by_id(handler, cmd->option_id);
 
-       boot(handler, opt, cmd, 0);
+       boot(handler, opt, cmd, handler->dry_run);
 }
 }
index 7207f8d94104e2b93b385cbef196ecf9320d539c..4cf7d7dadb5bd8256a7284a464a89fc51104fb64 100644 (file)
@@ -21,7 +21,8 @@ struct discover_context {
        struct list_item list;
 };
 
        struct list_item list;
 };
 
-struct device_handler *device_handler_init(struct discover_server *server);
+struct device_handler *device_handler_init(struct discover_server *server,
+               int dry_run);
 
 void device_handler_destroy(struct device_handler *devices);
 
 
 void device_handler_destroy(struct device_handler *devices);
 
index 536f6e65a7b34a88a916417f553eb7414a5773f3..c83b5747ee0ded939f69df4bbe5976fe51f9be20 100644 (file)
@@ -43,6 +43,7 @@ struct opts {
        enum opt_value show_help;
        const char *log_file;
        enum opt_value show_version;
        enum opt_value show_help;
        const char *log_file;
        enum opt_value show_version;
+       enum opt_value dry_run;
 };
 
 /**
 };
 
 /**
@@ -54,12 +55,14 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
        static const struct option long_options[] = {
                {"help",           no_argument,       NULL, 'h'},
                {"log",            required_argument, NULL, 'l'},
        static const struct option long_options[] = {
                {"help",           no_argument,       NULL, 'h'},
                {"log",            required_argument, NULL, 'l'},
+               {"dry-run",        no_argument,       NULL, 'n'},
                {"version",        no_argument,       NULL, 'V'},
                { NULL, 0, NULL, 0},
        };
                {"version",        no_argument,       NULL, 'V'},
                { NULL, 0, NULL, 0},
        };
-       static const char short_options[] = "hl:V";
+       static const char short_options[] = "hl:nV";
        static const struct opts default_values = {
                .log_file = "/var/log/petitboot/pb-discover.log",
        static const struct opts default_values = {
                .log_file = "/var/log/petitboot/pb-discover.log",
+               .dry_run = opt_no,
        };
 
        *opts = default_values;
        };
 
        *opts = default_values;
@@ -78,6 +81,9 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
                case 'l':
                        opts->log_file = optarg;
                        break;
                case 'l':
                        opts->log_file = optarg;
                        break;
+               case 'n':
+                       opts->dry_run = opt_yes;
+                       break;
                case 'V':
                        opts->show_version = opt_yes;
                        break;
                case 'V':
                        opts->show_version = opt_yes;
                        break;
@@ -145,7 +151,7 @@ int main(int argc, char *argv[])
        if (!server)
                return EXIT_FAILURE;
 
        if (!server)
                return EXIT_FAILURE;
 
-       handler = device_handler_init(server);
+       handler = device_handler_init(server, opts.dry_run == opt_yes);
        if (!handler)
                return EXIT_FAILURE;
 
        if (!handler)
                return EXIT_FAILURE;
 
index ddf0de34e7be5d6efd8b646d755bd5e07445de22..5d8debbbacd09ba3a53c9f49ab7e219f11e386aa 100644 (file)
@@ -45,7 +45,7 @@ static void print_usage(void)
 {
        print_version();
        printf(
 {
        print_version();
        printf(
-"Usage: petitboot-nc [-d, --dry-run] [-h, --help] [-l, --log log-file]\n"
+"Usage: petitboot-nc [-h, --help] [-l, --log log-file]\n"
 "                    [-s, --start-daemon] [-V, --version]\n");
 }
 
 "                    [-s, --start-daemon] [-V, --version]\n");
 }
 
@@ -60,7 +60,6 @@ enum opt_value {opt_undef = 0, opt_yes, opt_no};
  */
 
 struct opts {
  */
 
 struct opts {
-       enum opt_value dry_run;
        enum opt_value show_help;
        const char *log_file;
        enum opt_value start_daemon;
        enum opt_value show_help;
        const char *log_file;
        enum opt_value start_daemon;
@@ -74,7 +73,6 @@ struct opts {
 static int opts_parse(struct opts *opts, int argc, char *argv[])
 {
        static const struct option long_options[] = {
 static int opts_parse(struct opts *opts, int argc, char *argv[])
 {
        static const struct option long_options[] = {
-               {"dry-run",      no_argument,       NULL, 'd'},
                {"help",         no_argument,       NULL, 'h'},
                {"log",          required_argument, NULL, 'l'},
                {"start-daemon", no_argument,       NULL, 's'},
                {"help",         no_argument,       NULL, 'h'},
                {"log",          required_argument, NULL, 'l'},
                {"start-daemon", no_argument,       NULL, 's'},
@@ -96,9 +94,6 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
                        break;
 
                switch (c) {
                        break;
 
                switch (c) {
-               case 'd':
-                       opts->dry_run = opt_yes;
-                       break;
                case 'h':
                        opts->show_help = opt_yes;
                        break;
                case 'h':
                        opts->show_help = opt_yes;
                        break;
@@ -151,8 +146,7 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
        m->on_open = cui_on_open;
 
        m->scr.frame.title = talloc_asprintf(m,
        m->on_open = cui_on_open;
 
        m->scr.frame.title = talloc_asprintf(m,
-               "Petitboot (" PACKAGE_VERSION ")%s",
-               (pb_cui->cui->dry_run ? " (dry-run)" : ""));
+               "Petitboot (" PACKAGE_VERSION ")");
        m->scr.frame.help = talloc_strdup(m,
                "ESC=exit, Enter=accept, e=edit, o=open");
        m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
        m->scr.frame.help = talloc_strdup(m,
                "ESC=exit, Enter=accept, e=edit, o=open");
        m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
@@ -260,7 +254,7 @@ int main(int argc, char *argv[])
                return EXIT_FAILURE;
        }
 
                return EXIT_FAILURE;
        }
 
-       pb.cui = cui_init(&pb, NULL, opts.start_daemon, opts.dry_run);
+       pb.cui = cui_init(&pb, NULL, opts.start_daemon);
 
        if (!pb.cui)
                return EXIT_FAILURE;
 
        if (!pb.cui)
                return EXIT_FAILURE;
index fafa29315a2de6657c46fe84b8671ef454fb699c..37ba1c4477558b76479f0debe693a5a78de69855 100644 (file)
@@ -520,7 +520,7 @@ static struct discover_client_ops cui_client_ops = {
  */
 
 struct cui *cui_init(void* platform_info,
  */
 
 struct cui *cui_init(void* platform_info,
-       int (*js_map)(const struct js_event *e), int start_deamon, int dry_run)
+       int (*js_map)(const struct js_event *e), int start_deamon)
 {
        struct cui *cui;
        unsigned int i;
 {
        struct cui *cui;
        unsigned int i;
@@ -536,7 +536,6 @@ struct cui *cui_init(void* platform_info,
        cui->c_sig = pb_cui_sig;
        cui->platform_info = platform_info;
        cui->timer.handle_timeout = cui_handle_timeout;
        cui->c_sig = pb_cui_sig;
        cui->platform_info = platform_info;
        cui->timer.handle_timeout = cui_handle_timeout;
-       cui->dry_run = dry_run;
        cui->waitset = waitset_create(cui);
 
        /* Loop here for scripts that just started the server. */
        cui->waitset = waitset_create(cui);
 
        /* Loop here for scripts that just started the server. */
index 33f266181acc6d47bfb3656c6dff6a9e19189d7a..69c15d46e03518d7e88a6ffa1675fd03fd6f9b63 100644 (file)
@@ -51,7 +51,6 @@ struct cui {
        enum pb_nc_sig c_sig;
        sig_atomic_t abort;
        sig_atomic_t resize;
        enum pb_nc_sig c_sig;
        sig_atomic_t abort;
        sig_atomic_t resize;
-       int dry_run;
        struct nc_scr *current;
        struct pmenu *main;
        struct ui_timer timer;
        struct nc_scr *current;
        struct pmenu *main;
        struct ui_timer timer;
@@ -64,7 +63,7 @@ struct cui {
 };
 
 struct cui *cui_init(void* platform_info,
 };
 
 struct cui *cui_init(void* platform_info,
-       int (*js_map)(const struct js_event *e), int start_deamon, int dry_run);
+       int (*js_map)(const struct js_event *e), int start_deamon);
 struct nc_scr *cui_set_current(struct cui *cui, struct nc_scr *scr);
 int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item);
 int cui_boot_editor_run(struct pmenu_item *item);
 struct nc_scr *cui_set_current(struct cui *cui, struct nc_scr *scr);
 int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item);
 int cui_boot_editor_run(struct pmenu_item *item);
index cc5140ea67f52cd0f29c383c12b25cd542b11fee..c9cb4923863c06b96807514e1ab46eb709ae406d 100644 (file)
@@ -317,8 +317,7 @@ int main(int argc, char *argv[])
                return EXIT_FAILURE;
        }
 
                return EXIT_FAILURE;
        }
 
-       client = pbt_client_init(opts.backend, 1024, 640,
-               opts.start_daemon, opts.dry_run);
+       client = pbt_client_init(opts.backend, 1024, 640, opts.start_daemon);
 
        if (!client) {
                ui_result = EXIT_FAILURE;
 
        if (!client) {
                ui_result = EXIT_FAILURE;
index c664740d04e726025fa56d5319c0d99a7d8cdb22..875b40874fd845e2e43713e94bb7d9850e54f9ba 100644 (file)
@@ -261,8 +261,7 @@ static void pbt_client_destructor(struct pbt_client *client)
 }
 
 struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
 }
 
 struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
-       unsigned int width, unsigned int height,
-       int start_deamon, int dry_run)
+       unsigned int width, unsigned int height, int start_deamon)
 {
        struct pbt_client *pbt_client;
        unsigned int i;
 {
        struct pbt_client *pbt_client;
        unsigned int i;
@@ -280,7 +279,6 @@ struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
        pbt_client->waitset = waitset_create(pbt_client);
 
        pbt_client->sig = "pbt_client";
        pbt_client->waitset = waitset_create(pbt_client);
 
        pbt_client->sig = "pbt_client";
-       pbt_client->dry_run = dry_run;
        pbt_client->frame.scr = pbt_scr_init(pbt_client, pbt_client->waitset,
                        backend, width, height, NULL, NULL);
 
        pbt_client->frame.scr = pbt_scr_init(pbt_client, pbt_client->waitset,
                        backend, width, height, NULL, NULL);
 
index 2c96d489f4d889844ea46a29ed239a4567714bd4..7b9671fa26065c75911f2c5e9f7a50afb3e918e3 100644 (file)
@@ -42,7 +42,6 @@ void pbt_frame_status_printf(struct pbt_frame *frame, const char *format, ...);
 
 struct pbt_client {
        const char *sig;
 
 struct pbt_client {
        const char *sig;
-       int dry_run;
        struct pb_signal_data signal_data;
        void *client_data;
        struct pbt_frame frame;
        struct pb_signal_data signal_data;
        void *client_data;
        struct pbt_frame frame;
@@ -51,8 +50,7 @@ struct pbt_client {
 };
 
 struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
 };
 
 struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
-       unsigned int width, unsigned int height,
-       int start_deamon, int dry_run);
+       unsigned int width, unsigned int height, int start_deamon);
 void pbt_client_destroy(struct pbt_client *client);
 void pbt_client_resize(struct pbt_client *client);
 
 void pbt_client_destroy(struct pbt_client *client);
 void pbt_client_resize(struct pbt_client *client);
 
index 84e824e412e530f70f6427948b611ea48e071733..542f9497a8c07f45e4d1c8b283200c3b5d276bfc 100644 (file)
@@ -34,7 +34,7 @@ void pbt_print_usage(void)
 {
        pbt_print_version();
        printf(
 {
        pbt_print_version();
        printf(
-"Usage: petitboot-twin [-d, --dry-run] [-h, --help] [-l, --log log-file]\n"
+"Usage: petitboot-twin [-h, --help] [-l, --log log-file]\n"
 "                      [-r, --reset-defaults] [-s, --start-daemon]\n"
 "                      [-t, --timeout] [-V, --version]\n"
 "                      [[-f --fbdev] | [-x --x11]]\n");
 "                      [-r, --reset-defaults] [-s, --start-daemon]\n"
 "                      [-t, --timeout] [-V, --version]\n"
 "                      [[-f --fbdev] | [-x --x11]]\n");
@@ -47,7 +47,6 @@ void pbt_print_usage(void)
 int pbt_opts_parse(struct pbt_opts *opts, int argc, char *argv[])
 {
        static const struct option long_options[] = {
 int pbt_opts_parse(struct pbt_opts *opts, int argc, char *argv[])
 {
        static const struct option long_options[] = {
-               {"dry-run",        no_argument,       NULL, 'd'},
                {"fbdev",          no_argument,       NULL, 'f'},
                {"help",           no_argument,       NULL, 'h'},
                {"log",            required_argument, NULL, 'l'},
                {"fbdev",          no_argument,       NULL, 'f'},
                {"help",           no_argument,       NULL, 'h'},
                {"log",            required_argument, NULL, 'l'},
@@ -74,9 +73,6 @@ int pbt_opts_parse(struct pbt_opts *opts, int argc, char *argv[])
                        break;
 
                switch (c) {
                        break;
 
                switch (c) {
-               case 'd':
-                       opts->dry_run = pbt_opt_yes;
-                       break;
                case 'f':
                        opts->backend = pbt_twin_fbdev;
                        break;
                case 'f':
                        opts->backend = pbt_twin_fbdev;
                        break;
index e5af71ab856201acd76ec2334a223599eda85bfc..b6821cf2871aa388c8776458fae41e0eff3c4b16 100644 (file)
@@ -32,7 +32,6 @@ enum pbt_opt_value {pbt_opt_undef = 0, pbt_opt_yes, pbt_opt_no};
 
 struct pbt_opts {
        enum pbt_twin_backend backend;
 
 struct pbt_opts {
        enum pbt_twin_backend backend;
-       enum pbt_opt_value dry_run;
        enum pbt_opt_value show_help;
        const char *log_file;
        enum pbt_opt_value reset_defaults;
        enum pbt_opt_value show_help;
        const char *log_file;
        enum pbt_opt_value reset_defaults;