Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 57 lines 2.1 kB view raw
1#! /usr/bin/env nix-shell 2#! nix-shell -i bash -p coreutils moreutils curl jq nix-prefetch-git cargo gnugrep gawk nix 3# shellcheck shell=bash 4 5# You must run it from the root directory of a nixpkgs repo checkout 6 7set -euo pipefail 8 9versionJson="$(realpath "./pkgs/os-specific/linux/scx/version.json")" 10nixFolder="$(dirname "$versionJson")" 11 12localVer=$(jq -r .scx.version <$versionJson) 13latestVer=$(curl -s https://api.github.com/repos/sched-ext/scx/releases/latest | jq -r .tag_name | sed 's/v//g') 14 15if [ "$localVer" == "$latestVer" ]; then 16 exit 0 17fi 18 19latestHash=$(nix-prefetch-git https://github.com/sched-ext/scx.git --rev refs/tags/v$latestVer --quiet | jq -r .hash) 20 21tmp=$(mktemp -d) 22trap 'rm -rf -- "${tmp}"' EXIT 23 24git clone --depth 1 --branch "v$latestVer" https://github.com/sched-ext/scx.git "$tmp/scx" 25 26pushd "$tmp/scx" 27 28bpftoolRev=$(grep 'bpftool_commit =' ./meson.build | awk -F"'" '{print $2}') 29bpftoolHash=$(nix-prefetch-git https://github.com/libbpf/bpftool.git --rev $bpftoolRev --fetch-submodules --quiet | jq -r .hash) 30 31libbpfRev=$(grep 'libbpf_commit =' ./meson.build | awk -F"'" '{print $2}') 32libbpfHash=$(nix-prefetch-git https://github.com/libbpf/libbpf.git --rev $libbpfRev --fetch-submodules --quiet | jq -r .hash) 33 34jq \ 35 --arg latestVer "$latestVer" --arg latestHash "$latestHash" \ 36 --arg bpftoolRev "$bpftoolRev" --arg bpftoolHash "$bpftoolHash" \ 37 --arg libbpfRev "$libbpfRev" --arg libbpfHash "$libbpfHash" \ 38 ".scx.version = \$latestVer | .scx.hash = \$latestHash |\ 39 .bpftool.rev = \$bpftoolRev | .bpftool.hash = \$bpftoolHash |\ 40 .libbpf.rev = \$libbpfRev | .libbpf.hash = \$libbpfHash" \ 41 "$versionJson" | sponge $versionJson 42 43echo "scx: $localVer -> $latestVer" 44 45echo "Updating cargoHash. This may take a while..." 46popd 47cargoHash=$((nix-build --attr scx.rustscheds 2>&1 || true) | awk '/got/{print $2}') 48 49if [ -z "$cargoHash" ]; then 50 echo "Failed to get cargoHash, please update it manually" 51 exit 0 52fi 53 54jq \ 55 --arg cargoHash "$cargoHash" \ 56 ".scx.cargoHash = \$cargoHash" \ 57 "$versionJson" | sponge $versionJson