From c47a755ad6bb2f01fa732c7d3130cdcef3c3642a Mon Sep 17 00:00:00 2001
From: Michael Davis <michael.davis@cern.ch>
Date: Tue, 25 Apr 2017 02:19:16 +0200
Subject: [PATCH] Adds scripts to build RPMs for XRootD with SSI support

xrootd.spec.in in the XRootD SSI branch does not package the SSI
libraries/headers. I'm putting a patched version here temporarily until
Michal or Andy can fix it in the main XRootD repository.
---
 xroot_rpms/Dockerfile     |  82 ++++
 xroot_rpms/README.md      |  12 +
 xroot_rpms/build-rpms     |   9 +
 xroot_rpms/xrootd.spec.in | 922 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 1025 insertions(+)
 create mode 100644 xroot_rpms/Dockerfile
 create mode 100644 xroot_rpms/README.md
 create mode 100755 xroot_rpms/build-rpms
 create mode 100644 xroot_rpms/xrootd.spec.in

diff --git a/xroot_rpms/Dockerfile b/xroot_rpms/Dockerfile
new file mode 100644
index 0000000000..0423c1a6aa
--- /dev/null
+++ b/xroot_rpms/Dockerfile
@@ -0,0 +1,82 @@
+# ******************************************************************************
+#
+# The CERN Tape Archive (CTA) project
+# Copyright (C) 2017  CERN
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# ****************************************************************************/
+
+# Docker image to build XRootD RPMs
+
+# FROM must be the first command in Dockerfile
+
+FROM gitlab-registry.cern.ch/linuxsupport/cc7-base
+
+# Set up default environment
+
+RUN yum clean all && \
+    yum update -y && \
+    yum install -y \
+      ccache \
+      cgdb \
+      cmake \
+      gcc-c++ \
+      gdb \
+      git \
+      ltrace \
+      make \
+      psmisc \
+      rpm-build \
+      strace \
+      sudo \
+      vim \
+      yum-utils
+
+# Get XRootD
+
+RUN git clone https://github.com/xrootd/xrootd.git
+
+# Check out SSIV2
+
+RUN cd xrootd && git checkout xrdssiV2
+
+# Copy in patched xrootd.spec.in
+
+ADD xrootd.spec.in /xrootd/packaging/rhel/xrootd.spec.in
+RUN cp xrootd/packaging/rhel/xrootd.spec.in xrootd.spec
+
+# Install all necessary build dependencies
+
+RUN yum-builddep -y xrootd.spec
+
+# Create XRootD source RPM
+
+RUN cd xrootd/packaging && ./makesrpm.sh
+
+# Create final RPMs from the source RPM
+
+RUN rpmbuild --define "_topdir ${PWD}/rpmbuild_xrootd" --rebuild xrootd/packaging/*.src.rpm
+
+# Notes on XRootD version
+#
+# Newer version of CTA requires xroot >= 4.4.1-1
+#
+# epel version is more recent but eos-citrine-depend repo has a higher priority (4) than epel,
+#   so: need to set epel priority to 4:
+#
+#       RUN yum-config-manager --enable epel --setopt="epel.priority=4" 
+#
+#   or: if taking the older version from eos, eos-citrine-depend must be enabled so that the older version of xroot is
+#       installed by cta-cli and is not conflicting later when installing eos...
diff --git a/xroot_rpms/README.md b/xroot_rpms/README.md
new file mode 100644
index 0000000000..f6b1214969
--- /dev/null
+++ b/xroot_rpms/README.md
@@ -0,0 +1,12 @@
+# Build XRootD RPMs
+
+The version of xrootd.spec.in in the xrootd xrdssiV2 branch does not package the SSI library and header files.
+
+This is the temporary home for the patched version of xrootd.spec.in, until Michal or Andy can integrate it
+properly into the xrootd git respository.
+
+To build the RPMs:
+```
+./build-rpms
+```
+
diff --git a/xroot_rpms/build-rpms b/xroot_rpms/build-rpms
new file mode 100755
index 0000000000..7a61ad996b
--- /dev/null
+++ b/xroot_rpms/build-rpms
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+sudo docker build . -f ./Dockerfile -t buildxroot
+
+id=$(sudo docker create buildxroot bash)
+
+sudo docker cp ${id}:rpmbuild_xrootd/RPMS/x86_64/ .
+
+sudo docker rm -v ${id}
diff --git a/xroot_rpms/xrootd.spec.in b/xroot_rpms/xrootd.spec.in
new file mode 100644
index 0000000000..e8cf87dd1c
--- /dev/null
+++ b/xroot_rpms/xrootd.spec.in
@@ -0,0 +1,922 @@
+#-------------------------------------------------------------------------------
+# Helper macros
+#-------------------------------------------------------------------------------
+%if %{?rhel:1}%{!?rhel:0}
+    %if %{rhel} >= 7
+        %define use_systemd 1
+    %else
+        %define use_systemd 0
+    %endif
+%else
+    %if %{?fedora}%{!?fedora:0} >= 19
+        %define use_systemd 1
+    %else
+        %define use_systemd 0
+    %endif
+%endif
+
+%if %{?fedora}%{!?fedora:0} >= 22
+    %define use_libc_semaphore 1
+%else
+    %define use_libc_semaphore 0
+%endif
+
+%if %{?_with_ceph11:1}%{!?_with_ceph11:0}
+    %define _with_ceph 1
+%endif
+
+# Remove default rpm python bytecompiling scripts
+%global __os_install_post \
+    %(echo '%{__os_install_post}' | \
+      sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g \
+              s!/usr/lib[^[:space:]]*/brp-python-hardlink[[:space:]].*$!!g')
+
+#-------------------------------------------------------------------------------
+# Package definitions
+#-------------------------------------------------------------------------------
+Name:      xrootd
+Epoch:     1
+Version:   __VERSION__
+Release:   __RELEASE__%{?dist}%{?_with_cpp11:.cpp11}%{?_with_clang:.clang}
+Summary:   Extended ROOT file server
+Group:     System Environment/Daemons
+License:   LGPLv3+
+URL:       http://xrootd.org/
+
+# git clone http://xrootd.org/repo/xrootd.git xrootd
+# cd xrootd
+# git-archive master | gzip -9 > ~/rpmbuild/SOURCES/xrootd.tgz
+Source0:   xrootd.tar.gz
+
+%if %{?_with_compat:1}%{!?_with_compat:0}
+Source1:   xrootd-3.3.6.tar.gz
+%endif
+
+BuildRoot: %{_tmppath}/%{name}-root
+
+BuildRequires: cmake
+BuildRequires: krb5-devel
+BuildRequires: readline-devel
+BuildRequires: fuse-devel
+BuildRequires: libxml2-devel
+BuildRequires: krb5-devel
+BuildRequires: zlib-devel
+BuildRequires: ncurses-devel
+BuildRequires: python-devel
+BuildRequires: openssl-devel
+
+BuildRequires: selinux-policy-devel
+
+%if %{?_with_tests:1}%{!?_with_tests:0}
+BuildRequires: cppunit-devel
+%endif
+
+%if %{?_with_ceph:1}%{!?_with_ceph:0}
+    %if %{?_with_ceph11:1}%{!?_with_ceph11:0}
+BuildRequires: librados-devel >= 11.0
+BuildRequires: libradosstriper-devel >= 11.0
+    %else
+BuildRequires: ceph-devel >= 0.87
+    %endif
+%endif
+
+BuildRequires:	doxygen
+BuildRequires:	graphviz
+%if %{?rhel}%{!?rhel:0} == 5
+BuildRequires:	graphviz-gd
+%endif
+
+%if %{?_with_clang:1}%{!?_with_clang:0}
+BuildRequires: clang
+%endif
+
+Requires:	%{name}-server%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	%{name}-selinux = %{epoch}:%{version}-%{release}
+
+%if %{use_systemd}
+BuildRequires:    systemd
+BuildRequires:    systemd-devel
+Requires(pre):		systemd
+Requires(post):		systemd
+Requires(preun):	systemd
+Requires(postun):	systemd
+%else
+Requires(pre):		shadow-utils
+Requires(pre):		chkconfig
+Requires(post):		chkconfig
+Requires(preun):	chkconfig
+Requires(preun):	initscripts
+Requires(postun):	initscripts
+%endif
+
+%description
+The Extended root file server consists of a file server called xrootd
+and a cluster management server called cmsd.
+
+The xrootd server was developed for the root analysis framework to
+serve root files. However, the server is agnostic to file types and
+provides POSIX-like access to any type of file.
+
+The cmsd server is the next generation version of the olbd server,
+originally developed to cluster and load balance Objectivity/DB AMS
+database servers. It provides enhanced capability along with lower
+latency and increased throughput.
+
+#-------------------------------------------------------------------------------
+# libs
+#-------------------------------------------------------------------------------
+%package libs
+Summary:	Libraries used by xrootd servers and clients
+Group:		System Environment/Libraries
+
+%description libs
+This package contains libraries used by the xrootd servers and clients.
+
+#-------------------------------------------------------------------------------
+# devel
+#------------------------------------------------------------------------------
+%package devel
+Summary:	Development files for xrootd
+Group:		Development/Libraries
+Requires:	%{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description devel
+This package contains header files and development libraries for xrootd
+development.
+
+#-------------------------------------------------------------------------------
+# client-libs
+#-------------------------------------------------------------------------------
+%package client-libs
+Summary:	Libraries used by xrootd clients
+Group:		System Environment/Libraries
+Requires:	%{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
+%if %{use_libc_semaphore}
+Requires:       glibc >= 2.21
+%endif
+
+%description client-libs
+This package contains libraries used by xrootd clients.
+
+#-------------------------------------------------------------------------------
+# client-devel
+#-------------------------------------------------------------------------------
+%package client-devel
+Summary:	Development files for xrootd clients
+Group:		Development/Libraries
+Requires:	%{name}-devel%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	%{name}-client-libs%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description client-devel
+This package contains header files and development libraries for xrootd
+client development.
+
+#-------------------------------------------------------------------------------
+# server-libs
+#-------------------------------------------------------------------------------
+%package server-libs
+Summary:	Libraries used by xrootd servers
+Group:		System Environment/Libraries
+Requires:	%{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	%{name}-client-libs%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description server-libs
+This package contains libraries used by xrootd servers.
+
+#-------------------------------------------------------------------------------
+# server-devel
+#-------------------------------------------------------------------------------
+%package server-devel
+Summary:	Development files for xrootd servers
+Group:		Development/Libraries
+Requires:	%{name}-devel%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	%{name}-client-devel%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	%{name}-server-libs%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description server-devel
+This package contains header files and development libraries for xrootd
+server development.
+
+#-------------------------------------------------------------------------------
+# private devel
+#-------------------------------------------------------------------------------
+%package private-devel
+Summary:	Legacy xrootd headers
+Group:		Development/Libraries
+Requires:	%{name}-libs = %{epoch}:%{version}-%{release}
+%if %{?fedora}%{!?fedora:0} >= 10 || %{?rhel}%{!?rhel:0} >= 6
+BuildArch:	noarch
+%endif
+
+%description private-devel
+This package contains some private xrootd headers. The use of these
+headers is strongly discouraged. Backward compatibility between
+versions is not guaranteed for these headers.
+
+#-------------------------------------------------------------------------------
+# client
+#-------------------------------------------------------------------------------
+%package client
+Summary:	Xrootd command line client tools
+Group:		Applications/Internet
+Requires:	%{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	%{name}-client-libs%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description client
+This package contains the command line tools used to communicate with
+xrootd servers.
+
+#-------------------------------------------------------------------------------
+# server
+#-------------------------------------------------------------------------------
+%package server
+Summary:   Extended ROOT file server
+Group:     System Environment/Daemons
+Requires:  %{name}-libs        = %{epoch}:%{version}-%{release}
+Requires:  %{name}-client-libs = %{epoch}:%{version}-%{release}
+Requires:  %{name}-server-libs = %{epoch}:%{version}-%{release}
+Requires:  expect
+
+%description server
+XRootD server binaries
+
+#-------------------------------------------------------------------------------
+# fuse
+#-------------------------------------------------------------------------------
+%package fuse
+Summary:	Xrootd FUSE tool
+Group:		Applications/Internet
+Requires:	%{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	%{name}-client-libs%{?_isa} = %{epoch}:%{version}-%{release}
+Requires:	fuse
+
+%description fuse
+This package contains the FUSE (file system in user space) xrootd mount
+tool.
+
+#-------------------------------------------------------------------------------
+# python
+#-------------------------------------------------------------------------------
+%package python
+Summary:	Python bindings for XRootD
+Group:		Development/Libraries
+Requires:	%{name}-client-libs%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description python
+Python bindings for XRootD
+
+#-------------------------------------------------------------------------------
+# doc
+#-------------------------------------------------------------------------------
+%package doc
+Summary:	Developer documentation for the xrootd libraries
+Group:		Documentation
+%if %{?fedora}%{!?fedora:0} >= 10 || %{?rhel}%{!?rhel:0} >= 6
+BuildArch:	noarch
+%endif
+
+%description doc
+This package contains the API documentation of the xrootd libraries.
+
+#-------------------------------------------------------------------------------
+# selinux
+#-------------------------------------------------------------------------------
+%package selinux
+Summary:	 SELinux policy extensions for xrootd.
+Group:		 System Environment/Base
+%if %{?fedora}%{!?fedora:0} >= 10 || %{?rhel}%{!?rhel:0} >= 6
+BuildArch: noarch
+%endif
+Requires(post):   policycoreutils
+Requires(postun): policycoreutils
+Requires:         selinux-policy
+
+%description selinux
+SELinux policy extensions for running xrootd while in enforcing mode.
+
+#-------------------------------------------------------------------------------
+# ssi-libs
+#-------------------------------------------------------------------------------
+%package ssi-libs
+Summary:    Libraries used by the xrootd SSI plug-in
+Group:      System Environment/Libraries
+
+%description ssi-libs
+The Scalable Service Interface (SSI) plug-in implements a client-server
+request-response framework. This package contains the SSI libraries.
+
+#-------------------------------------------------------------------------------
+# ssi-devel
+#-------------------------------------------------------------------------------
+%package ssi-devel
+Summary:    Development files for the xrootd SSI plug-in
+Group:      Development/Libraries
+Requires:   %{name}-ssi-libs = %{epoch}:%{version}-%{release}
+
+%description ssi-devel
+The Scalable Service Interface (SSI) plug-in implements a client-server
+request-response framework. This package contains the SSI header files and
+development libraries.
+
+#-------------------------------------------------------------------------------
+# ceph
+#-------------------------------------------------------------------------------
+%if %{?_with_ceph:1}%{!?_with_ceph:0}
+%package ceph
+Summary: Ceph back-end plug-in for XRootD
+Group:   Development/Tools
+Requires: %{name}-server = %{epoch}:%{version}-%{release}
+%description ceph
+Ceph back-end plug-in for XRootD.
+%endif
+
+#-------------------------------------------------------------------------------
+# tests
+#-------------------------------------------------------------------------------
+%if %{?_with_tests:1}%{!?_with_tests:0}
+%package tests
+Summary: CPPUnit tests
+Group:   Development/Tools
+Requires: %{name}-client = %{epoch}:%{version}-%{release}
+%description tests
+This package contains a set of CPPUnit tests for xrootd.
+%endif
+
+%if %{?_with_compat:1}%{!?_with_compat:0}
+#-------------------------------------------------------------------------------
+# client-compat
+#-------------------------------------------------------------------------------
+%package client-compat
+Summary:	XRootD 3 compatibility client libraries
+Group:		System Environment/Libraries
+
+%description client-compat
+This package contains compatibility libraries for xrootd 3 clients.
+
+#-------------------------------------------------------------------------------
+# server-compat
+#-------------------------------------------------------------------------------
+%package server-compat
+Summary:	XRootD 3 compatibility server binaries
+Group:		System Environment/Daemons
+Requires:	%{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
+
+%description server-compat
+This package contains compatibility binaries for xrootd 3 servers.
+
+%endif
+
+#-------------------------------------------------------------------------------
+# Build instructions
+#-------------------------------------------------------------------------------
+%prep
+%setup -c -n xrootd
+
+%if %{?_with_compat:1}%{!?_with_compat:0}
+%setup -T -D -n %{name} -a 1
+%endif
+
+%build
+cd xrootd
+
+%if %{?_with_cpp11:1}%{!?_with_cpp11:0}
+export CXXFLAGS=-std=c++11
+%endif
+
+%if %{?_with_clang:1}%{!?_with_clang:0}
+export CC=clang
+export CXX=clang++
+%endif
+
+mkdir build
+pushd build
+%if %{?_with_tests:1}%{!?_with_tests:0}
+cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_TESTS=TRUE -DUSE_LIBC_SEMAPHORE=%{use_libc_semaphore} ../
+%else
+cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_LIBC_SEMAPHORE=%{use_libc_semaphore} ../
+%endif
+
+make -i VERBOSE=1 %{?_smp_mflags}
+popd
+
+pushd packaging/common
+make -f /usr/share/selinux/devel/Makefile
+popd
+
+doxygen Doxyfile
+
+%if %{?_with_compat:1}%{!?_with_compat:0}
+pushd ../xrootd-3.3.6
+mkdir build
+pushd build
+cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_PERL=FALSE ../
+make VERBOSE=1 %{?_smp_mflags}
+popd
+popd
+%endif
+
+#-------------------------------------------------------------------------------
+# Installation
+#-------------------------------------------------------------------------------
+%install
+rm -rf $RPM_BUILD_ROOT
+
+#-------------------------------------------------------------------------------
+# Install 3.3.6 compat
+#-------------------------------------------------------------------------------
+%if %{?_with_compat:1}%{!?_with_compat:0}
+pushd xrootd-3.3.6/build
+make install DESTDIR=$RPM_BUILD_ROOT
+rm -rf $RPM_BUILD_ROOT%{_includedir}
+rm -rf $RPM_BUILD_ROOT%{_datadir}
+rm -f $RPM_BUILD_ROOT%{_bindir}/{cconfig,cns_ssi,frm_admin,frm_xfragent,mpxstats}
+rm -f $RPM_BUILD_ROOT%{_bindir}/{wait41,xprep,xrd,xrdadler32,XrdCnsd,xrdcopy}
+rm -f $RPM_BUILD_ROOT%{_bindir}/{xrdcp,xrdcp-old,xrdfs,xrdgsiproxy,xrdpwdadmin}
+rm -f $RPM_BUILD_ROOT%{_bindir}/{xrdsssadmin,xrdstagetool,xrootdfs}
+rm -f $RPM_BUILD_ROOT%{_libdir}/libXrdAppUtils.so
+rm -f $RPM_BUILD_ROOT%{_libdir}/{libXrdClient.so,libXrdCl.so,libXrdCryptoLite.so}
+rm -f $RPM_BUILD_ROOT%{_libdir}/{libXrdCrypto.so,libXrdFfs.so,libXrdMain.so}
+rm -f $RPM_BUILD_ROOT%{_libdir}/{libXrdOfs.so,libXrdPosixPreload.so,libXrdPosix.so}
+rm -f $RPM_BUILD_ROOT%{_libdir}/{libXrdServer.so,libXrdUtils.so}
+
+for i in cmsd frm_purged frm_xfrd xrootd; do
+  mv $RPM_BUILD_ROOT%{_bindir}/$i $RPM_BUILD_ROOT%{_bindir}/${i}-3
+done
+popd
+%endif
+
+#-------------------------------------------------------------------------------
+# Install 4.x.y
+#-------------------------------------------------------------------------------
+pushd xrootd
+pushd  build
+make install DESTDIR=$RPM_BUILD_ROOT
+cat PYTHON_INSTALLED | sed -e "s|$RPM_BUILD_ROOT||g" > PYTHON_INSTALLED_FILES
+popd
+
+# configuration stuff
+rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/*
+
+# ceph posix unversioned so
+rm -f $RPM_BUILD_ROOT%{_libdir}/libXrdCephPosix.so
+
+# var paths
+mkdir -p $RPM_BUILD_ROOT%{_var}/log/xrootd
+mkdir -p $RPM_BUILD_ROOT%{_var}/run/xrootd
+mkdir -p $RPM_BUILD_ROOT%{_var}/spool/xrootd
+
+# init stuff
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xrootd
+
+%if %{use_systemd}
+
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
+install -m 644 packaging/common/xrootd@.service $RPM_BUILD_ROOT%{_unitdir}
+install -m 644 packaging/common/xrdhttp.socket   $RPM_BUILD_ROOT%{_unitdir}
+install -m 644 packaging/common/cmsd@.service $RPM_BUILD_ROOT%{_unitdir}
+install -m 644 packaging/common/frm_xfrd@.service $RPM_BUILD_ROOT%{_unitdir}
+install -m 644 packaging/common/frm_purged@.service $RPM_BUILD_ROOT%{_unitdir}
+
+# tmpfiles.d
+mkdir -p $RPM_BUILD_ROOT%{_tmpfilesdir}
+install -m 0644 packaging/rhel/xrootd.tmpfiles $RPM_BUILD_ROOT%{_tmpfilesdir}/%{name}.conf
+
+%else
+
+mkdir -p $RPM_BUILD_ROOT%{_initrddir}
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
+install -m 644 packaging/rhel/xrootd.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/xrootd
+
+install -m 755 packaging/rhel/cmsd.init $RPM_BUILD_ROOT%{_initrddir}/cmsd
+install -m 755 packaging/rhel/frm_purged.init $RPM_BUILD_ROOT%{_initrddir}/frm_purged
+install -m 755 packaging/rhel/frm_xfrd.init $RPM_BUILD_ROOT%{_initrddir}/frm_xfrd
+install -m 755 packaging/rhel/xrootd.init $RPM_BUILD_ROOT%{_initrddir}/xrootd
+install -m 755 packaging/rhel/xrootd.functions $RPM_BUILD_ROOT%{_initrddir}/xrootd.functions
+
+%endif
+
+# logrotate
+mkdir $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
+install -p -m 644 packaging/common/xrootd.logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/xrootd
+
+install -m 644 packaging/common/xrootd-clustered.cfg $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/xrootd-clustered.cfg
+install -m 644 packaging/common/xrootd-standalone.cfg $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/xrootd-standalone.cfg
+install -m 644 packaging/common/xrootd-filecache-clustered.cfg $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/xrootd-filecache-clustered.cfg
+install -m 644 packaging/common/xrootd-filecache-standalone.cfg $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/xrootd-filecache-standalone.cfg
+
+# client plug-in config
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/client.plugins.d
+install -m 644 packaging/common/client-plugin.conf.example $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/client.plugins.d/client-plugin.conf.example
+
+# client config
+install -m 644 packaging/common/client.conf $RPM_BUILD_ROOT%{_sysconfdir}/xrootd/client.conf
+
+# documentation
+mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}
+cp -pr doxydoc/html %{buildroot}%{_docdir}/%{name}-%{version}
+
+# selinux
+mkdir -p %{buildroot}%{_datadir}/selinux/packages/%{name}
+install -m 644 -p packaging/common/xrootd.pp \
+    %{buildroot}%{_datadir}/selinux/packages/%{name}/%{name}.pp
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+#-------------------------------------------------------------------------------
+# RPM scripts
+#-------------------------------------------------------------------------------
+%post   libs -p /sbin/ldconfig
+%postun libs -p /sbin/ldconfig
+
+%post   client-libs -p /sbin/ldconfig
+%postun client-libs -p /sbin/ldconfig
+
+%post   server-libs -p /sbin/ldconfig
+%postun server-libs -p /sbin/ldconfig
+
+%pre server
+
+getent group xrootd >/dev/null || groupadd -r xrootd
+getent passwd xrootd >/dev/null || \
+       useradd -r -g xrootd -c "XRootD runtime user" \
+       -s /sbin/nologin -d %{_localstatedir}/spool/xrootd xrootd
+exit 0
+
+%if %{use_systemd}
+
+%post server
+if [ $1 -eq 1 ] ; then
+    /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+
+%preun server
+if [ $1 -eq 0 ] ; then
+    for DAEMON in xrootd cmsd frm_purged frm xfrd; do
+        for INSTANCE in `/usr/bin/systemctl | grep $DAEMON@ | awk '{print $1;}'`; do
+            /usr/bin/systemctl --no-reload disable $INSTANCE > /dev/null 2>&1 || :
+            /usr/bin/systemctl stop $INSTANCE > /dev/null 2>&1 || :
+        done
+    done
+fi
+
+%postun server
+if [ $1 -ge 1 ] ; then
+    /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+    for DAEMON in xrootd cmsd frm_purged frm xfrd; do
+        for INSTANCE in `/usr/bin/systemctl | grep $DAEMON@ | awk '{print $1;}'`; do
+            /usr/bin/systemctl try-restart $INSTANCE >/dev/null 2>&1 || :
+        done
+    done
+fi
+
+%else
+
+%post server
+if [ $1 -eq 1 ]; then
+    /sbin/chkconfig --add xrootd
+    /sbin/chkconfig --add cmsd
+    /sbin/chkconfig --add frm_purged
+    /sbin/chkconfig --add frm_xfrd
+fi
+
+%preun server
+if [ $1 -eq 0 ]; then
+    /sbin/service xrootd stop >/dev/null 2>&1 || :
+    /sbin/service cmsd stop >/dev/null 2>&1 || :
+    /sbin/service frm_purged stop >/dev/null 2>&1 || :
+    /sbin/service frm_xfrd stop >/dev/null 2>&1 || :
+    /sbin/chkconfig --del xrootd
+    /sbin/chkconfig --del cmsd
+    /sbin/chkconfig --del frm_purged
+    /sbin/chkconfig --del frm_xfrd
+fi
+
+%postun server
+if [ $1 -ge 1 ]; then
+    /sbin/service xrootd condrestart >/dev/null 2>&1 || :
+    /sbin/service cmsd condrestart >/dev/null 2>&1 || :
+    /sbin/service frm_purged condrestart >/dev/null 2>&1 || :
+    /sbin/service frm_xfrd condrestart >/dev/null 2>&1 || :
+fi
+
+%endif
+
+#-------------------------------------------------------------------------------
+# Add a new user and group if necessary
+#-------------------------------------------------------------------------------
+%pre fuse
+getent group xrootd >/dev/null || groupadd -r xrootd
+getent passwd xrootd >/dev/null || \
+       useradd -r -g xrootd -c "XRootD runtime user" \
+       -s /sbin/nologin -d %{_localstatedir}/spool/xrootd xrootd
+exit 0
+
+#-------------------------------------------------------------------------------
+# Selinux
+#-------------------------------------------------------------------------------
+%post selinux
+/usr/sbin/semodule -i %{_datadir}/selinux/packages/%{name}/%{name}.pp >/dev/null 2>&1 || :
+
+%postun selinux
+if [ $1 -eq 0 ] ; then
+    /usr/sbin/semodule -r %{name} >/dev/null 2>&1 || :
+fi
+
+#-------------------------------------------------------------------------------
+# Files
+#-------------------------------------------------------------------------------
+%files
+# empty
+
+%files server
+%defattr(-,root,root,-)
+%{_bindir}/cconfig
+%{_bindir}/cmsd
+%{_bindir}/cns_ssi
+%{_bindir}/frm_admin
+%{_bindir}/frm_purged
+%{_bindir}/frm_xfragent
+%{_bindir}/frm_xfrd
+%{_bindir}/mpxstats
+%{_bindir}/wait41
+%{_bindir}/XrdCnsd
+%{_bindir}/xrdpwdadmin
+%{_bindir}/xrdsssadmin
+%{_bindir}/xrdmapc
+%{_bindir}/xrootd
+%{_bindir}/xrdpfc_print
+%{_bindir}/xrdacctest
+%{_mandir}/man8/cmsd.8*
+%{_mandir}/man8/cns_ssi.8*
+%{_mandir}/man8/frm_admin.8*
+%{_mandir}/man8/frm_purged.8*
+%{_mandir}/man8/frm_xfragent.8*
+%{_mandir}/man8/frm_xfrd.8*
+%{_mandir}/man8/mpxstats.8*
+%{_mandir}/man8/XrdCnsd.8*
+%{_mandir}/man8/xrdpwdadmin.8*
+%{_mandir}/man8/xrdsssadmin.8*
+%{_mandir}/man8/xrootd.8*
+%{_mandir}/man8/xrdpfc_print.8*
+%{_datadir}/xrootd
+%attr(-,xrootd,xrootd) %config(noreplace) %{_sysconfdir}/xrootd/xrootd-clustered.cfg
+%attr(-,xrootd,xrootd) %config(noreplace) %{_sysconfdir}/xrootd/xrootd-standalone.cfg
+%attr(-,xrootd,xrootd) %config(noreplace) %{_sysconfdir}/xrootd/xrootd-filecache-clustered.cfg
+%attr(-,xrootd,xrootd) %config(noreplace) %{_sysconfdir}/xrootd/xrootd-filecache-standalone.cfg
+%attr(-,xrootd,xrootd) %dir %{_var}/log/xrootd
+%attr(-,xrootd,xrootd) %dir %{_var}/run/xrootd
+%attr(-,xrootd,xrootd) %dir %{_var}/spool/xrootd
+%config(noreplace) %{_sysconfdir}/logrotate.d/xrootd
+
+%if %{use_systemd}
+%{_unitdir}/*
+%{_tmpfilesdir}/%{name}.conf
+%else
+%config(noreplace) %{_sysconfdir}/sysconfig/xrootd
+%{_initrddir}/*
+%endif
+
+%files libs
+%defattr(-,root,root,-)
+%{_libdir}/libXrdAppUtils.so.1*
+%{_libdir}/libXrdClProxyPlugin-4.so
+%{_libdir}/libXrdCks*-4.so
+%{_libdir}/libXrdCrypto.so.1*
+%{_libdir}/libXrdCryptoLite.so.1*
+%{_libdir}/libXrdCryptossl-4.so
+%{_libdir}/libXrdSec*-4.so
+%{_libdir}/libXrdUtils.so.*
+%{_libdir}/libXrdXml.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%dir %{_includedir}/xrootd
+%{_bindir}/xrootd-config
+%{_includedir}/xrootd/XProtocol
+%{_includedir}/xrootd/Xrd
+%{_includedir}/xrootd/XrdCks
+%{_includedir}/xrootd/XrdNet
+%{_includedir}/xrootd/XrdOuc
+%{_includedir}/xrootd/XrdSec
+%{_includedir}/xrootd/XrdSys
+%{_includedir}/xrootd/XrdVersion.hh
+%{_libdir}/libXrdAppUtils.so
+%{_libdir}/libXrdCrypto.so
+%{_libdir}/libXrdCryptoLite.so
+%{_libdir}/libXrdUtils.so
+%{_libdir}/libXrdXml.so
+%{_includedir}/xrootd/XrdXml/XrdXmlReader.hh
+
+%files client-libs
+%defattr(-,root,root,-)
+%{_libdir}/libXrdCl.so.2*
+%{_libdir}/libXrdClient.so.2*
+%{_libdir}/libXrdFfs.so.2*
+%{_libdir}/libXrdPosix.so.2*
+%{_libdir}/libXrdPosixPreload.so.1*
+%{_sysconfdir}/xrootd/client.plugins.d/client-plugin.conf.example
+%config(noreplace) %{_sysconfdir}/xrootd/client.conf
+# This lib may be used for LD_PRELOAD so the .so link needs to be included
+%{_libdir}/libXrdPosixPreload.so
+
+%files client-devel
+%defattr(-,root,root,-)
+%{_bindir}/xrdgsitest
+%{_includedir}/xrootd/XrdCl
+%{_includedir}/xrootd/XrdClient
+%{_includedir}/xrootd/XrdPosix
+%{_libdir}/libXrdCl.so
+%{_libdir}/libXrdClient.so
+%{_libdir}/libXrdFfs.so
+%{_libdir}/libXrdPosix.so
+%{_mandir}/man1/xrdgsitest.1*
+
+%files server-libs
+%defattr(-,root,root,-)
+%{_libdir}/libXrdBwm-4.so
+%{_libdir}/libXrdPss-4.so
+%{_libdir}/libXrdXrootd-4.so
+%{_libdir}/libXrdFileCache-4.so
+%{_libdir}/libXrdBlacklistDecision-4.so
+%{_libdir}/libXrdHttp-4.so
+%{_libdir}/libXrdOssSIgpfsT-4.so
+%{_libdir}/libXrdServer.so.*
+%{_libdir}/libXrdThrottle-4.so
+
+%files server-devel
+%defattr(-,root,root,-)
+%{_includedir}/xrootd/XrdAcc
+%{_includedir}/xrootd/XrdCms
+%{_includedir}/xrootd/XrdFileCache
+%{_includedir}/xrootd/XrdOss
+%{_includedir}/xrootd/XrdSfs
+%{_includedir}/xrootd/XrdXrootd
+%{_includedir}/xrootd/XrdHttp
+%{_libdir}/libXrdServer.so
+
+%files private-devel
+%defattr(-,root,root,-)
+%{_includedir}/xrootd/private
+
+%files client
+%defattr(-,root,root,-)
+%{_bindir}/xprep
+%{_bindir}/xrd
+%{_bindir}/xrdadler32
+%{_bindir}/xrdcopy
+%{_bindir}/xrdcp
+%{_bindir}/xrdcp-old
+%{_bindir}/xrdfs
+%{_bindir}/xrdgsiproxy
+%{_bindir}/xrdstagetool
+%{_mandir}/man1/xprep.1*
+%{_mandir}/man1/xrd.1*
+%{_mandir}/man1/xrdadler32.1*
+%{_mandir}/man1/xrdcopy.1*
+%{_mandir}/man1/xrdcp.1*
+%{_mandir}/man1/xrdcp-old.1*
+%{_mandir}/man1/xrdfs.1*
+%{_mandir}/man1/xrdgsiproxy.1*
+%{_mandir}/man1/xrdstagetool.1*
+
+%files fuse
+%defattr(-,root,root,-)
+%{_bindir}/xrootdfs
+%{_mandir}/man1/xrootdfs.1*
+%dir %{_sysconfdir}/xrootd
+
+%files python -f xrootd/build/PYTHON_INSTALLED_FILES
+%defattr(-,root,root,-)
+
+%files doc
+%defattr(-,root,root,-)
+%doc %{_docdir}/%{name}-%{version}
+
+%files ssi-libs
+%defattr(-,root,root,-)
+%{_libdir}/libXrdSsi-4.so
+%{_libdir}/libXrdSsiLib.so.1.0.0
+%{_libdir}/libXrdSsiLog-4.so
+%{_libdir}/libXrdSsiShMap.so.1.0.0
+
+%files ssi-devel
+%defattr(-,root,root,-)
+%{_includedir}/xrootd/XrdSsi
+%{_libdir}/libXrdSsiLib.so
+%{_libdir}/libXrdSsiLib.so.1
+%{_libdir}/libXrdSsiShMap.so
+%{_libdir}/libXrdSsiShMap.so.1
+
+%if %{?_with_ceph:1}%{!?_with_ceph:0}
+%files ceph
+%defattr(-,root,root,-)
+%{_libdir}/libXrdCeph-4.so
+%{_libdir}/libXrdCephXattr-4.so
+%{_libdir}/libXrdCephPosix.so*
+%endif
+
+%if %{?_with_tests:1}%{!?_with_tests:0}
+%files tests
+%defattr(-,root,root,-)
+%{_bindir}/text-runner
+%{_libdir}/libXrdClTests.so
+%{_libdir}/libXrdClTestsHelper.so
+%{_libdir}/libXrdClTestMonitor*.so
+
+%if %{?_with_ceph:1}%{!?_with_ceph:0}
+%{_libdir}/libXrdCephTests*.so
+%endif
+%endif
+
+%files selinux
+%defattr(-,root,root)
+%{_datadir}/selinux/packages/%{name}/%{name}.pp
+
+%if %{?_with_compat:1}%{!?_with_compat:0}
+%files client-compat
+%defattr(-,root,root,-)
+%{_libdir}/libXrdAppUtils.so.0*
+%{_libdir}/libXrdCksCalczcrc32.so*
+%{_libdir}/libXrdClient.so.1*
+%{_libdir}/libXrdCl.so.1*
+%{_libdir}/libXrdCryptoLite.so.0*
+%{_libdir}/libXrdCrypto.so.0*
+%{_libdir}/libXrdCryptossl.so*
+%{_libdir}/libXrdFfs.so.1*
+%{_libdir}/libXrdPosixPreload.so.0*
+%{_libdir}/libXrdPosix.so.1*
+%{_libdir}/libXrdSecgsiAuthzVO.so*
+%{_libdir}/libXrdSecgsiGMAPDN.so*
+%{_libdir}/libXrdSecgsi.so*
+%{_libdir}/libXrdSeckrb5.so*
+%{_libdir}/libXrdSecpwd.so*
+%{_libdir}/libXrdSec.so*
+%{_libdir}/libXrdSecsss.so*
+%{_libdir}/libXrdSecunix.so*
+%{_libdir}/libXrdUtils.so.1*
+
+%files server-compat
+%defattr(-,root,root,-)
+%{_bindir}/cmsd-3
+%{_bindir}/frm_purged-3
+%{_bindir}/frm_xfrd-3
+%{_bindir}/xrootd-3
+%{_libdir}/libXrdBwm.so*
+%{_libdir}/libXrdMain.so.1*
+%{_libdir}/libXrdOfs.so.1*
+%{_libdir}/libXrdPss.so*
+%{_libdir}/libXrdServer.so.1*
+%{_libdir}/libXrdXrootd.so*
+%endif
+
+#-------------------------------------------------------------------------------
+# Changelog
+#-------------------------------------------------------------------------------
+%changelog
+* Tue Dec 13 2016 Gerardo Ganis <gerardo.ganis@cern.ch>
+- Add xrdgsitest to xrootd-client-devel
+
+* Mon Mar 16 2015 Lukasz Janyst <ljanyst@cern.ch>
+- create the python package
+
+* Wed Mar 11 2015 Lukasz Janyst <ljanyst@cern.ch>
+- create the xrootd-ceph package
+
+* Thu Oct 30 2014 Lukasz Janyst <ljanyst@cern.ch>
+- update for 4.1 and introduce 3.3.6 compat packages
+
+* Thu Aug 28 2014 Lukasz Janyst <ljanyst@cern.ch>
+- add support for systemd
+
+* Wed Aug 27 2014 Lukasz Janyst <ljanyst@cern.ch>
+- use generic selinux policy build mechanisms
+
+* Tue Apr 01 2014 Lukasz Janyst <ljanyst@cern.ch>
+- correct the license field (LGPLv3+)
+- rename to xrootd4
+- add 'conflicts' statements
+- remove 'provides' and 'obsoletes'
+
+* Mon Mar 31 2014 Lukasz Janyst <ljanyst@cern.ch>
+- Add selinux policy
+
+* Fri Jan 24 2014 Lukasz Janyst <ljanyst@cern.ch>
+- Import XrdHttp
+
+* Fri Jun 7 2013 Lukasz Janyst <ljanyst@cern.ch>
+- adopt the EPEL RPM layout by Mattias Ellert
+
+* Tue Apr 2 2013 Lukasz Janyst <ljanyst@cern.ch>
+- remove perl
+
+* Thu Nov 1 2012 Justin Salmon <jsalmon@cern.ch>
+- add tests package
+
+* Fri Oct 21 2011 Lukasz Janyst <ljanyst@cern.ch> 3.1.0-1
+- bump the version to 3.1.0
+
+* Mon Apr 11 2011 Lukasz Janyst <ljanyst@cern.ch> 3.0.3-1
+- the first RPM release - version 3.0.3
+- the detailed release notes are available at:
+  http://xrootd.org/download/ReleaseNotes.html
-- 
GitLab