From: Eric Biggers Date: Tue, 29 Apr 2014 22:45:37 +0000 (-0500) Subject: mkwinpeimg: Support writing ISO image to stdout X-Git-Tag: v1.7.0~230 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=212ce21094a1b39aac2c0f183a8d97f530a6ba4b mkwinpeimg: Support writing ISO image to stdout --- diff --git a/NEWS b/NEWS index 727f8ab5..e44ff0be 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ Version 1.6.3-BETA: Fixed reading out-of-order entries in lookup table of version 3584 WIM / ESD files. + The 'mkwinpeimg' script now supports writing the ISO image to standard + output. + The shared library version has been bumped up; however, there are only a few incompatibilities: diff --git a/doc/man1/mkwinpeimg.1.in b/doc/man1/mkwinpeimg.1.in index befa2804..b0a5e96a 100644 --- a/doc/man1/mkwinpeimg.1.in +++ b/doc/man1/mkwinpeimg.1.in @@ -24,7 +24,8 @@ required so that the FAT filesystem can be created without root privileges. .PP The other type of bootable image that \fBmkwinpeimg\fR can make is a bootable ISO image. To make this type of image, give the \fB--iso\fR option. -\fBmkisofs\fR(1) is required to make this type of image. +\fBmkisofs\fR(1) is required to make this type of image. In \fB--iso\fR mode, +you can specify \fIIMAGE\fR as "-" to write the ISO image to standard output. .PP If you make a disk image, you could put it on a USB drive, and if you make an ISO image, you could put it on a CD. In addition, both types of images can be diff --git a/programs/mkwinpeimg.in b/programs/mkwinpeimg.in index 654249b2..48ffebb3 100755 --- a/programs/mkwinpeimg.in +++ b/programs/mkwinpeimg.in @@ -256,7 +256,7 @@ EOF check_needed_programs() { if [ -z "$waik_dir" -o -n "$modify_wim" ]; then - if ! type -P @IMAGEX_PROGNAME@ &> /dev/null ; then + if ! type -P "$imagex" &> /dev/null ; then cat << EOF ERROR: To make a customized image of Windows PE, we need the "$imagex" program from "wimlib" so that we can modify the boot.wim file. However, "$imagex" @@ -446,7 +446,7 @@ make_iso_img() { mkisofs -sysid "" -A "" -V "Microsoft Windows PE ($arch)" -d -N \ -b etfsboot.com -no-emul-boot -c boot.cat -hide etfsboot.com \ - -hide boot.cat -quiet -o "$image" "$tmp_dir" || stat_fail + -hide boot.cat -quiet -o "$image" "$tmp_dir" 1>&4 || stat_fail stat_done } @@ -506,6 +506,22 @@ make_disk_img() { calc_columns tmp_dir="$(mktemp -d)" process_command_line "$@" + +if [ "$image" = "-" ] ; then + # Writing image to standard output + if [ "$make" != iso ]; then + echo "ERROR: Writing image to standard output is only supported in --iso mode!" + exit 1 + fi + # We can't print anything to standard output except the ISO image + # itself. Play with the file descriptors. + + exec 4>&1 # 4 is now the original standard output. + exec 1>&2 # Anything that goes to standard output now, by default, + # actually goes to standard error. +else + exec 4>&1 # 4 is now a copy of standard output +fi if [ -z "$waik_dir" ]; then find_windows_dir fi @@ -538,4 +554,6 @@ elif [ $make = disk ]; then make_disk_img "$image" fi -echo "The image ($image) is $(stat -c %s "$image") bytes." +if [ "$image" != "-" ]; then + echo "The image ($image) is $(stat -c %s "$image") bytes." +fi