mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
Merge pull request #277811 from herberteuler/fix/yourkit
Add YourKit-JavaProfiler
This commit is contained in:
commit
69c3647fe2
16
pkgs/by-name/yo/yourkit-java/forbid-desktop-item-creation
Normal file
16
pkgs/by-name/yo/yourkit-java/forbid-desktop-item-creation
Normal file
@ -0,0 +1,16 @@
|
||||
CONFIG_DIR=$YS/config
|
||||
if [ ! -d $CONFIG_DIR ]; then
|
||||
mkdir -p $CONFIG_DIR
|
||||
fi
|
||||
|
||||
REGISTRY=$CONFIG_DIR/registry8.xml
|
||||
if [ ! -e $REGISTRY ]; then
|
||||
cat >$REGISTRY <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<registry8>
|
||||
<desktop-file.created>
|
||||
<boolean value="true"/>
|
||||
</desktop-file.created>
|
||||
</registry8>
|
||||
EOF
|
||||
fi
|
95
pkgs/by-name/yo/yourkit-java/package.nix
Normal file
95
pkgs/by-name/yo/yourkit-java/package.nix
Normal file
@ -0,0 +1,95 @@
|
||||
{ fetchzip
|
||||
, lib
|
||||
, stdenvNoCC
|
||||
, copyDesktopItems
|
||||
, imagemagick
|
||||
, makeDesktopItem
|
||||
, jre
|
||||
}:
|
||||
let
|
||||
vPath = v: lib.elemAt (lib.splitString "-" v) 0;
|
||||
|
||||
version = "2024.3-b157";
|
||||
|
||||
arches = {
|
||||
aarch64-linux = "arm64";
|
||||
x86_64-linux = "x64";
|
||||
};
|
||||
|
||||
arch =
|
||||
arches.${stdenvNoCC.targetPlatform.system} or (throw "Unsupported system");
|
||||
|
||||
hashes = {
|
||||
arm64 = "sha256-0a9maZhgtXH21Ph0o3Rb+rCPhAmZRxjZCRyDmTvusLk=";
|
||||
x64 = "sha256-nLaOOkPG2QEHkHd0S2AYLT2IpkMchGw9adyUDLCNQFg=";
|
||||
};
|
||||
|
||||
desktopItem = makeDesktopItem {
|
||||
name = "YourKit Java Profiler";
|
||||
desktopName = "YourKit Java Profiler " + version;
|
||||
type = "Application";
|
||||
exec = "yourkit-java-profiler %f";
|
||||
icon = "yourkit-java-profiler";
|
||||
categories = [ "Development" "Java" "Profiling" ];
|
||||
terminal = false;
|
||||
startupWMClass = "YourKit Java Profiler";
|
||||
};
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
inherit version;
|
||||
|
||||
pname = "yourkit-java";
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://download.yourkit.com/yjp/${vPath version}/YourKit-JavaProfiler-${version}-${arch}.zip";
|
||||
hash = hashes.${arch};
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ copyDesktopItems imagemagick ];
|
||||
|
||||
buildInputs = [ jre ];
|
||||
|
||||
desktopItems = [ desktopItem ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
cp -pr bin lib license.html license-redist.txt probes samples $out
|
||||
cp ${./forbid-desktop-item-creation} $out/bin/forbid-desktop-item-creation
|
||||
mv $out/bin/profiler.sh $out/bin/yourkit-java-profiler
|
||||
mkdir -p $out/share/icons
|
||||
convert $out/bin/profiler.ico\[0] \
|
||||
-size 256x256 \
|
||||
$out/share/icons/yourkit-java-profiler.png
|
||||
rm $out/bin/profiler.ico
|
||||
rm -rf $out/bin/{windows-*,mac,linux-{*-32,musl-*,ppc-*}}
|
||||
if [[ ${arch} = x64 ]]; then
|
||||
rm -rf $out/bin/linux-arm-64
|
||||
else
|
||||
rm -rf $out/bin/linux-x86-64
|
||||
fi
|
||||
substituteInPlace $out/bin/yourkit-java-profiler \
|
||||
--replace 'JAVA_EXE="$YD/jre64/bin/java"' JAVA_EXE=${jre}/bin/java
|
||||
# Use our desktop item, which will be purged when this package
|
||||
# gets removed
|
||||
sed -i -e "/^YD=/isource $out/bin/forbid-desktop-item-creation\\
|
||||
" \
|
||||
$out/bin/yourkit-java-profiler
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Award winning, fully featured low overhead profiler for Java EE and Java SE platforms";
|
||||
homepage = "https://www.yourkit.com";
|
||||
changelog = "https://www.yourkit.com/changes/";
|
||||
license = licenses.unfree;
|
||||
mainProgram = "yourkit-java-profiler";
|
||||
platforms = attrNames arches;
|
||||
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
||||
maintainers = with maintainers; [ herberteuler ];
|
||||
};
|
||||
}
|
54
pkgs/by-name/yo/yourkit-java/update.sh
Executable file
54
pkgs/by-name/yo/yourkit-java/update.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p coreutils curl gawk gnused nix-prefetch
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(dirname "$(readlink -f "$0")")"
|
||||
DRV_BASE=package.nix
|
||||
NIX_DRV="$ROOT/$DRV_BASE"
|
||||
if [[ ! -f "$NIX_DRV" ]]; then
|
||||
echo "ERROR: cannot find $DRV_BASE in $ROOT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function retrieve_latest_version () {
|
||||
curl https://www.yourkit.com/java/profiler/download/ \
|
||||
| grep -Eo '(Version|Build): ([a-z0-9#.-])+' \
|
||||
| awk '{ print $2 }' \
|
||||
| tr -d '\n' \
|
||||
| sed 's/#/-b/'
|
||||
}
|
||||
|
||||
function calc_hash () {
|
||||
local version=$1
|
||||
local url=$2
|
||||
nix-prefetch --option extra-experimental-features flakes \
|
||||
"{ stdenv, fetchzip }:
|
||||
stdenv.mkDerivation {
|
||||
pname = \"yourkit-java-binary\";
|
||||
version = \"$version\";
|
||||
src = fetchzip {
|
||||
url = \"$url\";
|
||||
};
|
||||
}"
|
||||
}
|
||||
|
||||
function update_hash () {
|
||||
local arch=$1
|
||||
local version=$2
|
||||
local date=$(echo $version | sed 's/-.*//')
|
||||
local url=https://download.yourkit.com/yjp/$date/YourKit-JavaProfiler-$version-$arch.zip
|
||||
local hash=$(calc_hash $version $url)
|
||||
sed -i -e "s|^.*$arch.*=.*\"sha256-.*$| $arch = \"$hash\";|" $NIX_DRV
|
||||
}
|
||||
|
||||
version=$(retrieve_latest_version)
|
||||
sed -i -e "s|^.*version.*=.*\".*$| version = \"$version\";|" $NIX_DRV
|
||||
for arch in arm64 x64; do
|
||||
update_hash $arch $version
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
||||
# eval: (sh-set-shell "bash")
|
||||
# End:
|
@ -19785,6 +19785,10 @@ with pkgs;
|
||||
|
||||
yodl = callPackage ../development/tools/misc/yodl { };
|
||||
|
||||
yourkit-java = callPackage ../by-name/yo/yourkit-java/package.nix {
|
||||
jre = jdk17;
|
||||
};
|
||||
|
||||
yq = python3.pkgs.toPythonApplication python3.pkgs.yq;
|
||||
|
||||
yq-go = callPackage ../development/tools/yq-go { };
|
||||
|
Loading…
Reference in New Issue
Block a user