forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-dep
executable file
·50 lines (38 loc) · 927 Bytes
/
update-dep
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
45
46
47
48
49
50
#!/bin/bash
set -e -x
if [ $# -ne 1 ]; then
echo "Must provide package name as argument."
echo -e "\nUsage:\n$0 PACKAGE_NAME \n"
exit 1
fi
package_name=$1
go get -d -t ${package_name}
package_path=$(echo ${package_name} | sed 's/\.\.\.$//')
rm -rf vendor/${package_path}
mkdir -p vendor/${package_path}
cp -r $GOPATH/src/${package_path}/ vendor/${package_path}
pushd $GOPATH/src/${package_path}
set +e
sha=$(git rev-parse --short HEAD)
git_repo=$?
set -e
if [ $git_repo -ne 0 ]; then
sha=$(hg id -i)
fi
popd
git_path=$(find vendor -name '.git')
rm -rf $git_path
hg_path=$(find vendor -name '.hg')
rm -rf $hg_path
if sed -h 2>&1 | grep -q GNU ; then
sed -i "s#${package_name}:.*#$package_name:$sha#g" deps.txt
else
sed -i '' "s#${package_name}:.*#$package_name:$sha#g" deps.txt
fi
set +e
grep "${package_name}:" deps.txt
found=$?
set -e
if [ $found -ne 0 ]; then
echo $package_name:$sha >> deps.txt
fi