summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 03a5226a32953c195256ef2cff907b2522715090 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Maintainer: Moses Narrow <moe_narrow@use.startmail.com>
# Maintainer: Rudi [KittyCash] <rudi@skycoinmail.com>
_pkgname=cx-chains
pkgname=${_pkgname}
_githuborg=skycoin
pkgdesc="Execute CX programs on blockchain. https://github.com/skycoin/cx-chains"
pkgver=0.22.0
#pkgver='autogenerated'
pkgrel=1
#pkgrel=3
arch=('x86_64' 'aarch64' 'armv8' 'armv7' 'armv7l' 'armv7h' 'armv6h' 'armhf' 'armel' 'arm')
_pkggopath="github.com/${_githuborg}/${_pkgname}"
url="https://${_pkggopath}"
makedepends=('git' 'go' 'musl' 'kernel-headers-musl')
source=("git+${url}.git" ##branch=${BRANCH:-develop}"
"git+https://github.com/skycoin/cx-tracker.git"
) #"PKGBUILD.sig")
sha256sums=('SKIP'
            'SKIP')

#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() {
#    export GOPATH=${srcdir}/go
#    export GOBIN=${GOPATH}/bin
		mkdir -p ${srcdir}/go/src/github.com/${_githuborg}/ ${srcdir}/go/bin
		ln -rTsf ${srcdir}/${_pkgname} ${srcdir}/go/src/${_pkggopath}
    ln -rTsf ${srcdir}/cx-tracker ${srcdir}/go/src/github.com/skycoin/cx-tracker
#    cd ${srcdir}/go/src/${_pkggopath}
#    cd ${srcdir}/go/src/github.com/skycoin/cx-tracker
#    go mod tidy -v
#    go mod vendor -v
#    cd ${srcdir}
	}

build() {
	export GOPATH=${srcdir}/go
	export GOBIN=${GOPATH}/bin
  #export CC=musl-gcc
  #export CGO_ENABLED=1

	_cmddir=${srcdir}/go/src/${_pkggopath}/cmd
  #_buildbins cipher-testdata
  #_buildbins monitor-peers
  #_buildbins cxchain-cli
  #_buildbins cxchain
  #_buildbins cli
cd ${srcdir}/go/src/${_pkggopath}/
rm go.mod
go mod init
go mod tidy -v
go mod vendor -v
make clean-vendor
go get github.com/skycoin/skycoin@develop
go get github.com/skycoin/cx
go get github.com/skycoin/cx-chains/cmd/cipher-testdata
go get github.com/skycoin/cx-chains/src/daemon/pex
go get github.com/skycoin/cx/cx@v0.7.5
go get github.com/skycoin/cx-chains/cmd/cxchain-cli
go get github.com/skycoin/cx-chains/src/wallet
go get github.com/skycoin/cx-chains/src/daemon
go get github.com/skycoin/cx-chains/src/cli
go get github.com/skycoin/cx-chains/src/api
go get github.com/skycoin/cx-chains/cmd/monitor-peers/connection
go get github.com/skycoin/cx-chains/cmd/cxchain
go get github.com/skycoin/cx-chains/src/readable
go get github.com/skycoin/dmsg
go get github.com/skycoin/dmsg/cipher
go get github.com/skycoin/dmsg/disc
go get github.com/skycoin/dmsg/httputil
go get github.com/skycoin/cx-chains/src/skycoin

make install

  _cmddir=${srcdir}/go/src/github.com/skycoin/cx-tracker/cmd
  #_buildbins cx-tracker
cd ${srcdir}/go/src/github.com/skycoin/cx-tracker/
make install
	#binary transparency
	cd $GOBIN
	_msg2 'binary sha256sums'
	sha256sum $(ls)
}

_buildbins() {

_binname=$1
_msg2 "building ${_binname} binary"
#SPEED UP TESTING OF BUILDS
#if [[ ! -f ${GOBIN}/${_binname} ]] ; then
	cd ${_cmddir}/${_binname}
  go build -trimpath --ldflags '-linkmode external -extldflags "-static" -buildid=' -o $GOBIN/ .
#fi
}

package() {
	#create directory trees
	_skypath=${pkgdir}/opt/${_pkgname}
	_skygobin=${_skypath}/bin
	mkdir -p ${pkgdir}/usr/bin
	mkdir -p ${_skygobin}
	#install binaries & symlink to /usr/bin
	_msg2 'installing binaries'
	_skybin="${srcdir}"/go/bin
	#collect the binaries & install
	_skybins=$( ls "$_skybin")
	for i in $_skybins; do
		install -Dm755 ${srcdir}/go/bin/${i} ${_skygobin}/${i}
		ln -rTsf ${_skygobin}/$i ${pkgdir}/usr/bin/${i}
		chmod 755 ${pkgdir}/usr/bin/${i}
	done
  _msg2 'correcting symlink names'
	#correct symlink names
	cd ${pkgdir}/usr/bin/
  mv ${pkgdir}/usr/bin/cipher-testdata ${pkgdir}/usr/bin/cxchain-cipher-testdata
  mv ${pkgdir}/usr/bin/monitor-peers ${pkgdir}/usr/bin/cxchain-monitor-peers
}

_msg2() {
(( QUIET )) && return
local mesg=$1; shift
printf "${BLUE}  ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}