summarylogtreecommitdiffstats
path: root/PKGBUILD
diff options
context:
space:
mode:
Diffstat (limited to 'PKGBUILD')
-rw-r--r--PKGBUILD106
1 files changed, 106 insertions, 0 deletions
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..14bea0418e8
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,106 @@
+# Maintainer: Moses Narrow <moe_narrow@use.startmail.com>
+pkgname1=btcd
+pkgname=btcd-git
+pkgver='autogenerated'
+pkgrel=1
+arch=('any')
+pkggopath=("github.com/btcsuite/$pkgname1")
+url="https://$pkggopath"
+makedepends=('git' 'dep' 'go')
+license=('ISC')
+options=('!strip' '!emptydirs')
+provides=('btcd')
+conflicts=('btcd')
+source=("git+${url}.git#branch=${BRANCH:-master}")
+sha256sums=('SKIP')
+
+
+export GOOS=linux
+export GOPATH="$srcdir"
+export GOROOT="$builddir"
+export GOBIN="$GOROOT"/bin
+export GOROOT_FINAL=/usr/lib/go
+
+export CGO_ENABLED=0
+
+case "$CARCH" in
+x86) export GOARCH="386" GO386="387" ;;
+x86_64) export GOARCH="amd64" ;;
+arm*) export GOARCH="arm" ;;
+armel) export GOARCH="arm" GOARM="5" ;;
+armhf) export GOARCH="arm" GOARM="6" ;;
+armv7) export GOARCH="arm" GOARM="7" ;;
+armv8) export GOARCH="arm64" ;;
+aarch64) export GOARCH="arm64" ;;
+mips) export GOARCH="mips" ;;
+mips64) export GOARCH="mips64" ;;
+mips64el) export GOARCH="mips64le" ;;
+mipsel) export GOARCH="mipsle" ;;
+*) return 1 ;;
+esac
+
+pkgver() {
+cd "$srcdir/$pkgname1"
+local date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
+local count=$(git rev-list --count HEAD)
+local commit=$(git rev-parse --short HEAD)
+echo "$date.${count}_$commit"
+}
+
+prepare() {
+# https://wiki.archlinux.org/index.php/Go_package_guidelines
+mkdir -p $srcdir/go/src/${pkggopath//$pkgname1/} "$srcdir"/go/bin
+ln -rTsf $srcdir/$pkgname1 $srcdir/go/src/$pkggopath
+cd $srcdir/go/src/$pkggopath/
+git checkout master
+git submodule --quiet update --init --recursive
+
+export GOPATH="$srcdir"/go
+export GOBIN=${GOPATH}/bin
+export PATH=${GOPATH}/bin:${PATH}
+msg2 'installing go dependencies'
+rm -rf Gopkg.lock
+rm -rf Gopkg.toml
+dep init
+dep ensure
+}
+
+build() {
+export GOPATH=$srcdir/go
+export GOBIN=${GOPATH}/bin
+export PATH=${GOPATH}/bin:${PATH}
+cd $srcdir/go/src/$pkggopath
+GO111MODULE=on go install \
+-gcflags "all=-trimpath=${GOPATH}" \
+-asmflags "all=-trimpath=${GOPATH}" \
+-ldflags "-extldflags $LDFLAGS" \
+-v ./...
+}
+
+package() {
+msg2 'Installing btcd...'
+btcdbin="$srcdir"/go/bin
+potentialnameconflicts=$( ls --ignore=btc* --ignore=bitcoin* "$btcdbin")
+cd $btcdbin
+for i in $potentialnameconflicts; do
+mv $btcdbin/$i $btcdbin/btc$i
+done
+btcdbins=$( ls "$btcdbin" )
+for i in $btcdbins; do
+install -Dm 755 "$srcdir/go/bin/$i" "$pkgdir/usr/bin/$i"
+done
+
+install -Dm 644 "$srcdir/$pkgname1/LICENSE" \
+-t "$pkgdir/usr/share/licenses/btcd"
+
+for _doc in CHANGES README.md sample-btcd.conf; do
+install -Dm 644 "$srcdir/$pkgname1/$_doc" \
+-t "$pkgdir/usr/share/doc/btcd"
+done
+cp -dpr --no-preserve=ownership "$srcdir/$pkgname1/docs" \
+"$pkgdir/usr/share/doc/btcd"
+
+msg2 'Cleaning up pkgdir...'
+find "$pkgdir" -type d -name .git -exec rm -r '{}' +
+find "$pkgdir" -type f -name .gitignore -exec rm -r '{}' +
+}