summarylogtreecommitdiffstats
path: root/deb.PKGBUILD
blob: d2f3ffd7785ce095fdc77d6694dc66b9e5ecf543 (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
# Maintainer: Moses Narrow <moe_narrow@use.startmail.com>
# Maintainer: Rudi [KittyCash] <rudi@skycoinmail.com>
_projectname=skycoin
pkgname=skycoin-explorer
_pkgname=${pkgname}
_githuborg=${_projectname}
pkgdesc="Skycoin Blockchain Explorer: https://explorer.skycoin.com/"
pkgver='autogenerated'
#pkgver='autogenerated'
_pkgver='0.27.1'
pkgrel=1
_pkgrel=${pkgrel}
#pkgrel=5
_pkggopath="github.com/${_githuborg}/${_pkgname}"
arch=('any')
_pkgarch=$(dpkg --print-architecture)
url="https://${_pkggopath}"
license=()
makedepends=('git' 'go' 'npm' 'musl' 'kernel-headers-musl' 'dpkg') # npm node-gyp angular-cli
source=("git+${url}.git") ##branch=${BRANCH:-master}")
sha256sums=('SKIP')


pkgver() {
  cd "${srcdir}/${_pkgname}"
  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}"
}


build () {
#  msg2 'installing go dependencies'
  export GOPATH="${srcdir}"/go
  export GOBIN=${GOPATH}/bin
  #use musl-gcc for static compilation
  export CC=musl-gcc

  mkdir -p ${srcdir}/go/src/${_pkggopath//${_pkgname}/} ${srcdir}/go/bin

  ln -rTsf ${srcdir}/${_pkgname} ${srcdir}/go/src/${_pkggopath}
  cd ${srcdir}/go/src/${_pkggopath}/
  #git checkout develop
  #git submodule --quiet update --init --recursive
  #rm -rf Gopkg.toml
  #rm -rf Gopkg.lock
  [[ ! -f go.mod ]] && go mod init
  #go get github.com/NYTimes/gziphandler@v0.0.0-20170623195520-56545f4a5d46
  #go mod vendor
  go build -trimpath --ldflags="" --ldflags " -s -w -linkmode external -extldflags '-static' -buildid=" .

  if [[! -d dist]]; then
  #build the UI
  npm install
  make build-ng
fi


### CONTROL FILES CREATION ###
#create control file for the debian package
echo "Package: ${_pkgname}" > ${srcdir}/control
echo "Version: ${_pkgver}-${_pkgrel}" >> ${srcdir}/control
echo "Priority: optional" >> ${srcdir}/control
echo "Section: web" >> ${srcdir}/control
echo "Architecture: ${_pkgarch}" >> ${srcdir}/control
#echo "Depends: ${_debdeps}" >> ${srcdir}/control
echo "Maintainer: Moses Narrow" >> ${srcdir}/control
echo "Description: ${pkgdesc}" >> ${srcdir}/control
}


package() {
  _debpkgdir="${_pkgname}-${_pkgver}-${_pkgrel}-${_pkgarch}"
  echo "${_debpkgdir}"
  _pkgdir="${pkgdir}/${_debpkgdir}"
  mkdir -p ${_pkgdir}/
  #create directory trees
  mkdir -p ${_pkgdir}/usr/bin
  mkdir -p ${_pkgdir}/opt/${_pkgname}/bin
  #mkdir -p ${pkgdir}/usr/lib/${projectname}/${pkgname}/
  #install binaries & symlink to /usr/bin
  msg2 'installing binaries'
  _skybins="${srcdir}"/go/bin
  _potentialnameconflicts=$( ls --ignore=skycoin* "$_skybins")
  cd ${_skybins}
  for i in ${_potentialnameconflicts}; do
    mv ${_skybins}/${i} ${_skybins}/skycoin-${i}
  done

  _skycoinbins=$( ls "$_skybins")
  for i in ${_skycoinbins}; do
    install -Dm755 ${srcdir}/go/bin/${i} ${_pkgdir}/opt/${_pkgname}/go/bin/${i}
    ln -rTsf ${_pkgdir}/opt/${_pkgname}/bin/${i} ${_pkgdir}/usr/bin/${i}
    chmod 755 ${_pkgdir}/usr/bin/${i}
  done

  cp -ar ${srcdir}/${_pkgname}/dist ${_pkgdir}/opt/${_pkgname}/dist

  _msg2 'installing control file'
  install -Dm755 ${srcdir}/control ${_pkgdir}/DEBIAN/control

  _msg2 'creating the debian package'
  #create the debian package
  cd $pkgdir
  dpkg-deb --build -z9 ${_debpkgdir}
  mv *.deb ../../
  #exit so the arch package doesn't get built
  exit
}

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