python312Packages.types-aiobotocore: 2.15.2 -> 2.15.2.post3 (#361801)
[NixPkgs.git] / pkgs / by-name / yo / yourkit-java / update.sh
blob0b95732f6b74a0aa74981b7f438d1cf5e35f3d2e
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p coreutils curl gawk gnused nix-prefetch
4 set -euo pipefail
6 ROOT="$(dirname "$(readlink -f "$0")")"
7 DRV_BASE=package.nix
8 NIX_DRV="$ROOT/$DRV_BASE"
9 if [[ ! -f "$NIX_DRV" ]]; then
10 echo "ERROR: cannot find $DRV_BASE in $ROOT"
11 exit 1
14 function retrieve_latest_version () {
15 curl https://www.yourkit.com/java/profiler/download/ \
16 | grep -Eo '(Version|Build): ([a-z0-9#.-])+' \
17 | awk '{ print $2 }' \
18 | tr -d '\n' \
19 | sed 's/#/-b/'
22 function calc_hash () {
23 local version=$1
24 local url=$2
25 nix-prefetch --option extra-experimental-features flakes \
26 "{ stdenv, fetchzip }:
27 stdenv.mkDerivation {
28 pname = \"yourkit-java-binary\";
29 version = \"$version\";
30 src = fetchzip {
31 url = \"$url\";
36 function update_hash () {
37 local arch=$1
38 local version=$2
39 local date=$(echo $version | sed 's/-.*//')
40 local url=https://download.yourkit.com/yjp/$date/YourKit-JavaProfiler-$version-$arch.zip
41 local hash=$(calc_hash $version $url)
42 sed -i -e "s|^.*$arch.*=.*\"sha256-.*$| $arch = \"$hash\";|" $NIX_DRV
45 version=$(retrieve_latest_version)
46 sed -i -e "s|^.*version.*=.*\".*$| version = \"$version\";|" $NIX_DRV
47 for arch in arm64 x64; do
48 update_hash $arch $version
49 done
51 # Local variables:
52 # mode: shell-script
53 # eval: (sh-set-shell "bash")
54 # End: