3
0
Fork 0
forked from mirrors/nixpkgs

freenet: build01494 -> 01497

This commit is contained in:
Daniel Nagy 2022-12-10 15:45:00 +01:00
parent f967d005f7
commit 68cb767b94
No known key found for this signature in database
GPG key ID: 1B8E8DCB576FB671
2 changed files with 92 additions and 34 deletions

View file

@ -1,61 +1,118 @@
{ lib, stdenv, fetchurl, jdk, bash, coreutils, substituteAll, nixosTests, jna }:
{ lib, stdenv, fetchurl, fetchFromGitHub, jdk, gradle, bash, coreutils
, substituteAll, nixosTests, perl, fetchpatch, writeText }:
let
version = "build01494";
version = "01497";
freenet_ext = fetchurl {
url = "https://github.com/freenet/fred/releases/download/${version}/freenet-ext.jar";
url = "https://github.com/freenet/fred/releases/download/build01495/freenet-ext.jar";
sha256 = "sha256-MvKz1r7t9UE36i+aPr72dmbXafCWawjNF/19tZuk158=";
};
bcprov = fetchurl {
url = "https://github.com/freenet/fred/releases/download/${version}/bcprov-jdk15on-1.59.jar";
sha256 = "sha256-HDHkTjMdJeRtKTs+juLQcCimfbAR50yyRDKFrtHVnIU=";
};
seednodes = fetchurl {
url = "https://downloads.freenetproject.org/alpha/opennet/seednodes.fref";
sha256 = "08awwr8n80b4cdzzb3y8hf2fzkr1f2ly4nlq779d6pvi5jymqdvv";
};
freenet-jars = stdenv.mkDerivation {
pname = "freenet-jars";
inherit version;
patches = [
# gradle 7 support
(fetchpatch {
url = "https://github.com/freenet/fred/pull/827.patch";
sha256 = "sha256-T1zymxRTADVhhwp2TyB+BC/J4gZsT/CUuMrT4COlpTY=";
})
];
src = fetchurl {
url = "https://github.com/freenet/fred/releases/download/${version}/freenet.jar";
sha256 = "sha256-1Pjc8Ob4EN7N05QkGTMKBn7z3myTDaQ98N48nNSLstg=";
};
in stdenv.mkDerivation rec {
pname = "freenet";
inherit version patches;
dontUnpack = true;
installPhase = ''
mkdir -p $out/share/freenet
ln -s ${bcprov} $out/share/freenet/bcprov.jar
ln -s ${freenet_ext} $out/share/freenet/freenet-ext.jar
ln -s ${jna}/share/java/jna-platform.jar $out/share/freenet/jna_platform.jar
ln -s ${jna}/share/java/jna.jar $out/share/freenet/jna.jar
ln -s $src $out/share/freenet/freenet.jar
'';
src = fetchFromGitHub {
owner = "freenet";
repo = "fred";
rev = "refs/tags/build${version}";
hash = "sha256-pywNPekofF/QotNVF28McojqK7c1Zzucds5rWV0R7BQ=";
};
in stdenv.mkDerivation {
pname = "freenet";
inherit version;
postPatch = ''
rm gradle/verification-{keyring.keys,metadata.xml}
'';
src = substituteAll {
nativeBuildInputs = [ gradle jdk ];
wrapper = substituteAll {
src = ./freenetWrapper;
inherit bash coreutils jdk seednodes;
freenet = freenet-jars;
};
dontUnpack = true;
# https://github.com/freenet/fred/blob/next/build-offline.sh
# fake build to pre-download deps into fixed-output derivation
deps = stdenv.mkDerivation {
pname = "${pname}-deps";
inherit src version patches;
passthru.tests = { inherit (nixosTests) freenet; };
nativeBuildInputs = [ gradle perl ];
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
gradle --no-daemon build
'';
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
installPhase = ''
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/''${\($5 =~ s/okio-jvm/okio/r)}" #e' \
| sh
'';
# Don't move info to share/
forceShare = [ "dummy" ];
outputHashMode = "recursive";
# Downloaded jars differ by platform
outputHash = "sha256-CZf5M3lI7Lz9Pl8U/lNoQ6V6Jxbmkxau8L273XFFS2E=";
outputHashAlgo = "sha256";
};
# Point to our local deps repo
gradleInit = writeText "init.gradle" ''
gradle.projectsLoaded {
rootProject.allprojects {
buildscript {
repositories {
clear()
maven { url '${deps}/'; metadataSources {mavenPom(); artifact()} }
}
}
repositories {
clear()
maven { url '${deps}/'; metadataSources {mavenPom(); artifact()} }
}
}
}
settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
maven { url '${deps}/'; metadataSources {mavenPom(); artifact()} }
}
}
}
'';
buildPhase = ''
gradle jar -Dorg.gradle.java.home=${jdk} --offline --no-daemon --info --init-script $gradleInit
'';
installPhase = ''
runHook preInstall
install -Dm444 build/libs/freenet.jar $out/share/freenet/freenet.jar
ln -s ${freenet_ext} $out/share/freenet/freenet-ext.jar
mkdir -p $out/bin
install -Dm555 $src $out/bin/freenet
ln -s ${freenet-jars}/share $out/share
install -Dm555 ${wrapper} $out/bin/freenet
substituteInPlace $out/bin/freenet \
--subst-var-by outFreenet $out
ln -s ${deps} $out/deps
runHook postInstall
'';
passthru.tests = { inherit (nixosTests) freenet; };
meta = {
description = "Decentralised and censorship-resistant network";
homepage = "https://freenetproject.org/";

View file

@ -1,7 +1,8 @@
#! @bash@/bin/bash
set -eo pipefail
PATH=@coreutils@/bin:$PATH
export CLASSPATH=@freenet@/share/freenet/bcprov.jar:@freenet@/share/freenet/freenet-ext.jar:@freenet@/share/freenet/jna_platform.jar:@freenet@/share/freenet/jna.jar:@freenet@/share/freenet/freenet.jar
export CLASSPATH=$(find @outFreenet@/deps/ -name "*.jar"|grep -v bcprov-jdk15on-1.48.jar|tr $'\n' :)
CLASSPATH=$CLASSPATH:@outFreenet@/share/freenet/freenet-ext.jar:@outFreenet@/share/freenet/freenet.jar
export FREENET_HOME="$HOME/.local/share/freenet"
if [ -n "$XDG_DATA_HOME" ] ; then