sfsnapshotgit 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # Handle command errors (-e) and coder sleep deprivation issues (-u)
  3. set -eu
  4. trap 'echo "An error occurred at line $LINENO"; exit 1' EXIT
  5. # Timestamp
  6. DS=`date -u +%Y%m%d%H%M`
  7. if [ $# -ne 1 ]
  8. then
  9. HEAD='master'
  10. else
  11. HEAD="$1"
  12. fi
  13. if [ -z "$HEAD" ]
  14. then
  15. echo "If specified, the refspec must not be empty"
  16. exit
  17. fi
  18. # Clean up and pull
  19. cd ~/staging/nagiosplugins
  20. git clean -qfdx
  21. git checkout "$HEAD"
  22. git pull origin "$HEAD"
  23. # Tags are important for git-describe
  24. git fetch --tags origin
  25. # Write our snapshot version string (similar to NP-VERSION-GEN) to "release"
  26. VS=$(git describe --abbrev=4 HEAD)
  27. # Configure and dist
  28. tools/setup
  29. ./configure
  30. make dist VERSION=${VS#release-} RELEASE=snapshot
  31. # The rest is probably going to change... The mv below is for backwards
  32. # compatibility, however I'd recommend:
  33. # ln -s nagios-plugins-${VS#release-}.tar.gz nagios-plugins-$HEAD.tar.gz
  34. # ln -s nagios-plugins-${VS#release-}.tar.gz nagios-plugins-trunk-$DS.tar.gz
  35. # ln -s nagios-plugins-master.tar.gz nagios-plugins-HEAD.tar.gz
  36. # NB: the 3rd one would be permannent, no need to do it each time
  37. # Additionally, we could check whenever we need to re-generate a snapshot.
  38. # This way we could make snapshots much more often as only symlink changes
  39. # would have to be uploaded.
  40. mv nagios-plugins-${VS#release-}.tar.gz nagios-plugins-trunk-$DS.tar.gz
  41. cp *.tar.gz /tmp/
  42. trap - EXIT