depot/packages/tools/pin/pin.sh

28 lines
653 B
Bash
Raw Normal View History

2022-07-30 20:39:22 +03:00
REPO_ROOT="${REPO_ROOT:-.}"
NPINS_DIRECTORY="${NPINS_DIRECTORY:-npins}"
cmd_update() {
for pkg in "$@"; do
oldver=$(nix eval --raw "${REPO_ROOT}#${pkg}.version")
npins update "$pkg"
newver=$(nix eval --raw "${REPO_ROOT}#${pkg}.version")
git add "${NPINS_DIRECTORY}"
git commit "${NPINS_DIRECTORY}" -m "packages/$pkg: $oldver -> $newver" || true
done
}
cmd_update_all() {
# shellcheck disable=SC2046
cmd_update $(jq < "${NPINS_DIRECTORY}/sources.json" -r '.pins | keys | .[]')
}
2022-07-30 20:39:22 +03:00
cmd="$1"
shift
case $cmd in
update)
cmd_update "$@";;
update-all)
cmd_update_all "$@";;
2022-07-30 20:39:22 +03:00
*)
echo Unknown command: "$cmd";;
esac