<commit_before>#!/usr/bin/env bash
set -euo pipefail

# To update all rt kernels run: ./update-rt.sh

# To update just one ./linux-rt-5.X.nix run: ./update-rt.sh ./linux-rt-5.X.nix

# To add a new kernel branch 5.Y run: ./update-rt.sh ./linux-rt-5.Y.nix
# (with nonexistent .nix file) and update all-packages.nix.

# To commit run with: env COMMIT=1

mirror=https://kernel.org/pub/linux/kernel

main() {
    if [ $# -ge 1 ]; then
        update-if-needed "$1"
    else
        update-all-if-needed
    fi
}

update-all-if-needed() {
    for f in "$(dirname "$0")"/linux-rt-*.nix; do
        update-if-needed "$f"
    done
}

file-version() {
    file="$1" # e.g. ./linux-rt-5.4.nix
    if [ -e "$file" ]; then
        grep ' version = ' "$file" | grep -o '[0-9].[^"]*'
    fi
}

latest-rt-version() {
    branch="$1" # e.g. 5.4
    curl -sL "$mirror/projects/rt/$branch/sha256sums.asc" |
        sed -ne '/.patch.xz/ { s/.*patch-\(.*\).patch.xz/\1/; p; q }'
}

update-if-needed() {<commit_msg>linux-rt: use latest version<commit_after>#!/usr/bin/env bash
set -euo pipefail

# To update all rt kernels run: ./update-rt.sh

# To update just one ./linux-rt-5.X.nix run: ./update-rt.sh ./linux-rt-5.X.nix

# To add a new kernel branch 5.Y run: ./update-rt.sh ./linux-rt-5.Y.nix
# (with nonexistent .nix file) and update all-packages.nix.

# To commit run with: env COMMIT=1

mirror=https://kernel.org/pub/linux/kernel

main() {
    if [ $# -ge 1 ]; then
        update-if-needed "$1"
    else
        update-all-if-needed
    fi
}

update-all-if-needed() {
    for f in "$(dirname "$0")"/linux-rt-*.nix; do
        update-if-needed "$f"
    done
}

file-version() {
    file="$1" # e.g. ./linux-rt-5.4.nix
    if [ -e "$file" ]; then
        grep ' version = ' "$file" | grep -o '[0-9].[^"]*'
    fi
}

latest-rt-version() {
    branch="$1" # e.g. 5.4
    curl -sL "$mirror/projects/rt/$branch/sha256sums.asc" |
        sed -ne '/.patch.xz/ { s/.*patch-\(.*\).patch.xz/\1/p}' |
        tail -n 1
}

update-if-needed() {
{'fraction_non_alphanumeric': 0.2074441687344913, 'fraction_numerical': 0.020347394540942927, 'mean_word_length': 2.1549295774647885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3619539', 'n_tokens_mistral': 863, 'n_tokens_neox': 805, 'n_words': 190}