]> wimlib.net Git - wimlib/blobdiff - programs/imagex.c
wimlib-imagex: Add --solid as alias for --pack-streams
[wimlib] / programs / imagex.c
index 142d809163af8ea019bd22fee93a41ddc3056099..9ebe277181dee6b7eb559f26131214f51b177c7d 100644 (file)
@@ -196,6 +196,7 @@ static const struct option capture_or_append_options[] = {
        {T("compress-slow"), no_argument,     NULL, IMAGEX_COMPRESS_SLOW_OPTION},
        {T("chunk-size"),  required_argument, NULL, IMAGEX_CHUNK_SIZE_OPTION},
        {T("pack-streams"), no_argument,      NULL, IMAGEX_PACK_STREAMS_OPTION},
+       {T("solid"),       no_argument,      NULL, IMAGEX_PACK_STREAMS_OPTION},
        {T("config"),      required_argument, NULL, IMAGEX_CONFIG_OPTION},
        {T("dereference"), no_argument,       NULL, IMAGEX_DEREFERENCE_OPTION},
        {T("flags"),       required_argument, NULL, IMAGEX_FLAGS_OPTION},
@@ -234,6 +235,7 @@ static const struct option export_options[] = {
        {T("no-check"),    no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
        {T("compress"),    required_argument, NULL, IMAGEX_COMPRESS_OPTION},
        {T("pack-streams"),no_argument,       NULL, IMAGEX_PACK_STREAMS_OPTION},
+       {T("solid"),       no_argument,       NULL, IMAGEX_PACK_STREAMS_OPTION},
        {T("chunk-size"),  required_argument, NULL, IMAGEX_CHUNK_SIZE_OPTION},
        {T("ref"),         required_argument, NULL, IMAGEX_REF_OPTION},
        {T("threads"),     required_argument, NULL, IMAGEX_THREADS_OPTION},
@@ -298,6 +300,7 @@ static const struct option optimize_options[] = {
        {T("recompress-slow"), no_argument,     NULL, IMAGEX_COMPRESS_SLOW_OPTION},
        {T("chunk-size"),  required_argument, NULL, IMAGEX_CHUNK_SIZE_OPTION},
        {T("pack-streams"),no_argument,       NULL, IMAGEX_PACK_STREAMS_OPTION},
+       {T("solid"),       no_argument,       NULL, IMAGEX_PACK_STREAMS_OPTION},
        {T("threads"),     required_argument, NULL, IMAGEX_THREADS_OPTION},
        {T("pipable"),     no_argument,       NULL, IMAGEX_PIPABLE_OPTION},
        {T("not-pipable"), no_argument,       NULL, IMAGEX_NOT_PIPABLE_OPTION},
@@ -434,11 +437,10 @@ get_compression_type(const tchar *optarg)
        }
 }
 
-static int
+static void
 set_compress_slow(void)
 {
-       int ret;
-       static const struct wimlib_lzx_compressor_params slow_params = {
+       static const struct wimlib_lzx_compressor_params lzx_slow_params = {
                .hdr = {
                        .size = sizeof(struct wimlib_lzx_compressor_params),
                },
@@ -446,7 +448,7 @@ set_compress_slow(void)
                .alg_params = {
                        .slow = {
                                .use_len2_matches = 1,
-                               .num_fast_bytes = 96,
+                               .nice_match_length = 96,
                                .num_optim_passes = 4,
                                .max_search_depth = 100,
                                .max_matches_per_pos = 10,
@@ -456,11 +458,24 @@ set_compress_slow(void)
                        },
                },
        };
-       ret = wimlib_set_default_compressor_params(WIMLIB_COMPRESSION_TYPE_LZX,
-                                                  &slow_params.hdr);
-       if (ret)
-               imagex_error(T("Couldn't set slow compression parameters.!"));
-       return ret;
+
+       static const struct wimlib_lzms_compressor_params lzms_slow_params = {
+               .hdr = {
+                       .size = sizeof(struct wimlib_lzms_compressor_params),
+               },
+               .min_match_length = 2,
+               .max_match_length = UINT32_MAX,
+               .nice_match_length = 96,
+               .max_search_depth = 100,
+               .max_matches_per_pos = 10,
+               .optim_array_length = 1024,
+       };
+
+       wimlib_set_default_compressor_params(WIMLIB_COMPRESSION_TYPE_LZX,
+                                            &lzx_slow_params.hdr);
+
+       wimlib_set_default_compressor_params(WIMLIB_COMPRESSION_TYPE_LZMS,
+                                            &lzms_slow_params.hdr);
 }
 
 struct string_set {
@@ -1101,16 +1116,22 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                return 0;
        switch (msg) {
        case WIMLIB_PROGRESS_MSG_WRITE_STREAMS:
+               {
+                       static bool first = true;
+                       if (first) {
+                               imagex_printf(T("Writing %"TS"-compressed data "
+                                               "using %u thread%"TS"\n"),
+                                             wimlib_get_compression_type_string(
+                                                       info->write_streams.compression_type),
+                                       info->write_streams.num_threads,
+                                       (info->write_streams.num_threads == 1) ? T("") : T("s"));
+                               first = false;
+                       }
+               }
                unit_shift = get_unit(info->write_streams.total_bytes, &unit_name);
                percent_done = TO_PERCENT(info->write_streams.completed_bytes,
                                          info->write_streams.total_bytes);
 
-               if (info->write_streams.completed_streams == 0) {
-                       imagex_printf(T("Writing %"TS"-compressed data using %u thread%"TS"\n"),
-                               wimlib_get_compression_type_string(info->write_streams.compression_type),
-                               info->write_streams.num_threads,
-                               (info->write_streams.num_threads == 1) ? T("") : T("s"));
-               }
                if (info->write_streams.total_parts <= 1) {
                        imagex_printf(T("\r%"PRIu64" %"TS" of %"PRIu64" %"TS" (uncompressed) "
                                "written (%u%% done)"),
@@ -1552,7 +1573,7 @@ imagex_apply(int argc, tchar **argv, int cmd)
        const tchar *wimfile;
        const tchar *target;
        const tchar *image_num_or_name = NULL;
-       int extract_flags = WIMLIB_EXTRACT_FLAG_SEQUENTIAL;
+       int extract_flags = 0;
 
        STRING_SET(refglobs);
 
@@ -1762,6 +1783,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
        struct wimlib_capture_source *capture_sources;
        size_t num_sources;
        bool name_defaulted;
+       bool compress_slow = false;
 
        for_opt(c, capture_or_append_options) {
                switch (c) {
@@ -1785,10 +1807,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
                                goto out_err;
                        break;
                case IMAGEX_COMPRESS_SLOW_OPTION:
-                       ret = set_compress_slow();
-                       if (ret)
-                               goto out_err;
-                       compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
+                       compress_slow = true;
                        break;
                case IMAGEX_CHUNK_SIZE_OPTION:
                        chunk_size = parse_chunk_size(optarg);
@@ -1882,19 +1901,26 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
        source = argv[0];
        wimfile = argv[1];
 
-       /* Set default compression type.  */
+       /* Set default compression type and parameters.  */
+
+
        if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {
-               struct wimlib_lzx_compressor_params params;
-               memset(&params, 0, sizeof(params));
-               params.hdr.size = sizeof(params);
-               params.algorithm = WIMLIB_LZX_ALGORITHM_FAST;
-               params.use_defaults = 1;
-
-               wimlib_set_default_compressor_params(WIMLIB_COMPRESSION_TYPE_LZX,
-                                                    &params.hdr);
                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,
+                                                            &params.hdr);
+               }
        }
 
+       if (compress_slow)
+               set_compress_slow();
+
        if (!tstrcmp(wimfile, T("-"))) {
                /* Writing captured WIM to standard output.  */
        #if 0
@@ -2714,7 +2740,7 @@ imagex_extract(int argc, tchar **argv, int cmd)
        const tchar *image_num_or_name;
        const tchar *pathlist;
        tchar *dest_dir = T(".");
-       int extract_flags = WIMLIB_EXTRACT_FLAG_SEQUENTIAL | WIMLIB_EXTRACT_FLAG_NORPFIX;
+       int extract_flags = WIMLIB_EXTRACT_FLAG_NORPFIX;
        int listfile_extract_flags = WIMLIB_EXTRACT_FLAG_GLOB_PATHS;
 
        STRING_SET(refglobs);
@@ -3409,10 +3435,7 @@ imagex_optimize(int argc, tchar **argv, int cmd)
                        break;
                case IMAGEX_COMPRESS_SLOW_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS;
-                       compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
-                       ret = set_compress_slow();
-                       if (ret)
-                               goto out_err;
+                       set_compress_slow();
                        break;
                case IMAGEX_CHUNK_SIZE_OPTION:
                        chunk_size = parse_chunk_size(optarg);