]> wimlib.net Git - wimlib/commitdiff
wimupdate: Add --wimboot-config=FILE option
authorEric Biggers <ebiggers3@gmail.com>
Mon, 28 Apr 2014 07:14:05 +0000 (02:14 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 28 Apr 2014 07:14:05 +0000 (02:14 -0500)
doc/man1/imagex-update.1.in
programs/imagex.c

index f688e6b7aa511d4cc05855e2862590c997dc0387..3e1e741795c99f6506c5031a4f32e4f6b025b468 100644 (file)
@@ -128,6 +128,22 @@ quotes and single quotes for the inner quotes.  Example:
 .RE
 .RE
 .fi
+.TP
+\fB--wimboot-config\fR=\fIFILE\fR
+If this option is specified, no commands shall be read from standard input, and
+instead the following command shall be executed:
+.IP
+.nf
+.RS
+.RS
+\fBadd\fR \fIFILE\fR /Windows/System32/WimBootCompress.ini
+.RE
+.RE
+.fi
+.IP
+This sets \fIFILE\fR as the WIMBoot configuration file for the image.  See the
+documentation for the \fB--wimboot\fR option of \fB@IMAGEX_PROGNAME@ apply\fR
+(1) for more information.
 .SH NOTES
 \fB@IMAGEX_PROGNAME@ update\fR is partly redundant with \fB@IMAGEX_PROGNAME@
 mountrw\fR, since if a WIM image can be mounted read-write, then there
index c3a08e8e1ff08f6e4f1e26a70afdab2b2032edbb..25a4471b2fecf756b9c9a12a70fa968186845fe9 100644 (file)
@@ -201,6 +201,7 @@ enum {
        IMAGEX_UPDATE_OF_OPTION,
        IMAGEX_VERBOSE_OPTION,
        IMAGEX_WIMBOOT_OPTION,
+       IMAGEX_WIMBOOT_CONFIG_OPTION,
        IMAGEX_XML_OPTION,
 };
 
@@ -387,6 +388,7 @@ static const struct option update_options[] = {
        {T("check"),       no_argument,       NULL, IMAGEX_CHECK_OPTION},
        {T("rebuild"),     no_argument,       NULL, IMAGEX_REBUILD_OPTION},
        {T("command"),     required_argument, NULL, IMAGEX_COMMAND_OPTION},
+       {T("wimboot-config"), required_argument, NULL, IMAGEX_WIMBOOT_CONFIG_OPTION},
 
        /* Default delete options */
        {T("force"),       no_argument,       NULL, IMAGEX_FORCE_OPTION},
@@ -3720,6 +3722,7 @@ imagex_update(int argc, tchar **argv, int cmd)
        size_t num_cmds;
        tchar *command_str = NULL;
        tchar *config_file = NULL;
+       tchar *wimboot_config = NULL;
 
        for_opt(c, update_options) {
                switch (c) {
@@ -3750,6 +3753,9 @@ imagex_update(int argc, tchar **argv, int cmd)
                                goto out_err;
                        }
                        break;
+               case IMAGEX_WIMBOOT_CONFIG_OPTION:
+                       wimboot_config = optarg;
+                       break;
                /* Default delete options */
                case IMAGEX_FORCE_OPTION:
                        default_delete_flags |= WIMLIB_DELETE_FLAG_FORCE;
@@ -3826,7 +3832,11 @@ imagex_update(int argc, tchar **argv, int cmd)
                cmd_file_contents = NULL;
                cmds = parse_update_command_file(&command_str, tstrlen(command_str),
                                                 &num_cmds);
-       } else {
+               if (!cmds) {
+                       ret = -1;
+                       goto out_free_cmd_file_contents;
+               }
+       } else if (!wimboot_config) {
                if (isatty(STDIN_FILENO)) {
                        tputs(T("Reading update commands from standard input..."));
                        recommend_man_page(CMD_UPDATE, stdout);
@@ -3840,10 +3850,14 @@ imagex_update(int argc, tchar **argv, int cmd)
                /* Parse the update commands */
                cmds = parse_update_command_file(&cmd_file_contents, cmd_file_nchars,
                                                 &num_cmds);
-       }
-       if (!cmds) {
-               ret = -1;
-               goto out_free_cmd_file_contents;
+               if (!cmds) {
+                       ret = -1;
+                       goto out_free_cmd_file_contents;
+               }
+       } else {
+               cmd_file_contents = NULL;
+               cmds = NULL;
+               num_cmds = 0;
        }
 
        /* Set default flags and capture config on the update commands */
@@ -3867,6 +3881,26 @@ imagex_update(int argc, tchar **argv, int cmd)
        if (ret)
                goto out_free_cmds;
 
+       if (wimboot_config) {
+               /* --wimboot-config=FILE is short for an
+                * "add FILE /Windows/System32/WimBootCompress.ini" command.
+                */
+               struct wimlib_update_command cmd = {
+                       .op = WIMLIB_UPDATE_OP_ADD,
+                       .add = {
+                               .fs_source_path = wimboot_config,
+                               .wim_target_path =
+                                       T("/Windows/System32/WimBootCompress.ini"),
+                               .config_file = NULL,
+                               .add_flags = 0,
+                       },
+               };
+               ret = wimlib_update_image(wim, image, &cmd, 1,
+                                         update_flags, imagex_progress_func);
+               if (ret)
+                       goto out_free_cmds;
+       }
+
        /* Overwrite the updated WIM */
        ret = wimlib_overwrite(wim, write_flags, num_threads,
                               imagex_progress_func);