Unverified Commit 284add3b authored by Justin Bedő's avatar Justin Bedő Committed by GitHub
Browse files

rPackages.RBioFormats: fix build and revdeps properly (#472944)

parents 78ee285a 6772a554
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -8,11 +8,11 @@

stdenv.mkDerivation rec {
  pname = "bftools";
  version = "6.3.0";
  version = "7.3.0";

  src = fetchzip {
    url = "http://downloads.openmicroscopy.org/bio-formats/${version}/artifacts/bftools.zip";
    sha256 = "02nvvmpfglpah1ihd08aw65g1794w588c988cdar1hfl4s80qwhb";
    hash = "sha256-EQ7P07d53e6Q/9Wt2Pa1h0TfuYblOZeByGW30oE3i6M=";
  };

  installPhase = ''
@@ -39,6 +39,7 @@ stdenv.mkDerivation rec {

  meta = {
    description = "Bundle of scripts for using Bio-Formats on the command line with bioformats_package.jar already included";
    mainProgram = "showinf";
    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
    license = lib.licenses.gpl2;
    platforms = lib.platforms.all;
+28 −1
Original line number Diff line number Diff line
@@ -1758,7 +1758,6 @@ let
    "Rmpi" # tries to run MPI processes
    "ReactomeContentService4R" # tries to connect to Reactome
    "PhIPData" # tries to download something from a DB
    "RBioFormats" # tries to download jar during load test
    "pbdMPI" # tries to run MPI processes
    "CTdata" # tries to connect to ExperimentHub
    "rfaRm" # tries to connect to Ebi
@@ -2030,6 +2029,34 @@ let
      '';
    });

    RBioFormats = old.RBioFormats.overrideAttrs (attrs: {
      # 1. Never download the jar file
      # 2. Use jar from pkgs.bftools instead
      # 3. Break the build if versions don't match
      propagatedBuildInputs = (attrs.propagatedBuildInputs or [ ]) ++ [ pkgs.bftools ];

      postPatch = ''
        substituteInPlace "R/zzz.R" \
          --replace-fail '!file.exists(bf_jar)' 'FALSE' \
          --replace-fail \
          '.jpackage(pkg, lib.loc = lib, morePaths = c(jars, bf_jar))' \
          '.jpackage(pkg, lib.loc = lib, morePaths = union(jars, "${lib.getBin pkgs.bftools}/share/java/bioformats_package.jar"))' \
          --replace-fail 'bf_jar <-' 'stopifnot(bf_ver == "${pkgs.bftools.version}");bf_jar <-'
      '';

      # Ensure that bftools version matches that in the package DESCRIPTION
      preInstall = ''
        rbf_version="$(sed  -n 's/^BioFormats: //p' DESCRIPTION)"
        bf_version="${pkgs.bftools.version}"
        if [ "$rbf_version" != "$bf_version" ]; then
           echo "BioFormats version mismatch detected!"
           echo "RBioformats needs: $rbf_version"
           echo "bftools provides: $bf_version"
           exit 1
        fi
      '';
    });

    rbm25 = old.rbm25.overrideAttrs (attrs: {
      postPatch = "patchShebangs configure";
    });