summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/update-libre.sh
blob: aea12df55cc596ed223d44963388fec1bae0b099 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix-prefetch-svn git curl
set -euo pipefail

nixpkgs="$(git rev-parse --show-toplevel)"
path="$nixpkgs/pkgs/os-specific/linux/kernel/linux-libre.nix"

old_rev="$(grep -o 'rev = ".*"' "$path" | awk -F'"' '{print $2}')"
old_sha256="$(grep -o 'sha256 = ".*"' "$path" | awk -F'"' '{print $2}')"

svn_url=https://www.fsfla.org/svn/fsfla/software/linux-libre/releases/branches/
rev="$(curl -s "$svn_url" | grep -Em 1 -o 'Revision [0-9]+' | awk '{print $2}')"

if [ "$old_rev" = "$rev" ]; then
    echo "No updates for linux-libre"
    exit 0
fi

sha256="$(QUIET=1 nix-prefetch-svn "$svn_url" "$rev" | tail -1)"

if [ "$old_sha256" = "$sha256" ]; then
    echo "No updates for linux-libre"
    exit 0
fi

sed -i -e "s/rev = \".*\"/rev = \"$rev\"/" \
    -e "s/sha256 = \".*\"/sha256 = \"$sha256\"/" "$path"

if [ -n "${COMMIT-}" ]; then
    git commit -qm "linux_latest-libre: $old_rev -> $rev" "$path" \
       $nixpkgs/pkgs/os-specific/linux/kernel/linux-libre.nix
    echo "Updated linux_latest-libre $old_rev -> $rev"
fi