wimlib-imagex: add --include-integrity option
authorEric Biggers <ebiggers3@gmail.com>
Sun, 21 Jan 2018 21:47:10 +0000 (13:47 -0800)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 21 Jan 2018 21:47:10 +0000 (13:47 -0800)
The --check option currently does two things: verify the integrity table
of the input WIM(s), and include an integrity table in the output
WIM(s).  Some users would like to do the latter only, especially if
there are large input WIM(s).

Add an option --include-integrity which does this.

doc/man1/wimcapture.1
doc/man1/wimdelete.1
doc/man1/wimexport.1
doc/man1/wiminfo.1
doc/man1/wimjoin.1
doc/man1/wimoptimize.1
doc/man1/wimsplit.1
doc/man1/wimupdate.1
programs/imagex.c

index 0830ffe..990c04c 100644 (file)
@@ -173,7 +173,12 @@ WIM.
 .TP
 \fB--check\fR
 Include extra integrity information in the resulting WIM.  With \fBwimappend\fR,
-also check the integrity of the WIM before appending to it.
+also check the integrity of the WIM before appending to it.  Also verify the
+integrity of any WIMs specified by \fB--update-of\fR and/or \fB--delta-from\fR.
+.TP
+\fB--include-integrity\fR
+Include extra integrity information in the resulting WIM, i.e. like
+\fB--check\fR but don't do any verification beforehand.
 .TP
 \fB--compress\fR=\fITYPE\fR[:\fILEVEL\fR]
 With \fBwimcapture\fR, use the specified compression format in the new WIM file.
index 6315106..20e0801 100644 (file)
@@ -27,7 +27,11 @@ images, although such a file may not be very useful.
 Before deleting the image, verify the WIM's integrity if extra integrity
 information is present.  In addition, include extra integrity information in the
 modified WIM, even if it was not present before.
-.TP 6
+.TP
+\fB--include-integrity\fR
+Include extra integrity information in the modified WIM, i.e. like \fB--check\fR
+but don't do any verification beforehand.
+.TP
 \fB--soft\fR
 Perform a "soft delete".  Specifying this flag overrides the default behavior of
 rebuilding the entire WIM after deleting an image.  Instead, only minimal
index dc9bef7..6cea5fa 100644 (file)
@@ -41,14 +41,19 @@ images are being exported, make the image that was the bootable image of the
 source WIM also the bootable image of the destination WIM.
 .TP
 \fB--check\fR
-Before exporting the image(s), verify the integrity of the source and
-destination WIMs if extra integrity information is present.  Also include extra
-integrity information in the destination WIM, even if it was not present before.
+Before exporting the image(s), verify the integrity of the source WIM,
+destination WIM, and any referenced WIMs whenever they have extra integrity
+information present.  Also include extra integrity information in the
+destination WIM, even if it was not present before.
 .TP
 \fB--nocheck\fR
 Do not include extra integrity information in the destination WIM, even if it
 was present before.
 .TP
+\fB--include-integrity\fR
+Include extra integrity information in the destination WIM, i.e. like
+\fB--check\fR but don't do any verification beforehand.
+.TP
 \fB--compress\fR=\fITYPE\fR[:\fILEVEL\fR]
 Specify the compression type, and optionally the compression level for that
 compression type, for \fIDEST_WIMFILE\fR.  Note that if \fIDEST_WIMFILE\fR
index 789c0db..0567517 100644 (file)
@@ -31,12 +31,16 @@ Windows PE from the WIM.
 .TP
 \fB--check\fR
 Verify the integrity of WIM if it contains extra integrity information.  In
-addition, if modifying the WIM, include extra integrity information in the
-modified WIM, even if it was not present before.
+addition, if modifying the WIM, add extra integrity information if it was not
+present before.
 .TP
 \fB--nocheck\fR
 If modifying the WIM, remove its extra integrity information, if it had any.
 .TP
