Build legacy drivers and publish per-OS packages with web activation and DEB
This commit is contained in:
92
cross/fetch-legacy.sh
Executable file
92
cross/fetch-legacy.sh
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# Downloads only. No Windows executable is run; caches stay outside source packages.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
[[ ${1:-} == --accept-archive ]] || { echo 'Review DDK archive licensing and provenance, then use --accept-archive. See LEGACY-BUILD.md.' >&2; exit 2; }
|
||||
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}; mkdir -p "$cache/legacy"; cache=$(realpath "$cache/legacy")
|
||||
for t in curl jq sha256sum sha512sum git; do
|
||||
command -v "$t" >/dev/null || { echo "Missing dependency: $t" >&2; exit 2; }
|
||||
done
|
||||
fetch(){ curl --fail --silent --show-error --location --retry 2 --connect-timeout 15 --max-time 1800 --proto '=https' --proto-redir '=https' "$@"; }
|
||||
asset(){
|
||||
local tag=$1 name=$2 key=$3 url digest actual meta tmp
|
||||
local envsha="${key}_SHA256"; digest=${!envsha:-}
|
||||
url="https://github.com/KunYi/WDK_DDKArchive/releases/download/$tag/$name"
|
||||
if [[ -z $digest ]]; then
|
||||
if meta=$(fetch "https://api.github.com/repos/KunYi/WDK_DDKArchive/releases/tags/$tag"); then
|
||||
digest=$(jq -r --arg name "$name" '.assets[]|select(.name==$name)|(.digest // "")|sub("^sha256:";"")' <<<"$meta")
|
||||
fi
|
||||
fi
|
||||
if [[ -e $cache/$name && -e $cache/$name.sha256 ]]; then (cd "$cache"; sha256sum -c "$name.sha256") || return 1; else
|
||||
tmp=$(mktemp "$cache/.download.XXXXXX"); if ! fetch "$url" -o "$tmp"; then rm -f "$tmp"; return 1; fi
|
||||
actual=$(sha256sum "$tmp" | cut -d' ' -f1)
|
||||
if [[ -n $digest && ${digest,,} != "$actual" ]]; then rm -f "$tmp"; echo "Hash mismatch: $name" >&2; return 1; fi
|
||||
mv "$tmp" "$cache/$name" || return 1; printf '%s %s\n' "$actual" "$name" > "$cache/$name.sha256"
|
||||
fi
|
||||
actual=$(sha256sum "$cache/$name"|cut -d' ' -f1)
|
||||
if [[ -n $digest && ${digest,,} != "$actual" ]]; then echo "Hash mismatch: $name" >&2; return 1; fi
|
||||
printf 'url=%s\nsha256=%s\nexpected=%s\n' "$url" "$actual" "${digest:-UNVERIFIED}" > "$cache/$name.origin"
|
||||
[[ -n $digest ]] || echo "WARNING $name: archive not independently verified; SHA256 records bytes only." >&2
|
||||
}
|
||||
rc=0
|
||||
asset NT4_DDK winnt40.ddk.iso NT4_DDK || rc=1
|
||||
asset Win98DDK win98ddk.exe WIN98_DDK || rc=1
|
||||
# WinWorld publishes this SHA-512 on the Windows 95 DDK download page.
|
||||
# Unofficial archival copy, not a signed Microsoft distribution.
|
||||
name=win95ddk.7z
|
||||
mirror2='https://git.iiot-factory.com/chris/mars_nwe_pcab/raw/branch/main/windll/Microsoft%20Windows%2095%20DDK.7z'
|
||||
mirror1='https://dl.winworldpc.com/Abandonware%20SDKs/Microsoft%20Windows%2095%20DDK.7z'
|
||||
sha512=${WIN95_DDK_SHA512:-119ed8a4361805ec8b36f227da741a864cad77586ff7f87c696a74d7d438b3253b643c97765414867575f1d20e65c9cd70762c7d8481108778a0af0c4c0061bf}
|
||||
if [[ ! $sha512 =~ ^[a-fA-F0-9]{128}$ ]]; then
|
||||
echo 'Invalid WIN95_DDK_SHA512' >&2; exit 2
|
||||
fi
|
||||
if [[ ${MARS_SKIP_WIN95_DDK:-0} == 1 && ${MARS_REQUIRE_WIN95_DDK:-0} == 1 ]]; then
|
||||
echo 'MARS_SKIP_WIN95_DDK and MARS_REQUIRE_WIN95_DDK conflict.' >&2; exit 2
|
||||
fi
|
||||
fetch_win95(){
|
||||
local url tmp mismatch=0
|
||||
local -a urls=()
|
||||
[[ -z ${WIN95_DDK_URL:-} ]] || urls+=("$WIN95_DDK_URL")
|
||||
[[ ${WIN95_DDK_URL:-} == "$mirror2" ]] || urls+=("$mirror2")
|
||||
[[ ${WIN95_DDK_URL:-} == "$mirror1" ]] || urls+=("$mirror1")
|
||||
if [[ -f $cache/$name ]]; then
|
||||
printf '%s %s\n' "$sha512" "$cache/$name" | sha512sum -c - || return 1
|
||||
echo "Using cached $cache/$name"
|
||||
[[ -f $cache/$name.origin ]] || printf 'url=LOCAL_CACHE\nsha512=%s\n' "$sha512" > "$cache/$name.origin"
|
||||
return 0
|
||||
fi
|
||||
for url in "${urls[@]}"; do
|
||||
echo "Trying Windows 95 DDK: $url"
|
||||
tmp=$(mktemp "$cache/.win95.XXXXXX") || return 1
|
||||
if fetch "$url" -o "$tmp"; then
|
||||
if printf '%s %s\n' "$sha512" "$tmp" | sha512sum -c -; then
|
||||
mv -- "$tmp" "$cache/$name" || { rm -f -- "$tmp"; return 1; }
|
||||
printf 'url=%s\nsha512=%s\n' "$url" "$sha512" > "$cache/$name.origin" || return 1
|
||||
echo "Downloaded and verified: $cache/$name"
|
||||
return 0
|
||||
fi
|
||||
mismatch=1
|
||||
echo 'WARNING: Windows 95 archive hash mismatch; trying next mirror.' >&2
|
||||
fi
|
||||
rm -f -- "$tmp"
|
||||
done
|
||||
if (( mismatch )); then
|
||||
echo 'ERROR: No mirror supplied a valid Windows 95 archive.' >&2; return 1
|
||||
fi
|
||||
echo 'WARNING: All Windows 95 DDK mirrors unavailable.' >&2
|
||||
if [[ ${MARS_REQUIRE_WIN95_DDK:-0} == 1 ]]; then return 1; fi
|
||||
echo 'Optional Windows 95 reference DDK skipped; NT4-based build can continue.' >&2
|
||||
return 0
|
||||
}
|
||||
if [[ ${MARS_SKIP_WIN95_DDK:-0} == 1 ]]; then
|
||||
echo 'Skipping optional Windows 95 reference DDK.'
|
||||
else
|
||||
fetch_win95 || rc=1
|
||||
fi
|
||||
# WinPcap is an open source reference and optional compatibility transport.
|
||||
if [[ ! -d $cache/winpcap31/.git ]]; then
|
||||
git clone --depth 1 --branch WINPCAP_3_1 https://github.com/wireshark/winpcap.git "$cache/winpcap31" || rc=1
|
||||
fi
|
||||
if [[ -d $cache/winpcap31/.git ]]; then git -C "$cache/winpcap31" rev-parse HEAD > "$cache/winpcap31.commit"; fi
|
||||
./cross/fetch-winpcap.sh || rc=1
|
||||
exit "$rc"
|
||||
Reference in New Issue
Block a user