2022-07-30 20:39:22 +03:00
|
|
|
REPO_ROOT="${REPO_ROOT:-.}"
|
|
|
|
NPINS_DIRECTORY="${NPINS_DIRECTORY:-npins}"
|
|
|
|
|
2022-08-30 21:49:05 +03:00
|
|
|
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)
|
2022-08-30 21:49:05 +03:00
|
|
|
cmd_update "$@";;
|
|
|
|
update-all)
|
|
|
|
cmd_update_all "$@";;
|
2022-07-30 20:39:22 +03:00
|
|
|
*)
|
|
|
|
echo Unknown command: "$cmd";;
|
|
|
|
esac
|