summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e04a21fe3f14098593419878f8d79ff43cd63f1c (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Maintainer: Konstantin Gizdov < arch at kge dot pw >
# Contributor: Jan Kašpar < jan.kaspar at gmail dot com >
# Contributor: Alex Pearce < alex at alexpearce dot me >
pkgbase=xrootd
pkgname=('xrootd' 'python-xrootd' 'python-pyxrootd' 'python2-xrootd' 'python2-pyxrootd')
pkgdesc="Software framework for fast, low latency, scalable and fault tolerant data access."
pkgver=4.8.5
pkgrel=4
arch=('x86_64')
url="http://xrootd.org"
license=('LGPL3')
makedepends=('ceph' 'cmake' 'python')
checkdepends=('cppunit')
source=("${url}/download/v${pkgver}/xrootd-${pkgver}.tar.gz")
sha256sums=('42e4d2cc6f8b442135f09bcc12c7be38b1a0c623a005cb5e69ff3d27997bdf73')

prepare() {
    cd "${srcdir}/${pkgbase}-${pkgver}"

    mkdir -p "${srcdir}/build"
    cd "${srcdir}/build"

    # LDFLAGS="${LDFLAGS} -pthread -Wl,--no-undefined" \  # fails to compile tests
    CFLAGS="${CFLAGS}" \
    CXXFLAGS="${CXXFLAGS}" \
    LDFLAGS="${LDFLAGS}" \
    cmake -DCMAKE_BUILD_TYPE:STRING=Release \
          -DCMAKE_INSTALL_LIBDIR:PATH=lib \
          -DCMAKE_INSTALL_PREFIX:PATH=/usr \
          -DBUILD_TESTS=1 \
          -DCPPUNIT_FOUND=1 \
          -DCPPUNIT_INCLUDE_DIRS=/usr/include \
          -DCPPUNIT_LIBRARIES=/usr/lib/libcppunit.so \
          -DXRD_PYTHON_REQ_VERSION=$( python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))' ) \
          "${srcdir}/${pkgbase}-${pkgver}"

    cd "${srcdir}"
    mv "${srcdir}/build" "${srcdir}/build-py3"
    mkdir -p "${srcdir}/build"
    cd "${srcdir}/build"
    # LDFLAGS="${LDFLAGS} -pthread -Wl,--no-undefined" \  # fails to compile tests
    CFLAGS="${CFLAGS}" \
    CXXFLAGS="${CXXFLAGS}" \
    LDFLAGS="${LDFLAGS}" \
    cmake -DCMAKE_BUILD_TYPE:STRING=Release \
          -DCMAKE_INSTALL_LIBDIR:PATH=lib \
          -DCMAKE_INSTALL_PREFIX:PATH=/usr \
          -DBUILD_TESTS=1 \
          -DCPPUNIT_FOUND=1 \
          -DCPPUNIT_INCLUDE_DIRS=/usr/include \
          -DCPPUNIT_LIBRARIES=/usr/lib/libcppunit.so \
          -DXRD_PYTHON_REQ_VERSION=$( python2 -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))' ) \
          "${srcdir}/${pkgbase}-${pkgver}"
    mv "${srcdir}/build/bindings/python"  "${srcdir}/build-py3/bindings/python2"
    cd "${srcdir}"
    rm -rf "${srcdir}/build"
    mv "${srcdir}/build-py3" "${srcdir}/build"
}

build() {
    cd "${srcdir}/build"
    # Python2 bindings first
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python3"
    mv "${srcdir}/build/bindings/python2" "${srcdir}/build/bindings/python"
    make

    # Python bindings second
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python2"
    mv "${srcdir}/build/bindings/python3" "${srcdir}/build/bindings/python"
    make -f "bindings/python/Makefile"
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python3"
}

