summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7599857424445a19a76509a009e03db3bf5d0433 (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
# Maintainer: Randall Winkhart <idgr at tutanota dot com>
pkgname=mutn
pkgver=0.2.3
pkgrel=1
pkgdesc='A simple, self-hosted, SSH-synchronized password/note manager for the CLI (based on libmutton)'
arch=('x86_64' 'i686' 'i486' 'pentium4' 'aarch64' 'armv7h' 'riscv64')
url='https://github.com/rwinkhart/MUTN'
license=('MIT')
depends=(gnupg)
makedepends=(go grep gzip)
optdepends=(
    'wl-clipboard: Wayland clipboard support'
    'xclip: X11 clipboard support'
    'bash-completion: Bash completion support'
)
source=("git+https://github.com/rwinkhart/MUTN.git#tag=v${pkgver}")
sha512sums=(SKIP)

build() {
    cd ${srcdir}/MUTN

    # compress man page
    gzip -kf ./docs/man

    # determine microarchitecture feature level
    case $CARCH in
        'x86_64')
            cpuFlags=$(grep -E 'flags\s+:\s' /proc/cpuinfo)
            if [ ! -z "$(grep 'avx512f' <<< "$cpuFlags")" ]; then
                export GOAMD64=v4
            elif [ ! -z "$(grep 'avx2' <<< "$cpuFlags")" ]; then
                export GOAMD64=v3
            elif [ ! -z "$(grep 'sse4_2' <<< "$cpuFlags")" ]; then
                export GOAMD64=v2
            else
                export GOAMD64=v1
            fi
            ;;
        # TODO check aarch64 feature level
    esac

    # compile binary
    CGO_ENABLED=1 go build -ldflags="-s -w" -trimpath ./mutn.go
}

package() {
    cd ${srcdir}/MUTN
    install -Dm755 ./mutn ${pkgdir}/usr/bin/mutn
    install -Dm644 ./LICENSE ${pkgdir}/usr/share/licenses/mutn/LICENSE
    install -Dm644 ./completions/zsh/_mutn ${pkgdir}/usr/share/zsh/site-functions/_mutn
    install -Dm644 ./completions/bash/mutn ${pkgdir}/usr/share/bash-completion/completions/mutn
    install -Dm644 ./docs/man.gz ${pkgdir}/usr/share/man/man1/mutn.1.gz
}