Skip to content

Commit 60ee662

Browse files
authored
Merge pull request #308 from dscho/check-for-missing-dlls
Prevent missing DLLs in Git for Windows
2 parents 02c6e55 + c6b03bc commit 60ee662

File tree

2 files changed

+82
-5
lines changed

2 files changed

+82
-5
lines changed

check-for-missing-dlls.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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,"=>") # `ldd` output
55+
case "$dlls" in
56+
*"/$a$LF"*) ;; # okay, it's included
57+
*) echo "$current is missing $a" >&2;;
58+
esac
59+
;;
60+
dll,name:) # `objdump -p` output
61+
case "$dlls" in
62+
*"/$c$LF"*) ;; # okay, it's included
63+
*) echo "$current is missing $c" >&2;;
64+
esac
65+
;;
66+
esac
67+
done
68+
done
69+
printf "$next_line" >&2

make-file-list.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ grep -v -e '\.[acho]$' -e '\.l[ao]$' -e '/aclocal/' \
146146
-e '^/mingw../itcl/' \
147147
-e '^/mingw../t\(cl\|k\)[^/]*/\(demos\|msgs\|encoding\|tzdata\)/' \
148148
-e '^/mingw../bin/\(autopoint\|[a-z]*-config\)$' \
149-
-e '^/mingw../bin/lib\(asprintf\|gettext\|gnutlsxx\|pcre[013-9a-oq-z]\|quadmath\|stdc++\)[^/]*\.dll$' \
149+
-e '^/mingw../bin/lib\(asprintf\|gettext\|gnutls\|gnutlsxx\|gmpxx\|pcre[013-9a-oq-z]\|quadmath\|stdc++\)[^/]*\.dll$' \
150150
-e '^/mingw../bin/\(asn1\|gnutls\|idn\|mini\|msg\|nettle\|ngettext\|ocsp\|pcre\|rtmp\|xgettext\)[^/]*\.exe$' \
151+
-e '^/mingw../bin/recode-sr-latin.exe$' \
152+
-e '^/mingw../bin/\(cert\|p11\|psk\|srp\)tool.exe$' \
153+
-e '^/usr/bin/msys-\(ncurses++w6\|asprintf-[0-9]*\|\)\.dll$' \
151154
-e '^/mingw../.*/git-\(remote-testsvn\|shell\)\.exe$' \
152155
-e '^/mingw../.*/git-cvsserver.*$' \
153156
-e '^/mingw../.*/gitweb/' \
@@ -161,7 +164,10 @@ grep -v -e '\.[acho]$' -e '\.l[ao]$' -e '/aclocal/' \
161164
-e '^/mingw../share/git\(k\|-gui\)/lib/msgs/' \
162165
-e '^/mingw../share/nghttp2/' \
163166
-e '^/usr/bin/msys-\(db\|icu\|gfortran\|stdc++\|quadmath\)[^/]*\.dll$' \
164-
-e '^/usr/bin/dumper\.exe$' \
167+
-e '^/usr/bin/msys-\(gmpxx\|gnutlsxx\|xml2\|xslt\|exslt\)-.*\.dll$' \
168+
-e '^/usr/bin/msys-svn_swig_\(py\|ruby\)-.*\.dll$' \
169+
-e '^/usr/bin/\(dumper\|sasl.*\)\.exe$' \
170+
-e '^/usr/lib/gio/' -e '^/usr/lib/sasl2/msys-sasldb-.*\.dll$' \
165171
-e '^/usr/share.*/magic$' \
166172
-e '^/usr/share/perl5/core_perl/Unicode/' \
167173
-e '^/usr/share/perl5/core_perl/pods/' \
@@ -191,10 +197,12 @@ else
191197
-e '^/git-\(bash\|cmd\)\.exe$' \
192198
-e '^/mingw../bin/\(certtool\.exe\|create-shortcut\.exe\)$' \
193199
-e '^/mingw../bin/\(curl\.exe\|envsubst\.exe\|gettext\.exe\)$' \
200+
-e '^/mingw../bin/.*-\(inflate\|deflate\)hd\.exe$' \
194201
-e '^/mingw../bin/\(gettext\.sh\|gettextize\)$' \
195202
-e '^/mingw../bin/\(gitk\|git-upload-archive\.exe\)$' \
196203
-e '^/mingw../bin/lib\(atomic\|charset\)-.*\.dll$' \
197-
-e '^/mingw../bin/lib\(gcc_s_seh\|gmpxx\)-.*\.dll$' \
204+
-e '^/mingw../bin/libgcc_s_seh-.*\.dll$' \
205+
-e '^/mingw../bin/libjemalloc\.dll$' \
198206
-e '^/mingw../bin/lib\(gomp\|jansson\|minizip\)-.*\.dll$' \
199207
-e '^/mingw../bin/libvtv.*\.dll$' \
200208
-e '^/mingw../bin/libpcreposix.*\.dll$' \
@@ -247,14 +255,14 @@ else
247255
-e '^/usr/bin/msys-\(atomic\|charset\|cilkrts\)-.*\.dll$' \
248256
-e '^/usr/bin/msys-\(hdb\|kadm5\|kafs\|kdc\|otp\|sl\).*\.dll$' \
249257
-e '^/usr/bin/msys-sqlite3[a-z].*\.dll$' \
250-
-e '^/usr/bin/msys-\(gmpxx\|gomp.*\|vtv.*\)-.*\.dll$' \
258+
-e '^/usr/bin/msys-\(gomp.*\|vtv.*\)-.*\.dll$' \
251259
-e '^/usr/lib/\(awk\|coreutils\|gawk\|openssl\|ssh\)/' \
252260
-e '^/usr/libexec/\(bigram\|code\|frcode\)\.exe$' \
253261
-e '^/usr/share/\(cygwin\|git\)/' \
254262
-e '^/usr/ssl/misc/' \
255263
-e '^/usr/bin/\(captoinfo\|clear\|infocmp\|infotocap\)\.exe$' \
256264
-e '^/usr/bin/\(reset\|tabs\|tic\|toe\|tput\|tset\)\.exe$' \
257-
-e '^/usr/bin/msys-\(formw6\|menuw6\|ncurses++w6\)\.dll$' \
265+
-e '^/usr/bin/msys-\(formw6\|menuw6\)\.dll$' \
258266
-e '^/usr/bin/msys-\(panelw6\|ticw6\)\.dll$' \
259267
-e '^/usr/\(lib\|share\)/terminfo/' -e '^/usr/share/tabset/' \
260268
-e "^\\($(echo $EXTRA_FILE_EXCLUDES |

0 commit comments

Comments
 (0)