Statistics
| Branch: | Tag: | Revision:

root / dev-utils / do_release.sh @ 8a51e7f9d298095ea3ce9a733514d09ff417695c

History | View | Annotate | Download (3.6 KB)

1
#!/bin/bash
2
3
git_branch()
4
{
5
	local g="$(git rev-parse --git-dir 2>/dev/null)"
6
	if [ -n "$g" ]; then
7
		local r
8
		local b
9
		if [ -d "$g/../.dotest" ] ; then
10
			r="|AM/REBASE"
11
			b="$(git symbolic-ref HEAD 2>/dev/null)"
12
		elif [ -f "$g/.dotest-merge/interactive" ] ; then
13
			r="|REBASE-i"
14
			b="$(cat $g/.dotest-merge/head-name)"
15
		elif [ -d "$g/.dotest-merge" ] ; then
16
			r="|REBASE-m"
17
			b="$(cat $g/.dotest-merge/head-name)"
18
		elif [ -f "$g/MERGE_HEAD" ] ; then
19
			r="|MERGING"
20
			b="$(git symbolic-ref HEAD 2>/dev/null)"
21
		else
22
			if [ -f $g/BISECT_LOG ] ; then
23
				r="|BISECTING"
24
			fi
25
			if  ! b="$(git symbolic-ref HEAD 2>/dev/null)"  ; then
26
				b="$(cut -c1-7 $g/HEAD)..."
27
			fi
28
		fi
29
		if [ -n "$1" ] ; then
30
			printf "$1" "${b##refs/heads/}$r"
31
		else
32
			printf "%s" "${b##refs/heads/}$r"
33
		fi
34
	fi
35
}
36
37
38
user=$1
39
if [ -z "$user" ] ; then
40
	echo "Error: must specify user as first argument"
41
	exit
42
fi
43
44
scp_pub='scp -o StrictHostKeyChecking=no -o PubkeyAuthentication=yes -o BatchMode=yes'
45
ssh_pub='ssh -o StrictHostKeyChecking=no -o PubkeyAuthentication=yes -o BatchMode=yes'
46
47
if [ ! -d "images" ] ; then
48
	echo "ERROR: images directory does not exist"
49
	echo "Aborting Update"
50
	exit;
51
fi
52
53
cd images
54
rm -rf src custom
55
56
#make sure we can clone latest source to upload
57
gargoyle_checkout_branchname=$( git_branch )
58
if [ -z  "$gargoyle_checkout_branchname" ] ; then
59
	gargoyle_checkout_branchname="master"
60
fi
61
mkdir src
62
cd src
63
git clone git://gargoyle-router.com/gargoyle.git
64
cd gargoyle
65
git checkout "$gargoyle_checkout_branchname"
66
cd ..
67
if [ ! -d "gargoyle" ] ; then
68
	echo "ERROR: Cannot clone source tree from: git://gargoyle-router.com/gargoyle.git"
69
	echo "Aborting Update"
70
	echo ""
71
	exit;
72
fi
73
cd ..
74
75
76
#prepare for upload by determining current version and stable version branch
77
#package dir will be current or next stable version branch
78
version=$(find . -name "gargoyle_*"  | egrep -o "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
79
major_version="1.0"
80
if [ -n "$version" ] ; then
81
	major_version=$(echo "$version" | egrep -o "^[0-9]+\.[0-9]+")
82
	
83
	major_full_version=$(echo $major_version | sed -e 's/\..*$//g')
84
	major_point_version=$(echo $major_version | sed -e 's/^.*\.//g')
85
	is_odd=$(( $major_point_version % 2 ))
86
	if [ "$is_odd" = "1" ] ; then
87
		major_point_version=$(( $major_point_version + 1 ))
88
		major_version="$major_full_version.$major_point_version"
89
	fi
90
fi
91
92
93
#give user a chance to cancel
94
echo "Updating for gargoyle branch = $gargoyle_checkout_branchname"
95
echo "Updating for version = $version"
96
echo "Upcoming major version (for package naming) = $major_version"
97
echo ""
98
echo "Beginning update in 10 seconds (kill the job if version info above is wrong!)"
99
echo ""
100
countdown=10
101
while [ $countdown -gt 0 ] ; do
102
	echo "$countdown"
103
	sleep 1
104
	countdown=$(( $countdown - 1 ))
105
done
106
107
echo "Now Doing Update..."
108
109
110
#upload packages and images
111
image_dirs=$(ls)
112
for i in $image_dirs ; do
113
	if [ "$i" != "brcm-2.4" ] ; then
114
		echo $i
115
	
116
		$scp_pub $i/* $user@gargoyle-router.com:gargoyle_site/downloads/images/$i/
117
		$ssh_pub $user@gargoyle-router.com "rm -rf   gargoyle_site/packages/gargoyle-$major_version/$i"
118
		$ssh_pub $user@gargoyle-router.com "mkdir -p gargoyle_site/packages/gargoyle-$major_version/$i"
119
		$scp_pub ../built/$i/* $user@gargoyle-router.com:gargoyle_site/packages/gargoyle-$major_version/$i/
120
	fi
121
done
122
123
#upload tarball of latest code
124
mkdir src
125
cd src
126
tar cvzf gargoyle_$version-src.tar.gz gargoyle
127
rm -rf gargoyle
128
$scp_pub gargoyle_$version-src.tar.gz $user@gargoyle-router.com:gargoyle_site/downloads/src/
129
130
#update download list
131
$ssh_pub $user@gargoyle-router.com  "./update.sh"
132
133
134
#tag release
135
git tag "$version" -m "Tag $version"
136
git push --tags
137