Created
August 27, 2023 23:28
-
-
Save mkg20001/f1db00a96fca97098ee529dd9ee188bf to your computer and use it in GitHub Desktop.
Nixpkgs OpenWRT update script
This file contains 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
#!/usr/bin/env bash | |
# This script assums it is being run in a nixpkgs checkout | |
# This script will try to update all packages with sources from git.openwrt.org | |
# to their latest unstable version automatically | |
set -e | |
for p in $(grep -rn git.openwrt pkgs/ | sed "s|:.*$||g" | sort | uniq); do | |
URL=$(cat "$p" | grep git.openwrt | grep -o "\".*\"" | head -n 1 | sed "s|\"||g") | |
CURREV=$(cat "$p" | grep rev | grep -o "\".*\"" | head -n 1 | sed "s|\"||g") | |
VER=$(cat "$p" | grep -o "unstable-[0-9-]*") | |
NAME=$(cat "$p" | grep pname | grep -o "\".*\"" | head -n 1 | sed "s|\"||g") | |
JSON=$(nix-prefetch-git "$URL") | |
REV=$(echo "$JSON" | jq -r .rev) | |
if [[ "$REV" != "$CURREV" ]]; then | |
sed "s|rev = .*$|rev = \"$REV\";|" -i "$p" | |
HASH=$(echo "$JSON" | jq -r .hash) | |
sed "s|sha256 = .*$|hash = \"$HASH\";|" -i "$p" | |
sed "s|hash = .*$|hash = \"$HASH\";|" -i "$p" | |
DATE=$(echo "$JSON" | jq -r .date | sed "s|T.*$||g") | |
sed "s|version = .*$|version = \"unstable-$DATE\";|" -i "$p" | |
git add "$p" | |
git commit -m "$NAME: $VER -> unstable-$DATE" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment