summaryrefslogtreecommitdiff
path: root/packdist.sh
blob: 85fb5a0f1eb134291456db9fd4b8c4513b5914f8 (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
#!/bin/bash

SRCTEST=src/server.c
PACKAGE=lighttpd
BASEDOWNLOADURL="https://download.lighttpd.net/lighttpd/releases-1.4.x"
SNAPSHOTURL="https://download.lighttpd.net/lighttpd/snapshots-1.4.x"

if [[ "`id -un`" != "stbuehler" ]] && [[ -z "$AUTHOR" ]]; then
  export AUTHOR="gstrauss"
  export KEYID="AF16D0F0"
fi

AUTHOR="${AUTHOR:-stbuehler}"

# may take one argument for prereleases like
# ./packdist.sh [--nopack] rc1-r10

syntax() {
	echo "./packdist.sh [--nopack] [--help] [~rc1]" >&2
	exit 2
}

if [ ! -f ${SRCTEST} ]; then
	echo "Current directory is not the source directory"
	exit 1
fi

dopack=1

while [ $# -gt 0 ]; do
	case "$1" in
	"--nopack")
		dopack=0
		;;
	"--help")
		syntax
		;;
	"rc"*|"~rc"*)
		if [ -n "$append" ]; then
			echo "Only one append allowed" >&2
			syntax
		fi
		echo "Appending '$1'"
		append="$1"
		BASEDOWNLOADURL="${SNAPSHOTURL}"
		;;
	*)
		echo "Unknown option '$1'" >&2
		syntax
		;;
	esac
	shift
done

force() {
	"$@" || {
		echo "Command failed: $*"
		exit 1
	}
}

# summarize all changes since last release
genchanges() {
	(
		cat ../NEWS | sed "/^- ${version}/,/^-/p;d" | sed "/^- /d;/^$/d" | sed -e 's/^  \*/\*/'
	) > CHANGES
	return 0
}

# generate links in old textile format "text":url
genlinks_changes() {
	local repourl ticketurl inf out
	repourl="https://redmine.lighttpd.net/projects/lighttpd/repository/revisions/"
	ticketurl="https://redmine.lighttpd.net/issues/"
	inf="$1"
	outf="$1".links
	(
		sed -e 's%\(https://[a-zA-Z0-9.:_/\-]\+\)%"\1":\1%g' |
		sed -e 's%#\([0-9]\+\)%"#\1":'"${ticketurl}"'\1%g' |
		sed -e 's%r\([0-9]\+\)%"r\1":'"${repourl}"'\1%g' |
		sed -e 's%\(CVE-[0-9\-]\+\)%"\1":https://cve.mitre.org/cgi-bin/cvename.cgi?name=\1%g' |
		cat
	) < "$inf" > "$outf"
}
genlinks_downloads() {
	local repourl ticketurl inf out
	repourl="https://redmine.lighttpd.net/projects/lighttpd/repository/revisions/"
	ticketurl="https://redmine.lighttpd.net/issues/"
	inf="$1"
	outf="$1".links
	(
		sed -e 's%\(https://[a-zA-Z0-9.:_/\-]\+\)%"\1":\1%g' |
		cat
	) < "$inf" > "$outf"
}

blog_post() {
	if [ -z "${append}" ]; then
		# release
		cat <<EOF
---
layout: post
title: ${version}
author: $AUTHOR
author_email: ${AUTHOR}@lighttpd.net
categories:
- download
tags:
- ${version}
- lighttpd
- releases
---
{% excerpt %}

h2. Important changes

TODO

h2. Downloads

EOF
		cat DOWNLOADS.links
		cat <<EOF

{% endexcerpt %}
h2. Changes from ${prevversion}

EOF
		cat CHANGES.links
	else
		# pre release
		cat <<EOF
---
layout: post
title: 'PRE-RELEASE: lighttpd ${version}${append}'
categories:
- lighttpd
tags:
- '1.4'
- ${version}
- lighttpd
- prerelease
---
{% excerpt %}
We would like to draw your attention to the latest pre-release of the stable 1.4 branch of lighttpd.

You can get the pre-release from these urls:
EOF
		cat DOWNLOADS.links
		cat <<EOF

Please test it as much as possible and provide us with feedback.
A lot of testing ensures a good release.

<!-- TODO: describe major changes -->

{% endexcerpt %}

h4. Changes from ${prevversion}

EOF
		cat CHANGES.links

		cat <<EOF

If you want to get the latest source for any branch, you can get it from our svn repository.
Documentation to do so can be obtained from this page: "DevelSubversion":https://redmine.lighttpd.net/projects/lighttpd/wiki/DevelSubversion
Bug reports or feature requests can be filed in our ticket system: "New Issue":https://redmine.lighttpd.net/projects/lighttpd/issues/new
Please make sure to check if there isn't a ticket already here: "Issues":https://redmine.lighttpd.net/projects/lighttpd/issues
Perhaps you also want to have a look at our "download site":https://download.lighttpd.net/lighttpd/

Thank you for flying light.
EOF
	fi
}

