Created
May 28, 2024 19:17
-
-
Save Laura7089/6f7acc31e60ce19aa32329067e8c110e to your computer and use it in GitHub Desktop.
Small `Justfile` to manage a fleet of AUR packages. Automates common tasks, see `just -l`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env -S just --justfile | |
PKG_GLOB := "*.pkg.*" | |
BROWSER := env_var_or_default("BROWSER", "xdg-open") | |
# build the package (need to be next to PKGBUILD) | |
[no-cd] | |
[no-exit-message] | |
build *args="--force": && check | |
makepkg {{args}} | |
# build and install the package (need to be next to PKGBUILD) | |
[no-cd] | |
[no-exit-message] | |
install *args="--force": | |
makepkg -si {{args}} | |
# check the package with namcap (need to be next to PKGBUILD) | |
[no-cd] | |
check *args="": | |
namcap {{args}} PKGBUILD | |
find \ | |
-iname "{{PKG_GLOB}}" \ | |
>/dev/null 2>&1 \ | |
&& namcap {{args}} "$(just latest)" \ | |
|| exit 0 | |
# generate the .SRCINFO file (need to be next to PKGBUILD) | |
[no-cd] | |
[no-exit-message] | |
srcinfo: | |
makepkg --printsrcinfo > .SRCINFO | |
# initialise the AUR git repo for a package (need to be next to PKGBUILD) | |
[no-cd] | |
gitinit: | |
#!/bin/bash | |
set -euxo pipefail | |
if [[ -e .git ]]; then | |
echo "existing git repo found, exiting" | |
exit 1 | |
fi | |
git init --initial-branch=master | |
echo "pkg" >> .gitignore | |
echo "src" >> .gitignore | |
echo '{{PKG_GLOB}}' >> .gitignore | |
git remote add origin \ | |
"ssh://[email protected]/$(basename "$PWD").git" | |
git config push.autoSetupRemote true | |
# create a new package | |
new name type="normal": | |
mkdir -p "{{name}}" | |
cp \ | |
/usr/share/pacman/PKGBUILD{{ if type != "normal" { "-" + type } else { "" } }}.proto \ | |
"{{name}}/PKGBUILD" | |
cd "{{name}}" && just gitinit | |
@echo "Don't forget to add nvchecker configuration for {{name}}!" | |
# get the latest file for a package (need to be next to PKGBUILD) | |
[no-cd] | |
latest: | |
ls -1 {{PKG_GLOB}} | tail -1 | |
# clean a package directory (need to be next to PKGBUILD) | |
[no-cd] | |
clean: && cleangitignore | |
@[ -f PKGBUILD ] || (echo "no PKGBUILD found, exiting for safety" && exit 1) | |
rm -rfv pkg src | |
rm -fv {{PKG_GLOB}} | |
[private] | |
[no-cd] | |
cleangitignore: | |
#!/bin/sh | |
set -eux | |
if [[ -e .gitignore ]]; then | |
globs="$(grep '^[^!#]' .gitignore | grep -v .gitignore)" | |
for glob in $globs; do | |
sh -c "rm -rfv $glob" | |
done | |
fi | |
# clean up all the package in the entire directory | |
cleanall: | |
find -maxdepth 1 -mindepth 1 -type d -not -name legacy \ | |
-ok sh -c '(cd {} && just clean)' \; | |
# check for new versions of configured packages | |
updates: | |
nvchecker -c nvchecker_config.toml | |
# mark packages as having been updated | |
markupdated *names: | |
nvtake -c nvchecker_config.toml {{names}} | |
# open the upstream in a browser (need to be next to PKGBUILD) | |
[no-cd] | |
openurl: | |
{{BROWSER}} "$(bash -c 'source PKGBUILD && echo "$url"')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment