@@ -35,13 +35,13 @@ set -e
35
35
setup_color
36
36
37
37
if [ -z " $1 " ] || [ " $1 " = " -h" ]; then
38
- echo " $( red " Usage:" ) $( basename " $0 " ) ESD"
39
- exit 0
38
+ echo " $( red " Usage:" ) $( basename " $0 " ) ESD"
39
+ exit 0
40
40
fi
41
41
42
42
check_tool () {
43
- if ! which " $1 " > /dev/null; then
44
- echo " $( red " Error:" ) wimlib tools not found"
43
+ if ! which " $1 " > /dev/null; then
44
+ echo " $( red " Error:" ) wimlib tools not found"
45
45
exit 1
46
46
fi
47
47
}
@@ -52,21 +52,25 @@ check_tool wimexport
52
52
esd=" $1 "
53
53
54
54
if [ ! -f " ${esd} " ]; then
55
- echo " $( red " Error:" ) ${esd} not found"
56
- exit 2
55
+ echo " $( red " Error:" ) ${esd} not found"
56
+ exit 2
57
57
fi
58
58
59
59
tmpdir=$( mktemp -d)
60
60
61
61
__cleanup () {
62
- print_task " Cleaning up $( green " ${tmpdir} " ) "
63
- rm -rf " ${tmpdir} "
62
+ print_task " Cleaning up $( green " ${tmpdir} " ) "
63
+ rm -rf " ${tmpdir} "
64
64
}
65
65
trap __cleanup EXIT
66
66
67
67
print_task " Exporting images from $( green " ${esd} " ) "
68
68
69
- image_count=$( wiminfo " ${esd} " --header | grep ' ^Image Count' | cut -d= -f 2 )
69
+ image_count=$( wiminfo " ${esd} " --header | grep ' ^Image Count' | cut -d= -f 2)
70
+ if ! [ " ${image_count} " -gt 0 ] 2> /dev/null; then
71
+ echo " $( red " Error:" ) could not get ${esd} image count"
72
+ exit 3
73
+ fi
70
74
echo " Found ${image_count} images."
71
75
72
76
print_subtask " Exporting image 1"
@@ -80,7 +84,7 @@ wimexport "${esd}" 3 "${tmpdir}/sources/boot.wim" --compress=LZX --chunk-size=32
80
84
81
85
for index in $( seq 4 " ${image_count} " )
82
86
do
83
- print_subtask " Exporting image ${index} "
87
+ print_subtask " Exporting image ${index} "
84
88
wimexport " ${esd} " " ${index} " " ${tmpdir} /sources/install.esd" --compress=LZMS --chunk-size 128K --recompress
85
89
done
86
90
0 commit comments