summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a76f06f9fae2a97cff7845ca7fd46a53d2a5cea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Maintainer: Raghavendra Bhuvan <rage28@googlemail.com>
pkgname=git-user
pkgver=v2.0.5
pkgrel=1
pkgdesc=" Git plugin that allows you to save multiple user profiles and set them as project defaults"
arch=('any')
url="https://github.com/gesquive/${pkgname}.git"
license=('MIT')
depends=('go')
makedepends=('git')
options=('!strip' '!emptydirs')
_gourl="github.com/gesquive/${pkgname}"

prepare() {
    # if a global GOPATH is already set push save it
    if [ ! -z "$GOPATH" ];then
        PREV_GOPATH=$GOPATH
    fi
    unset GOPATH
}

build() {
    GOPATH="$srcdir" go get -fix -v -x ${_gourl}
}

check() {
    GOPATH="$GOPATH:$srcdir" go test -v -x ${_gourl}
}

package() {
    mkdir -p "$pkgdir/usr/bin"
    install -p -m755 "$srcdir/bin/"* "$pkgdir/usr/bin"

    mkdir -p "$pkgdir/$GOPATH"
    cp -Rv --preserve=timestamps "$srcdir/"{src,pkg} "$pkgdir/$GOPATH" &>/dev/null || :

    # Package license (if available)
    for f in LICENSE COPYING LICENSE.* COPYING.*; do
        if [ -e "$srcdir/src/$_gourl/$f" ]; then
        install -Dm644 "$srcdir/src/$_gourl/$f" "$pkgdir/usr/share/licenses/$pkgname/$f"
        fi
    done

    unset GOPATH
    # if previous GOPATH detected export it back
    if [ ! -z "$PREV_GOPATH" ];then
        export GOPATH=${PREV_GOPATH}
        unset PREV_GOPATH
    fi
}