summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f9aa3931b62a5e516e4c52ffa547646f67bfc618 (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
# Maintainer: Xuanwo <xuanwo@archlinuxcn.org>
# Maintainer: Allen Zhong <allen@moe.cat>
pkgname=tikv-pd
pkgver=7.6.0
pkgrel=1
pkgdesc='Manage and schedule the TiKV cluster.'
depends=('glibc')
makedepends=('go' 'make' 'git' 'unzip')
arch=('x86_64')
url='https://github.com/tikv/pd'
license=('Apache')
provides=('pd-server')
backup=(etc/pd/pd.toml)
install=pd.install
source=(pd-${pkgver}.tar.gz::https://github.com/tikv/pd/archive/v${pkgver}.tar.gz
        pd.service
        pd-sysusers.conf
        pd-tmpfiles.conf
        pd.toml)
sha256sums=('f505d5348cb82018936a444b9692d7686c76de809a72f07fba9777080aff7fbb'
            'b03d12f2f8d6eb2e9d654d6258ca39000225cdf1418840f7e35081631bc4d924'
            '5edd250ba9e70a4f8d27581ed658f0fbfeca58ca62429dec12bb5fffc0919b67'
            '15633aaa2d7726375112a1b5af88105878f09c176a542cde6d0e5f0c4eee4495'
            '10d3fdb40e522c8731e87a7ba2acc6a7866d8f967a6b931247ae8ff97709065a')

_gopkgname='github.com/tikv/pd'

prepare() {
  export GOPATH="$srcdir/build"
  rm -rf "$GOPATH/src/$_gopkgname"
  mkdir -p `dirname "$GOPATH/src/$_gopkgname"`
  mv -Tv "$srcdir/pd-${pkgver}" "$GOPATH/src/$_gopkgname"

  # patch Makefile
  sed -i 's/go build/go build $(GOFLAGS)/g' "$GOPATH/src/$_gopkgname/Makefile"
  sed -i 's/CGO_ENABLED=0/CGO_ENABLED=1/g' "$GOPATH/src/$_gopkgname/Makefile"
  sed -i 's/BUILD_CGO_ENABLED := 0/BUILD_CGO_ENABLED := 1/g' "$GOPATH/src/$_gopkgname/Makefile"
  sed -i '/shell git /d' "$GOPATH/src/$_gopkgname/Makefile"
  sed -i '/PDReleaseVersion/d' "$GOPATH/src/$_gopkgname/Makefile"
  sed -i '/describe-dashboard.sh git-hash/d' "$GOPATH/src/$_gopkgname/Makefile"
}

build() {
  export GOPATH="$srcdir/build"
  export PATH=$GOPATH/bin:$PATH
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"

  cd $GOPATH/src/$_gopkgname

  _LDFLAGS="-X $_gopkgname/pkg/versioninfo.PDReleaseVersion=$pkgver -X $_gopkgname/pkg/versioninfo.PDGitBranch=release -X $_gopkgname/pkg/versioninfo.PDGitHash=v$pkgver -X $_gopkgname/pkg/versioninfo.PDGitBranch=release -X github.com/pingcap/tidb-dashboard/pkg/utils/version.PDVersion=$pkgver -X github.com/pingcap/tidb-dashboard/pkg/utils/version.BuildGitHash=v$pkgver"

  LDFLAGS=$_LDFLAGS make build tools
}

package() {
  # Install binary
  install -Dm755 "$srcdir/build/src/$_gopkgname/bin/pd-server" "$pkgdir/usr/bin/pd-server"
  install -Dm755 "$srcdir/build/src/$_gopkgname/bin/pd-ctl" "$pkgdir/usr/bin/pd-ctl"
  install -Dm755 "$srcdir/build/src/$_gopkgname/bin/pd-tso-bench" "$pkgdir/usr/bin/pd-tso-bench"
  install -Dm755 "$srcdir/build/src/$_gopkgname/bin/pd-recover" "$pkgdir/usr/bin/pd-recover"
  install -Dm755 "$srcdir/build/src/$_gopkgname/bin/pd-heartbeat-bench" "$pkgdir/usr/bin/pd-heartbeat-bench"
  install -Dm755 "$srcdir/build/src/$_gopkgname/bin/regions-dump" "$pkgdir/usr/bin/pd-regions-dump"
  install -Dm755 "$srcdir/build/src/$_gopkgname/bin/stores-dump" "$pkgdir/usr/bin/pd-stores-dump"

  # Install systemd service
  install -Dm644 "$srcdir/pd.service" "$pkgdir/usr/lib/systemd/system/pd.service"
  # Install sysusers
  install -Dm644 "$srcdir/pd-sysusers.conf" "$pkgdir/usr/lib/sysusers.d/pd.conf"
  # Install tmpfiles
  install -Dm644 "$srcdir/pd-tmpfiles.conf" "$pkgdir/usr/lib/tmpfiles.d/pd.conf"
  # Install default pd config
  install -Dm644 pd.toml "$pkgdir/etc/pd/pd.toml"
}

# vim: ft=sh syn=sh et