21 lines
1.8 KiB
Bash
Executable File
21 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
cache=${MARS_TOOLCHAIN_DIR:-$PWD/.toolchains}; cache=$(realpath -m "$cache/legacy")
|
|
[[ -f $cache/winnt40.ddk.iso ]] || { echo 'No NT4 ISO; run cross/fetch-legacy.sh --accept-archive' >&2; exit 1; }
|
|
(cd "$cache"; sha256sum -c winnt40.ddk.iso.sha256)
|
|
if [[ -e $cache/nt4-extracted/READY ]]; then echo "Cached NT4 files: $cache/nt4-extracted"; exit 0; fi
|
|
[[ ! -e $cache/nt4-extracted ]] || { echo 'Incomplete extraction; move it aside first.' >&2; exit 1; }
|
|
work=$(mktemp -d "$cache/.nt4.XXXXXX"); trap 'rm -rf -- "$work"' EXIT
|
|
mkdir "$work/iso" "$work/expanded"; 7z x -y -o"$work/iso" "$cache/winnt40.ddk.iso" >/dev/null
|
|
# Extract any cabinet groups without running setup.exe; keep paths separate.
|
|
i=0
|
|
while IFS= read -r -d '' f; do i=$((i+1)); mkdir "$work/expanded/$i"; cabextract -q -d "$work/expanded/$i" "$f" || echo "Cannot extract CAB: $f" >&2; done < <(find "$work/iso" -type f -iname '*.cab' -print0)
|
|
# Some old DDKs store individual compressed files (NDIS.H_, etc.).
|
|
while IFS= read -r -d '' f; do i=$((i+1)); mkdir "$work/expanded/$i"; 7z x -y -o"$work/expanded/$i" "$f" >/dev/null 2>&1 || true; done < <(find "$work/iso" -type f \( -iname '*.h_' -o -iname '*.li_' -o -iname '*.in_' \) -print0)
|
|
find "$work" -type f \( -iname 'ndis.h' -o -iname 'ntddk.h' -o -iname 'ndis.lib' \) -printf '%P\n' | tee "$work/DDK-FILES.txt"
|
|
if ! find "$work" -type f -iname ndis.h -print -quit | grep -q . || ! find "$work" -type f -iname ntddk.h -print -quit | grep -q . || ! find "$work" -type f -iname ndis.lib -print -quit | grep -q .; then
|
|
echo 'Cannot find DDK components in this layout. Set NT4_DDK_INCLUDE and NT4_NDIS_LIB from your own extracted x86 DDK.' >&2; exit 1
|
|
fi
|
|
touch "$work/READY"; mv "$work" "$cache/nt4-extracted"; trap - EXIT
|