-
Notifications
You must be signed in to change notification settings - Fork 1
/
SFDownloads-Repo.sh
executable file
·90 lines (73 loc) · 2.22 KB
/
SFDownloads-Repo.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
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
VERBOSE=NO
DEBUG=NO
MIRROR=ufpr
RSYNC="/usr/bin/rsync"
URL="sourceforge.net"
errmsg() {
echo "`basename $0`: $1" >&2
if [ $# -ne 1 ]; then
exit $2
fi
}
debugmsg() {
if [ x$DEBUG != x ]; then
echo "`basename $0`: $1" >&2
fi
}
if [ $# -ne 1 -o "$1" == "help" ]; then
echo
echo " `basename -n $0`: SFDownloads-Repo: download from SourceForge.Net"
echo " the repositories of free software projects."
echo
echo " Given a file, as an argument, with a list of SourceForge.Net "
echo " projects and their type of repositories, according to shown in "
echo " the develop page of each project page at SourceForge.Net, this "
echo " script tries to download a copy of these repositories using rsync"
echo " command."
echo
echo " usage: `basename $0` filename"
echo
exit 0
fi
[ -x $RSYNC ] || errmsg "$RSYNC not found." -1
cat $1 | while read line; do
project="`echo "$line" | cut -d, -f1 | sed 's/"//g'`"
repository_type="`echo "$line" | cut -d, -f2 | sed 's/"//g'`"
dir_name="$project"
if [ "$VERBOSE" == "YES" ]; then
echo "`basename $0`: Downloading project $project from a "
echo "$repository_type repository"
fi
case "$repository_type" in
'1-GIT')
repository_command="$RSYNC -avz $project.git.$URL::gitroot/$project/* ."
;;
'2-Bazaar')
repository_command="$RSYNC -avz $project.bzr.$URL::bzrroot/$project/* ."
;;
'3-Mercurial')
repository_command="$RSYNC -avz $project.hg.$URL::hgroot/$project/* ."
;;
'4-SVN')
repository_command="$RSYNC -avz $project.svn.$URL::svn/$project/* ."
;;
'5-CVS')
repository_command="$RSYNC -avz $project.cvs.$URL::cvsroot/$project/* ."
;;
esac
# I give up!
if [ -d "$dir_name" ]; then
debugmsg "$project already downloaded"
continue
fi
mkdir -p "$dir_name"
pushd "$dir_name" >/dev/null
debugmsg "$repository_command"
$repository_command
if [ $? -gt 0 ]; then
errmsg "Failed downloading for project $project"
rm -rf "$dir_name"
fi
popd > /dev/null
done