Compare commits

...

5 Commits

5 changed files with 127 additions and 15 deletions

View File

@ -1,5 +1,9 @@
priority -50
#
# General snippets
#
snippet maint "Maintainer tag" i
`#!/usr/bin/env bash
echo "# Maintainer:" $(cat /etc/makepkg.conf $XDG_CONFIG_HOME/pacman/makepkg.conf 2>/dev/null | grep -oP '^PACKAGER="\K[^"]+')
@ -13,11 +17,11 @@ pkgrel=${3:1}
pkgdesc='$4'
arch=(${5:'any'})
url='$6'
license=($7)
depends=($8)
makedepends=($9)
checkdepends=($10)
optdepends=($11)
license=('$7')
depends=('$8')
makedepends=('$9')
checkdepends=('$10')
optdepends=('$11')
options=('!lto')
source=("$pkgname::git+$12")
b2sums=('SKIP')
@ -31,12 +35,25 @@ prepare() {
}
endsnippet
snippet patch "patch files" i
`#!/usr/bin/env bash
source PKGBUILD
for s in "${source[@]}"; do
if [[ "$s" == *".patch"* ]]; then
printf "patch --strip=1 --input=\"\$srcdir/%s\"\n" "${s%::*}"
fi
done
`
endsnippet
snippet ver "pkgver" i
pkgver() {
cd "$pkgname"$1
git describe --tags | sed 's/^v//'
git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
printf 'r%s.g%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
endsnippet
@ -65,7 +82,6 @@ package() {
}
endsnippet
## General package() snippets
snippet pkgbin "Package binary" i
# binary
install -vDm755 -t "$pkgdir/usr/bin" $1
@ -81,8 +97,10 @@ snippet pkglic "Package license" i
install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" $1
endsnippet
## Go specific
snippet goprep "Prepare (Go)" i
#
# Go specific
#
snippet prepgo "Prepare (Go)" i
# create directory for build output
mkdir build
@ -90,7 +108,7 @@ snippet goprep "Prepare (Go)" i
go mod download
endsnippet
snippet gobuild "Build (Go)" i
snippet buildgo "Build (Go)" i
# set Go flags
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
@ -106,27 +124,60 @@ snippet gobuild "Build (Go)" i
.
endsnippet
snippet gochk "Check (Go)" i
snippet chkgo "Check (Go)" i
go test -v ./...
endsnippet
## Rust specific
snippet rustprep "Prepare (Rust)" i
#
# Rust specific
#
snippet preprs "Prepare (Rust)" i
# download dependencies
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
endsnippet
snippet rustbuild "Build (Rust)" i
snippet buildrs "Build (Rust)" i
cargo build --frozen --release --all-features
endsnippet
snippet rustchk "Check (Rust)" i
snippet chkrs "Check (Rust)" i
cargo test --frozen --all-features
endsnippet
snippet rustpkg "Package (Rust)" i
snippet pkgrs "Package (Rust)" i
# binary
install -vDm755 -t "$pkgdir/usr/bin" "target/release/$pkgname"
endsnippet
#
# Common Lisp specific
#
snippet clname "Package Name (Common Lisp)" i
_pkgname="${pkgname#cl-}"
endsnippet
snippet vercl "Version (Common Lisp)" i
# first known commit to receive latest version
local _pkgver='$1'
local _pkgcommit='$2'
git tag "$_pkgver" "$_pkgcommit"
git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
endsnippet
snippet chkcl "Check (Common Lisp)" i
sbcl --script ../run-tests.lisp
endsnippet
snippet pkgcl "Package (Common Lisp)" i
# library
install -vDm644 -t "$pkgdir/usr/share/common-lisp/source/$_pkgname" ./*.{lisp,asd}
find . -mindepth 1 -maxdepth 1 -type d -not -name '.git' -exec cp -vr -t "$pkgdir/usr/share/common-lisp/source/$_pkgname" {} \+
cp -vr \
directories \
files ./*.asd \
"$pkgdir/usr/share/common-lisp/source/$_pkgname"
endsnippet
# vim: tabstop=2 shiftwidth=2 expandtab

View File

@ -24,4 +24,49 @@ function tag2commit() {
git ls-remote $repository $tag
}
# wrapper around extra-x86_64-build for caching downloaded dependencies
# TODO expand to use testing/staging
function ab-extra() {
local EXTRA_ARGS=()
# capture output for parsing dependencies
makepkg_output=$(makepkg --printsrcinfo)
#
# cache various downloads
#
# rust - crates
if grep -q "depends = rust\|cargo" <<<"$makepkg_output"; then
EXTRA_ARGS+=(
-d /var/cache/cargo/git:/build/.cargo/git
-d /var/cache/cargo/registry:/build/.cargo/registry
)
fi
# go - modules
if grep -q "depends = go" <<<"$makepkg_output"; then
EXTRA_ARGS+=(
-d /var/cache/golang/pkg:/build/go/pkg
-d /var/cache/golang/build:/build/.cache/go-build
)
fi
# dart - packages
if grep -q "depends = dart" <<<"$makepkg_output"; then
EXTRA_ARGS+=(-d /var/cache/dartlang:/build/.pub-cache)
fi
# javascript - npm/yarn/pkg
if grep -q "depends = npm\|yarn\|nodejs" <<<"$makepkg_output"; then
EXTRA_ARGS+=(
-d /var/cache/javascript/npm:/build/.npm
-d /var/cache/javascript/pkg-cache:/build/.pkg-cache
-d /var/cache/javascript/yarn:/build/.cache/yarn
)
fi
extra-x86_64-build -- ${EXTRA_ARGS[@]} ${@}
}
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View File

@ -0,0 +1,9 @@
#
# direnv
#
if command -v direnv &> /dev/null; then
eval "$(direnv hook zsh)"
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View File

@ -1,4 +1,9 @@
#
# zoxide
#
if command -v zoxide &> /dev/null; then
eval "$(zoxide init zsh)"
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View File

@ -2,6 +2,8 @@
# local zsh file
#
# NOTE: all modifications to $PATH to be placed in this file
# PKGBUILD checker
if command -v shellcheck &> /dev/null; then
alias pbcheck='SHELLCHECK_OPTS="-e SC2034 -e SC2164 -e SC2154 -e SC2148" shellcheck'