Code

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