mirror of
https://github.com/dockur/windows.git
synced 2025-10-29 12:15:50 +00:00
Update install.sh
This commit is contained in:
parent
37c3319982
commit
2881603870
1 changed files with 32 additions and 27 deletions
|
|
@ -190,7 +190,7 @@ getESD() {
|
||||||
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
|
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "Invalid ESD version specified: $version" && return 1
|
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
@ -201,6 +201,9 @@ getESD() {
|
||||||
mkdir -p "$dir"
|
mkdir -p "$dir"
|
||||||
|
|
||||||
local wFile="catalog.cab"
|
local wFile="catalog.cab"
|
||||||
|
local xFile="products.xml"
|
||||||
|
local eFile="esd_edition.xml"
|
||||||
|
local fFile="products_filter.xml"
|
||||||
|
|
||||||
{ wget "$winCatalog" -O "$dir/$wFile" -q; rc=$?; } || :
|
{ wget "$winCatalog" -O "$dir/$wFile" -q; rc=$?; } || :
|
||||||
(( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1
|
(( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1
|
||||||
|
|
@ -209,33 +212,33 @@ getESD() {
|
||||||
|
|
||||||
if ! cabextract "$wFile" > /dev/null; then
|
if ! cabextract "$wFile" > /dev/null; then
|
||||||
cd /run
|
cd /run
|
||||||
error "Failed to extract CAB file!" && return 1
|
error "Failed to extract $wFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /run
|
cd /run
|
||||||
|
|
||||||
if [ ! -s "$dir/products.xml" ]; then
|
if [ ! -s "$dir/$xFile" ]; then
|
||||||
error "Failed to find products.xml!" && return 1
|
error "Failed to find $xFile in $wFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local esdLang="en-us"
|
local esdLang="en-us"
|
||||||
local editionName="Professional"
|
local editionName="Professional"
|
||||||
local edQuery='//File[Architecture="'${PLATFORM}'"][Edition="'${editionName}'"]'
|
local edQuery='//File[Architecture="'${PLATFORM}'"][Edition="'${editionName}'"]'
|
||||||
|
|
||||||
echo -e '<Catalog>' > "${dir}/products_filter.xml"
|
echo -e '<Catalog>' > "$dir/$fFile"
|
||||||
xmllint --nonet --xpath "${edQuery}" "${dir}/products.xml" >> "${dir}/products_filter.xml" 2>/dev/null
|
xmllint --nonet --xpath "${edQuery}" "$dir/$xFile" >> "$dir/$fFile" 2>/dev/null
|
||||||
echo -e '</Catalog>'>> "${dir}/products_filter.xml"
|
echo -e '</Catalog>'>> "$dir/$fFile"
|
||||||
xmllint --nonet --xpath '//File[LanguageCode="'${esdLang}'"]' "${dir}/products_filter.xml" >"${dir}/esd_edition.xml"
|
xmllint --nonet --xpath '//File[LanguageCode="'${esdLang}'"]' "$dir/$fFile" >"$dir/$eFile"
|
||||||
|
|
||||||
size=$(stat -c%s "${dir}/esd_edition.xml")
|
size=$(stat -c%s "$dir/$eFile")
|
||||||
if ((size<20)); then
|
if ((size<20)); then
|
||||||
error "Failed to find Windows product!" && return 1
|
error "Failed to find Windows product in $eFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ESD_URL=$(xmllint --nonet --xpath '//FilePath' "${dir}/esd_edition.xml" | sed -E -e 's/<[\/]?FilePath>//g')
|
ESD_URL=$(xmllint --nonet --xpath '//FilePath' "$dir/$eFile" | sed -E -e 's/<[\/]?FilePath>//g')
|
||||||
|
|
||||||
if [ -z "$ESD_URL" ]; then
|
if [ -z "$ESD_URL" ]; then
|
||||||
error "Failed to find ESD URL!" && return 1
|
error "Failed to find ESD URL in $eFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$dir"
|
rm -rf "$dir"
|
||||||
|
|
@ -326,7 +329,7 @@ downloadImage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! validVersion "$version"; then
|
if ! validVersion "$version"; then
|
||||||
error "Invalid VERSION, value \"$version\" is not recognized!" && return 1
|
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
desc=$(printVersion "$version" "Windows")
|
desc=$(printVersion "$version" "Windows")
|
||||||
|
|
@ -395,9 +398,10 @@ extractESD() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local dir="$2"
|
local dir="$2"
|
||||||
|
local version="$3"
|
||||||
|
local desc="$4"
|
||||||
local size size_gb space space_gb desc
|
local size size_gb space space_gb desc
|
||||||
|
|
||||||
desc=$(printVersion "$VERSION" "Windows")
|
|
||||||
local msg="Extracting $desc bootdisk..."
|
local msg="Extracting $desc bootdisk..."
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
|
|
@ -422,7 +426,7 @@ extractESD() {
|
||||||
|
|
||||||
wimlib-imagex apply "$iso" 1 "${dir}" --quiet 2>/dev/null || {
|
wimlib-imagex apply "$iso" 1 "${dir}" --quiet 2>/dev/null || {
|
||||||
retVal=$?
|
retVal=$?
|
||||||
error "Extracting bootdisk failed" && return $retVal
|
error "Extracting $desc bootdisk failed" && return $retVal
|
||||||
}
|
}
|
||||||
|
|
||||||
local bootWimFile="${dir}/sources/boot.wim"
|
local bootWimFile="${dir}/sources/boot.wim"
|
||||||
|
|
@ -449,7 +453,7 @@ extractESD() {
|
||||||
|
|
||||||
local edition imageIndex imageEdition
|
local edition imageIndex imageEdition
|
||||||
|
|
||||||
case "${VERSION,,}" in
|
case "${version,,}" in
|
||||||
"win11${PLATFORM,,}")
|
"win11${PLATFORM,,}")
|
||||||
edition="11 pro"
|
edition="11 pro"
|
||||||
;;
|
;;
|
||||||
|
|
@ -457,7 +461,7 @@ extractESD() {
|
||||||
edition="10 pro"
|
edition="10 pro"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "Invalid version specified: $VERSION" && return 1
|
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
@ -466,7 +470,7 @@ extractESD() {
|
||||||
[[ "${imageEdition,,}" != *"$edition"* ]] && continue
|
[[ "${imageEdition,,}" != *"$edition"* ]] && continue
|
||||||
wimlib-imagex export "${iso}" ${imageIndex} "${installWimFile}" --compress=LZMS --chunk-size 128K --quiet || {
|
wimlib-imagex export "${iso}" ${imageIndex} "${installWimFile}" --compress=LZMS --chunk-size 128K --quiet || {
|
||||||
retVal=$?
|
retVal=$?
|
||||||
error "Addition of ${imageIndex} to the image failed" && return $retVal
|
error "Addition of ${imageIndex} to the $desc image failed" && return $retVal
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
done
|
done
|
||||||
|
|
@ -478,16 +482,17 @@ extractImage() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local dir="$2"
|
local dir="$2"
|
||||||
|
local version="$3"
|
||||||
local desc="downloaded ISO"
|
local desc="downloaded ISO"
|
||||||
local size size_gb space space_gb
|
local size size_gb space space_gb
|
||||||
|
|
||||||
if [[ "${iso,,}" == *".esd" ]]; then
|
if [[ "$EXTERNAL" != [Yy1]* ]] && [ -z "$CUSTOM" ]; then
|
||||||
extractESD "$iso" "$dir" && return 0
|
desc=$(printVersion "$version" "downloaded ISO")
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$EXTERNAL" != [Yy1]* ]] && [ -z "$CUSTOM" ]; then
|
if [[ "${iso,,}" == *".esd" ]]; then
|
||||||
desc=$(printVersion "$VERSION" "downloaded ISO")
|
extractESD "$iso" "$dir" "$version" "$desc" && return 0
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local msg="Extracting $desc image..."
|
local msg="Extracting $desc image..."
|
||||||
|
|
@ -544,7 +549,7 @@ detectImage() {
|
||||||
local dsc
|
local dsc
|
||||||
dsc=$(printVersion "$DETECTED" "$DETECTED")
|
dsc=$(printVersion "$DETECTED" "$DETECTED")
|
||||||
|
|
||||||
warn "got $dsc, but no matching XML file exists, $FB."
|
warn "got $dsc, but no matching $DETECTED.xml file exists, $FB."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -597,7 +602,7 @@ detectImage() {
|
||||||
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
||||||
info "Detected: $desc"
|
info "Detected: $desc"
|
||||||
else
|
else
|
||||||
warn "detected $desc, but no matching XML file exists, $FB."
|
warn "detected $desc, but no matching $DETECTED.xml file exists, $FB."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -875,7 +880,7 @@ updateImage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! wimlib-imagex update "$loc" "$index" --command "add $asset /autounattend.xml" > /dev/null; then
|
if ! wimlib-imagex update "$loc" "$index" --command "add $asset /autounattend.xml" > /dev/null; then
|
||||||
warn "failed to add XML to ISO image, $FB" && return 1
|
warn "failed to add "$(basename $asset)" to ISO image, $FB" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -1047,7 +1052,7 @@ if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! extractImage "$ISO" "$DIR"; then
|
if ! extractImage "$ISO" "$DIR" "$VERSION"; then
|
||||||
rm -f "$ISO"
|
rm -f "$ISO"
|
||||||
exit 62
|
exit 62
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue