*/
/*
- * Copyright (C) 2012, 2013 Eric Biggers
+ * Copyright (C) 2012, 2013, 2014 Eric Biggers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
IMAGEX_UNIX_DATA_OPTION,
IMAGEX_UPDATE_OF_OPTION,
IMAGEX_VERBOSE_OPTION,
+ IMAGEX_WIMBOOT_OPTION,
IMAGEX_XML_OPTION,
};
/* --resume is undocumented for now as it needs improvement. */
{T("resume"), no_argument, NULL, IMAGEX_RESUME_OPTION},
+ {T("wimboot"), no_argument, NULL, IMAGEX_WIMBOOT_OPTION},
{NULL, 0, NULL, 0},
};
{T("not-pipable"), no_argument, NULL, IMAGEX_NOT_PIPABLE_OPTION},
{T("update-of"), required_argument, NULL, IMAGEX_UPDATE_OF_OPTION},
{T("delta-from"), required_argument, NULL, IMAGEX_DELTA_FROM_OPTION},
+ {T("wimboot"), no_argument, NULL, IMAGEX_WIMBOOT_OPTION},
{NULL, 0, NULL, 0},
};
{T("no-wildcards"), no_argument, NULL, IMAGEX_NO_WILDCARDS_OPTION},
{T("nullglob"), no_argument, NULL, IMAGEX_NULLGLOB_OPTION},
{T("preserve-dir-structure"), no_argument, NULL, IMAGEX_PRESERVE_DIR_STRUCTURE_OPTION},
+ {T("wimboot"), no_argument, NULL, IMAGEX_WIMBOOT_OPTION},
{NULL, 0, NULL, 0},
};
va_end(va);
}
+static void _format_attribute(printf, 1, 2)
+imagex_warning(const tchar *format, ...)
+{
+ va_list va;
+ va_start(va, format);
+ tfputs(T("WARNING: "), stderr);
+ tvfprintf(stderr, format, va);
+ tputc(T('\n'), stderr);
+ va_end(va);
+}
+
/* Print formatted error message to stderr. */
static void _format_attribute(printf, 1, 2)
imagex_error_with_errno(const tchar *format, ...)
is_comment_line(const tchar *line, size_t len)
{
for (;;) {
- if (*line == T('#'))
+ if (*line == T('#') || *line == T(';'))
return true;
if (!istspace(*line) && *line != T('\0'))
return false;
"of capture config file\n"),
stderr);
} else {
- imagex_error(T("Invalid capture config file section \"%"TS"\""),
- line - 1);
+ imagex_warning(T("Unknown capture config file section \"%"TS"\""),
+ line - 1);
return CAPTURE_CONFIG_INVALID_SECTION;
}
return CAPTURE_CONFIG_CHANGED_SECTION;
int ret;
ret = check_config_section(line, len, cur_section);
- if (ret == CAPTURE_CONFIG_INVALID_SECTION)
- return false;
- if (ret == CAPTURE_CONFIG_CHANGED_SECTION)
+ if (ret == CAPTURE_CONFIG_CHANGED_SECTION ||
+ ret == CAPTURE_CONFIG_INVALID_SECTION)
return true;
switch (*cur_section) {
tchar *endp = tmemchr(p, T('\n'), nchars);
size_t len = endp - p + 1;
*endp = T('\0');
+ if (p != endp && *(endp - 1) == T('\r')) {
+ *(endp - 1) = '\0';
+ len--;
+ }
if (!is_comment_line(p, len))
if (!parse_capture_config_line(p, len, &cur_section, config))
return -1;
case IMAGEX_RESUME_OPTION:
extract_flags |= WIMLIB_EXTRACT_FLAG_RESUME;
break;
+ case IMAGEX_WIMBOOT_OPTION:
+ extract_flags |= WIMLIB_EXTRACT_FLAG_WIMBOOT;
+ break;
default:
goto out_usage;
}
tchar *source;
tchar *source_copy;
- const tchar *config_file = NULL;
+ tchar *config_file = NULL;
tchar *config_str;
struct wimlib_capture_config *config;
goto out_free_base_wimfiles;
write_flags |= WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS;
break;
+ case IMAGEX_WIMBOOT_OPTION:
+ add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_WIMBOOT;
+ break;
default:
goto out_usage;
}
if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {
- compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
-
- if (!compress_slow) {
- struct wimlib_lzx_compressor_params params = {
- .hdr.size = sizeof(params),
- .algorithm = WIMLIB_LZX_ALGORITHM_FAST,
- .use_defaults = 1,
- };
- wimlib_set_default_compressor_params(WIMLIB_COMPRESSION_TYPE_LZX,
- ¶ms.hdr);
+ if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_WIMBOOT) {
+ compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
+ } else {
+ compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
+ if (!compress_slow) {
+ struct wimlib_lzx_compressor_params params = {
+ .hdr.size = sizeof(params),
+ .algorithm = WIMLIB_LZX_ALGORITHM_FAST,
+ .use_defaults = 1,
+ };
+ wimlib_set_default_compressor_params(WIMLIB_COMPRESSION_TYPE_LZX,
+ ¶ms.hdr);
+ }
}
+
}
if (compress_slow)
set_compress_slow();
+ /* Set default configuration file */
+#ifdef __WIN32__
+ if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_WIMBOOT) && !config) {
+ struct stat st;
+
+ config_file = alloca(wcslen(source) * sizeof(wchar_t) + 100);
+ swprintf(config_file, L"%ls\\%ls",
+ source, L"Windows\\System32\\WimBootCompress.ini");
+
+ if (tstat(config_file, &st)) {
+ imagex_printf(L"\"%ls\" does not exist; using "
+ "default configuration\n",
+ config_file);
+ config_file = NULL;
+ } else {
+ add_image_flags &= ~WIMLIB_ADD_IMAGE_FLAG_WINCONFIG;
+ }
+ }
+#endif
+
if (!tstrcmp(wimfile, T("-"))) {
/* Writing captured WIM to standard output. */
#if 0
ret = wimlib_set_output_chunk_size(wim, chunk_size);
if (ret)
goto out_free_wim;
+ } else if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_WIMBOOT) &&
+ compression_type == WIMLIB_COMPRESSION_TYPE_XPRESS) {
+ ret = wimlib_set_output_chunk_size(wim, 4096);
+ if (ret)
+ goto out_free_wim;
}
if (pack_chunk_size != UINT32_MAX) {
ret = wimlib_set_output_pack_chunk_size(wim, pack_chunk_size);
case IMAGEX_PRESERVE_DIR_STRUCTURE_OPTION:
notlist_extract_flags &= ~WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE;
break;
+ case IMAGEX_WIMBOOT_OPTION:
+ extract_flags |= WIMLIB_EXTRACT_FLAG_WIMBOOT;
+ break;
default:
goto out_usage;
}
{
static const tchar *s =
T(
-IMAGEX_PROGNAME " (" PACKAGE ") " PACKAGE_VERSION "\n"
-"Copyright (C) 2012, 2013 Eric Biggers\n"
+IMAGEX_PROGNAME " (distributed with " PACKAGE " " PACKAGE_VERSION ")\n"
+"Copyright (C) 2012, 2013, 2014 Eric Biggers\n"
"License GPLv3+; GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"