+\fB--include-integrity\fR
+If modifying the WIM, add extra integrity information if it was not present
+before, i.e. like \fB--check\fR but don't also do the verification beforehand.
+.TP
 \fB--image-property\fR \fINAME\fR=\fIVALUE\fR
 Assign an arbitrary property to the specified \fIIMAGE\fR in the XML document of
 the WIM.  \fINAME\fR is an element path such as "WINDOWS/VERSION/MAJOR", and
index eb7b400..6073aab 100644 (file)
@@ -15,6 +15,10 @@ When reading each \fISPLIT_WIM_PART\fR, verify its integrity if it contains
 extra integrity information.  In addition, include extra integrity information
 in \fIOUT_WIMFILE\fR, even if the split WIM parts did not contain this
 information.
+.TP
+\fB--include-integrity\fR
+Include extra integrity information in \fIOUT_WIMFILE\fR, i.e. like
+\fB--check\fR but don't also verify the split WIM parts beforehand.
 .SH EXAMPLES
 Join a split WIM, with the parts named `windows*.swm' where the * is anything
 (usually the number of the part, except for the first part which may have no
index 832279d..657f7df 100644 (file)
@@ -25,6 +25,10 @@ even if it was not present before.
 Do not include extra integrity information in the optimized WIM, even if it was
 present before.
 .TP
+\fB--include-integrity\fR
+Include extra integrity information in the optimized WIM, i.e. like
+\fB--check\fR but don't also verify the WIM beforehand.
+.TP
 \fB--recompress\fR
 Recompress all data in the WIM while optimizing it.  This will significantly
 increase the time needed to optimize the WIM, but it may result in a better
index 06ac0d3..de1eb20 100644 (file)
@@ -16,6 +16,10 @@ having names numbered in order of the parts.
 Before splitting the WIM, verify its integrity if it contains extra integrity
 information.  Also include extra integrity information in each split WIM part,
 even if \fIWIMFILE\fR did not contain it.
+.TP
+\fB--include-integrity\fR
+Include extra integrity information in each split WIM part, i.e. like
+\fB--check\fR but don't also verify \fIWIMFILE\fR beforehand.
 .SH EXAMPLES
 Splits the WIM 'windows.wim' into 'windows.swm', 'windows2.swm', 'windows3.swm',
 etc. where each part is at most 100 MiB:
index e4e7b01..a3beadf 100644 (file)
@@ -102,6 +102,10 @@ Before updating the WIM, verify its integrity if it contains extra integrity
 information.  Also include extra integrity information in the updated WIM even
 if it was not present before.
 .TP
+\fB--include-integrity\fR
+Include extra integrity information in the updated WIM, i.e. like \fB--check\fR
+but don't also verify the WIM beforehand.
+.TP
 \fB--threads\fR=\fINUM_THREADS\fR
 Number of threads to use for compressing newly added files.  Default: autodetect
 (number of processors).
index 69d7a6c..a10ac48 100644 (file)
@@ -177,6 +177,7 @@ enum {
        IMAGEX_FORCE_OPTION,
        IMAGEX_HEADER_OPTION,
        IMAGEX_IMAGE_PROPERTY_OPTION,
+       IMAGEX_INCLUDE_INTEGRITY_OPTION,
        IMAGEX_INCLUDE_INVALID_NAMES_OPTION,
        IMAGEX_LAZY_OPTION,
        IMAGEX_METADATA_OPTION,
@@ -241,6 +242,7 @@ static const struct option capture_or_append_options[] = {
        {T("check"),       no_argument,       NULL, IMAGEX_CHECK_OPTION},
        {T("no-check"),    no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
        {T("nocheck"),     no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
+       {T("include-integrity"), no_argument, NULL, IMAGEX_INCLUDE_INTEGRITY_OPTION},
        {T("compress"),    required_argument, NULL, IMAGEX_COMPRESS_OPTION},
        {T("chunk-size"),  required_argument, NULL, IMAGEX_CHUNK_SIZE_OPTION},
        {T("solid"),       no_argument,      NULL, IMAGEX_SOLID_OPTION},
@@ -273,6 +275,7 @@ static const struct option capture_or_append_options[] = {
 
 static const struct option delete_options[] = {
        {T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION},
+       {T("include-integrity"), no_argument, NULL, IMAGEX_INCLUDE_INTEGRITY_OPTION},
        {T("soft"),  no_argument, NULL, IMAGEX_SOFT_OPTION},
        {T("unsafe-compact"), no_argument, NULL, IMAGEX_UNSAFE_COMPACT_OPTION},
        {NULL, 0, NULL, 0},
@@ -291,6 +294,7 @@ static const struct option export_options[] = {
        {T("check"),       no_argument,       NULL, IMAGEX_CHECK_OPTION},
        {T("nocheck"),     no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
        {T("no-check"),    no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
+       {T("include-integrity"), no_argument, NULL, IMAGEX_INCLUDE_INTEGRITY_OPTION},
        {T("compress"),    required_argument, NULL, IMAGEX_COMPRESS_OPTION},
        {T("recompress"),  no_argument,       NULL, IMAGEX_RECOMPRESS_OPTION},
        {T("chunk-size"),  required_argument, NULL, IMAGEX_CHUNK_SIZE_OPTION},
@@ -334,6 +338,7 @@ static const struct option info_options[] = {
        {T("check"),        no_argument,       NULL, IMAGEX_CHECK_OPTION},
        {T("nocheck"),      no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
        {T("no-check"),     no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
+       {T("include-integrity"), no_argument,  NULL, IMAGEX_INCLUDE_INTEGRITY_OPTION},
        {T("extract-xml"),  required_argument, NULL, IMAGEX_EXTRACT_XML_OPTION},
        {T("header"),       no_argument,       NULL, IMAGEX_HEADER_OPTION},
        {T("lookup-table"), no_argument,       NULL, IMAGEX_BLOBS_OPTION},
@@ -345,6 +350,7 @@ static const struct option info_options[] = {
 
 static const struct option join_options[] = {
        {T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION},
+       {T("include-integrity"), no_argument, NULL, IMAGEX_INCLUDE_INTEGRITY_OPTION},
        {NULL, 0, NULL, 0},
 };
 
@@ -365,6 +371,7 @@ static const struct option optimize_options[] = {
        {T("check"),       no_argument,       NULL, IMAGEX_CHECK_OPTION},
        {T("nocheck"),     no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
        {T("no-check"),    no_argument,       NULL, IMAGEX_NOCHECK_OPTION},
+       {T("include-integrity"), no_argument, NULL, IMAGEX_INCLUDE_INTEGRITY_OPTION},
        {T("compress"),    required_argument, NULL, IMAGEX_COMPRESS_OPTION},
        {T("recompress"),  no_argument,       NULL, IMAGEX_RECOMPRESS_OPTION},
        {T("chunk-size"),  required_argument, NULL, IMAGEX_CHUNK_SIZE_OPTION},
@@ -381,6 +388,7 @@ static const struct option optimize_options[] = {
 
 static const struct option split_options[] = {
        {T("check"), no_argument, NULL, IMAGEX_CHECK_OPTION},
+       {T("include-integrity"), no_argument, NULL, IMAGEX_INCLUDE_INTEGRITY_OPTION},
        {NULL, 0, NULL, 0},
 };
 
@@ -403,6 +411,7 @@ static const struct option update_options[] = {
         * update_command_add_option().  */
        {T("threads"),     required_argument, NULL, IMAGEX_THREADS_OPTION},
        {T("check"),       no_argument,       NULL, IMAGEX_CHECK_OPTION},
+       {T("include-integrity"), no_argument, NULL, IMAGEX_INCLUDE_INTEGRITY_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},
@@ -1895,6 +1904,8 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd)
                        break;
                case IMAGEX_CHECK_OPTION:
                        open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                case IMAGEX_NOCHECK_OPTION:
@@ -2428,6 +2439,8 @@ imagex_delete(int argc, tchar **argv, int cmd)
                switch (c) {
                case IMAGEX_CHECK_OPTION:
                        open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                case IMAGEX_SOFT_OPTION:
@@ -2889,6 +2902,8 @@ imagex_export(int argc, tchar **argv, int cmd)
                        break;
                case IMAGEX_CHECK_OPTION:
                        open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                case IMAGEX_NOCHECK_OPTION:
@@ -3344,8 +3359,6 @@ imagex_info(int argc, tchar **argv, int cmd)
 {
        int c;
        bool boot         = false;
-       bool check        = false;
-       bool nocheck      = false;
        bool header       = false;
        bool blobs        = false;
        bool xml          = false;
@@ -3358,6 +3371,7 @@ imagex_info(int argc, tchar **argv, int cmd)
        int image;
        int ret;
        int open_flags = 0;
+       int write_flags = 0;
        struct wimlib_wim_info info;
 
        for_opt(c, info_options) {
@@ -3366,10 +3380,13 @@ imagex_info(int argc, tchar **argv, int cmd)
                        boot = true;
                        break;
                case IMAGEX_CHECK_OPTION:
-                       check = true;
+                       open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
+                       write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                case IMAGEX_NOCHECK_OPTION:
-                       nocheck = true;
+                       write_flags |= WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY;
                        break;
                case IMAGEX_HEADER_OPTION:
                        header = true;
@@ -3423,14 +3440,6 @@ imagex_info(int argc, tchar **argv, int cmd)
                        goto out;
        }
 
-       if (check && nocheck) {
-               imagex_error(T("Can't specify both --check and --nocheck"));
-               goto out_err;
-       }
-
-       if (check)
-               open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
-
        ret = wimlib_open_wim_with_progress(wimfile, open_flags, &wim,
                                            imagex_progress_func, NULL);
        if (ret)
@@ -3568,15 +3577,11 @@ imagex_info(int argc, tchar **argv, int cmd)
                /* Only call wimlib_overwrite() if something actually needs to
                 * be changed.  */
                if (boot || any_property_changes ||
-                   (check && !info.has_integrity_table) ||
-                   (nocheck && info.has_integrity_table))
+                   ((write_flags & WIMLIB_WRITE_FLAG_CHECK_INTEGRITY) &&
+                    !info.has_integrity_table) ||
+                   ((write_flags & WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY) &&
+                    info.has_integrity_table))
                {
-                       int write_flags = 0;
-
-                       if (check)
-                               write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
-                       if (nocheck)
-                               write_flags |= WIMLIB_WRITE_FLAG_NO_CHECK_INTEGRITY;
                        ret = wimlib_overwrite(wim, write_flags, 1);
                } else {
                        imagex_printf(T("The file \"%"TS"\" was not modified "
@@ -3593,7 +3598,6 @@ out:
 
 out_usage:
        usage(CMD_INFO, stderr);
-out_err:
        ret = -1;
        goto out;
 }
@@ -3612,6 +3616,8 @@ imagex_join(int argc, tchar **argv, int cmd)
                switch (c) {
                case IMAGEX_CHECK_OPTION:
                        swm_open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
                        wim_write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                default:
@@ -3792,6 +3798,8 @@ imagex_optimize(int argc, tchar **argv, int cmd)
                switch (c) {
                case IMAGEX_CHECK_OPTION:
                        open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                case IMAGEX_NOCHECK_OPTION:
@@ -3939,6 +3947,8 @@ imagex_split(int argc, tchar **argv, int cmd)
                switch (c) {
                case IMAGEX_CHECK_OPTION:
                        open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                default:
@@ -4084,6 +4094,8 @@ imagex_update(int argc, tchar **argv, int cmd)
                        break;
                case IMAGEX_CHECK_OPTION:
                        open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+                       /* fall-through */
+               case IMAGEX_INCLUDE_INTEGRITY_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
                        break;
                case IMAGEX_REBUILD_OPTION: