1 #@ Include file for the make-release.sh generic release builder.
2 #@ It also needs two hooks: update_stable_hook(), update_release_hook(),
3 #@ which need to "git add" what they have modified.
5 : ${PROGRAM:?"Need \$PROGRAM"}
6 : ${UPROGRAM:?"Need \$UPROGRAM"}
7 : ${MANUAL:?"May need \$MANUAL for announcement references"}
9 : ${UPLOAD:?"Need \$UPLOAD URL for scp(1)"}
12 : ${ACCOUNT:?"May need mailx(1) -A \$ACCOUNT"}
13 : ${MAILTO:?"May need \$MAILTO for announcement"}
14 : ${MAILBCC:?"May need \$MAILBCC for announcement"}
20 ORIG_LC_ALL=${LC_ALL} LC_ALL=C
23 DATE_MAN=`date -u +'%B %d, %Y'`
24 DATE_ISO=`date -u +%Y-%m-%d`
28 [ ${#} -gt 0 ] && printf '%s ' "${@}"
39 headref="`git rev-parse --verify HEAD`"
41 for i in `git rev-parse --branches=stable master^{commit}`; do
42 if [ ${headref} = ${i} ]; then
47 if [ -z "${brref}" ]; then
48 echo >&2 'Not on the [master] or a [stable/*] branch'
51 if [ "`git status --porcelain --ignored |
52 ${awk} 'BEGIN{no=0}{++no}END{print no}'`" -ne 0 ]; then
53 echo >&2 'Directory not clean, see git status --ignored'
57 echo 'Preparing a release on commit '"${headref}"
58 #brname="`git branch | sed -e '/^* /b X' -e d -e :X -e 's/^* //'`"
59 brname=`git symbolic-ref --short HEAD`
60 echo ' That is '"${brname}"
61 printf ' Name of release tag: '
64 vmaj=`{ echo ${VERSION}; } | sed -e 's/^\([^.]\{1,\}\).*/\1/'`
65 vmin=`{ echo ${VERSION}; } | sed -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`
66 [ ${vmin} = ${VERSION} ] && VERSION=${VERSION}.0 vmin=0
67 vupd=`{ echo ${VERSION}; } |
68 sed -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`
69 [ ${vupd} = ${VERSION} ] && VERSION=${VERSION}.0 vupd=0
72 if yesno 'Is '${PROGRAM}' <v'${REL}'> correct?'; then :; else
73 echo >&2 'Bailing out'
77 stblbrname=stable/v${vmaj}.${vmin} need_stblbrname=
78 brref=`git rev-parse --verify ${stblbrname} 2>/dev/null`
79 if [ -z "${brref}" ]; then
80 if yesno 'Create new branch '"${stblbrname}"' after release tag'; then
83 elif [ ${brref} != ${headref} ] || [ ${brname} != ${stblbrname} ]; then
84 echo >&2 "For ${REL} we should be on ${stblbrname}, not ${brname}"
85 echo >&2 'Bailing out'
89 relbrname=release/v${VERSION}
90 brref=`git rev-parse --verify ${relbrname} 2>/dev/null`
91 if [ -z "${brref}" ]; then :; else
92 echo >&2 "The ${relbrname} already exists"
93 echo >&2 'Bailing out'
99 if yesno 'Shall '${PROGRAM}' v'${REL}' have a symbolic name?'; then
100 printf ' ..and it shall be known as: '
102 if yesno 'Is '"${RELSYM}"' correct?'; then :; else
103 echo >&2 'Bailing out'
106 stblmsg="Bump ${UPROGRAM} v${REL} (\"${RELSYM}\"), ${DATE_ISO}"
107 relmsg="Bump ${UPROGRAM} v${REL}.ar (\"${RELSYM}\"), ${DATE_ISO}"
108 RELSYM=" (\"${RELSYM}\")"
110 stblmsg="Bump ${UPROGRAM} v${REL}, ${DATE_ISO}"
111 relmsg="Bump ${UPROGRAM} v${REL}.ar, ${DATE_ISO}"
115 echo 'Updating stable/ files to match the release'
117 if [ -f gen-version.h ] && [ -f make-config.in ]; then
118 grep=grep sed=sed cmp=cmp mv=mv make -f make-config.in _update-version
119 git add gen-version.h
123 LC_ALL=${ORIG_LC_ALL} git commit -S -n -m "${stblmsg}"
124 LC_ALL=${ORIG_LC_ALL} git tag -s -f -m "${stblmsg}" v${REL}
126 if [ -n "${need_stblbrname}" ]; then
127 git checkout -b ${stblbrname}
129 # Normally done in post-commit hook, but not once initially created
130 if yesno 'Shall i update stable/latest "symlink"?'; then
131 git update-ref refs/heads/stable/latest ${stblbrname}
133 if yesno 'Shall i update stable/stable "symlink"?'; then
134 git update-ref refs/heads/stable/stable ${stblbrname}
139 if yesno 'Create release/ branch?'; then
140 git checkout -b ${relbrname}
142 git rm -f .gitignore .mailmap TODO make-release.*
145 LC_ALL=${ORIG_LC_ALL} git commit -S -n -m "${relmsg}"
146 LC_ALL=${ORIG_LC_ALL} git tag -s -f -m "${relmsg}" v${REL}.ar
148 if yesno 'Shall i update release/latest "symlink"?'; then
149 git update-ref refs/heads/release/latest ${relbrname}
151 if yesno 'Shall i update release/stable "symlink"?'; then
152 git update-ref refs/heads/release/stable ${relbrname}
155 relbrname=${stblbrname}
161 if [ ${relbrname} != ${stblbrname} ] &&
162 `git rev-parse --verify timeline^{commit} >/dev/null 2>&1` &&
163 yesno 'Shall i update [timeline]?'; then
164 git checkout timeline
166 git archive --format=tar "v${REL}.ar" | tar -x -f -
168 LC_ALL=${ORIG_LC_ALL} git commit -S -n -m "${relmsg}"
174 [ ${relbrname} != ${stblbrname} ] && git checkout ${stblbrname}
175 git log --no-walk --decorate --oneline --branches --remotes
176 yesno 'Push git(1) repo?' && git push
181 if [ ${relbrname} != ${stblbrname} ] && yesno 'Create tarballs?'; then
184 # Repack with standard tar(1) to avoid new-style headers
185 git archive --format=tar --prefix="${PROGRAM}-${REL}/" v${REL}.ar |
186 ( cd "${TMPDIR}" && tar -x -f - )
189 tar -c -f "${PROGRAM}-${REL}.tar" "${PROGRAM}-${REL}"
190 < "${PROGRAM}-${REL}.tar" xz -e -C sha256 > "${PROGRAM}-${REL}.tar.xz"
191 < "${PROGRAM}-${REL}.tar" gzip > "${PROGRAM}-${REL}.tar.gz"
192 rm "${PROGRAM}-${REL}.tar"
194 : > "${PROGRAM}-${REL}.cksum"
195 openssl sha1 "${PROGRAM}-${REL}.tar.xz" >> "${PROGRAM}-${REL}.cksum"
196 openssl sha256 "${PROGRAM}-${REL}.tar.xz" >> "${PROGRAM}-${REL}.cksum"
197 openssl sha512 "${PROGRAM}-${REL}.tar.xz" >> "${PROGRAM}-${REL}.cksum"
198 openssl sha1 "${PROGRAM}-${REL}.tar.gz" >> "${PROGRAM}-${REL}.cksum"
199 openssl sha256 "${PROGRAM}-${REL}.tar.gz" >> "${PROGRAM}-${REL}.cksum"
200 openssl sha512 "${PROGRAM}-${REL}.tar.gz" >> "${PROGRAM}-${REL}.cksum"
202 echo >> "${PROGRAM}-${REL}.cksum"
203 gpg --detach-sign --armor "${PROGRAM}-${REL}.tar.xz"
204 cat "${PROGRAM}-${REL}.tar.xz.asc" >> "${PROGRAM}-${REL}.cksum"
205 gpg --detach-sign --armor "${PROGRAM}-${REL}.tar.gz"
206 cat "${PROGRAM}-${REL}.tar.gz.asc" >> "${PROGRAM}-${REL}.cksum"
213 # Announcement .txt and .html
215 if yesno 'Prepare announcement?'; then
218 if `git cat-file -e ${relbr}:NEWS 2>/dev/null`; then
219 git show ${relbr}:NEWS > "${TMPDIR}/.${PROGRAM}-${REL}.news"
221 : > "${TMPDIR}/.${PROGRAM}-${REL}.news"
224 { echo "${relmsg}"; echo; } > "${TMPDIR}/${PROGRAM}-${REL}.txt"
225 if [ -f .git/make-release.txt ]; then
227 if [ -n "${bigballs}" ] && [ -f "${TMPDIR}/${PROGRAM}-${REL}.cksum" ]
229 cks=`< "${TMPDIR}/${PROGRAM}-${REL}.cksum" sed -e 's/ //' -e '/^$/,$d'`
230 < "${TMPDIR}/${PROGRAM}-${REL}.cksum" sed '1,/^$/d' \
231 > "${TMPDIR}/.${PROGRAM}-${REL}.sigs"
232 < .git/make-release.txt ${awk} \
233 -v INS="${cks}" -v SIGS="${TMPDIR}/.${PROGRAM}-${REL}.sigs" \
234 -v NEWS="${TMPDIR}/.${PROGRAM}-${REL}.news" '
235 /-----CHECKSUMS-----/{
238 for(i = 1; i <= atop; ++i){
239 match(a[i], /(\(.+\))/)
240 tfn = substr(a[i], RSTART + 1, RLENGTH - 2)
241 tpre = substr(a[i], 1, RSTART - 1)
242 tsuf = substr(a[i], RSTART + RLENGTH + 1)
243 if(fn == "" || fn != tfn)
244 printf "%s:\n", (fn = tfn)
245 printf " %6s %s\n", tpre, tsuf
249 /-----SIGNATURES-----/{
250 while(getline sl < SIGS)
255 while(getline sl < NEWS)
260 ' >> "${TMPDIR}/${PROGRAM}-${REL}.txt"
261 rm -f "${TMPDIR}/.${PROGRAM}-${REL}.sigs"
263 < .git/make-release.txt ${awk} \
264 -v NEWS="${TMPDIR}/.${PROGRAM}-${REL}.news" '
266 while(getline sl < NEWS)
271 ' >> "${TMPDIR}/${PROGRAM}-${REL}.txt"
273 elif [ -f "${TMPDIR}/.${PROGRAM}-${REL}.news" ]; then
274 cat "${TMPDIR}/.${PROGRAM}-${REL}.news" >> \
275 "${TMPDIR}/${PROGRAM}-${REL}.txt"
278 rm -f "${TMPDIR}/.${PROGRAM}-${REL}.news"
280 LC_ALL=${ORIG_LC_ALL} ${EDITOR} "${TMPDIR}/${PROGRAM}-${REL}.txt"
282 # HTML convert ready for S-Web42
284 < "${TMPDIR}/${PROGRAM}-${REL}.txt" ${awk} -v manual="${MANUAL}" '
287 print "<?begin?><?mode icewatsm?><pre>"
299 while(match(s, /(\\?https?\??:\/\/[^ ]*)/)){
300 pre = substr(s, 1, RSTART - 1)
301 mat = substr(s, RSTART, RLENGTH)
302 s = substr(s, RSTART + RLENGTH)
303 if("\\" == substr(mat, 1, 1))
307 if(match(mat, /^https\?/))
308 mat = "https" substr(xt = mat, RSTART + 6)
309 if(match(mat, /sdaoden\.eu/))
310 mat = "<?lref" (xt ? "t " : " ") mat (xt ? "<>" xt : "") "?>"
312 mat = "<?href" (xt ? "t " : " ") mat (xt ? "<>" xt : "") "?>"
321 /^[[:space:]]*s-.*-mode[[:space:]]*$/{
324 /^(NOTES|ChangeLog)/{
330 /^(Appendix|git\(1\) shortlog)/{
346 # Create S-Web42 local references for the possible anchors:
347 # *XY*# / $XY# / -XY# / `XY${APO}# / `~XY${APO}# / "XY"#
348 # (where the mdocmx(7) anchor follows the number sign).
349 # Ideally the anchors have been automatically expanded by
350 # make-news-anchors.sh before.
352 /(^|\(|[[:space:]]+)("[^"]+"|\*[^\*]+\*|`[^'${APO}']+'${APO}'|[-~][-\/:_.[:alnum:]]+|\$[_[:alnum:]]+)#[0-9]+/))
354 pre = (RSTART > 1) ? substr(s, 1, RSTART - 1) : ""
355 mat = substr(s, RSTART, RLENGTH)
356 s = substr(s, RSTART + RLENGTH)
358 # Unfortunately groups are not supported
359 if(match(mat, /^(\(|[[:space:]]+)/) != 0 && RLENGTH > 0){
360 pre = pre substr(mat, 1, RLENGTH)
361 mat = substr(mat, RSTART + RLENGTH)
364 match(mat, /#[0-9]+/)
365 targ = substr(mat, RSTART + 1, RLENGTH)
366 mat = substr(mat, 1, RSTART - 1)
367 res = res pre "<?lreft " manual "#" targ "<>" mat "?>"
375 print "</pre><?end?>"
377 ' > "${TMPDIR}/.${PROGRAM}-ann.html"
385 if [ -n "${bigballs}" ] && yesno 'Upload archives'; then
390 echo "-put ${PROGRAM}-${REL}.tar.xz"
391 echo "-rm ${PROGRAM}-latest.tar.xz"
392 echo "-ln -s ${PROGRAM}-${REL}.tar.xz ${PROGRAM}-latest.tar.xz"
394 echo "-put ${PROGRAM}-${REL}.tar.xz.asc"
395 echo "-rm ${PROGRAM}-latest.tar.xz.asc"
396 echo "-ln -s ${PROGRAM}-${REL}.tar.xz.asc ${PROGRAM}-latest.tar.xz.asc"
398 echo "-put ${PROGRAM}-${REL}.tar.gz"
399 echo "-rm ${PROGRAM}-latest.tar.gz"
400 echo "-ln -s ${PROGRAM}-${REL}.tar.gz ${PROGRAM}-latest.tar.gz"
402 echo "-put ${PROGRAM}-${REL}.tar.gz.asc"
403 echo "-rm ${PROGRAM}-latest.tar.gz.asc"
404 echo "-ln -s ${PROGRAM}-${REL}.tar.gz.asc ${PROGRAM}-latest.tar.gz.asc"
406 if [ -n "${anntxt}" ]; then
407 echo "-put ${PROGRAM}-${REL}.txt"
408 echo "-rm ${PROGRAM}-latest.txt"
409 echo "-ln -s ${PROGRAM}-${REL}.txt ${PROGRAM}-latest.txt"
412 echo "-chmod 0644 ${PROGRAM}-${REL}.*"
421 if [ -n "${anntxt}" ] && yesno 'Send announcement mail?'; then
422 LC_ALL=${ORIG_LC_ALL} ${MAILX} -A ${ACCOUNT} \
423 -s "[ANN]ounce of ${UPROGRAM} v${REL}${RELSYM}" \
424 -q "${TMPDIR}/${PROGRAM}-${REL}.txt" \
425 -b ${MAILBCC} ${MAILTO}
428 # Finally remove the temporary instances than ran this
429 rm -f .git/make-release.*