update-version 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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=$(LC_ALL=C date -u -d "$2" "+%B %d, %Y")
  22. SHORTDATE=$(date -u -d "$2" "+%Y-%m-%d")
  23. else
  24. LONGDATE=$(LC_ALL=C date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%B %d, %Y")
  25. SHORTDATE=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%Y-%m-%d")
  26. fi
  27. # Current version number
  28. CURRENTVERSION=4.1.2
  29. # Last date
  30. LASTDATE=2024-12-09
  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 "When using \"newdate\" you can specify the release date with"
  40. echo "a second argument in the form of YYYY-MM-DD."
  41. echo ""
  42. echo "Current version=$CURRENTVERSION"
  43. echo "Current Modification date=$LASTDATE"
  44. echo ""
  45. exit 1
  46. fi
  47. newversion=$1
  48. if [ "x$newversion" = "xnewdate" ]
  49. then
  50. newversion=$CURRENTVERSION
  51. fi
  52. # Update version number and release date in common code
  53. perl -i -p -e "s/VERSION \".*\"/VERSION \"$1\"/;" include/common.h.in
  54. perl -i -p -e "s/MODIFICATION_DATE \".*\"/MODIFICATION_DATE \"$SHORTDATE\"/;" include/common.h.in
  55. perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" include/common.h.in
  56. # Update version number and release date in main code
  57. perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" src/nrpe.c
  58. perl -i -p -e "s/Last Modified: [0-9].*/Last Modified: $SHORTDATE/;" src/check_nrpe.c
  59. # Update version number and release date in configure.in
  60. perl -i -p -e "if( /^AC_INIT/) { s/$CURRENTVERSION/$1/; }" configure.ac
  61. perl -i -p -e "s/PKG_VERSION=.*/PKG_VERSION=\"$1\"/;" configure.ac
  62. perl -i -p -e "s/PKG_REL_DATE=.*\"/PKG_REL_DATE=\"$SHORTDATE\"/;" configure.ac
  63. # Run autoconf to update configure (this is easier than updating every instance
  64. # of the version number in configure)
  65. autoconf
  66. # Update RPM spec file with version number
  67. perl -i -p -e "s/%define version .*/%define version $1/;" nrpe.spec.in
  68. perl -i -p -e "if( /\%define _docdir/) { s/$CURRENTVERSION/$1/; }" nrpe.spec.in
  69. # Update this file with version number and last date
  70. perl -i -p -e "s/^CURRENTVERSION=.*/CURRENTVERSION=$newversion/;" update-version
  71. perl -i -p -e "s/^LASTDATE=.*/LASTDATE=$SHORTDATE/;" update-version