xref: /lighttpd1.4/packdist.sh (revision bff59765)
1#!/bin/bash
2
3SRCTEST=src/server.c
4PACKAGE=lighttpd
5BASEDOWNLOADURL="https://download.lighttpd.net/lighttpd/releases-1.4.x"
6SNAPSHOTURL="https://download.lighttpd.net/lighttpd/snapshots-1.4.x"
7
8if [[ "`id -un`" != "stbuehler" ]] && [[ -z "$AUTHOR" ]]; then
9  export AUTHOR="gstrauss"
10  export KEYID="AF16D0F0"
11fi
12
13AUTHOR="${AUTHOR:-stbuehler}"
14
15# may take one argument for prereleases like
16# ./packdist.sh [--nopack] rc1-r10
17
18syntax() {
19	echo "./packdist.sh [--nopack] [--help] [~rc1]" >&2
20	exit 2
21}
22
23if [ ! -f ${SRCTEST} ]; then
24	echo "Current directory is not the source directory"
25	exit 1
26fi
27
28dopack=1
29
30while [ $# -gt 0 ]; do
31	case "$1" in
32	"--nopack")
33		dopack=0
34		;;
35	"--help")
36		syntax
37		;;
38	"rc"*|"~rc"*)
39		if [ -n "$append" ]; then
40			echo "Only one append allowed" >&2
41			syntax
42		fi
43		echo "Appending '$1'"
44		append="$1"
45		BASEDOWNLOADURL="${SNAPSHOTURL}"
46		;;
47	*)
48		echo "Unknown option '$1'" >&2
49		syntax
50		;;
51	esac
52	shift
53done
54
55force() {
56	"$@" || {
57		echo "Command failed: $*"
58		exit 1
59	}
60}
61
62# summarize all changes since last release
63genchanges() {
64	(
65		cat ../NEWS | sed "/^- ${version}/,/^-/p;d" | sed "/^- /d;/^$/d" | sed -e 's/^  \*/\*/'
66	) > CHANGES
67	return 0
68}
69
70# generate links in old textile format "text":url
71genlinks_changes() {
72	local repourl ticketurl inf out
73	repourl="https://redmine.lighttpd.net/projects/lighttpd/repository/revisions/"
74	ticketurl="https://redmine.lighttpd.net/issues/"
75	inf="$1"
76	outf="$1".links
77	(
78		sed -e 's%\(https://[a-zA-Z0-9.:_/\-]\+\)%"\1":\1%g' |
79		sed -e 's%#\([0-9]\+\)%"#\1":'"${ticketurl}"'\1%g' |
80		sed -e 's%r\([0-9]\+\)%"r\1":'"${repourl}"'\1%g' |
81		sed -e 's%\(CVE-[0-9\-]\+\)%"\1":https://cve.mitre.org/cgi-bin/cvename.cgi?name=\1%g' |
82		cat
83	) < "$inf" > "$outf"
84}
85genlinks_downloads() {
86	local repourl ticketurl inf out
87	repourl="https://redmine.lighttpd.net/projects/lighttpd/repository/revisions/"
88	ticketurl="https://redmine.lighttpd.net/issues/"
89	inf="$1"
90	outf="$1".links
91	(
92		sed -e 's%\(https://[a-zA-Z0-9.:_/\-]\+\)%"\1":\1%g' |
93		cat
94	) < "$inf" > "$outf"
95}
96
97blog_post() {
98	if [ -z "${append}" ]; then
99		# release
100		cat <<EOF
101---
102layout: post
103title: ${version}
104author: $AUTHOR
105author_email: ${AUTHOR}@lighttpd.net
106categories:
107- download
108tags:
109- ${version}
110- lighttpd
111- releases
112---
113{% excerpt %}
114
115h2. Important changes
116
117TODO
118
119h2. Downloads
120
121EOF
122		cat DOWNLOADS.links
123		cat <<EOF
124
125{% endexcerpt %}
126h2. Changes from ${prevversion}
127
128EOF
129		cat CHANGES.links
130	else
131		# pre release
132		cat <<EOF
133---
134layout: post
135title: 'PRE-RELEASE: lighttpd ${version}${append}'
136categories:
137- lighttpd
138tags:
139- '1.4'
140- ${version}
141- lighttpd
142- prerelease
143---
144{% excerpt %}
145We would like to draw your attention to the latest pre-release of the stable 1.4 branch of lighttpd.
146
147You can get the pre-release from these urls:
148EOF
149		cat DOWNLOADS.links
150		cat <<EOF
151
152Please test it as much as possible and provide us with feedback.
153A lot of testing ensures a good release.
154
155<!-- TODO: describe major changes -->
156
157{% endexcerpt %}
158
159h4. Changes from ${prevversion}
160
161EOF
162		cat CHANGES.links
163
164		cat <<EOF
165
166If you want to get the latest source for any branch, you can get it from our svn repository.
167Documentation to do so can be obtained from this page: "DevelSubversion":https://redmine.lighttpd.net/projects/lighttpd/wiki/DevelSubversion
168Bug reports or feature requests can be filed in our ticket system: "New Issue":https://redmine.lighttpd.net/projects/lighttpd/issues/new
169Please make sure to check if there isn't a ticket already here: "Issues":https://redmine.lighttpd.net/projects/lighttpd/issues
170Perhaps you also want to have a look at our "download site":https://download.lighttpd.net/lighttpd/
171
172Thank you for flying light.
173EOF
174	fi
175}
176
177if [ ${dopack} = "1" ]; then
178	force ./autogen.sh
179
180	if [ -d distbuild ]; then
181		# make distcheck may leave readonly files
182		chmod u+w -R distbuild
183		rm -rf distbuild
184	fi
185
186	force mkdir distbuild
187	force cd distbuild
188
189	force ../configure --prefix=/usr
190
191	# force make
192	# force make check
193
194	force make -j 4 distcheck
195	force fakeroot make dist
196else
197	force cd distbuild
198fi
199
200version=`./config.status -V | head -n 1 | cut -d' ' -f3`
201name="${PACKAGE}-${version}"
202if [ -n "${append}" ]; then
203	cp "${name}.tar.gz" "${name}${append}.tar.gz"
204	cp "${name}.tar.xz" "${name}${append}.tar.xz"
205	name="${name}${append}"
206fi
207
208force sha256sum "${name}.tar."{gz,xz} > "${name}.sha256sum"
209force sha512sum "${name}.tar."{gz,xz} > "${name}.sha512sum"
210
211rm -f "${name}".tar.*.asc
212
213force gpg ${KEYID:+-u "${KEYID}"} -a --output "${name}.tar.gz.asc" --detach-sig "${name}.tar.gz"
214force gpg ${KEYID:+-u "${KEYID}"} -a --output "${name}.tar.xz.asc" --detach-sig "${name}.tar.xz"
215
216(
217	echo "* ${BASEDOWNLOADURL}/${name}.tar.gz"
218	echo "** GPG signature: ${BASEDOWNLOADURL}/${name}.tar.gz.asc"
219	echo "** SHA256: @$(sha256sum ${name}.tar.gz | cut -d' ' -f1)@"
220	echo "* ${BASEDOWNLOADURL}/${name}.tar.xz"
221	echo "** GPG signature: ${BASEDOWNLOADURL}/${name}.tar.xz.asc"
222	echo "** SHA256: @$(sha256sum ${name}.tar.xz | cut -d' ' -f1)@"
223	echo "* SHA256 checksums: ${BASEDOWNLOADURL}/${name}.sha256sum"
224	echo "* SHA512 checksums: ${BASEDOWNLOADURL}/${name}.sha512sum"
225) > DOWNLOADS
226
227(
228	echo "* \"${name}.tar.gz\":${BASEDOWNLOADURL}/${name}.tar.gz (\"GPG signature\":${BASEDOWNLOADURL}/${name}.tar.gz.asc)"
229	echo "** SHA256: @$(sha256sum ${name}.tar.gz | cut -d' ' -f1)@"
230	echo "* \"${name}.tar.xz\":${BASEDOWNLOADURL}/${name}.tar.xz (\"GPG signature\":${BASEDOWNLOADURL}/${name}.tar.xz.asc)"
231	echo "** SHA256: @$(sha256sum ${name}.tar.xz | cut -d' ' -f1)@"
232	echo "* \"SHA256 checksums\":${BASEDOWNLOADURL}/${name}.sha256sum"
233	echo "* \"SHA512 checksums\":${BASEDOWNLOADURL}/${name}.sha512sum"
234) > DOWNLOADS.links
235
236force genchanges
237force genlinks_changes CHANGES
238#force genlinks_downloads DOWNLOADS
239
240prevversion="${version%.*}.$((${version##*.} - 1))"
241
242if [ -z "${append}" ]; then
243	# only for Releases
244	(
245		cat <<EOF
246h1. Release Info
247
248* Version: ${version}
249* Previous version: [[Release-${prevversion//./_}|${prevversion}]]
250* Branch: 1.4
251* Status: stable
252* Release Purpose: bug fixes
253* Release manager: $AUTHOR
254* Released date: $(date +"%Y-%m-%d")
255
256h1. Important changes from ${prevversion}
257
258TODO
259
260h1. Downloads
261
262EOF
263		cat DOWNLOADS
264		cat <<EOF
265
266h1. Changes from ${prevversion}
267
268EOF
269		cat CHANGES
270		cat <<EOF
271
272h1. External references
273
274* https://www.lighttpd.net/$(date +"%Y/%-m/%-d")/${version}
275
276EOF
277	) > "Release-${version//./_}.page"
278
279	cat "Release-${version//./_}.page"
280fi
281
282echo
283echo -------
284echo
285
286
287
288blog_post > $(date +"%Y-%m-%d")-"${version}.textile"
289cat $(date +"%Y-%m-%d")-"${version}.textile"
290
291echo
292echo -------
293echo
294
295echo wget "${BASEDOWNLOADURL}/${name}".'{tar.gz,tar.xz,sha256sum,sha512sum}'
296echo sha256sum -c "${name}".sha256sum
297echo sha512sum -c "${name}".sha512sum
298