if [ ${dopack} = "1" ]; then
	force ./autogen.sh

	if [ -d distbuild ]; then
		# make distcheck may leave readonly files
		chmod u+w -R distbuild
		rm -rf distbuild
	fi

	force mkdir distbuild
	force cd distbuild

	force ../configure --prefix=/usr

	# force make
	# force make check

	force make -j 4 distcheck
	force fakeroot make dist
else
	force cd distbuild
fi

version=`./config.status -V | head -n 1 | cut -d' ' -f3`
name="${PACKAGE}-${version}"
if [ -n "${append}" ]; then
	cp "${name}.tar.gz" "${name}${append}.tar.gz"
	cp "${name}.tar.xz" "${name}${append}.tar.xz"
	name="${name}${append}"
fi

force sha256sum "${name}.tar."{gz,xz} > "${name}.sha256sum"
force sha512sum "${name}.tar."{gz,xz} > "${name}.sha512sum"

rm -f "${name}".tar.*.asc

force gpg ${KEYID:+-u "${KEYID}"} -a --output "${name}.tar.gz.asc" --detach-sig "${name}.tar.gz"
force gpg ${KEYID:+-u "${KEYID}"} -a --output "${name}.tar.xz.asc" --detach-sig "${name}.tar.xz"

(
	echo "* ${BASEDOWNLOADURL}/${name}.tar.gz"
	echo "** GPG signature: ${BASEDOWNLOADURL}/${name}.tar.gz.asc"
	echo "** SHA256: @$(sha256sum ${name}.tar.gz | cut -d' ' -f1)@"
	echo "* ${BASEDOWNLOADURL}/${name}.tar.xz"
	echo "** GPG signature: ${BASEDOWNLOADURL}/${name}.tar.xz.asc"
	echo "** SHA256: @$(sha256sum ${name}.tar.xz | cut -d' ' -f1)@"
	echo "* SHA256 checksums: ${BASEDOWNLOADURL}/${name}.sha256sum"
	echo "* SHA512 checksums: ${BASEDOWNLOADURL}/${name}.sha512sum"
) > DOWNLOADS

(
	echo "* \"${name}.tar.gz\":${BASEDOWNLOADURL}/${name}.tar.gz (\"GPG signature\":${BASEDOWNLOADURL}/${name}.tar.gz.asc)"
	echo "** SHA256: @$(sha256sum ${name}.tar.gz | cut -d' ' -f1)@"
	echo "* \"${name}.tar.xz\":${BASEDOWNLOADURL}/${name}.tar.xz (\"GPG signature\":${BASEDOWNLOADURL}/${name}.tar.xz.asc)"
	echo "** SHA256: @$(sha256sum ${name}.tar.xz | cut -d' ' -f1)@"
	echo "* \"SHA256 checksums\":${BASEDOWNLOADURL}/${name}.sha256sum"
	echo "* \"SHA512 checksums\":${BASEDOWNLOADURL}/${name}.sha512sum"
) > DOWNLOADS.links

force genchanges
force genlinks_changes CHANGES
#force genlinks_downloads DOWNLOADS

prevversion="${version%.*}.$((${version##*.} - 1))"

if [ -z "${append}" ]; then
	# only for Releases
	(
		cat <<EOF
h1. Release Info

* Version: ${version}
* Previous version: [[Release-${prevversion//./_}|${prevversion}]]
* Branch: 1.4
* Status: stable
* Release Purpose: bug fixes
* Release manager: $AUTHOR
* Released date: $(date +"%Y-%m-%d")

h1. Important changes from ${prevversion}

TODO

h1. Downloads

EOF
		cat DOWNLOADS
		cat <<EOF

h1. Changes from ${prevversion}

EOF
		cat CHANGES
		cat <<EOF

h1. External references

* https://www.lighttpd.net/$(date +"%Y/%-m/%-d")/${version}

EOF
	) > "Release-${version//./_}.page"

	cat "Release-${version//./_}.page"
fi

echo
echo -------
echo



blog_post > $(date +"%Y-%m-%d")-"${version}.textile"
cat $(date +"%Y-%m-%d")-"${version}.textile"

echo
echo -------
echo

echo wget "${BASEDOWNLOADURL}/${name}".'{tar.gz,tar.xz,sha256sum,sha512sum}'
echo sha256sum -c "${name}".sha256sum
echo sha512sum -c "${name}".sha512sum