-
Notifications
You must be signed in to change notification settings - Fork 11
/
come_deps.sh
executable file
·77 lines (71 loc) · 1.63 KB
/
come_deps.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/bash -eu
SRC_DIR=`pwd`/src
CD_FILE=`pwd`/Comedeps
if [ ! -f ${CD_FILE} ];
then
echo "No Comedeps file at ${CD_FILE}"
exit 2
fi
cat ${CD_FILE} | while read line
do
echo "Loading ${line}"
dep=( ${line} )
pkg=${dep[0]}
vcs=${dep[1]}
url=${dep[2]}
hash=${dep[3]}
# you can specify a branch as a fifth parameter if the hash is not
# on master -- if you don't do this, then people who don't have that
# branch already checked out will fail to fetch the specified hash
branch=${dep[4]-master}
if [ -z ${hash} ]
then
echo "Must specify a commit hash/revision number, got[${hash}]"
exit 3
fi
dir=${SRC_DIR}/${pkg}
if [ -d ${dir} ];
then
echo "Package[${pkg}] already exists in dir[${dir}]"
else
mkdir -p `dirname ${dir}`
case ${vcs} in
git)
echo "Cloning git repository[${url}] to dir[${dir}]"
git clone ${url} ${dir}
;;
bzr)
echo "Cloning bazaar repository[${url}] to dir[${dir}]"
bzr branch ${url} ${dir}
;;
hg)
echo "Cloning hg repository[${url}] to dir[${dir}]"
hg clone -r ${hash} ${url} ${dir}
;;
*)
echo "Unknown vcs system[${vcs}]. Fix type or update script"
exit 4
;;
esac
fi
echo "Checking out revision ${hash}"
case ${vcs} in
git)
cd ${dir}
git fetch --prune --tags
git checkout --quiet ${branch}
git pull --quiet origin ${branch}
git checkout --quiet ${hash}
;;
bzr)
cd ${dir}; bzr up -r ${hash}
;;
hg)
echo "hg vcs already has -r [${hash}]"
;;
*)
echo "Unknown vcs system[${vcs}]. Fix type or update script"
exit 4
;;
esac
done