-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgonjac-builder.sh
executable file
·73 lines (63 loc) · 1.2 KB
/
gonjac-builder.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
#!/bin/bash
repos_dir=~/repos
function abort {
echo $1 >&2
echo "Aborting!"
exit 1
}
function usage {
echo "Usage: gonjac_builder.sh -r <repo> -b <branch> -i <identifier> [-f <flags>]">&2
}
while getopts "r:b:f:i:" opt ; do
case $opt in
r)
repo_name=$OPTARG
;;
b)
branch=$OPTARG
;;
f)
flags=$OPTARG
;;
i)
ID=$OPTARG
;;
\?)
usage
exit 1
esac
done
if [ -z $repo_name ]; then
usage
abort "Repo was not specified"
exit 1
fi
if [ -z $branch ]; then
usage
abort "Branch was not specified"
exit 1
fi
if [ -z $ID ]; then
usage
abort "ID was not specified"
exit 1
fi
gonjac_dir="/tmp/gonjac-od"
repo_dir="$repos_dir/$repo_name"
repo_out="$gonjac_dir/$repo_name-$branch-$ID"
tar_name="$repo_name-$branch-$ID"
pushd $repo_dir || abort "No such repo"
git pull
git checkout $branch || abort "Branch does not exist"
make clean
make -j || abort "Compilation failed"
popd
cp -r $repo_dir $repo_out
pushd $gonjac_dir
pushd $tar_name
echo "Removing .git directory from $(pwd)"
rm -rf $repo_out/.git
popd #$tar_name
tar -zcvf $tar_name.tar.gz $tar_name
rm -rf $tar_name
popd