update-version 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. # Make sure autoconf is installed and is the correct version
  3. min_autoconf_major=2
  4. min_autoconf_minor=59
  5. autoconf_error="Autoconf version $min_autoconf_major.$min_autoconf_minor or later must be installed to run this script."
  6. autoconf_version=`(autoconf -V 2> /dev/null) |\
  7. grep "^autoconf (GNU Autoconf)" | gawk '{print $NF}'`
  8. if [ "$autoconf_version" != "" ] ; then
  9. autoconf_major=`echo $autoconf_version | gawk -F '.' '{print $1}'`
  10. autoconf_minor=`echo $autoconf_version | gawk -F '.' '{print $2}'`
  11. if [ $autoconf_major -lt $min_autoconf_major -o $autoconf_minor -lt $min_autoconf_minor ] ; then
  12. echo $autoconf_error
  13. exit 1
  14. fi
  15. else
  16. echo $autoconf_error
  17. exit 1
  18. fi
  19. # Get date (two formats)
  20. if [ -n "$2" ]; then
  21. LONGDATE=`date -d "$2" "+%B %d, %Y"`
  22. SHORTDATE=`date -d "$2" "+%m-%d-%Y"`
  23. else
  24. LONGDATE=`date "+%B %d, %Y"`
  25. SHORTDATE=`date "+%m-%d-%Y"`
  26. fi
  27. # Current version number
  28. CURRENTVERSION=3.0-beta1
  29. # Last date
  30. LASTDATE=04-21-2016
  31. if [ "x$1" = "x" ]
  32. then
  33. echo "Usage: $0 <version number | \"newdate\"> [revision date]"
  34. echo ""
  35. echo "Run this script with the name of the new version (i.e \"2.6\") to"
  36. echo "update version number and modification date in files."
  37. echo "Use the \"newdate\" argument if you want to keep the current version"
  38. echo "number and just update the modification date."
  39. echo ""
  40. echo "Current version=$CURRENTVERSION"
  41. echo "Current Modification date=$LASTDATE"
  42. echo ""
  43. exit 1
  44. fi
  45. newversion=$1
  46. if [ "x$newversion" = "xnewdate" ]
  47. then
  48. newversion=$CURRENTVERSION
  49. fi
  50. # Update version number and release date in common code
  51. perl -i -p -e "s/VERSION \".*\"/VERSION \"$1\"/;" include/common.h
  52. perl -i -p -e "s/MODIFICATION_DATE \".*\"/MODIFICATION_DATE \"$SHORTDATE\"/;" include/common.h
  53. perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" include/common.h
  54. # Update version number and release date in main code
  55. perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" src/nrpe.c
  56. perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" src/check_nrpe.c
  57. # Update version number and release date in configure.in
  58. perl -i -p -e "if( /^AC_INIT/) { s/$CURRENTVERSION/$1/; }" configure.ac
  59. perl -i -p -e "s/PKG_VERSION=.*/PKG_VERSION=\"$1\"/;" configure.ac
  60. perl -i -p -e "s/PKG_REL_DATE=.*\"/PKG_REL_DATE=\"$SHORTDATE\"/;" configure.ac
  61. # Run autoconf to update configure (this is easier than updating every instance
  62. # of the version number in configure)
  63. autoconf
  64. # Update RPM spec file with version number
  65. perl -i -p -e "s/%define version .*/%define version $1/;" nrpe.spec
  66. perl -i -p -e "if( /\%define _docdir/) { s/$CURRENTVERSION/$1/; }" nrpe.spec
  67. # Update this file with version number and last date
  68. perl -i -p -e "s/^CURRENTVERSION=.*/CURRENTVERSION=$newversion/;" update-version
  69. perl -i -p -e "s/^LASTDATE=.*/LASTDATE=$SHORTDATE/;" update-version