|
| 1 | +#!/bin/sh |
| 2 | +# install-sharness.sh |
| 3 | +# |
| 4 | +# Copyright (c) 2014 Juan Batiz-Benet |
| 5 | +# Copyright (c) 2015 Christian Couder |
| 6 | +# MIT Licensed; see the LICENSE file in this repository. |
| 7 | +# |
| 8 | +# This script checks that Sharness is installed in: |
| 9 | +# |
| 10 | +# $(pwd)/$clonedir/$sharnessdir/ |
| 11 | +# |
| 12 | +# where $clonedir and $sharnessdir are configured below. |
| 13 | +# |
| 14 | +# If Sharness is not installed, this script will clone it |
| 15 | +# from $urlprefix (defined below). |
| 16 | +# |
| 17 | +# If Sharness is not uptodate with $version (defined below), |
| 18 | +# this script will fetch and will update the installed |
| 19 | +# version to $version. |
| 20 | +# |
| 21 | + |
| 22 | +# settings |
| 23 | +version=2298d6a491f43da26a89175173b6b56edd4313dd |
| 24 | +urlprefix=https://github.com/mlafeldt/sharness.git |
| 25 | +clonedir=lib |
| 26 | +sharnessdir=sharness |
| 27 | + |
| 28 | +if test -f "$clonedir/$sharnessdir/SHARNESS_VERSION_$version" |
| 29 | +then |
| 30 | + # There is the right version file. Great, we are done! |
| 31 | + exit 0 |
| 32 | +fi |
| 33 | + |
| 34 | +die() { |
| 35 | + echo >&2 "$@" |
| 36 | + exit 1 |
| 37 | +} |
| 38 | + |
| 39 | +checkout_version() { |
| 40 | + git checkout "$version" || die "Could not checkout '$version'" |
| 41 | + rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'" |
| 42 | + touch "SHARNESS_VERSION_$version" || die "Could not create 'SHARNESS_VERSION_$version'" |
| 43 | + echo "Sharness version $version is checked out!" |
| 44 | +} |
| 45 | + |
| 46 | +if test -d "$clonedir/$sharnessdir/.git" |
| 47 | +then |
| 48 | + # We need to update sharness! |
| 49 | + cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory" |
| 50 | + git fetch || die "Could not fetch to update sharness" |
| 51 | +else |
| 52 | + # We need to clone sharness! |
| 53 | + mkdir -p "$clonedir" || die "Could not create '$clonedir' directory" |
| 54 | + cd "$clonedir" || die "Could not cd into '$clonedir' directory" |
| 55 | + |
| 56 | + git clone "$urlprefix" || die "Could not clone '$urlprefix'" |
| 57 | + cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory" |
| 58 | +fi |
| 59 | + |
| 60 | +checkout_version |
0 commit comments