blob: 408a265a5e0ab28e306ebc5ae43b5d8a5a788783 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
{
lib,
buildPythonPackage,
callPackage,
fetchFromGitHub,
runCommandLocal,
# Build inputs
gfal2-python,
# For tests
xrootd, # pkgs.xrootd
}:
(buildPythonPackage rec {
pname = "gfal2-util";
version = "1.9.1";
format = "setuptools";
src = fetchFromGitHub {
owner = "cern-fts";
repo = "gfal2-util";
rev = "v${version}";
hash = "sha256-KKtbxr64FsMUIGXPk3yz66dbQVNCWoGbq3/+q47tS6Q=";
};
# Replace the ad-hoc python executable finding
# and change the shebangs from `#!/bin/sh` to `#!/usr/bin/env python`
# for fixup phase to work correctly.
postPatch = ''
for script in src/gfal-*; do
patch "$script" ${./gfal-util-script.patch}
done
'';
propagatedBuildInputs = [ gfal2-python ];
pythonImportsCheck = [ "gfal2_util" ];
meta = {
description = "CLI for gfal2";
homepage = "https://github.com/cern-fts/gfal2-utils";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ ShamrockLee ];
};
}).overrideAttrs
(
finalAttrs: previousAttrs:
lib.recursiveUpdate previousAttrs {
passthru = {
inherit (gfal2-python) gfal2;
fetchGfal2 = lib.makeOverridable (
callPackage ./fetchgfal2.nix { gfal2-util = finalAttrs.finalPackage; }
);
# With these functionality tests, it should be safe to merge version bumps once all the tests are passed.
tests =
let
# Use the the bin output hash of gfal2-util as version to ensure that
# the test gets rebuild everytime gfal2-util gets rebuild
versionFODTests =
finalAttrs.version + "-" + lib.substring (lib.stringLength builtins.storeDir + 1) 32 "${self}";
self = finalAttrs.finalPackage;
in
lib.optionalAttrs gfal2-python.gfal2.enablePluginStatus.xrootd (
let
# Test against a real-world dataset from CERN Open Data
# borrowed from `xrootd.tests`.
urlTestFile = xrootd.tests.test-xrdcp.url;
hashTestFile = xrootd.tests.test-xrdcp.outputHash;
urlTestDir = dirOf urlTestFile;
in
{
test-copy-file-xrootd = finalAttrs.passthru.fetchGfal2 {
url = urlTestFile;
hash = hashTestFile;
extraGfalCopyFlags = [ "--verbose" ];
pname = "gfal2-util-test-copy-file-xrootd";
version = versionFODTests;
allowSubstitutes = false;
};
test-copy-dir-xrootd = finalAttrs.passthru.fetchGfal2 {
url = urlTestDir;
hash = "sha256-vOahIhvx1oE9sfkqANMGUvGeLHS737wyfYWo4rkvrxw=";
recursive = true;
extraGfalCopyFlags = [ "--verbose" ];
pname = "gfal2-util-test-copy-dir-xrootd";
version = versionFODTests;
allowSubstitutes = false;
};
test-ls-dir-xrootd =
(runCommandLocal "test-gfal2-util-ls-dir-xrootd" { } ''
set -eu -o pipefail
gfal-ls "$url" | grep "$baseNameExpected" | tee "$out"
'').overrideAttrs
(
finalAttrs: previousAttrs: {
pname = previousAttrs.name;
version = versionFODTests;
name = "${finalAttrs.pname}-${finalAttrs.version}";
nativeBuildInputs = [ self ];
url = urlTestDir;
baseNameExpected = baseNameOf urlTestFile;
outputHashMode = "flat";
outputHashAlgo = "sha256";
outputHash = builtins.hashString finalAttrs.outputHashAlgo (finalAttrs.baseNameExpected + "\n");
}
);
}
);
};
}
)
|