check() {
    cd "${srcdir}/build/tests"

    ./common/text-runner ./XrdCephTests/libXrdCephTests.so "All Tests"

    ##
    # This requires a running XRootD server with multiIP DNS forwarder and local disk servers
    # only run this if you have configured the env correctly,
    # examples in https://github.com/xrootd/xrootd-test-suite
    # sample environment can be configured like so:
    # export XRDTEST_MAINSERVERURL=metaman.xrd.test
    # or export XRDTEST_MAINSERVERURL=http://xrootd.cern.ch/
    # export XRDTEST_DISKSERVERURL=srv1.xrd.test
    # or export XRDTEST_DISKSERVERURL=http://xrootd.cern.ch/
    # export XRDTEST_DATAPATH=/tests/test-files/
    # export XRDTEST_LOCALFILE=/data/a048e67f-4397-4bb8-85eb-8d7e40d90763.dat
    # or export XRDTEST_LOCALFILE=/tmp/accwe.root
    # export XRDTEST_REMOTEFILE=${XRDTEST_MAINSERVERURL}${XRDTEST_DATAPATH}/a048e67f-4397-4bb8-85eb-8d7e40d90763.dat
    # or export XRDTEST_MULTIIPSERVERURL=multiip.xrd.test
    # ./common/text-runner ./XrdClTests/libXrdClTests.so "All Tests"
}

package_xrootd() {
    pkgdesc="Software framework for fast, low latency, scalable and fault tolerant data access."
    depends=('ceph' 'python' 'cppunit')
    cd "${srcdir}/build"

    # Python2 first
    mv "${srcdir}/build/bindings/python3" "${srcdir}/build/bindings/python"
    make DESTDIR="${pkgdir}" install
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python3"

    rm -rf "${pkgdir}/usr/lib"/python*
}

package_python-xrootd() {
    pkgdesc="Python Client API for XRootD"
    depends=('xrootd')
    cd "${srcdir}/build"
    # Python3
    mv "${srcdir}/build/bindings/python3" "${srcdir}/build/bindings/python"
    make -f "bindings/python/Makefile" DESTDIR="${pkgdir}" install
    rm -rf "${pkgdir}/usr/bin"
    rm -rf "${pkgdir}/usr/include"
    rm -rf "${pkgdir}/usr/share"
    rm -rf "${pkgdir}/usr/lib/"lib*.so*
    rm -rf "${pkgdir}/usr/lib/"python*/site-packages/pyxrootd*
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python3"
}

package_python-pyxrootd() {
    pkgdesc="Python bindings for XRootD"
    depends=('python-xrootd')
    cd "${srcdir}/build"
    # Python3
    mv "${srcdir}/build/bindings/python3" "${srcdir}/build/bindings/python"
    make -f "bindings/python/Makefile" DESTDIR="${pkgdir}" install
    rm -rf "${pkgdir}/usr/bin"
    rm -rf "${pkgdir}/usr/include"
    rm -rf "${pkgdir}/usr/share"
    rm -rf "${pkgdir}/usr/lib/"lib*.so*
    rm -rf "${pkgdir}/usr/lib/"python*/site-packages/XRootD
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python3"
}

package_python2-xrootd() {
    pkgdesc="Python2 Client API for XRootD"
    depends=('xrootd')
    cd "${srcdir}/build"
    # Python2
    mv "${srcdir}/build/bindings/python2" "${srcdir}/build/bindings/python"
    make -f "bindings/python/Makefile" DESTDIR="${pkgdir}" install
    rm -rf "${pkgdir}/usr/bin"
    rm -rf "${pkgdir}/usr/include"
    rm -rf "${pkgdir}/usr/share"
    rm -rf "${pkgdir}/usr/lib/"lib*.so*
    rm -rf "${pkgdir}/usr/lib/"python*/site-packages/pyxrootd*
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python2"
}

package_python2-pyxrootd() {
    pkgdesc="Python2 bindings for XRootD"
    depends=('python2-xrootd')
    cd "${srcdir}/build"
    # Python3
    mv "${srcdir}/build/bindings/python2" "${srcdir}/build/bindings/python"
    make -f "bindings/python/Makefile" DESTDIR="${pkgdir}" install
    rm -rf "${pkgdir}/usr/bin"
    rm -rf "${pkgdir}/usr/include"
    rm -rf "${pkgdir}/usr/share"
    rm -rf "${pkgdir}/usr/lib/"lib*.so*
    rm -rf "${pkgdir}/usr/lib/"python*/site-packages/XRootD
    mv "${srcdir}/build/bindings/python" "${srcdir}/build/bindings/python2"
}