.SH NAME
@IMAGEX_PROGNAME@-update \- Update a WIM image
.SH SYNOPSIS
-\fB@IMAGEX_PROGNAME@ update\fR \fIWIMFILE\fR [\fIIMAGE\fR] [\fIOPTION\fR...] < \fICMDFILE\fR
+\fB@IMAGEX_PROGNAME@ update\fR \fIWIMFILE\fR [\fIIMAGE\fR] [\fIOPTION\fR...] [< \fICMDFILE\fR]
.SH DESCRIPTION
\fB@IMAGEX_PROGNAME@ update\fR modifies the specified \fIIMAGE\fR in the Windows
Imaging (WIM) file \fIWIMFILE\fR by adding, deleting, or renaming files or
The modifications to perform on the WIM image are specified as a sequence of
commands, one per line, read in a text file from standard input. It is
recommended that standard input be redirected from a file (\fICMDFILE\fR), as
-shown above, rather than typing in commands interactively.
+shown above, rather than typing in commands interactively. Alternatively, to
+specify a command directly on the command line, see the \fB--command\fR option.
.SH AVAILABLE COMMANDS
This section documents the commands that may appear in the \fICMDFILE\fR
described above.
Rebuilding the WIM is slower, but will save a little bit of space that would
otherwise be left as a hole in the WIM. Also see
\fB@IMAGEX_PROGNAME@-optimize\fR (1).
+.TP
+\fB--command\fR=\fISTRING\fR
+Instead of reading update commands from standard input, read a single update
+command directly from the string \fISTRING\fR specified on the command line.
+This option cannot be provided more than one time and cannot be used to specify
+more than one update command.
.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
T(
IMAGEX_PROGNAME" update WIMFILE [IMAGE_NUM | IMAGE_NAME] [--check] [--rebuild]\n"
" [--threads=NUM_THREADS] [DEFAULT_ADD_OPTIONS]\n"
-" [DEFAULT_DELETE_OPTIONS] < CMDFILE\n"
+" [DEFAULT_DELETE_OPTIONS] [--command=STRING] [< CMDFILE]\n"
),
};
IMAGEX_ALLOW_OTHER_OPTION,
IMAGEX_BOOT_OPTION,
IMAGEX_CHECK_OPTION,
+ IMAGEX_COMMAND_OPTION,
IMAGEX_COMMIT_OPTION,
IMAGEX_COMPRESS_OPTION,
IMAGEX_CONFIG_OPTION,
{T("threads"), required_argument, NULL, IMAGEX_THREADS_OPTION},
{T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION},
{T("rebuild"), no_argument, NULL, IMAGEX_REBUILD_OPTION},
+ {T("command"), required_argument, NULL, IMAGEX_COMMAND_OPTION},
/* Default delete options */
{T("force"), no_argument, NULL, IMAGEX_FORCE_OPTION},
{T("noacls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION},
{T("no-acls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION},
{T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION},
+
{NULL, 0, NULL, 0},
};
int default_delete_flags = 0;
unsigned num_threads = 0;
int c;
- tchar *cmd_file_contents;
+ tchar *cmd_file_contents = NULL;
size_t cmd_file_nchars;
struct wimlib_update_command *cmds;
size_t num_cmds;
int num_images;
+ tchar *command_str = NULL;
const tchar *config_file = NULL;
tchar *config_str;
case IMAGEX_REBUILD_OPTION:
write_flags |= WIMLIB_WRITE_FLAG_REBUILD;
break;
-
+ case IMAGEX_COMMAND_OPTION:
+ if (command_str) {
+ imagex_error(T("--command may only be specified "
+ "one time. Please provide\n"
+ " the update commands "
+ "on standard input instead."));
+ ret = -1;
+ goto out;
+ }
+ command_str = tstrdup(optarg);
+ if (!command_str) {
+ imagex_error(T("Out of memory!"));
+ ret = -1;
+ goto out;
+ }
+ break;
/* Default delete options */
case IMAGEX_FORCE_OPTION:
default_delete_flags |= WIMLIB_DELETE_FLAG_FORCE;
config = &default_capture_config;
}
- /* Read update commands from standard input */
- if (isatty(STDIN_FILENO)) {
- tputs(T("Reading update commands from standard input..."));
- recommend_man_page(T("update"));
- }
- cmd_file_contents = stdin_get_text_contents(&cmd_file_nchars);
- if (!cmd_file_contents) {
- ret = -1;
- goto out_free_config;
- }
+ /* Read update commands from standard input, or the command string if
+ * specified. */
+ if (command_str) {
+ cmds = parse_update_command_file(&command_str, tstrlen(command_str),
+ &num_cmds);
+ } else {
+ if (isatty(STDIN_FILENO)) {
+ tputs(T("Reading update commands from standard input..."));
+ recommend_man_page(T("update"));
+ }
+ cmd_file_contents = stdin_get_text_contents(&cmd_file_nchars);
+ if (!cmd_file_contents) {
+ ret = -1;
+ goto out_free_config;
+ }
- /* Parse the update commands */
- cmds = parse_update_command_file(&cmd_file_contents, cmd_file_nchars,
- &num_cmds);
+ /* 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;
out_wimlib_free:
wimlib_free(wim);
out:
+ free(command_str);
return ret;
out_usage:
usage(UPDATE);