archrelease: copy trunk to community-any
[ArchLinux/community.git] / charm / trunk / PKGBUILD
blobf33cd0414b325a37155ab92711aa5987c4c9bafc
1 # Maintainer: George Rawlinson <grawlinson@archlinux.org>
2 # Contributor: Christian Muehlhaeuser <muesli at gmail dot com>
4 pkgname=charm
5 pkgver=0.12.5
6 pkgrel=1
7 pkgdesc='The backend for the Charm cloud'
8 arch=('x86_64')
9 url='https://charm.sh/cloud/'
10 license=('MIT')
11 depends=('glibc')
12 makedepends=('git' 'go')
13 conflicts=('charm-tool')
14 replaces=('charm-tool')
15 backup=('etc/charm.conf')
16 options=('!lto')
17 _commit='31a737e71a1e43ead4a3c597271036f19164e98d'
18 source=(
19   "git+https://github.com/charmbracelet/charm.git#commit=$_commit"
20   'charm.conf'
21   'systemd.service'
22   'sysusers.conf'
23   'tmpfiles.conf'
25 b2sums=('SKIP'
26         'c6414097223dde827dfcbaf500d29c45843b3b0a08600a3a69c7d4ec9781675f7b677cc9bc59f88c6c3734a8ee349ee589e5d2070a3aa6afa35f4825766270e6'
27         'ad16df43405a2969abfaf3e6f4cd6edcb2a29661a8a27bbaa13b34d3febb979356538340940383d5c737b9bd4fa434920395ea4e960951660073f8d31d225dac'
28         'b6b509de048f1d63d3d08dda04f3e5743fc212ec44f4a7a83a98a429f9a8fdf01194b83aba7588d02b5712f9bef3efcface1197d3ca458aee5d1be955f6782cd'
29         '2eee2c889e4efe83a534249c7048340b67819d81096a0fd7a23522d2eda46b833709eab1a0359538fdfbe27dbe4154c9d235535374e27c441dc7c030277f7218')
31 pkgver() {
32   cd charm
34   git describe --tags | sed 's/^v//'
36 prepare() {
37   cd charm
39   # create directory for build output
40   mkdir build
42   # download dependencies
43   export GOPATH="${srcdir}"
44   go mod download
47 build() {
48   cd charm 
50   # set Go flags
51   export CGO_CPPFLAGS="${CPPFLAGS}"
52   export CGO_CFLAGS="${CFLAGS}"
53   export CGO_CXXFLAGS="${CXXFLAGS}"
54   export GOPATH="${srcdir}"
56   go build -v \
57     -buildmode=pie \
58     -mod=readonly \
59     -modcacherw \
60     -ldflags "-compressdwarf=false \
61     -linkmode external \
62     -extldflags ${LDFLAGS} \
63     -X main.Version=$pkgver \
64     -X main.CommitSHA=$_commit" \
65     -o build \
66     .
68   # generate man page
69   ./build/charm man > build/charm.1
71   # ensure reproducibility of man page
72   # i'm not 100% sure where the man sub-command gets the date from, i assume
73   # it uses $TODAYS_DATE, so this should make the man page reproducible
74   local _commit_date=$(git show --no-patch --format=%cd --date=format:%Y-%m-%d)
76   sed \
77     -i build/charm.1 \
78     -e "s/\"[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\"/\"$_commit_date\"/"
80   # generate shell completion
81   for shell in bash fish zsh; do
82     ./build/charm completion "$shell" > "build/$shell.completion"
83   done
86 check() {
87   cd charm
89   go test -v ./...
92 package() {
93   # systemd integration
94   install -vDm644 systemd.service "$pkgdir/usr/lib/systemd/system/charm.service"
95   install -vDm644 sysusers.conf "$pkgdir/usr/lib/sysusers.d/charm.conf"
96   install -vDm644 tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/charm.conf"
97   install -vDm644 charm.conf "$pkgdir/etc/charm.conf"
99   cd charm
101   # binary
102   install -vDm755 -t "$pkgdir/usr/bin" build/charm
104   # shell completion
105   install -vDm644 build/bash.completion "$pkgdir/usr/share/bash-completion/completions/charm"
106   install -vDm644 build/fish.completion "$pkgdir/usr/share/fish/vendor_completions.d/charm.fish"
107   install -vDm644 build/zsh.completion "$pkgdir/usr/share/zsh/site-functions/_charm"
109   # man page
110   install -vDm644 -t "$pkgdir/usr/share/man/man1" build/charm.1
112   # license
113   install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
116 # vim:set ts=2 sw=2 et: