3
3
# Recreate git-sdk-$VERSION.exe
4
4
5
5
test -z " $1 " && {
6
- echo " Usage: $0 <version> [<gitbranch>] "
6
+ echo " Usage: $0 <version>"
7
7
exit 1
8
8
}
9
9
@@ -25,75 +25,58 @@ x86_64)
25
25
;;
26
26
esac
27
27
28
- GIT_BRANCH=" ${2:- master} "
29
- GIT_CLONE_URL=https://github.com/git-for-windows/git
28
+ GIT_SDK_URL=https://github.com/git-for-windows/git-sdk-$BITNESS
30
29
31
30
FAKEROOTDIR=" $( cd " $( dirname " $0 " ) " && pwd) /root"
32
31
TARGET=" $HOME " /git-sdk-installer-" $1 " -$BITNESS .7z.exe
33
32
OPTS7=" -m0=lzma -mx=9 -md=64M"
34
33
TMPPACK=/tmp.7z
35
34
SCRIPT_PATH=" $( cd " $( dirname " $0 " ) " && pwd) "
35
+ BIN_DIR=/mingw$BITNESS /bin
36
36
37
- mkdir -p " $FAKEROOTDIR /usr/bin" " $FAKEROOTDIR /etc" ||
38
- die " Could not create fake root directory"
37
+ echo " Enumerating required files..." >&2
38
+ # First, enumerate the .dll files needed by the .exe files, then, enumerate all
39
+ # the .dll files in bin/, then filter out the duplicates (which are the .dll
40
+ # files in bin/ which are needed by the .exe files).
41
+ exes_and_dlls=
42
+ todo=" git.exe ../libexec/git-core/git-remote-https.exe "
43
+ # Add DLLs' transitive dependencies
44
+ while test -n " $todo "
45
+ do
46
+ file=${todo%% * }
47
+ todo=${todo#* }
48
+ exes_and_dlls=" $exes_and_dlls$file "
49
+
50
+ for dll in $( objdump -p " $BIN_DIR /$file " |
51
+ sed -n " s|^\tDLL Name: ||p" )
52
+ do
53
+ case " $exes_and_dlls $todo " in
54
+ * " $dll " * ) ;; # already found/queued
55
+ * ) test ! -f " $BIN_DIR /$dll " || todo=" $todo$dll " ;;
56
+ esac
57
+ done
58
+ done
59
+
60
+ echo " Copying and compressing files..." >&2
61
+ rm -rf " $FAKEROOTDIR " &&
62
+ mkdir -p " $FAKEROOTDIR /mini$BIN_DIR " ||
63
+ die " Could not create $FAKEROOTDIR$BIN_DIR directory"
39
64
40
65
sed -e " s|@@ARCH@@|$ARCH |g" \
41
66
-e " s|@@BITNESS@@|$BITNESS |g" \
42
- -e " s|@@GIT_BRANCH@@|$GIT_BRANCH |g" \
43
- -e " s|@@GIT_CLONE_URL@@|$GIT_CLONE_URL |g" \
67
+ -e " s|@@GIT_SDK_URL@@|$GIT_SDK_URL |g" \
44
68
< " $SCRIPT_PATH " /setup-git-sdk.bat > " $FAKEROOTDIR " /setup-git-sdk.bat ||
45
69
die " Could not generate setup script"
46
70
47
- cp /usr/bin/dash.exe " $FAKEROOTDIR /usr/bin/sh.exe" &&
48
- sed -e ' s/^#\(XferCommand.*curl\).*/\1 --anyauth -C - -L -f %u >%o/' \
49
- < /etc/pacman.conf > " $FAKEROOTDIR /etc/pacman.conf.proxy" ||
50
- die " Could not copy extra files into fake root"
51
-
52
- dlls_for_exes () {
53
- # Add DLLs' transitive dependencies
54
- dlls=
55
- todo=" $* "
56
- while test -n " $todo "
57
- do
58
- path=${todo%% * }
59
- todo=${todo#* }
60
- case " $path " in ' ' |' ' ) continue ;; esac
61
- for dll in $( objdump -p " $path " |
62
- sed -n ' s/^\tDLL Name: msys-/usr\/bin\/msys-/p' )
63
- do
64
- case " $dlls " in
65
- * " $dll " * ) ;; # already found
66
- * ) dlls=" $dlls $dll " ; todo=" $todo /$dll " ;;
67
- esac
68
- done
69
- done
70
- echo " $dlls "
71
- }
72
-
73
- fileList=" etc/nsswitch.conf \
74
- etc/pacman.conf \
75
- etc/pacman.d \
76
- usr/bin/pacman-key \
77
- usr/bin/tput.exe \
78
- usr/bin/pacman.exe \
79
- usr/bin/curl.exe \
80
- usr/bin/gpg.exe \
81
- usr/bin/chmod.exe \
82
- usr/bin/wc.exe \
83
- usr/bin/find.exe \
84
- $( dlls_for_exes /usr/bin/gpg.exe /usr/bin/curl.exe /usr/bin/chmod.exe \
85
- /usr/bin/wc.exe /usr/bin/find.exe) \
86
- usr/ssl/certs/ca-bundle.crt \
87
- var/lib/pacman \
88
- usr/share/pacman/keyrings \
89
- $FAKEROOTDIR /setup-git-sdk.bat $FAKEROOTDIR /etc $FAKEROOTDIR /usr"
71
+ (cd $BIN_DIR && cp $exes_and_dlls " $FAKEROOTDIR /mini$BIN_DIR " ) ||
72
+ die " Could not copy .exe and .dll files into fake root"
90
73
91
74
type 7za ||
92
75
pacman -Sy --noconfirm p7zip ||
93
76
die " Could not install 7-Zip"
94
77
95
78
echo " Creating archive" &&
96
- (cd / && 7za -x' !var/lib/pacman/*' a $OPTS7 " $TMPPACK " $fileList ) &&
79
+ (cd " $FAKEROOTDIR " && 7za -x' !var/lib/pacman/*' a $OPTS7 " $TMPPACK " * ) &&
97
80
(cat " $SCRIPT_PATH /../7-Zip/7zSD.sfx" &&
98
81
echo ' ;!@Install@!UTF-8!' &&
99
82
echo ' Title="Git for Windows ' $BITNESS ' -bit SDK"' &&
0 commit comments