-
Notifications
You must be signed in to change notification settings - Fork 222
/
do_release.sh
executable file
·137 lines (116 loc) · 3.57 KB
/
do_release.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
git_branch()
{
local g="$(git rev-parse --git-dir 2>/dev/null)"
if [ -n "$g" ]; then
local r
local b
if [ -d "$g/../.dotest" ] ; then
r="|AM/REBASE"
b="$(git symbolic-ref HEAD 2>/dev/null)"
elif [ -f "$g/.dotest-merge/interactive" ] ; then
r="|REBASE-i"
b="$(cat $g/.dotest-merge/head-name)"
elif [ -d "$g/.dotest-merge" ] ; then
r="|REBASE-m"
b="$(cat $g/.dotest-merge/head-name)"
elif [ -f "$g/MERGE_HEAD" ] ; then
r="|MERGING"
b="$(git symbolic-ref HEAD 2>/dev/null)"
else
if [ -f $g/BISECT_LOG ] ; then
r="|BISECTING"
fi
if [ ! b="$(git symbolic-ref HEAD 2>/dev/null)" ] ; then
b="$(cut -c1-7 $g/HEAD)..."
fi
fi
if [ -n "$1" ] ; then
printf "$1" "${b##refs/heads/}$r"
else
printf "%s" "${b##refs/heads/}$r"
fi
fi
}
user=$1
if [ -z "$user" ] ; then
echo "Error: must specify user as first argument"
exit
fi
scp_pub='scp -o StrictHostKeyChecking=no -o PubkeyAuthentication=yes -o BatchMode=yes'
ssh_pub='ssh -o StrictHostKeyChecking=no -o PubkeyAuthentication=yes -o BatchMode=yes'
if [ ! -d "images" ] ; then
echo "ERROR: images directory does not exist"
echo "Aborting Update"
exit;
fi
cd images
rm -rf src custom
#make sure we can clone latest source to upload
gargoyle_checkout_branchname=$( git_branch )
if [ -z "$gargoyle_checkout_branchname" ] ; then
gargoyle_checkout_branchname="master"
fi
mkdir src
cd src
git clone git://gargoyle-router.com/gargoyle.git
cd gargoyle
git checkout "$gargoyle_checkout_branchname"
cd ..
if [ ! -d "gargoyle" ] ; then
echo "ERROR: Cannot clone source tree from: git://gargoyle-router.com/gargoyle.git"
echo "Aborting Update"
echo ""
exit;
fi
cd ..
#prepare for upload by determining current version and stable version branch
#package dir will be current or next stable version branch
version=$(find . -name "gargoyle_*" | egrep -o "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
major_version="1.0"
if [ -n "$version" ] ; then
major_version=$(echo "$version" | egrep -o "^[0-9]+\.[0-9]+")
major_full_version=$(echo $major_version | sed -e 's/\..*$//g')
major_point_version=$(echo $major_version | sed -e 's/^.*\.//g')
is_odd=$(( $major_point_version % 2 ))
if [ "$is_odd" = "1" ] ; then
major_point_version=$(( $major_point_version + 1 ))
major_version="$major_full_version.$major_point_version"
fi
fi
#give user a chance to cancel
echo "Updateing for gargoyle branch = $gargoyle_checkout_branchname"
echo "Updating for version = $version"
echo "Upcoming major version (for package naming) = $major_version"
echo ""
echo "Beginning update in 10 seconds (kill the job if version info above is wrong!)"
echo ""
countdown=10
while [ $countdown -gt 0 ] ; do
echo "$countdown"
sleep 1
countdown=$(( $countdown - 1 ))
done
echo "Now Doing Update..."
#upload packages and images
image_dirs=$(ls)
for i in $image_dirs ; do
if [ "$i" != "brcm-2.4" ] ; then
echo $i
$scp_pub $i/* $user@gargoyle-router.com:gargoyle_site/downloads/images/$i/
$ssh_pub $user@gargoyle-router.com "rm -rf gargoyle_site/packages/gargoyle-$major_version/$i"
$ssh_pub $user@gargoyle-router.com "mkdir -p gargoyle_site/packages/gargoyle-$major_version/$i"
$scp_pub ../built/$i/* $user@gargoyle-router.com:gargoyle_site/packages/gargoyle-$major_version/$i/
fi
done
#upload tarball of latest code
mkdir src
cd src
tar cvzf gargoyle_$version-src.tar.gz gargoyle
rm -rf gargoyle
$scp_pub gargoyle_$version-src.tar.gz $user@gargoyle-router.com:gargoyle_site/downloads/src/
#update download list
$ssh_pub $user@gargoyle-router.com "./update.sh"
#tag release
git tag "$version" -m "Tag $version"
git push --tags