summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 097033814b4f89d2cd5a5daae72aeb2c7b0e6593 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Maintainer: Moses Narrow <moe_narrow@use.startmail.com>
# Maintainer: Steve Skydev <steve@skycoin.net>
projectname=skycoin
pkgname=skywire-mainnet
pkgname1=skywire
pkgdesc="Skywire: Building a New Internet. Skycoin.net"
pkgver='autogenerated'
pkggopath="github.com/$projectname/$pkgname1"
pkgrel=6
arch=('any')
url="https://${pkggopath}"
license=()
makedepends=(dep git go gcc)
provides=('skywire')
conflicts=('skywire')
source=("git+${url}.git#branch=${BRANCH:-mainnet}")
sha256sums=('SKIP')
validpgpkeys=('DE08F924EEE93832DABC642CA8DC761B1C0C0CFC')

export GOOS=linux
export GOPATH="$srcdir"
export GOROOT="$builddir"
export GOBIN="$GOROOT"/bin
export GOROOT_FINAL=/usr/lib/go

export CGO_ENABLED=1

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 mainnet
  git submodule --quiet update --init --recursive

  export GOPATH="$srcdir"/go
  export GOBIN=${GOPATH}/bin
  export PATH=${GOPATH}/bin:${PATH}
  msg2 'installing go dependencies'
  dep init
  dep ensure
}

build() {
  export GOPATH=$srcdir/go
  export GOBIN=${GOPATH}/bin
  export PATH=${GOPATH}/bin:${PATH}
  cd $srcdir/go/src/$pkggopath
  make build
  make install
  #user must generate default json config by running this script after install
	msg 2 'creating setup script; please run skywire-seup after installation'
  echo -e '#!/bin/bash \n # this script sets up skywire after installation \n mkdir -p ~/skywire \n sudo chmod 777 ~/skywire \n sudo chmod 777 ~/apps \n cd ~/ \n ln -s /usr/lib/skycoin/skywire/apps ~/ \n skywire-cli node gen-config -r \n skywire-manager-node gen-config -r \n skywire-manager-node \n #skywire-node skywire-config.json' > $srcdir/go/bin/$pkgname1-setup
  chmod +x $srcdir/go/bin/$pkgname1-setup
}

package() {
    options=(!strip staticlibs)
  #create directory trees
  mkdir -p $pkgdir/usr/bin
  mkdir -p $pkgdir/usr/lib/$projectname/go/bin
  mkdir -p $pkgdir/usr/lib/$projectname/$pkgname1/
  #restate go envs
  export GOPATH=$pkgdir/usr/lib/$projectname/go
  export GOBIN=$pkgdir/usr/lib/$projectname/go/bin
	#putting the sources in /usr/lib/skycoin/skywire
	cp -r $srcdir/$pkgname1/ $pkgdir/usr/lib/$projectname/
  msg2 'installing binaries'
  skybins="$srcdir"/go/bin
  ln -rTsf $skybins/manager-node $skybins/$pkgname1-manager-node
  skywirebins=$( ls $skybins )
  for i in $skywirebins; do
    install -Dm755 $srcdir/go/bin/$i $pkgdir/usr/lib/$projectname/go/bin/$i
    ln -rTsf $pkgdir/usr/lib/$projectname/go/bin/$i $pkgdir/usr/bin/$i
    chmod 755 $pkgdir/usr/bin/$i
  done
  msg2 'please run skywire-setup after installing this package'
}