]> wimlib.net Git - wimlib/blobdiff - programs/mkwinpeimg.in
lzms_decompress.c: pack states together in struct lzms_decompressor
[wimlib] / programs / mkwinpeimg.in
index 48ffebb3442dbf2346ada080ce44bdf482fc84ab..f95e8e96090b47bdcefffaa77f2d3b807b7831e4 100755 (executable)
@@ -21,7 +21,6 @@
 script_name="$(basename "$0")"
 PREFIX_REG="::"
 WIMLIB_VERSION=@VERSION@
 script_name="$(basename "$0")"
 PREFIX_REG="::"
 WIMLIB_VERSION=@VERSION@
-imagex=@IMAGEX_PROGNAME@
 
 calc_columns () {
        STAT_COL=80
 
 calc_columns () {
        STAT_COL=80
@@ -148,7 +147,7 @@ process_command_line() {
                        windows_dir="$2"
                        windows_dir_specified=yes
                        if [ -n "$waik_dir" ]; then
                        windows_dir="$2"
                        windows_dir_specified=yes
                        if [ -n "$waik_dir" ]; then
-                               echo "ERROR: Cannot specify both --windows-dir and --waik-dir!"
+                               echo 1>&2 "ERROR: Cannot specify both --windows-dir and --waik-dir!"
                                exit 1
                        fi
                        shift
                                exit 1
                        fi
                        shift
@@ -156,7 +155,7 @@ process_command_line() {
                -A|--waik-dir)
                        waik_dir="$2"
                        if [ -n "$windows_dir" ]; then
                -A|--waik-dir)
                        waik_dir="$2"
                        if [ -n "$windows_dir" ]; then
-                               echo "ERROR: Cannot specify both --windows-dir and --waik-dir!"
+                               echo 1>&2 "ERROR: Cannot specify both --windows-dir and --waik-dir!"
                                exit 1
                        fi
                        shift
                                exit 1
                        fi
                        shift
@@ -192,7 +191,7 @@ process_command_line() {
                                arch="AMD64"
                                arch_id="3"
                        else
                                arch="AMD64"
                                arch_id="3"
                        else
-                               echo "ERROR: $2 is not a valid arch (x86/amd64)"
+                               echo 1>&2 "ERROR: $2 is not a valid arch (x86/amd64)"
                                exit 1
                        fi
                        shift
                                exit 1
                        fi
                        shift
@@ -209,7 +208,7 @@ process_command_line() {
                        break
                        ;;
                *)
                        break
                        ;;
                *)
-                       echo "Invalid option \"$1\""
+                       echo 1>&2 "Invalid option \"$1\""
                        usage
                        exit 1
                        ;;
                        usage
                        exit 1
                        ;;
@@ -218,8 +217,8 @@ process_command_line() {
        done
 
        if [ $# -ne 1 ]; then
        done
 
        if [ $# -ne 1 ]; then
-               echo "You must specify the name of the image file to create!"
-               echo "Run \"$script_name -h\" to see usage information."
+               echo 1>&2 "You must specify the name of the image file to create!"
+               echo 1>&2 "Run \"$script_name -h\" to see usage information."
                exit 1
        else
                image="$1"
                exit 1
        else
                image="$1"
@@ -236,17 +235,17 @@ find_windows_dir() {
        fi
        if [ ! -d "$windows_dir" ]; then
                if [ -z "$windows_dir_specified" ]; then
        fi
        if [ ! -d "$windows_dir" ]; then
                if [ -z "$windows_dir_specified" ]; then
-                       cat << EOF
+                       cat 1>&2 << EOF
 ERROR: Could not find the directory that the Windows 7 or 8 ISO image is mounted
 on!  Please specify this directory using the --windows-dir option.
 EOF
                else
 ERROR: Could not find the directory that the Windows 7 or 8 ISO image is mounted
 on!  Please specify this directory using the --windows-dir option.
 EOF
                else
-                       echo "ERROR: Could not find the directory \"$windows_dir\"!"
+                       echo 1>&2 "ERROR: Could not find the directory \"$windows_dir\"!"
                fi
                exit 1
        fi
        if [ ! -d "$windows_dir/sources" ]; then
                fi
                exit 1
        fi
        if [ ! -d "$windows_dir/sources" ]; then
-               cat << EOF
+               cat 1>&2 << EOF
 ERROR: The directory "$windows_dir" exists, but it seems that the Windows 7 or 8
 ISO image is not mounted on it.  Please mount the image to continue.
 EOF
 ERROR: The directory "$windows_dir" exists, but it seems that the Windows 7 or 8
 ISO image is not mounted on it.  Please mount the image to continue.
 EOF
@@ -256,10 +255,10 @@ EOF
 
 check_needed_programs() {
        if [ -z "$waik_dir" -o -n "$modify_wim" ]; then
 
 check_needed_programs() {
        if [ -z "$waik_dir" -o -n "$modify_wim" ]; 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"
+               if ! type -P wimlib-imagex &> /dev/null ; then
+                       cat 1>&2 << EOF
+ERROR: To make a customized image of Windows PE, we need the wimlib-imagex program
+from "wimlib" so that we can modify the boot.wim file.  However, wimlib-imagex
 doesn't seem to be installed.  Please install "wimlib" to continue.
 EOF
                        exit 1
 doesn't seem to be installed.  Please install "wimlib" to continue.
 EOF
                        exit 1
@@ -268,7 +267,7 @@ EOF
 
        if [ $make = iso ]; then
                if ! type -P mkisofs &> /dev/null ; then
 
        if [ $make = iso ]; then
                if ! type -P mkisofs &> /dev/null ; then
-                       cat << EOF
+                       cat 1>&2 << EOF
 ERROR: To make a bootable ISO image of Windows PE, we need the "mkisofs"
 program, but it doesn't seem to be installed.  Please install the "cdrkit"
 package to continue, or try omitting the --iso option to make a disk image
 ERROR: To make a bootable ISO image of Windows PE, we need the "mkisofs"
 program, but it doesn't seem to be installed.  Please install the "cdrkit"
 package to continue, or try omitting the --iso option to make a disk image
@@ -278,7 +277,7 @@ EOF
                fi
        elif [ $make = disk ] ; then
                if ! type -P syslinux &> /dev/null ; then
                fi
        elif [ $make = disk ] ; then
                if ! type -P syslinux &> /dev/null ; then
-                       cat << EOF
+                       cat 1>&2 << EOF
 ERROR: To make a bootable disk image of Windows PE, we need the "syslinux"
 program, but it doesn't seem to be installed.  Please install the "syslinux"
 package to continue, or try using the --iso option to make an ISO image instead
 ERROR: To make a bootable disk image of Windows PE, we need the "syslinux"
 program, but it doesn't seem to be installed.  Please install the "syslinux"
 package to continue, or try using the --iso option to make an ISO image instead
@@ -288,7 +287,7 @@ EOF
                fi
 
                if ! type -P mformat mcopy &> /dev/null; then
                fi
 
                if ! type -P mformat mcopy &> /dev/null; then
-                       cat << EOF
+                       cat 1>&2 << EOF
 ERROR: To make a bootable disk image of Windows PE, we need the "mformat" and
 "mcopy" programs from the "mtools" package.  These programs allow us to
 format a FAT filesystem and copy files to it without needing root privileges.
 ERROR: To make a bootable disk image of Windows PE, we need the "mformat" and
 "mcopy" programs from the "mtools" package.  These programs allow us to
 format a FAT filesystem and copy files to it without needing root privileges.
@@ -300,7 +299,7 @@ EOF
 
        if [ -n "$waik_dir" ] &&  [ -f "$waik_dir"/wAIK${arch}.msi ]; then
                if ! type -P cabextract &> /dev/null ; then
 
        if [ -n "$waik_dir" ] &&  [ -f "$waik_dir"/wAIK${arch}.msi ]; then
                if ! type -P cabextract &> /dev/null ; then
-                       cat << EOF
+                       cat 1>&2 << EOF
 ERROR: The boot files in the Windows Automated Installation Kit (WAIK) are
 inside cabinet archives.  To extract these files, we need the "cabextract"
 program, but it doesn't seem to be installed.  Please install "cabextract" to
 ERROR: The boot files in the Windows Automated Installation Kit (WAIK) are
 inside cabinet archives.  To extract these files, we need the "cabextract"
 program, but it doesn't seem to be installed.  Please install "cabextract" to
@@ -378,7 +377,7 @@ get_boot_wim() {
                        remove_setup=yes
                        wim="$windows_dir/sources/boot.wim"
                        stat_busy "Exporting image from \"$wim\""
                        remove_setup=yes
                        wim="$windows_dir/sources/boot.wim"
                        stat_busy "Exporting image from \"$wim\""
-                       "$imagex" export "$windows_dir"/sources/boot.wim 2 \
+                       wimlib-imagex export "$windows_dir"/sources/boot.wim 2 \
                                                --boot "$boot_wim" || stat_fail
                        stat_done
                fi
                                                --boot "$boot_wim" || stat_fail
                        stat_done
                fi
@@ -432,7 +431,7 @@ modify_boot_wim() {
        exec 3>&-
 
        stat_busy "Rebuilding WIM with changes made"
        exec 3>&-
 
        stat_busy "Rebuilding WIM with changes made"
-       "$imagex" update "$boot_wim" --rebuild \
+       wimlib-imagex update "$boot_wim" --rebuild \
                < "$tmp_dir/__mkwinpeimg.update.cmds" > /dev/null || stat_fail
        stat_done
 }
                < "$tmp_dir/__mkwinpeimg.update.cmds" > /dev/null || stat_fail
        stat_done
 }
@@ -510,7 +509,7 @@ process_command_line "$@"
 if [ "$image" = "-" ] ; then
        # Writing image to standard output
        if [ "$make" != iso ]; then
 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!"
+               echo 1>&2 "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
                exit 1
        fi
        # We can't print anything to standard output except the ISO image
@@ -529,7 +528,7 @@ if [ -n "$start_script" -o -n "$overlay" -o -n "$remove_setup" ]; then
        modify_wim=yes
 fi
 check_needed_programs
        modify_wim=yes
 fi
 check_needed_programs
-trap cleanup exit
+trap cleanup EXIT
 
 if [ $make != wim ]; then
        mkdir -p "$tmp_dir"/{boot,sources}
 
 if [ $make != wim ]; then
        mkdir -p "$tmp_dir"/{boot,sources}