#!/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 < {% endexcerpt %} h4. Changes from ${prevversion} EOF cat CHANGES.links cat < "${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 < "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