# Contributor: David Huffman <storedbox@outlook.com>
# Maintainer: David Huffman <storedbox@outlook.com>

_gosu_repo='github.com/tianon/gosu'
_gosu_ver=1.9
_gosu_src="gosu-$_gosu_ver"

_runc_repo='github.com/opencontainers/runc'
_runc_ver=0.1.0
_runc_src="runc-$_runc_ver"

pkgname=gosu
pkgver=$_gosu_ver
pkgrel=0
pkgdesc="Simple Go-based setuid+setgid+setgroups+exec"
url="https://github.com/tianon/gosu"
arch="all"
license="GPL-3.0"
depends=""
depends_dev=""
makedepends="$depends_dev coreutils go"
install=""
subpackages=""
source="https://github.com/tianon/gosu/archive/$_gosu_ver/$_gosu_src.tar.gz
        https://github.com/opencontainers/runc/archive/v$_runc_ver/$_runc_src.tar.gz"

builddir="$srcdir"/$_gosu_repo
prepare() {
	mkdir -p $_gosu_repo $_runc_repo
	mv -T $_gosu_src $_gosu_repo || return 1
	mv -T $_runc_src $_runc_repo || return 1

	default_prepare
}

build() {
	cd "$builddir"
	CGO_ENABLED=0 GOPATH="$startdir:$srcdir/$_runc_repo/Godeps/_workspace" \
		go build -v -ldflags '-s -w' || return 1
}

package() {
	cd "$builddir"
	local bindir="$pkgdir/usr/bin"
	mkdir -p "$bindir" || return 1
	cp gosu "$bindir" || return 1
}

md5sums="9c0dfb590c317cde7592652764f2c341  gosu-1.9.tar.gz
73971b4020a39445f071c3b3d5361a30  runc-0.1.0.tar.gz"
sha256sums="12770f2127ec436a6e368750258631d1eda3f5fe647059f2219fbd27d5d6d838  gosu-1.9.tar.gz
681d6d89541ae2e06757f999a242a1f97bbcb1ad6e10f4cdee287ec4a9d2bff9  runc-0.1.0.tar.gz"
sha512sums="f4bc1fa812f7588b657fbab3394407133a42422e54500c9e9adb9010f550b45839d7bfa3bbb79241a7c00e67292ba3ff9ffcf5ce7c000d88e6b64ac6f88fb169  gosu-1.9.tar.gz
8a9ff02b0161eda0a730194b0fbf7ad76e8f379992e74061ef49302da3492fd0c53f06db9153ded4d934d67bbf6f4291d6154254f1b924ef73c97c44cd14ffcf  runc-0.1.0.tar.gz"
