pkgname=gum pkgver=0.15.0 pkgrel=1 pkgdesc='A tool for glamorous shell scripts' arch=('x86_64') url='https://github.com/charmbracelet/gum' license=('MIT') depends=('glibc') makedepends=('go') options=('!lto') source=(https://github.com/charmbracelet/gum/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz) sha256sums=(a6a05f4b36ce622458091ca17345765ed1e248a6ca737bade2fa27ac2e4bdff5) prepare() { cd ${pkgname}-${pkgver} # create directory for build output mkdir build export GOPROXY=https://goproxy.cn # download dependencies export GOPATH=${srcdir} go mod download } build() { cd ${pkgname}-${pkgver} export GOPROXY=https://goproxy.cn # set Go flags export CGO_CPPFLAGS="${CPPFLAGS}" export CGO_CFLAGS="${CFLAGS}" export CGO_CXXFLAGS="${CXXFLAGS}" export GOPATH="${srcdir}" # commit date for binary & man page local _commit_date=$(git show --no-patch --format=%cd --date=format:%Y-%m-%d) go build -v \ -buildmode=pie \ -mod=readonly \ -modcacherw \ -ldflags "-compressdwarf=false \ -linkmode external \ -extldflags \"${LDFLAGS}\" \ -X main.Version=${pkgver} \ -X main.CommitSHA=$(git rev-parse HEAD) \ -X main.CommitDate=$_commit_date" \ -o build \ . # man page ./build/gum man > build/gum.1 # i'm not 100% sure where the man sub-command gets the date from, i assume # it uses $TODAYS_DATE, so this should make the man page reproducible sed \ -i build/gum.1 \ -e "s/\"[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\"/\"$_commit_date\"/" # completions for shell in bash fish zsh; do ./build/gum completion "$shell" > "build/$shell-completion" done } package() { cd ${pkgname}-${pkgver} # binary install -vDm755 -t ${pkgdir}/usr/bin build/gum # man pages install -vDm644 -t ${pkgdir}/usr/share/man/man1 build/gum.1 # completions install -vDm644 build/bash-completion ${pkgdir}/usr/share/bash-completion/completions/gum install -vDm644 build/fish-completion ${pkgdir}/usr/share/fish/vendor_completions.d/gum.fish install -vDm644 build/zsh-completion ${pkgdir}/usr/share/zsh/site-functions/_gum }