From d2db6ea4b328c452e67622649a11fdafd4009378 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 21 Aug 2022 23:48:10 +0200 Subject: [PATCH] set-version.sh: Update to handle debian/changes and PROGRAM_VERSION in Makefile. --- set-version.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/set-version.sh b/set-version.sh index e0c6f6c..76356ee 100755 --- a/set-version.sh +++ b/set-version.sh @@ -1,9 +1,68 @@ #!/bin/bash +# Simple script to make it easy to update the version number for the program. +# +# Debian +# ---------------------------- +# For releasing debian packages, there must be a name and email associated with the version. +# You can pass "-n|--name" and "-e|--email" as parameters to this script. +# +# You can if you want set the following enviroment variables in your shell to have your name and email be inserted without cli flags. +# DEB_MAINT_NAME +# DEB_MAINT_EMAIL -if [ $# -lt 1 ]; then - echo "$0 " +function usage() { + echo "Usage: ${0##*/} [ -h|--help ] [ -n|--name ] [ -e|--email ] [ --nodebchanges ] " exit 1 +} + +eval set -- "$(getopt -n "${0##*/}" -o "hn:e:" -l "help,name:,email:,nodebchanges" -- "$@")" + +WRITE_DEBCHANGES=1 +while true; do + + case $1 in + -n|--name) + shift + DEB_MAINT_NAME=$1 + ;; + -e|--email) + shift + DEB_MAINT_EMAIL=$1 + ;; + --nodebchanges) + WRITE_DEBCHANGES=0 + ;; + -h|--help) usage ;; + --) shift + break + ;; + esac + shift +done + +[ $# -gt 0 ] || [ $? -eq 0 ] || usage + +VERSION=$@ + +if [ ${WRITE_DEBCHANGES} -ne 0 ]; then + # Update debian changelog + ex debian/changelog < $(date -R) + +. +xit +EOF + echo -e "[\e[34m::\e[0m] Inserted template in \e[1mdebian/changelog\e[0m. \e[33mMake sure you edit this file with the actual changes!\e[0m" +else : + echo -e "[\e[33m::\e[0m] Skipping \e[1mdebian/changelog\e[0m." fi -sed -i "s:PROGRAM_VERSION=\(.*\):PROGRAM_VERSION=$1:g" scripts/info.sh -sed -i "s~\print(\"Version:\ v\(.*\)\\\n\")~print(\\\"Version:\ v$1\\\n\\\")~g" src/main.go + +# Update Makefile +sed -i "s:PROGRAM_VERSION=\(.*\):PROGRAM_VERSION=$1:g" Makefile +echo -e "[\e[34m::\e[0m] Set PROGRAM_VERSION=\e[34m$1\e[0m in \e[1mMakefile\e[0m"