]> wimlib.net Git - wimlib/blobdiff - programs/mkwinpeimg
mkwinpeimg: Add IA64 arch and update docs
[wimlib] / programs / mkwinpeimg
index a21651af049a4091db93073406e75da34c93b413..3075c28d112f31bbe1310569bb219709e8fb3c94 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # This script can make a customized bootable image of Windows PE.
 #
 #
 # This script can make a customized bootable image of Windows PE.
 #
@@ -20,6 +20,7 @@
 
 script_name="$(basename $0)"
 PREFIX_REG="::"
 
 script_name="$(basename $0)"
 PREFIX_REG="::"
+WIMLIB_VERSION=1.2.3
 
 calc_columns () {
        STAT_COL=80
 
 calc_columns () {
        STAT_COL=80
@@ -104,7 +105,10 @@ Usage: $script_name [OPTIONS] IMAGE
                               specified.
   -O, --overlay=DIR        Adds all the files in DIR to the Windows PE image.
   -t, --tmp-dir=DIR        Use DIR as the temporary base of the ISO filesystem.  
                               specified.
   -O, --overlay=DIR        Adds all the files in DIR to the Windows PE image.
   -t, --tmp-dir=DIR        Use DIR as the temporary base of the ISO filesystem.  
-                              Defaults to making one using \"mktemp -d\".
+                              Defaults to making one using "mktemp -d".
+  -a, --arch=ARCH          Use the Windows PE version from the WAIK that has
+                              the CPU architecture ARCH.  Possible values:
+                              "x86", "amd64", or "ia64".  Default is "x86".
   -h, --help               Display this information.
   -v, --version            Show version information.
 
   -h, --help               Display this information.
   -v, --version            Show version information.
 
@@ -113,7 +117,7 @@ EOF
 }
 
 version() {
 }
 
 version() {
-       echo "$script_name (wimlib 0.4.8)"
+       echo "$script_name (wimlib $WIMLIB_VERSION)"
        exit 0
 }
 
        exit 0
 }
 
@@ -121,12 +125,17 @@ make=disk
 
 process_command_line() {
 
 
 process_command_line() {
 
-       if ! options=$(getopt -o oiw:W:s:O:t:A:hv -l \
-               only-wim,iso,wim:,windows-dir:,start-script:,overlay:,tmp-dir:,waik-dir:,help,version \
+       if ! options=$(getopt -o oiw:W:s:O:t:A:a:hv -l \
+               only-wim,iso,wim:,windows-dir:,start-script:,overlay:,tmp-dir:,waik-dir:,arch:,help,version \
                                -- "$@" ); then
                usage
                exit 1
        fi
                                -- "$@" ); then
                usage
                exit 1
        fi
+
+       # default arch value
+       arch="X86"
+       arch_id="1"
+
        eval set -- "$options"
        while [ $# -gt 0 ]; do
                case "$1" in
        eval set -- "$options"
        while [ $# -gt 0 ]; do
                case "$1" in
@@ -170,6 +179,22 @@ process_command_line() {
                        tmp_dir="$2"
                        shift
                        ;;
                        tmp_dir="$2"
                        shift
                        ;;
+               -a|--arch)
+                       if [ "$2" == "x86" ]; then
+                               arch="X86"
+                               arch_id="1"
+                       elif [ "$2" == "ia64" ]; then
+                               arch="IA64"
+                               arch_id="2"
+                       elif [ "$2" == "amd64" ]; then
+                               arch="AMD64"
+                               arch_id="3"
+                       else 
+                               echo "ERROR: $2 is not a valid arch (x86/amd64/ia64)"
+                               exit 1
+                       fi
+                       shift
+                       ;;
                -h|--help)
                        usage
                        exit 0
                -h|--help)
                        usage
                        exit 0
@@ -189,6 +214,7 @@ process_command_line() {
                esac
                shift
        done
                esac
                shift
        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."
        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."
@@ -198,7 +224,6 @@ process_command_line() {
        fi
 }
 
        fi
 }
 
-
 find_windows_dir() {
        if [ -z "$windows_dir_specified" ]; then
                for windows_dir in /mnt/windows /mnt/windows7 /mnt/windows8; do
 find_windows_dir() {
        if [ -z "$windows_dir_specified" ]; then
                for windows_dir in /mnt/windows /mnt/windows7 /mnt/windows8; do
@@ -231,8 +256,8 @@ check_needed_programs() {
        if [ -z "$waik_dir" -o -n "$modify_wim" ]; then
                if ! type -P imagex &> /dev/null ; then
                        cat << EOF
        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\"
+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"
 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
@@ -242,8 +267,8 @@ EOF
        if [ $make = iso ]; then
                if ! type -P mkisofs &> /dev/null ; then
                        cat << EOF 
        if [ $make = iso ]; then
                if ! type -P mkisofs &> /dev/null ; then
                        cat << 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\"
+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
 instead of an ISO image.
 EOF
 package to continue, or try omitting the --iso option to make a disk image
 instead of an ISO image.
 EOF
@@ -252,8 +277,8 @@ EOF
        elif [ $make = disk ] ; then
                if ! type -P syslinux &> /dev/null ; then
                        cat << EOF
        elif [ $make = disk ] ; then
                if ! type -P syslinux &> /dev/null ; then
                        cat << 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\"
+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
 of a disk image.
 EOF
 package to continue, or try using the --iso option to make an ISO image instead
 of a disk image.
 EOF
@@ -262,10 +287,10 @@ EOF
 
                if ! type -P mformat mcopy &> /dev/null; then
                        cat << EOF
 
                if ! type -P mformat mcopy &> /dev/null; then
                        cat << 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
+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.
 format a FAT filesystem and copy files to it without needing root privileges.
-Please install \"mtools\" if you want to make a disk image of Windows PE.  Or,
+Please install "mtools" if you want to make a disk image of Windows PE.  Or,
 try using the --iso option to make an ISO image instead of a disk image.
 EOF
                fi
 try using the --iso option to make an ISO image instead of a disk image.
 EOF
                fi
@@ -275,8 +300,8 @@ EOF
                if ! type -P cabextract &> /dev/null ; then
                        cat << EOF
 ERROR: The boot files in the Windows Automated Installation Kit (WAIK) are
                if ! type -P cabextract &> /dev/null ; then
                        cat << 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
+inside cabinet archives.  To extract these files, we need the "cabextract"
+program, but it doesn't seem to be installed.  Please install "cabextract" to
 continue.
 EOF
                        exit 1
 continue.
 EOF
                        exit 1
@@ -286,20 +311,19 @@ EOF
 }
 
 get_primary_boot_files() {
 }
 
 get_primary_boot_files() {
-
        if [ -n "$waik_dir" ]; then
                # Get boot files from the WAIK.
 
        if [ -n "$waik_dir" ]; then
                # Get boot files from the WAIK.
 
-               stat_busy "Copying primary boot files from the Windows Automated Installation Kit ($waik_dir)"
+               stat_busy "Copying primary boot files from the Windows Automated Installation Kit ($waik_dir, $arch)"
                if [ $make = iso ]; then
                if [ $make = iso ]; then
-                       cabextract "$waik_dir"/wAIKX86.msi -F F_WINPE_X86_etfsboot.com -p \
+                       cabextract "$waik_dir"/wAIK${arch}.msi -F F_WINPE_${arch}_etfsboot.com -p \
                                        > "$tmp_dir"/etfsboot.com || stat_fail
                fi
                                        > "$tmp_dir"/etfsboot.com || stat_fail
                fi
-               cabextract "$waik_dir"/wAIKX86.msi -F F1_BOOTMGR -p \
+               cabextract "$waik_dir"/wAIK${arch}.msi -F F${arch_id}_BOOTMGR -p \
                                > "$tmp_dir"/bootmgr || stat_fail
                                > "$tmp_dir"/bootmgr || stat_fail
-               cabextract "$waik_dir"/wAIKX86.msi -F F_WINPE_X86_boot.sdi -p \
+               cabextract "$waik_dir"/wAIK${arch}.msi -F F_WINPE_${arch}_boot.sdi -p \
                                > "$tmp_dir"/boot/boot.sdi || stat_fail
                                > "$tmp_dir"/boot/boot.sdi || stat_fail
-               cabextract "$waik_dir"/wAIKX86.msi -F F_WINPE_X86_bcd -p \
+               cabextract "$waik_dir"/wAIK${arch}.msi -F F_WINPE_${arch}_bcd -p \
                                > "$tmp_dir"/boot/bcd || stat_fail
                stat_done
        else
                                > "$tmp_dir"/boot/bcd || stat_fail
                stat_done
        else
@@ -326,7 +350,7 @@ get_boot_wim() {
                if [ -n "$waik_dir" ]; then
                        # WAIK
                        stat_busy "Extracting boot.wim from \"$waik_dir/WinPE.cab\""
                if [ -n "$waik_dir" ]; then
                        # WAIK
                        stat_busy "Extracting boot.wim from \"$waik_dir/WinPE.cab\""
-                       cabextract "$waik_dir/WinPE.cab" -F F1_WINPE.WIM -p \
+                       cabextract "$waik_dir/WinPE.cab" -F F${arch_id}_WINPE.WIM -p \
                                        > "$boot_wim" 2>/dev/null || stat_fail
                        stat_done
                else
                                        > "$boot_wim" 2>/dev/null || stat_fail
                        stat_done
                else
@@ -335,7 +359,7 @@ get_boot_wim() {
                        wim="$windows_dir/sources/boot.wim"
                        stat_busy "Exporting image from \"$wim\""
                        imagex export "$windows_dir"/sources/boot.wim 2 \
                        wim="$windows_dir/sources/boot.wim"
                        stat_busy "Exporting image from \"$wim\""
                        imagex export "$windows_dir"/sources/boot.wim 2 \
-                                               --compress --boot "$boot_wim" || stat_fail
+                                               --boot "$boot_wim" || stat_fail
                        stat_done
                fi
        else
                        stat_done
                fi
        else
@@ -347,7 +371,6 @@ get_boot_wim() {
 }
 
 modify_boot_wim() {
 }
 
 modify_boot_wim() {
-
        boot_wim="$1"
        mnt_dir="$2"
 
        boot_wim="$1"
        mnt_dir="$2"
 
@@ -391,7 +414,6 @@ EOF
 }
 
 make_iso_img() {
 }
 
 make_iso_img() {
-
        image="$1"
 
        # Make the ISO using the mkisofs command from cdrkit
        image="$1"
 
        # Make the ISO using the mkisofs command from cdrkit
@@ -403,11 +425,9 @@ make_iso_img() {
                -hide boot.cat -quiet -o "$image" "$tmp_dir" || stat_fail
 
        stat_done
                -hide boot.cat -quiet -o "$image" "$tmp_dir" || stat_fail
 
        stat_done
-
 }
 
 make_disk_img() {
 }
 
 make_disk_img() {
-
        image="$1"
 
        stat_busy "Making disk image \"$image\""
        image="$1"
 
        stat_busy "Making disk image \"$image\""
@@ -444,7 +464,6 @@ EOF
        stat_done
 }
 
        stat_done
 }
 
-
 calc_columns
 tmp_dir="$(mktemp -d)"
 mnt_dir="$tmp_dir"/.boot.wim.mount
 calc_columns
 tmp_dir="$(mktemp -d)"
 mnt_dir="$tmp_dir"/.boot.wim.mount