summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9a7ac6cdadb4b96ea313aa4aab90c45fe91b64a3 (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
# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=zinc
pkgver=0.3.6
pkgrel=1
pkgdesc='A lightweight alternative to Elasticsearch that requires minimal resources'
arch=('x86_64')
url='https://zinclabs.io/'
license=('Apache')
depends=('glibc')
makedepends=(
  'git'
  'go'
  'nodejs'
  'npm'
)
options=('!lto')
_commit='7dfe47c3279531e5a959575f261ab42b4299c153'
source=("$pkgname::git+https://github.com/zinclabs/zinc.git#commit=$_commit")
md5sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # create directory for build output
  mkdir build

  # download dependencies
  go mod download
}

build() {
  cd "$pkgname"

  # generate web UI
  pushd web
  npm install
  npm run build
  popd

  # set Go flags
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"

  # ensure build date is reproducible
  local _build_date="$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d_%I:%M:%S%p-GMT)"

  go build -v \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags ${LDFLAGS} \
    -X github.com/zinclabs/zinc/pkg/meta/v1.Version=${pkgver}
    -X github.com/zinclabs/zinc/pkg/meta/v1.BuildDate=${_build_date}
    -X github.com/zinclabs/zinc/pkg/meta/v1.CommitHash=${_commit}" \
    -o build \
    ./cmd/...
}

#check() {
#  cd "$pkgname"
#
#  export ZINC_FIRST_ADMIN_USER="admin"
#  export ZINC_FIRST_ADMIN_PASSWORD="Complexpass#123" 
#
#  go test -v ./...
#}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" build/zinc

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
}