#!/bin/sh # Prepend an entry to the Debian changelog. # changelog.sh "what changed" set -eu version=${1:-} message=${2:-} root=$(cd "$(dirname "$0")/.." && pwd) file=$root/packaging/deb/changelog if [ -z "$version" ] || [ -z "$message" ]; then echo 'usage: make changelog MSG="what changed"' >&2 exit 2 fi author=${DEBFULLNAME:-tiredsysadmin} email=${DEBEMAIL:-rcmd@garage.rcmd.space} tmp=$(mktemp) { printf 'keeporg (%s) unstable; urgency=medium\n\n' "$version" printf '%s\n' "$message" | fold -s -w 72 | sed -e '1s/^/ * /' -e '2,$s/^/ /' printf '\n' printf ' -- %s <%s> %s\n\n' "$author" "$email" "$(date -R)" cat "$file" } > "$tmp" mv "$tmp" "$file" printf 'added %s to %s\n' "$version" "$file"