forked from timcharper/git_osx_installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_installer.sh
executable file
·44 lines (31 loc) · 1.08 KB
/
test_installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
INSTALL_DIR="/usr/local/git/"
[ $# -gt 0 ] && GIT_PKG="$1" || GIT_PKG="$(ls git-*.pkg | head -1)"
if ! [ -f "$GIT_PKG" ]; then echo "$GIT_PKG does not exist"; exit 2; fi
[ $# -gt 1 ] && GIT_DIR="$2" || GIT_DIR="stage/$(echo "${GIT_PKG%.*}" | grep -o 'git-[0-9.]\+')"
if ! [ -d "$GIT_DIR" ]; then echo "$GIT_DIR does not exist"; exit 2; fi
echo "Uninstalling old version..."
[ -x /usr/local/git/uninstall ] && "$INSTALL_DIR/uninstall" --yes
[ -x /usr/local/git/uninstall.sh ] && "$INSTALL_DIR/uninstall.sh" --yes
echo "Installing $GIT_PKG..."
sudo /usr/sbin/installer -pkg "$GIT_PKG" -target / || exit 2
echo "Testing..."
RETVAL=0
for file in "$INSTALL_DIR/bin/git"; do
if ! [ -f "$file" ]; then
echo "'$file' DOES NOT EXIST!"
RETVAL=1
fi
done
(cd "$GIT_DIR" && find usr) | while read file; do
if ! [ -e "/$file" ]; then
echo "/$file did not get installed!"
RETVAL=1
fi
done
if ls -alR "$INSTALL_DIR"/* | awk '{print $3}' | awk 'NF' | grep -qv root; then
echo "Some user-owned files exist!"
RETVAL=1
fi
[ $RETVAL -eq 0 ] && echo "Success!"
exit $RETVAL