11 (buildPythonPackage rec {
14 src = fetchFromGitHub {
18 hash = "sha256-3JbJgKD17aYkrB/aaww7IQU8fLFrTCh868KWlLPxmlk=";
21 # Replace the ad-hoc python executable finding
22 # and change the shebangs from `#!/bin/sh` to `#!/usr/bin/env python`
23 # for fixup phase to work correctly.
25 for script in src/gfal-*; do
26 patch "$script" ${./gfal-util-script.patch}
30 propagatedBuildInputs = [
34 pythonImportsCheck = [
39 description = "CLI for gfal2";
40 homepage = "https://github.com/cern-fts/gfal2-utils";
41 license = licenses.asl20;
42 maintainers = with maintainers; [ ShamrockLee ];
44 }).overrideAttrs (finalAttrs: previousAttrs: lib.recursiveUpdate previousAttrs {
46 inherit (gfal2-python) gfal2;
48 fetchGfal2 = lib.makeOverridable (callPackage ./fetchgfal2.nix { gfal2-util = finalAttrs.finalPackage; });
50 # With these functionality tests, it should be safe to merge version bumps once all the tests are passed.
53 # Use the the bin output hash of gfal2-util as version to ensure that
54 # the test gets rebuild everytime gfal2-util gets rebuild
55 versionFODTests = finalAttrs.version + "-" + lib.substring (lib.stringLength builtins.storeDir + 1) 32 "${self}";
56 self = finalAttrs.finalPackage;
58 lib.optionalAttrs gfal2-python.gfal2.enablePluginStatus.xrootd (
60 # Test against a real-world dataset from CERN Open Data
61 # borrowed from `xrootd.tests`.
62 urlTestFile = xrootd.tests.test-xrdcp.url;
63 hashTestFile = xrootd.tests.test-xrdcp.outputHash;
64 urlTestDir = dirOf urlTestFile;
67 test-copy-file-xrootd = finalAttrs.passthru.fetchGfal2 {
70 extraGfalCopyFlags = [ "--verbose" ];
71 pname = "gfal2-util-test-copy-file-xrootd";
72 version = versionFODTests;
73 allowSubstitutes = false;
76 test-copy-dir-xrootd = finalAttrs.passthru.fetchGfal2 {
78 hash = "sha256-vOahIhvx1oE9sfkqANMGUvGeLHS737wyfYWo4rkvrxw=";
80 extraGfalCopyFlags = [ "--verbose" ];
81 pname = "gfal2-util-test-copy-dir-xrootd";
82 version = versionFODTests;
83 allowSubstitutes = false;
86 test-ls-dir-xrootd = (runCommandLocal "test-gfal2-util-ls-dir-xrootd" { } ''
88 gfal-ls "$url" | grep "$baseNameExpected" | tee "$out"
89 '').overrideAttrs (finalAttrs: previousAttrs: {
90 pname = previousAttrs.name;
91 version = versionFODTests;
92 name = "${finalAttrs.pname}-${finalAttrs.version}";
93 nativeBuildInputs = [ self ];
95 baseNameExpected = baseNameOf urlTestFile;
96 outputHashMode = "flat";
97 outputHashAlgo = "sha256";
98 outputHash = builtins.hashString finalAttrs.outputHashAlgo (finalAttrs.baseNameExpected + "\n");