linux-rt: add update script

+80
+77
pkgs/os-specific/linux/kernel/update-rt.sh
···
··· 1 + #!/usr/bin/env bash 2 + set -euo pipefail 3 + 4 + # To update all rt kernels run: ./update-rt.sh 5 + 6 + # To update just one ./linux-rt-5.X.nix run: ./update-rt.sh ./linux-rt-5.X.nix 7 + 8 + # To add a new kernel branch 5.Y run: ./update-rt.sh ./linux-rt-5.Y.nix 9 + # (with nonexistent .nix file) and update all-packages.nix. 10 + 11 + # To commit run with: env COMMIT=1 12 + 13 + mirror=https://kernel.org/pub/linux/kernel 14 + 15 + main() { 16 + if [ $# -ge 1 ]; then 17 + update-if-needed "$1" 18 + else 19 + update-all-if-needed 20 + fi 21 + } 22 + 23 + update-all-if-needed() { 24 + for f in "$(dirname "$0")"/linux-rt-*.nix; do 25 + update-if-needed "$f" 26 + done 27 + } 28 + 29 + file-version() { 30 + file="$1" # e.g. ./linux-rt-5.4.nix 31 + if [ -e "$file" ]; then 32 + grep ' version = ' "$file" | grep -o '[0-9].[^"]*' 33 + fi 34 + } 35 + 36 + latest-rt-version() { 37 + branch="$1" # e.g. 5.4 38 + curl -sL "$mirror/projects/rt/$branch/sha256sums.asc" | 39 + sed -ne '/.patch.xz/ { s/.*patch-\(.*\).patch.xz/\1/; p; q }' 40 + } 41 + 42 + update-if-needed() { 43 + file="$1" # e.g. ./linux-rt-5.4.nix (created if does not exist) 44 + branch=$(basename "$file" .nix) # e.g. linux-rt-5.4 45 + branch=${branch#linux-rt-} # e.g. 5.4 46 + cur=$(file-version "$file") # e.g. 5.4.59-rt36 or empty 47 + new=$(latest-rt-version "$branch") # e.g. 5.4.61-rt37 48 + kversion=${new%-*} # e.g. 5.4.61 49 + major=${branch%.*} # e.g 5 50 + nixattr="linux-rt_${branch/./_}" 51 + if [ "$new" = "$cur" ]; then 52 + echo "$nixattr: $cur (up-to-date)" 53 + return 54 + fi 55 + khash=$(nix-prefetch-url "$mirror/v${major}.x/linux-${kversion}.tar.xz") 56 + phash=$(nix-prefetch-url "$mirror/projects/rt/${branch}/older/patch-${new}.patch.xz") 57 + if [ "$cur" ]; then 58 + msg="$nixattr: $cur -> $new" 59 + else 60 + msg="$nixattr: init at $new" 61 + prev=$(ls "$(dirname "$0")"/linux-rt-*.nix | tail -1) 62 + cp "$prev" "$file" 63 + cur=$(file-version "$file") 64 + fi 65 + echo "$msg" 66 + sed -i "$file" \ 67 + -e "s/$cur/$new/" \ 68 + -e "s|kernel/v[0-9]*|kernel/v$major|" \ 69 + -e "1,/.patch.xz/ s/sha256 = .*/sha256 = \"$khash\";/" \ 70 + -e "1,/.patch.xz/! s/sha256 = .*/sha256 = \"$phash\";/" 71 + if [ "${COMMIT:-}" ]; then 72 + git add "$file" 73 + git commit -m "$msg" 74 + fi 75 + } 76 + 77 + return 2>/dev/null || main "$@"
+3
pkgs/os-specific/linux/kernel/update.sh
··· 58 echo "Updated $OLDVER -> $V" 59 done 60 61 # Update linux-libre 62 COMMIT=1 $NIXPKGS/pkgs/os-specific/linux/kernel/update-libre.sh 63
··· 58 echo "Updated $OLDVER -> $V" 59 done 60 61 + # Update linux-rt 62 + COMMIT=1 $NIXPKGS/pkgs/os-specific/linux/kernel/update-rt.sh 63 + 64 # Update linux-libre 65 COMMIT=1 $NIXPKGS/pkgs/os-specific/linux/kernel/update-libre.sh 66