#ifdef __WIN32__
# include "imagex-win32.h"
-# define OS_PREFERRED_PATH_SEPARATOR L'\\'
-# define OS_PREFERRED_PATH_SEPARATOR_STRING L"\\"
# define print_security_descriptor win32_print_security_descriptor
#else /* __WIN32__ */
# include <getopt.h>
# include <langinfo.h>
-# define OS_PREFERRED_PATH_SEPARATOR '/'
-# define OS_PREFERRED_PATH_SEPARATOR_STRING "/"
# define print_security_descriptor default_print_security_descriptor
static inline void set_fd_to_binary_mode(int fd)
{
IMAGEX_NOT_PIPABLE_OPTION,
IMAGEX_NO_ACLS_OPTION,
IMAGEX_NO_ATTRIBUTES_OPTION,
+ IMAGEX_NO_REPLACE_OPTION,
IMAGEX_NO_WILDCARDS_OPTION,
IMAGEX_NULLGLOB_OPTION,
IMAGEX_ONE_FILE_ONLY_OPTION,
IMAGEX_UPDATE_OF_OPTION,
IMAGEX_VERBOSE_OPTION,
IMAGEX_WIMBOOT_OPTION,
+ IMAGEX_WIMBOOT_CONFIG_OPTION,
IMAGEX_XML_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},
+ {T("wimboot-config"), required_argument, NULL, IMAGEX_WIMBOOT_CONFIG_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},
+ {T("no-replace"), no_argument, NULL, IMAGEX_NO_REPLACE_OPTION},
{NULL, 0, NULL, 0},
};
static int
get_compression_type(const tchar *optarg)
{
- if (!tstrcasecmp(optarg, T("maximum")) || !tstrcasecmp(optarg, T("lzx")))
+ if (!tstrcasecmp(optarg, T("maximum")) ||
+ !tstrcasecmp(optarg, T("lzx")) ||
+ !tstrcasecmp(optarg, T("max")))
return WIMLIB_COMPRESSION_TYPE_LZX;
else if (!tstrcasecmp(optarg, T("fast")) || !tstrcasecmp(optarg, T("xpress")))
return WIMLIB_COMPRESSION_TYPE_XPRESS;
percent_done = TO_PERCENT(info->write_streams.completed_bytes,
info->write_streams.total_bytes);
- if (info->write_streams.total_parts <= 1) {
- imagex_printf(T("\r%"PRIu64" %"TS" of %"PRIu64" %"TS" (uncompressed) "
- "written (%u%% done)"),
- info->write_streams.completed_bytes >> unit_shift,
- unit_name,
- info->write_streams.total_bytes >> unit_shift,
- unit_name,
- percent_done);
- } else {
- imagex_printf(T("\rWriting resources from part %u of %u: "
- "%"PRIu64 " %"TS" of %"PRIu64" %"TS" (%u%%) written"),
- (info->write_streams.completed_parts ==
- info->write_streams.total_parts) ?
- info->write_streams.completed_parts :
- info->write_streams.completed_parts + 1,
- info->write_streams.total_parts,
- info->write_streams.completed_bytes >> unit_shift,
- unit_name,
- info->write_streams.total_bytes >> unit_shift,
- unit_name,
- percent_done);
- }
+ imagex_printf(T("\r%"PRIu64" %"TS" of %"PRIu64" %"TS" (uncompressed) "
+ "written (%u%% done)"),
+ info->write_streams.completed_bytes >> unit_shift,
+ unit_name,
+ info->write_streams.total_bytes >> unit_shift,
+ unit_name,
+ percent_done);
if (info->write_streams.completed_bytes >= info->write_streams.total_bytes)
imagex_printf(T("\n"));
break;
case WIMLIB_PROGRESS_MSG_SCAN_BEGIN:
imagex_printf(T("Scanning \"%"TS"\""), info->scan.source);
- if (*info->scan.wim_target_path) {
- imagex_printf(T(" (loading as WIM path: "
- "\""WIMLIB_WIM_PATH_SEPARATOR_STRING"%"TS"\")...\n"),
- info->scan.wim_target_path);
- } else {
+ if (WIMLIB_IS_WIM_ROOT_PATH(info->scan.wim_target_path)) {
imagex_printf(T("\n"));
+ } else {
+ imagex_printf(T(" (loading as WIM path: \"%"TS"\")...\n"),
+ info->scan.wim_target_path);
}
memset(&last_scan_progress, 0, sizeof(last_scan_progress));
break;
T("NTFS volume") : T("directory")),
info->extract.target);
break;
- case WIMLIB_PROGRESS_MSG_EXTRACT_TREE_BEGIN:
- if (info->extract.extract_root_wim_source_path[0]) {
- imagex_printf(T("Extracting \"%"TS"\" from image %d "
- "(\"%"TS"\") in \"%"TS"\" to \"%"TS"\"\n"),
- info->extract.extract_root_wim_source_path,
- info->extract.image,
- info->extract.image_name,
- info->extract.wimfile_name,
- info->extract.target);
- }
- break;
case WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS:
percent_done = TO_PERCENT(info->extract.completed_bytes,
info->extract.total_bytes);
}
break;
case WIMLIB_PROGRESS_MSG_APPLY_TIMESTAMPS:
- if (info->extract.extract_root_wim_source_path[0] == T('\0'))
- imagex_printf(T("Setting timestamps on all extracted files...\n"));
+ imagex_printf(T("Setting timestamps on all extracted files...\n"));
break;
case WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END:
if (info->extract.extract_flags & WIMLIB_EXTRACT_FLAG_NTFS) {
case WIMLIB_PROGRESS_MSG_UPDATE_END_COMMAND:
switch (info->update.command->op) {
case WIMLIB_UPDATE_OP_DELETE:
- imagex_printf(T("Deleted WIM path "
- "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
+ imagex_printf(T("Deleted WIM path \"%"TS"\"\n"),
info->update.command->delete_.wim_path);
break;
case WIMLIB_UPDATE_OP_RENAME:
- imagex_printf(T("Renamed WIM path "
- "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\" => "
- "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
+ imagex_printf(T("Renamed WIM path \"%"TS"\" => \"%"TS"\"\n"),
info->update.command->rename.wim_source_path,
info->update.command->rename.wim_target_path);
break;
break;
}
break;
+ case WIMLIB_PROGRESS_MSG_REPLACE_FILE_IN_WIM:
+ imagex_printf(T("Updating \"%"TS"\" in WIM image\n"),
+ info->replace.path_in_wim);
+ break;
+ case WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE:
+ imagex_printf(T("\nExtracting \"%"TS"\" as normal file (not WIMBoot pointer)\n"),
+ info->wimboot_exclude.path_in_wim);
+ break;
default:
break;
}
cmd->add.add_flags |= WIMLIB_ADD_FLAG_STRICT_ACLS;
else if (!tstrcmp(option, T("--dereference")))
cmd->add.add_flags |= WIMLIB_ADD_FLAG_DEREFERENCE;
+ else if (!tstrcmp(option, T("--no-replace")))
+ cmd->add.add_flags |= WIMLIB_ADD_FLAG_NO_REPLACE;
else
recognized = false;
break;
if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {
+ /* No compression type specified. Use the default. */
+
if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_WIMBOOT) {
+ /* With --wimboot, default to XPRESS compression. */
compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
+ } else if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS) {
+ /* With --pack-streams or --solid, default to LZMS
+ * compression. (However, this will not affect packed
+ * resources!) */
+ compression_type = WIMLIB_COMPRESSION_TYPE_LZMS;
} else {
+ /* Otherwise, default to LZX compression in fast mode.
+ */
compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
if (!compress_slow && pack_ctype != WIMLIB_COMPRESSION_TYPE_LZX) {
struct wimlib_lzx_compressor_params params = {
/* Set up capture source in non-source-list mode. */
capture_sources = alloca(sizeof(struct wimlib_capture_source));
capture_sources[0].fs_source_path = source;
- capture_sources[0].wim_target_path = NULL;
+ capture_sources[0].wim_target_path = WIMLIB_WIM_ROOT_PATH;
capture_sources[0].reserved = 0;
num_sources = 1;
capture_sources_malloced = false;
WIMStruct *wim = NULL;
int image;
int ret;
- const tchar *path = T("");
+ const tchar *path = WIMLIB_WIM_ROOT_PATH;
int c;
struct print_dentry_options options = {
.detailed = false,
if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {
/* The user did not specify a compression type; default
- * to that of the source WIM. */
+ * to that of the source WIM, unless --pack-streams or
+ * --solid was specified. */
- compression_type = src_info.compression_type;
+ if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS)
+ compression_type = WIMLIB_COMPRESSION_TYPE_LZMS;
+ else
+ compression_type = src_info.compression_type;
}
ret = wimlib_create_new_wim(compression_type, &dest_wim);
if (ret)
STRING_SET(refglobs);
- tchar *root_path = T("");
+ tchar *root_path = WIMLIB_WIM_ROOT_PATH;
for_opt(c, extract_options) {
switch (c) {
size_t num_cmds;
tchar *command_str = NULL;
tchar *config_file = NULL;
+ tchar *wimboot_config = NULL;
for_opt(c, update_options) {
switch (c) {
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;
case IMAGEX_STRICT_ACLS_OPTION:
default_add_flags |= WIMLIB_ADD_FLAG_STRICT_ACLS;
break;
+ case IMAGEX_NO_REPLACE_OPTION:
+ default_add_flags |= WIMLIB_ADD_FLAG_NO_REPLACE;
+ break;
default:
goto out_usage;
}
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);
/* 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 */
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;
+
+ cmd.op = WIMLIB_UPDATE_OP_ADD;
+ cmd.add.fs_source_path = wimboot_config;
+ cmd.add.wim_target_path = T("/Windows/System32/WimBootCompress.ini");
+ cmd.add.config_file = NULL;
+ cmd.add.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);
" [--nocheck] [--flags EDITION_ID] [--dereference]\n"
" [--config=FILE] [--threads=NUM_THREADS] [--source-list]\n"
" [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n"
-" [--update-of=[WIMFILE:]IMAGE]\n"
+" [--update-of=[WIMFILE:]IMAGE] [--wimboot]\n"
),
[CMD_APPLY] =
T(
" (DIRECTORY | NTFS_VOLUME) [--check] [--ref=\"GLOB\"]\n"
" [--no-acls] [--strict-acls] [--no-attributes]\n"
" [--rpfix] [--norpfix] [--hardlink] [--symlink]\n"
-" [--include-invalid-names]\n"
+" [--include-invalid-names] [--wimboot]\n"
),
[CMD_CAPTURE] =
T(
" [--dereference] [--config=FILE] [--threads=NUM_THREADS]\n"
" [--source-list] [--no-acls] [--strict-acls] [--rpfix]\n"
" [--norpfix] [--update-of=[WIMFILE:]IMAGE]\n"
-" [--delta-from=WIMFILE]\n"
+" [--delta-from=WIMFILE] [--wimboot]\n"
),
[CMD_DELETE] =
T(
T(
" %"TS" WIMFILE [IMAGE_NUM | IMAGE_NAME] [--check] [--rebuild]\n"
" [--threads=NUM_THREADS] [DEFAULT_ADD_OPTIONS]\n"
-" [DEFAULT_DELETE_OPTIONS] [--command=STRING] [< CMDFILE]\n"
+" [DEFAULT_DELETE_OPTIONS] [--command=STRING]\n"
+" [--wimboot-config=FILE| [< CMDFILE]\n"
),
};