diff options
Diffstat (limited to 'tools/sfsnapshotgit')
-rwxr-xr-x | tools/sfsnapshotgit | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/tools/sfsnapshotgit b/tools/sfsnapshotgit deleted file mode 100755 index 8bc19fc..0000000 --- a/tools/sfsnapshotgit +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # sfsnapshotgit - Snapshot script for Git repository | ||
3 | # Original author: Thomas Guyot-Sionnest <tguyot@gmail.com> | ||
4 | # | ||
5 | # Given an optional branch name (master by default), this script creates | ||
6 | # a snapshot from the tip of the branch and move it to ~/staging/. | ||
7 | # The repository, origin and destination directory can be overridden | ||
8 | # with environment variable (see below) | ||
9 | |||
10 | # Handle command errors (-e) and coder sleep deprivation issues (-u) | ||
11 | set -eu | ||
12 | trap 'echo "An error occurred in sfsnapshotgit at line $LINENO"; exit 1' EXIT | ||
13 | |||
14 | # Send all command output to STDERR while allowing us to write to STDOUT | ||
15 | # using fd 3 | ||
16 | exec 3>&1 1>&2 | ||
17 | |||
18 | # Git repository, origin and destination directory can be overridden by | ||
19 | # setting SFSNAP_REPO, SFSNAP_ORIGIN and SFSNAP_DEST respectively from the | ||
20 | # caller The defaults are: | ||
21 | SFSNAP_REPO=${SFSNAP_REPO-~/staging/nagiosplugins} | ||
22 | SFSNAP_ORIGIN=${SFSNAP_ORIGIN-origin} | ||
23 | SFSNAP_DEST=${SFSNAP_DEST-~/staging/snapshot} | ||
24 | |||
25 | # If one argument is given, this is the branch to create the snapshot from | ||
26 | if [ $# -eq 0 ] | ||
27 | then | ||
28 | HEAD='master' | ||
29 | elif [ $# -eq 1 ] | ||
30 | then | ||
31 | if [ -z "$1" ] | ||
32 | then | ||
33 | echo "If specified, the refspec must not be empty" | ||
34 | exit | ||
35 | fi | ||
36 | HEAD="$1" | ||
37 | else | ||
38 | echo "Too many arguments" | ||
39 | exit | ||
40 | fi | ||
41 | |||
42 | # Clean up and pull | ||
43 | cd "$SFSNAP_REPO" | ||
44 | # Sometimes "make dist" can modify versioned files so we must reset first | ||
45 | git reset --hard | ||
46 | git clean -qfdx | ||
47 | |||
48 | # Any branch used to create snapshots must already exist and be properly configured | ||
49 | git checkout "$HEAD" | ||
50 | |||
51 | # Get the remote tracking branch from config | ||
52 | origin=$(git config branch.$HEAD.remote) | ||
53 | ref=$(git config branch.$HEAD.merge |sed -e 's|^refs/heads/||') | ||
54 | git fetch "$origin" | ||
55 | git reset --hard "$origin/$ref" | ||
56 | |||
57 | # Tags are important for git-describe, but take only the ones from the hard-coded origin | ||
58 | git fetch --tags "$SFSNAP_ORIGIN" | ||
59 | |||
60 | # Write our snapshot version string (similar to NP-VERSION-GEN) to "release" | ||
61 | VS=$(git describe --abbrev=4 HEAD) | ||
62 | VS=${VS#release-} | ||
63 | |||
64 | # Configure and dist only if needed | ||
65 | if [ ! -e "$SFSNAP_DEST/nagios-plugins-$VS.tar.gz" ] | ||
66 | then | ||
67 | tools/setup | ||
68 | ./configure | ||
69 | make dist VERSION=$VS RELEASE=snapshot | ||
70 | cp nagios-plugins-$VS.tar.gz "$SFSNAP_DEST/" | ||
71 | fi | ||
72 | |||
73 | # fd 3 goes to STDOUT; print the generated filename | ||
74 | echo "nagios-plugins-$VS.tar.gz" 1>&3 | ||
75 | |||
76 | trap - EXIT | ||
77 | |||