init commit

This commit is contained in:
Daniel Fichtinger 2025-07-08 15:19:30 -04:00
commit ccc8634843
3 changed files with 738 additions and 0 deletions

52
update-integrity Executable file
View file

@ -0,0 +1,52 @@
#!/bin/sh
# Small script for updating the sha256 sums in PKGBUILD files.
# Useful for AUR maintainers.
# Automatically replaces sha256sums* with updated versions from
# makepkg -g. Previous PKGBUILD is always backed up.
# Requires kakoune (pacman -S kakoune)
# Author: Daniel Fichtinger <daniel@ficd.ca>
# License: GPLv3
# check if user gave path to a PKGBUILD,
# or a directory that contains it.
if [ "$#" -eq 0 ]; then
input="$PWD"
else
input="$1"
fi
if [ -d "$input" ]; then
input="$input/PKGBUILD"
fi
if [ "$(basename "$input")" != "PKGBUILD" ] || [ ! -f "$input" ]; then
echo "PKGBUILD not found!"
exit 1
fi
pwd="$(dirname "$input")"
# use kak -f to perform the replacement
# select first and last line with sha256sums
# select union of those selections
# replace selection with output of makepkg -g
kak_filter='gg/sha256sums<ret>xZgg<a-/><ret>x<a-z>u|makepkg -g<ret>'
# run the filter and write to temp file
tempfile="$(mktemp)"
env -C "$pwd" kak -f "$kak_filter" <"$input" >"$tempfile"
# user confirmation
${PAGER:-less} "$tempfile"
printf 'Do you want to proceed? [y/N]: '
read -r answer
case "$answer" in
[Yy]*)
echo "Replacing..."
# back up previous
mv "$input" "${input}.bak"
mv "$tempfile" "$input"
;;
*)
echo "Aborted."
rm "$tempfile"
exit 1
;;
esac