Skip to content

Commit 7d4a8d7

Browse files
committed
real status messages
1 parent f16d832 commit 7d4a8d7

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changes
2+
3+
## Unreleased
4+
5+
1. Replaced status messages with nicer, easier-to-read messages in color.

windows-esd-to-iso

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,70 @@
11
#!/bin/sh
22

3-
set -ex
3+
# Color support from portable-color <https://mattiebee.dev/portable-color>
4+
5+
_try_color() {
6+
[ -n "${NO_COLOR}" ] && return 1
7+
[ -n "${CLICOLOR_FORCE}" ] && return 0
8+
test -t 1 || return 1
9+
[ -n "${CLICOLOR}" ] && return 0
10+
return 0
11+
}
12+
setup_color() {
13+
TPUT=$(which tput 2>/dev/null) && _try_color || TPUT=true
14+
}
15+
_qtput() {
16+
[ -z "${TPUT}" ] && return 0 # if not set up, don't do anything
17+
"${TPUT}" "$@" 2>/dev/null || true
18+
}
19+
_twrap() {
20+
output="$1"
21+
shift
22+
_qtput "$@"
23+
printf %s "$output"
24+
_qtput sgr0
25+
}
26+
bold() { _twrap "$1" bold; }
27+
green() { _twrap "$1" setaf 2; }
28+
blue() { _twrap "$1" setaf 4; }
29+
30+
print_task() { echo "$(green "==>") $(bold "$@")"; }
31+
print_subtask() { echo "$(blue "==>") $(bold "$@")"; }
32+
33+
set -e
34+
setup_color
435

536
esd="${1}"
637
tmpdir=$(mktemp -d)
738

839
__cleanup() {
9-
set -e
40+
print_task "Cleaning up $(green "${tmpdir}")"
1041
rm -rf "${tmpdir}"
1142
}
1243
trap __cleanup EXIT
1344

45+
print_task "Exporting images from $(green "${esd}")"
46+
1447
image_count=$(wiminfo "${esd}" --header | grep '^Image Count' | cut -d= -f 2 )
48+
echo "Found ${image_count} images."
1549

50+
print_subtask "Exporting image 1"
1651
wimapply "${esd}" 1 "${tmpdir}"
17-
wimexport "${esd}" 2 "${tmpdir}/sources/boot.wim" --compress=LZX --chunk-size 32K
18-
wimexport "${esd}" 3 "${tmpdir}/sources/boot.wim" --compress=LZX --chunk-size 32K --boot
1952

20-
for index in $(seq 4 ${image_count})
53+
print_subtask "Exporting image 2"
54+
wimexport "${esd}" 2 "${tmpdir}/sources/boot.wim" --compress=LZX --chunk-size=32K
55+
56+
print_subtask "Exporting image 3"
57+
wimexport "${esd}" 3 "${tmpdir}/sources/boot.wim" --compress=LZX --chunk-size=32K --boot
58+
59+
for index in $(seq 4 "${image_count}")
2160
do
22-
wimexport "${esd}" "${index}" "${tmpdir}/sources/install.esd" --compress=LZMS --chunk-size 128K
61+
print_subtask "Exporting image ${index}"
62+
wimexport "${esd}" "${index}" "${tmpdir}/sources/install.esd" --compress=LZMS --chunk-size 128K --recompress
2363
done
2464

2565
basename="$(basename "${esd}" .esd)"
2666
iso="${basename}.iso"
2767

2868
rm -f "${iso}"
69+
print_task "Creating ${iso}"
2970
hdiutil makehybrid -o "${iso}" -iso -udf -hard-disk-boot -eltorito-boot "${tmpdir}/efi/microsoft/boot/efisys.bin" -iso-volume-name ESD_ISO -udf-volume-name ESD-ISO "${tmpdir}"
30-

0 commit comments

Comments
 (0)