nagios-nrpe/update-version

82 lines
3.0 KiB
Plaintext
Raw Normal View History

2016-06-24 12:21:25 +02:00
#!/bin/sh
# Make sure autoconf is installed and is the correct version
min_autoconf_major=2
min_autoconf_minor=59
autoconf_error="Autoconf version $min_autoconf_major.$min_autoconf_minor or later must be installed to run this script."
autoconf_version=`(autoconf -V 2> /dev/null) |\
grep "^autoconf (GNU Autoconf)" | gawk '{print $NF}'`
if [ "$autoconf_version" != "" ] ; then
autoconf_major=`echo $autoconf_version | gawk -F '.' '{print $1}'`
autoconf_minor=`echo $autoconf_version | gawk -F '.' '{print $2}'`
if [ $autoconf_major -lt $min_autoconf_major -o $autoconf_minor -lt $min_autoconf_minor ] ; then
echo $autoconf_error
exit 1
fi
else
echo $autoconf_error
exit 1
fi
# Get date (two formats)
if [ -n "$2" ]; then
2017-05-13 13:05:54 +02:00
LONGDATE=$(LC_ALL=C date -u -d "$2" "+%B %d, %Y")
SHORTDATE=$(date -u -d "$2" "+%Y-%m-%d")
2016-06-24 12:21:25 +02:00
else
2017-05-13 13:05:54 +02:00
LONGDATE=$(LC_ALL=C date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%B %d, %Y")
SHORTDATE=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%Y-%m-%d")
2016-06-24 12:21:25 +02:00
fi
# Current version number
2017-06-20 10:37:07 +02:00
CURRENTVERSION=3.1.1
2016-06-24 12:21:25 +02:00
# Last date
2017-06-20 10:37:07 +02:00
LASTDATE=2017-05-24
2016-06-24 12:21:25 +02:00
if [ "x$1" = "x" ]
then
echo "Usage: $0 <version number | \"newdate\"> [revision date]"
echo ""
echo "Run this script with the name of the new version (i.e \"2.6\") to"
echo "update version number and modification date in files."
echo "Use the \"newdate\" argument if you want to keep the current version"
echo "number and just update the modification date."
echo ""
echo "Current version=$CURRENTVERSION"
echo "Current Modification date=$LASTDATE"
echo ""
exit 1
fi
newversion=$1
if [ "x$newversion" = "xnewdate" ]
then
newversion=$CURRENTVERSION
fi
# Update version number and release date in common code
2017-05-04 11:53:58 +02:00
perl -i -p -e "s/VERSION \".*\"/VERSION \"$1\"/;" include/common.h.in
perl -i -p -e "s/MODIFICATION_DATE \".*\"/MODIFICATION_DATE \"$SHORTDATE\"/;" include/common.h.in
perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" include/common.h.in
2016-06-24 12:21:25 +02:00
# Update version number and release date in main code
perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" src/nrpe.c
perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" src/check_nrpe.c
# Update version number and release date in configure.in
2017-05-04 11:53:58 +02:00
perl -i -p -e "if( /^AC_INIT/) { s/$CURRENTVERSION/$1/; }" configure.ac
perl -i -p -e "s/PKG_VERSION=.*/PKG_VERSION=\"$1\"/;" configure.ac
perl -i -p -e "s/PKG_REL_DATE=.*\"/PKG_REL_DATE=\"$SHORTDATE\"/;" configure.ac
2016-06-24 12:21:25 +02:00
# Run autoconf to update configure (this is easier than updating every instance
# of the version number in configure)
autoconf
# Update RPM spec file with version number
2017-05-13 13:05:54 +02:00
perl -i -p -e "s/%define version .*/%define version $1/;" nrpe.spec.in
perl -i -p -e "if( /\%define _docdir/) { s/$CURRENTVERSION/$1/; }" nrpe.spec.in
2016-06-24 12:21:25 +02:00
# Update this file with version number and last date
perl -i -p -e "s/^CURRENTVERSION=.*/CURRENTVERSION=$newversion/;" update-version
perl -i -p -e "s/^LASTDATE=.*/LASTDATE=$SHORTDATE/;" update-version