archrelease: copy trunk to community-any
[ArchLinux/community.git] / gum / trunk / PKGBUILD
blob33126d8f0fcbe55aa55a5cd3831e9261112c57cb
1 # Maintainer: George Rawlinson <grawlinson@archlinux.org>
3 pkgname=gum
4 pkgver=0.10.0
5 pkgrel=1
6 pkgdesc='A tool for glamorous shell scripts'
7 arch=('x86_64')
8 url='https://github.com/charmbracelet/gum'
9 license=('MIT')
10 depends=('glibc')
11 makedepends=('git' 'go')
12 options=('!lto')
13 _commit='0f0f8e91899ac7a7aa2996623f979dfe6bbc5940'
14 source=("$pkgname::git+$url#commit=$_commit")
15 b2sums=('SKIP')
17 pkgver() {
18   cd "$pkgname"
20   git describe --tags | sed 's/^v//'
23 prepare() {
24   cd "$pkgname"
26   # create directory for build output
27   mkdir build
29   # download dependencies
30   export GOPATH="${srcdir}"
31   go mod download
34 build() {
35   cd "$pkgname"
37   # set Go flags
38   export CGO_CPPFLAGS="${CPPFLAGS}"
39   export CGO_CFLAGS="${CFLAGS}"
40   export CGO_CXXFLAGS="${CXXFLAGS}"
41   export GOPATH="${srcdir}"
43   # commit date for binary & man page
44   local _commit_date=$(git show --no-patch --format=%cd --date=format:%Y-%m-%d)
46   go build -v \
47     -buildmode=pie \
48     -mod=readonly \
49     -modcacherw \
50     -ldflags "-compressdwarf=false \
51     -linkmode external \
52     -extldflags ${LDFLAGS} \
53     -X main.Version=$pkgver \
54     -X main.CommitSHA=$_commit \
55     -X main.CommitDate=$_commit_date" \
56     -o build \
57     .
59   # man page
60   ./build/gum man > build/gum.1
62   # i'm not 100% sure where the man sub-command gets the date from, i assume
63   # it uses $TODAYS_DATE, so this should make the man page reproducible
64   sed \
65     -i build/gum.1 \
66     -e "s/\"[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\"/\"$_commit_date\"/"
68   # completions
69   for shell in bash fish zsh; do
70     ./build/gum completion "$shell" > "build/$shell-completion"
71   done
74 package() {
75   cd "$pkgname"
77   # binary
78   install -vDm755 -t "$pkgdir/usr/bin" build/gum
80   # documentation
81   install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
83   # man pages
84   install -vDm644 -t "$pkgdir/usr/share/man/man1" build/gum.1
86   # completions
87   install -vDm644 build/bash-completion "$pkgdir/usr/share/bash-completion/completions/gum"
88   install -vDm644 build/fish-completion "$pkgdir/usr/share/fish/vendor_completions.d/gum.fish"
89   install -vDm644 build/zsh-completion "$pkgdir/usr/share/zsh/site-functions/_gum"
91   # license
92   install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE