Script to create signed git tag for new Shorewall release. Signed tag will be created in the code and release repository.
Signed-off-by: Matt Darfeuille <matd...@gmail.com> --- build/release | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 build/release diff --git a/build/release b/build/release new file mode 100644 index 00000000..747cf9bc --- /dev/null +++ b/build/release @@ -0,0 +1,234 @@ +#!/bin/sh +# +# +# Shorewall Release Processing -- (C) 2003-2017 -- Tom Eastep (teas...@shorewall.net) +# -- (C) 2005,2006 -- Cristian Rodriguez (webmas...@shorewall.net) +# -- (C) 2017 -- Matt Darfeuille (matd...@gmail.com) +# Version : $Id: buildshorewall 9189 2008-12-29 19:55:18Z teastep $ +# +# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of Version 2 of the GNU General Public License +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Usage: +# +# release [ <OPTIONS> ] <VERSION> +# +# Script to create signed tag for new Shorewall release. +# The signed tag is to be created +# in the code and release repository. +# If both options -c and -r are not given +# the default value of the 'git tag' command will be used. +# +################################################################################ +# C O N F I G U R A T I O N +################################################################################ +# +# Tools Directory +# +TOOLSDIR=~/shorewall/tools/build +# +# GIT Code Repository +# +GIT=~/shorewall/trunk +# +# Git Release Repository +# +GITRELEASEDIR=~/shorewall/release +# +# Message for the newly created tag +# The '-a' option will add the <$VERSION> to the end of the string +# If the variable is empty ('MESSAGE=') no +# message will be added to the tag +# +MESSAGE="Releasing Shorewall Version" +################################################################################ +# +################################################################################ +# F U N C T I O N S +################################################################################ + +usage() +{ + me=$(basename $0) + + echo "Usage: $me [ <OPTIONS> ] <VERSION>." + echo "Where <OPTIONS> is one of:" + echo " -c -- Object that the new tag will refer to (code repository)." + echo " -r -- Object that the new tag will refer to (release repository)." + echo " -a -- Append <VERSION> to the end of the message tag." + echo " -u -- Execute the upload script." + echo "Where <VERSION> is:" + echo " <VERSION> -- Version for the new tag name." + + exit 1 +} + +fatal_error() +{ + echo " ERROR: $@" >&2 + exit 1 +} + +check_working_tree() # $1 = path of repository +{ + [ -d "$1" ] || fatal_error "Directory $1 does not exist." + [ -d ${1}/.git ] || fatal_error "Directory ${1}/.git is not a git repository." + + echo "Checking if ${1}/.git is clean..." + + if git --git-dir=${1}/.git --work-tree=${1} diff --quiet; then + if git --git-dir=${1}/.git --work-tree=${1} diff --quiet --cached; then + return 0 + else + fatal_error "Staging area not clean." + fi + else + fatal_error "Working tree not clean." + fi +} + +create_tag() # $1 = path of repository, $2 = object +{ + if check_working_tree $1; then + if [ -n "$2" ]; then + echo "Creating tag $VERSION in ${1}/.git, object: ${2}..." + + if [ -n "$MESSAGE" ]; then + git --git-dir=${1}/.git tag -s $VERSION -m "$MESSAGE" $2 + [ $? -ne 0 ] && fatal_error "Failed to create tag $VERSION in ${1}/.git." + else + git --git-dir=${1}/.git tag -s $VERSION $2 + [ $? -ne 0 ] && fatal_error "Failed to create tag $VERSION in ${1}/.git." + fi + else + echo "Creating tag $VERSION in ${1}/.git..." + + if [ -n "$MESSAGE" ]; then + git --git-dir=${1}/.git tag -s $VERSION -m "$MESSAGE" + [ $? -ne 0 ] && fatal_error "Failed to create tag $VERSION in ${1}/.git." + else + git --git-dir=${1}/.git tag -s $VERSION + [ $? -ne 0 ] && fatal_error "Failed to create tag $VERSION in ${1}/.git." + fi + fi + fi +} + +################################################################################ +# E X E C U T I O N S T A R T S H E R E +################################################################################ + +# +# Parss the runline +# +finished=0 + +while [ $finished -eq 0 -a $# -gt 0 ]; do + option=$1 + + case $option in + -*) + option=${option#-} + + [ -z "$option" ] && usage + + while [ -n "$option" ]; do + case $option in + c*) + option=${option#c} + + if [ -z "$option" -a $# -gt 0 ]; then + shift + option=$1 + fi + + if [ -n "$option" ]; then + GIT_CODE_OBJECT=$option + else + fatal_error "The -c option requires a value." + fi + + option= + ;; + r*) + option=${option#r} + + if [ -z "$option" -a $# -gt 0 ]; then + shift + option=$1 + fi + + if [ -n "$option" ]; then + GIT_RELEASE_OBJECT=$option + else + fatal_error "The -r option requires a value." + fi + + option= + ;; + u*) + upload=Yes + option=${option#u} + ;; + a*) + APPEND_VERSION=Yes + option=${option#v} + ;; + *) + usage + ;; + esac + done + + shift + ;; + *) + finished=1 + ;; + esac +done + +[ $# -ne 1 ] && usage + +VERSION=$1 + +if [ -n "$MESSAGE" ]; then + [ -n "$APPEND_VERSION" ] && MESSAGE="$MESSAGE $VERSION" +fi + + +case $VERSION in + 5.1.*|5.1.*.*) + ;; + *) + fatal_error "Unsupported Version ${VERSION}." + ;; +esac + +if [ -z "$GIT_CODE_OBJECT" -a -z "$GIT_RELEASE_OBJECT" ]; then + create_tag $GIT + create_tag $GITRELEASEDIR +else + if [ -z "$GIT_CODE_OBJECT" -o -z "$GIT_RELEASE_OBJECT" ]; then + fatal_error "An object for the code and release repository is required." + fi + + create_tag $GIT $GIT_CODE_OBJECT + create_tag $GITRELEASEDIR $GIT_RELEASE_OBJECT +fi + +if [ -n "$upload" ]; then + [ -f $TOOLSDIR/upload ] && $TOOLSDIR/upload $VERSION +fi -- 2.13.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Shorewall-devel mailing list Shorewall-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/shorewall-devel