mirror of
https://github.com/dockur/windows.git
synced 2026-07-07 05:07:26 +01:00
fix: Improve ESD image parsing (#1812)
This commit is contained in:
+26
-3
@@ -447,22 +447,45 @@ extractESD() {
|
|||||||
size=9606127360
|
size=9606127360
|
||||||
checkFreeSpace "$dir" "$size" || return 1
|
checkFreeSpace "$dir" "$size" || return 1
|
||||||
|
|
||||||
|
local esdInfo
|
||||||
|
esdInfo=$(wimlib-imagex info "$iso") || {
|
||||||
|
error "Cannot read ESD file information!"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
local esdImageCount
|
local esdImageCount
|
||||||
esdImageCount=$(wimlib-imagex info "$iso" | awk '/Image Count:/ {print $3}')
|
esdImageCount=$(awk '/Image Count:/ {print $3}' <<< "$esdInfo")
|
||||||
|
|
||||||
if [ -z "$esdImageCount" ]; then
|
if [ -z "$esdImageCount" ]; then
|
||||||
error "Cannot read the image count in ESD file!" && return 1
|
error "Cannot read the image count in ESD file!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sizes=$(wimlib-imagex info "$iso" | grep "Total Bytes:")
|
if (( esdImageCount < 3 )); then
|
||||||
links=$(wimlib-imagex info "$iso" | grep "Hard Link Bytes:")
|
error "Invalid ESD file: expected at least 3 images, found $esdImageCount."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sizes=$(grep "Total Bytes:" <<< "$esdInfo" || true)
|
||||||
|
links=$(grep "Hard Link Bytes:" <<< "$esdInfo" || true)
|
||||||
|
|
||||||
total1=$(awk "NR==1{ print; }" <<< "$sizes" | cut -d':' -f2 | sed 's/^ *//')
|
total1=$(awk "NR==1{ print; }" <<< "$sizes" | cut -d':' -f2 | sed 's/^ *//')
|
||||||
links1=$(awk "NR==1{ print; }" <<< "$links" | cut -d':' -f2 | sed 's/^ *//')
|
links1=$(awk "NR==1{ print; }" <<< "$links" | cut -d':' -f2 | sed 's/^ *//')
|
||||||
|
|
||||||
|
if [[ ! "$total1" =~ ^[0-9]+$ ]] || [[ ! "$links1" =~ ^[0-9]+$ ]]; then
|
||||||
|
error "Cannot read bootdisk size from ESD file!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
total=$(( total1 - links1 ))
|
total=$(( total1 - links1 ))
|
||||||
|
|
||||||
total3=$(awk "NR==3{ print; }" <<< "$sizes" | cut -d':' -f2 | sed 's/^ *//')
|
total3=$(awk "NR==3{ print; }" <<< "$sizes" | cut -d':' -f2 | sed 's/^ *//')
|
||||||
links3=$(awk "NR==3{ print; }" <<< "$links" | cut -d':' -f2 | sed 's/^ *//')
|
links3=$(awk "NR==3{ print; }" <<< "$links" | cut -d':' -f2 | sed 's/^ *//')
|
||||||
|
|
||||||
|
if [[ ! "$total3" =~ ^[0-9]+$ ]] || [[ ! "$links3" =~ ^[0-9]+$ ]]; then
|
||||||
|
error "Cannot read bootdisk size from ESD file!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
total3=$(( total3 - links3 ))
|
total3=$(( total3 - links3 ))
|
||||||
total3=$(( total3 + 60000000 ))
|
total3=$(( total3 + 60000000 ))
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -589,22 +589,22 @@ getESD() {
|
|||||||
|
|
||||||
echo "$result" > "$dir/$eFile"
|
echo "$result" > "$dir/$eFile"
|
||||||
|
|
||||||
local tag="FilePath"
|
tag="FilePath"
|
||||||
ESD=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" | sed -E -e "s/<[\/]?$tag>//g" 2>/dev/null)
|
ESD=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" 2>/dev/null | sed -E -e "s/<[\/]?$tag>//g" || true)
|
||||||
|
|
||||||
if [ -z "$ESD" ]; then
|
if [ -z "$ESD" ]; then
|
||||||
error "Failed to find ESD URL in $eFile!" && return 1
|
error "Failed to find ESD URL in $eFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tag="Sha1"
|
tag="Sha1"
|
||||||
ESD_SUM=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" | sed -E -e "s/<[\/]?$tag>//g" 2>/dev/null)
|
ESD_SUM=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" 2>/dev/null | sed -E -e "s/<[\/]?$tag>//g" || true)
|
||||||
|
|
||||||
if [ -z "$ESD_SUM" ]; then
|
if [ -z "$ESD_SUM" ]; then
|
||||||
error "Failed to find ESD checksum in $eFile!" && return 1
|
error "Failed to find ESD checksum in $eFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tag="Size"
|
tag="Size"
|
||||||
ESD_SIZE=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" | sed -E -e "s/<[\/]?$tag>//g" 2>/dev/null)
|
ESD_SIZE=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" 2>/dev/null | sed -E -e "s/<[\/]?$tag>//g" || true)
|
||||||
|
|
||||||
if [ -z "$ESD_SIZE" ]; then
|
if [ -z "$ESD_SIZE" ]; then
|
||||||
error "Failed to find ESD filesize in $eFile!" && return 1
|
error "Failed to find ESD filesize in $eFile!" && return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user