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

pkgname=sake
pkgver=0.14.0
pkgrel=1
pkgdesc='CLI tool that enables you to run commands on servers via ssh'
arch=('x86_64')
url='https://sakecli.com'
license=('MIT')
depends=('glibc')
makedepends=('git' 'go')
options=('!lto')
_commit='2c96becd0f9e68dda3e69618a0f64995203f851f'
source=("$pkgname::git+https://github.com/alajmo/sake#commit=$_commit")
b2sums=('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"

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

  go build -v \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags ${LDFLAGS} \
    -X github.com/alajmo/sake/cmd.version=$pkgver \
    -X github.com/alajmo/sake/cmd.commit=$_commit \
    -X github.com/alajmo/sake/cmd.date=$(date -d@"$SOURCE_DATE_EPOCH" +%Y%m%d-%H:%M:%S)" \
    -o build \
   .

   # create shell completions
  for shell in bash fish zsh; do
    ./build/sake completion "$shell" > "build/$shell-completions"
  done
}

package() {
  cd "$pkgname"

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

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

  # man page
  install -vDm644 -t "$pkgdir/usr/share/man/man1" core/sake.1

  # shell auto-completions
  install -vDm644 build/bash-completions "$pkgdir/usr/share/bash-completion/completions/sake"
  install -vDm644 build/fish-completions "$pkgdir/usr/share/fish/vendor_completions.d/sake.fish"
  install -vDm644 build/zsh-completions "$pkgdir/usr/share/zsh/site-functions/_sake"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}