Skip to content

Commit dbdea78

Browse files
committed
Add a tool to detect missing DLLs from make-file-list.sh's output
We recently built a Git for Windows snapshot with a broken `git-remote-https`: it was missing a `.dll` file because `mingw-w64-curl`'s package metadata failed to indicate that it depends on `libzstd.dll`. In the meantime, we fixed that problem. However, it took manual testing to detect the breakage, and we would like to have an easier time finding this type of bug in the future. So let's add a script that runs through the output of `make-file-list.sh` to see whether any `.dll` file is missing. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 2e518ba commit dbdea78

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

check-for-missing-dlls.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
die () {
4+
echo "$*" >&2
5+
exit 1
6+
}
7+
8+
thisdir="$(cd "$(dirname "$0")" && pwd)" ||
9+
die "Could not determine script directory"
10+
11+
sys_dlls="$(ls "$SYSTEMROOT/system32"/*.dll "$SYSTEMROOT/system32"/*.DLL "$SYSTEMROOT/system32"/*.drv | tr A-Z a-z)" ||
12+
die "Could not enumerate system .dll files"
13+
14+
LF='
15+
'
16+
17+
ARCH="$(uname -m)" ||
18+
die "Could not determine architecture"
19+
20+
case "$ARCH" in
21+
i686) BITNESS=32;;
22+
x86_64) BITNESS=64;;
23+
*) die "Unhandled architecture: $ARCH";;
24+
esac
25+
26+
if test -t 2
27+
then
28+
next_line='\033[K\r'
29+
else
30+
next_line='\n'
31+
fi
32+
33+
all_files="$(export ARCH BITNESS && "$thisdir"/make-file-list.sh | tr A-Z a-z)" &&
34+
usr_bin_dlls="$(echo "$all_files" | grep '^usr/bin/[^/]*\.dll$')" &&
35+
mingw_bin_dlls="$(echo "$all_files" | grep '^mingw'$BITNESS'/bin/[^/]*\.dll$')" &&
36+
dirs="$(echo "$all_files" | sed -n 's/[^/]*\.\(dll\|exe\)$//p' | sort | uniq)" &&
37+
for dir in $dirs
38+
do
39+
printf "dir: $dir$next_line\\r" >&2
40+
41+
case "$dir" in
42+
usr/*) dlls="$dlls$LF$usr_bin_dlls$LF";;
43+
mingw$BITNESS/*) dlls="$dlls$LF$mingw_bin_dlls$LF";;
44+
*) dlls="$sys_dlls$LF";;
45+
esac
46+
47+
/usr/bin/objdump -p $(echo "$all_files" | sed -ne 's,[][],\\&,g' -e "s,^$dir[^/]*\.\(dll\|exe\)$,/&,p") |
48+
tr A-Z\\r a-z\ |
49+
grep -e '^.dll name:' -e '^[^ ]*\.\(dll\|exe\):' |
50+
while read a b c d
51+
do
52+
case "$a,$b" in
53+
*.exe:,*|*.dll:,*) current="${a%:}";;
54+
dll,name:)
55+
case "$dlls" in
56+
*"/$c$LF"*) ;; # okay, it's included
57+
*) echo "$current is missing $c" >&2;;
58+
esac
59+
;;
60+
esac
61+
done
62+
done
63+
printf "$next_line" >&2

0 commit comments

Comments
 (0)