summaryrefslogtreecommitdiff
path: root/bin/xfsprogs_release.sh
blob: d17ac96bf36c362193fa2940da95c9ee888a0341 (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/bin/bash

SOURCE="$PWD"
VERSION_FILE="$SOURCE/VERSION"
CONFIGURE_FILE="$SOURCE/configure.ac"
DEB_FILE="$SOURCE/debian/changelog"
LIST="[email protected]"
FORNEXT_DIR="/home/cmaiolin/Source/xfsprogs/for-next"
LAST_HEAD=""
DEBUG=1

VER_MAJ="$1"
VER_MIN="$2"
VER_REV="$3"

CHANGELOG_FILE="/tmp/changelog.$$"

##### COMMON #####

# Print Usage information
usage(){
	echo " ./xfsprogs_relase.sh <maj_ver> <min_ver> <revision>"
	exit
}

# Check update versioning
check_args(){
	if [ -z ${VER_MAJ} ]; then
		echo "SET MAJ VERSION"
		usage
	fi
	if [ -z ${VER_MIN} ]; then
		echo "SET MIN VERSION"
		usage
	fi
	if [ -z ${VER_REV} ]; then
		echo "SET REVISION"
		usage
	fi
}

# Open neomutt with the composed message to send
send_email(){
SUBJECT="$1"
BODY="$2"

	if [ -z "$SUBJECT" ]; then
		echo "No subject... exiting"
		exit 1
	fi

	if [ -f $BODY ]; then
		neomutt -F ~/.mutt/muttrc-local-korg -s "$SUBJECT" $LIST -i $BODY
	else
		echo "No message body... exiting"
		exit 1
	fi

}

print_shortlog(){
LAST_HEAD=$1
HEAD=$2

	if [ -z $LAST_HEAD ]; then
		echo "Previous head not set... exiting"
		exit 1
	fi

	if [ -z $HEAD ]; then
		HEAD="HEAD"
	fi

	echo "$(git shortlog --format="[%h] %s" $LAST_HEAD..$HEAD)"
}

print_diffstat(){
LAST_HEAD=$1
HEAD=$2

	if [ -z $LAST_HEAD ]; then
		echo "Previous head not set... exiting"
		exit 1
	fi

	if [ -z $HEAD ]; then
		HEAD="HEAD"
	fi

	echo "$(git diff --stat --summary -C -M $LAST_HEAD..$HEAD)"
}

print_commit_count(){
LAST_HEAD=$1
HEAD=$2

	if [ -z $LAST_HEAD ]; then
		echo "Previous head not set... exiting"
		exit 1
	fi

	if [ -z $HEAD ]; then
		HEAD="HEAD"
	fi

	echo "$(git log --oneline $LAST_HEAD.. | wc -l)"
}

print_head(){
	if [ "$1" == "short" ]; then
		HEAD=$(git log --oneline --format="%h" -1)
	else
		HEAD=$(git log --oneline --format="%H" -1)
	fi
	echo "$HEAD"
}

##### COMMON END #####


##### FOR-NEXT UPDATE #####
compose_fornext_email(){

	MAIL_FILE=$(mktemp)
	LAST_HEAD=$1

if [ -z $LAST_HEAD ]; then
	echo "compose_email: Previous head not set... exiting"
	exit 1
fi

# BEGIN_OF_MESSAGE
cat << EOF > $MAIL_FILE
Hello.

The xfsprogs for-next branch, located at:

https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/refs/?h=for-next

Has just been updated.

Patches often get missed, so if your outstanding patches are properly reviewed on
the list and not included in this update, please let me know.

The new head of the for-next branch is commit:

$(print_head)

$(print_commit_count $LAST_HEAD) new commits:

$(print_shortlog $LAST_HEAD)

Code Diffstat:

$(print_diffstat $LAST_HEAD)
EOF
# END_OF_MESSAGE

echo $MAIL_FILE
}

compose_release_email(){

	MAIL_FILE=$(mktemp)
	LAST_HEAD=$1

cat << EOF > $MAIL_FILE
Hi folks,

The xfsprogs repository at:

	git://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git

has just been updated.

Patches often get missed, so if your outstanding patches are properly reviewed
on the list and not included in this update, please let me know.

The for-next branch has also been updated to match the state of master.

The new head of the master branch is commit:

$(print_head)

New commits:

$(print_shortlog $LAST_HEAD)

Code Diffstat:

$(print_diffstat $LAST_HEAD)
EOF

#END_OF_MESSAGE
echo $MAIL_FILE

}
fornext_announce(){

	LAST_HEAD=$1

	if [ -z $LAST_HEAD ]; then
		echo "No starting HEAD specified... exiting"
		exit 1
	fi

	SUBJECT="[ANNOUNCE] xfsprogs: for-next updated to $(print_head short)"
	BODY=$(compose_fornext_email $LAST_HEAD)

	send_email "$SUBJECT" $BODY
}

release_announce(){
	LAST_HEAD=$1
	RELEASE=$(git describe --abbrev=0)

	if [ -z $LAST_HEAD ]; then
		echo "No starting HEAD specified... exiting"
		exit 1
	fi

	SUBJECT="[ANNOUNCE] xfsprogs $RELEASE released"
	BODY=$(compose_release_email $LAST_HEAD)

	send_email "$SUBJECT" $BODY
}
##### FOR-NEXT UPDATE #####

##### RELEASE SETUP ######
update_version_file(){
	echo "updating version"
	sed -i -e "s/^PKG_MAJOR=.*/PKG_MAJOR=$VER_MAJ/" $VERSION_FILE
	sed -i -e "s/^PKG_MINOR=.*/PKG_MINOR=$VER_MIN/" $VERSION_FILE
	sed -i -e "s/^PKG_REVISION=.*/PKG_REVISION=$VER_REV/" $VERSION_FILE
}

update_configure_file(){
	CONF_AC="AC_INIT([xfsprogs],[$VER_MAJ.$VER_MIN.$VER_REV],[[email protected]])"

	sed -i "s/^AC_INIT.*/$CONF_AC/" $CONFIGURE_FILE
}

update_debian_changelog(){
#if [ ! -s $CHANGELOG_FILE ]; then
#	echo "Error: changelog does not exist or empty. Exiting..."
#	exit
#fi

sed -i "1s/^/\n/" $DEB_FILE
sed -i "1s/^/ -- Nathan Scott <[email protected]>  `date -R`\n/" $DEB_FILE
sed -i "1s/^/\n/" $DEB_FILE

#while read -r LINE; do
#	sed -i "1s/^/  * $LINE\n/" $DEB_FILE
#done <$CHANGELOG_FILE

sed -i "1s/^/  * New upstream release\n/" $DEB_FILE
sed -i "1s/^/\n/" $DEB_FILE
sed -i "1s/^/xfsprogs ($VER_MAJ.$VER_MIN.$VER_REV) unstable; urgency=low\n/" $DEB_FILE
}

# Get user inputs for each changelog entry
# XXX this should be automated based on patches subjects
get_changelog(){
	LOG=""
	while [ 1 ]; do
		read -p "Changelog entry:" tmplog

		if [ -z "$tmplog" ]; then
			break;
		fi
		echo "$tmplog" >> $CHANGELOG_FILE
	done
}


#MOVE TO THE CORRECT REPO
#cd $FORNEXT_DIR

#check_args
#get_changelog
#update_version_file
#update_configure_file
#update_debian_changelog
#rm $CHANGELOG_FILE
#email_fornext $1
#fornext_announce 37e6e80a6

while getopts "n:r:" opt; do
	case $opt in
		n)	# for-next
			LAST_HEAD=$OPTARG
			fornext_announce $LAST_HEAD
			;;
		r)	# Release
			LAST_HEAD=$OPTARG
			release_announce $LAST_HEAD
			;;
		*)
			usage
			;;
	esac
done