-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgenerate_changelog
executable file
·160 lines (145 loc) · 4.49 KB
/
generate_changelog
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
showhelp()
{
cat << ENDHELP
usage: configure [options]
Configure Control Center
Options:
--scheme=<build_scheme>
Builds Control Center with specified build scheme. Supported schemes is: master, dev, branch. Default: master
--no-debian
Disables build of deb file
--maintainer=<name>
Name of package maintainer
--maintainer-email=<email>
Email of package maintainer email. Appropriate GPG key should exist in the system
--version-postfix=<postfix>
Place an extra version number of debian package
--debian-release=<codename>
Codename of target Debian/Ubuntu release
--help
Display this help screen
ENDHELP
}
name_prefix=control-center
scheme="master"
branch=`git branch | grep \* | cut -d ' ' -f2`
maintainer="Subutai Social"
maintainer_email="[email protected]"
build_deb=1
prefix=/usr
debian_release=$(lsb_release -a | awk 'FNR == 4 {print $2}')
version_postfix=$(date +%Y%m%d%H%M%S)
while [ $# -ge 1 ]; do
case "$1" in
--scheme=*)
scheme="`echo ${1} | awk '{print substr($0,10)}'`" ;;
--maintainer=*)
maintainer="`echo ${1} | awk '{print substr($0,14)}'`" ;;
--maintainer-email=*)
maintainer_email="`echo ${1} | awk '{print substr($0,20)}'`" ;;
--no-debian)
build_deb=0 ;;
--debian-release=*)
debian_release="`echo ${1} | awk '{print substr($0,18)}'`" ;;
--version-postfix=*)
version_postfix=-"`echo ${1} | awk '{print substr($0,19)}'`" ;;
--help)
showhelp
exit 0
;;
--build=*) ;;
--prefix=*)
prefix=`echo ${1} | awk '{print substr($0,10)}'`
;;
--includedir=*) ;;
--mandir=*) ;;
--infodir=*) ;;
--sysconfdir=*) ;;
--localstatedir=*) ;;
--disable-silent-rules) ;;
--libdir=*) ;;
--libexecdir=*) ;;
--disable-maintainer-mode) ;;
--disable-dependency-tracking) ;;
*)
echo "ERROR: Unknown argument: $1"
showhelp
exit 1
;;
esac
shift
done
echo "Preparing $scheme build"
if [ "$scheme" == "branch" ]; then
# Configure output binary name
echo "Current branch is $branch"
if [ "$branch" != "master" ]; then
name_base="$name_prefix-$branch"
fi
elif [ "$scheme" == "dev" ]; then
name_base="$name_prefix-dev"
elif [ "$scheme" == "master" ]; then
name_base="$name_prefix"
else
echo "ERROR! $scheme scheme is not supported"
showhelp
exit 1
fi
echo "Building $name_base"
# Configure Debian packager
echo "checking debuild"
which debuild
if [ $? != 0 ]; then
echo "debuild was not found"
elif [ $build_deb == 0 ]; then
echo "skipping deb package"
else
if [ "$maintainer" == "" ]; then
echo "Maintainer name should not be empty"
showhelp
exit 1
fi
echo "Checking GPG"
gpg_bin=`which gpg`
if [ $? != 0 ]; then
echo "GPG is not installed on this computer. Aborting"
exit 2
fi
echo "Checking GPG key"
key=`gpg --list-keys "$maintainer_email"`
if [ $? != 0 ]; then
echo "Failed to find GPG key for $maintainer_email"
exit 2
fi
# Preparing changelog
rm -f changelog
started=0
while IFS='' read -r line || [[ -n "$line" ]]; do
st=${line:0:2}
if [ "$st" == "##" ]; then
if [ $started -eq 1 ]; then
date_formatted=`date -d"$release_date" "+%a, %d %b %Y %H:%M:%S %z"`
echo "" >> changelog
echo " -- $maintainer <$maintainer_email> $date_formatted" >> changelog
echo "" >> changelog
started=0
fi
started=1
release_date=`echo $line | cut -d "]" -f2 | sed -e 's/^[[:space:]]*//'`
version_num=`echo $line | cut -d "[" -f2 | cut -d "]" -f1`
echo "subutai-$name_base ($version_num$version_postfix~$debian_release) $debian_release; urgency=medium" >> changelog
echo "" >> changelog
elif [ "$st" == "* " ]; then
echo " $line" >> changelog
fi
done < CHANGELOG
if [ $started -eq 1 ]; then
date_formatted=`date -d"$release_date" "+%a, %d %b %Y %H:%M:%S %z"`
echo "" >> changelog
echo " -- $maintainer <$maintainer_email> $date_formatted" >> changelog
echo "" >> changelog
started=0
fi
mv changelog deb-packages/deb-packages-internal/debian
fi