ruoyunbai 2bb9621e30 1
2021-09-29 21:06:16 +08:00

518 lines
17 KiB
RPMSpec

# Conditional build stuff; from rpm 4.4 /usr/lib/rpm/macros.
# bcond_without defaults to WITH, and vice versa.
%if %{!?with:1}0
%define with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
%endif
%if %{!?without:1}0
%define without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
%endif
%if %{!?bcond_with:1}0
%define bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
%endif
%if %{!?bcond_without:1}0
%define bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
%endif
# If _initrddir is defined, which indicates that we are on a system with SYSV
# init.d services, define _initrddir to be /etc/init.d so that the source
# tarball will work across both Red Hat and SUSE distros.
%if %{?_initrddir:1}0
%define _initrddir /etc/init.d
%endif
# some binaries under /bin in el5|6 are only provided in /usr/bin in el7+.
# the el7 rpms actually provide the old location, but can't be used as a rpm requirement
# introducing the rootbin macro for this, as none seems to exists
%if 0%{?el6:1} || 0%{?el5:1}
%define rootbin /bin
%else
%define rootbin /usr/bin
%endif
### Features disabled by default
%bcond_with blcr
%bcond_with cpuset
%bcond_with cgroups
%bcond_with debug
%bcond_with drmaa
%bcond_with gui
%bcond_with libcpuset
%bcond_with memacct
%bcond_with munge
%bcond_with numa
%bcond_with pam
%bcond_with top
%bcond_with readline
### Features enabled by default
%bcond_without scp
%bcond_without spool
%bcond_without syslog
### Autoconf macro expansions
%define ac_with_blcr --%{?with_blcr:en}%{!?with_blcr:dis}able-blcr
%define ac_with_cpuset --%{?with_cpuset:en}%{!?with_cpuset:dis}able-cpuset
%define ac_with_cgroups --%{?with_cgroups:en}%{!?with_cgroups:dis}able-cgroups
%define ac_with_debug --with%{!?with_debug:out}-debug %{?with_debug:CFLAGS="-O0 -g3" CXXFLAGS="-O0 -g3"}
%define ac_with_drmaa --%{?with_drmaa:en}%{!?with_drmaa:dis}able-drmaa
%define ac_with_gui --%{?with_gui:en}%{!?with_gui:dis}able-gui --with%{!?with_gui:out}-tcl
%define ac_with_munge --%{?with_munge:en}%{!?with_munge:dis}able-munge-auth --%{?with_munge:en}%{!?with_munge:dis}able-munge-library
%define ac_with_numa --%{?with_numa:en}%{!?with_numa:dis}able-numa-support
%define ac_with_memacct --%{?with_memacct:en}%{!?with_memacct:dis}able-memacct
%define ac_with_libcpuset --%{?with_libcpuset:en}%{!?with_libcpuset:dis}able-libcpuset
%define ac_with_top --%{?with_top:en}%{!?with_top:dis}able-top-tempdir-only
%define ac_with_pam --with%{!?with_pam:out}-pam%{?with_pam:=/%{_lib}/security}
%define ac_with_scp --with-rcp=%{?with_scp:scp}%{!?with_scp:pbs_rcp}
%define ac_with_spool --%{?with_spool:en}%{!?with_spool:dis}able-spool
%define ac_with_syslog --%{?with_syslog:en}%{!?with_syslog:dis}able-syslog
%define ac_trqauthd_sock_dir %{?trqauthd_sock_dir:%{trqauthd_sock_dir}}%{!?trqauthd_sock_dir:/tmp}
### Build Requirements
%define breq_cpuset %{?with_cpuset:hwloc-devel}
%define breq_gui %{?with_gui:tcl-devel tk-devel tclx}
%define breq_numa %{?with_cpuset:hwloc-devel}
%define breq_munge %{?with_munge:munge-devel}
%define breq_pam %{?with_pam:pam-devel}
%define breq_readline %{?with_readline:readline-devel}
%define breq_scp %{?with_scp:/usr/bin/scp}
# Requirements
%define req_cgroups %{?with_cgroups:%{rootbin}/lssubsys}
### Macro variables
%{!?torque_user:%global torque_user torque}
%{!?torque_home:%global torque_home %{_var}/spool/%{name}}
%{!?torque_server:%global torque_server localhost}
%{!?sendmail_path:%global sendmail_path %{_sbindir}/sendmail}
### Do not strip executables when debugging.
%if %{with debug}
%global __os_install_post /usr/lib/rpm/brp-compress
%global __debug_install_post %{nil}
%global debug_package %{nil}
%endif
### Handle logic for snapshots
%define tarversion @SPEC_VERSION@
#define snap 0
%if %{?snap}0
%{expand:%%define version %(echo %{tarversion} | sed 's/-snap\..*$//')}
%{expand:%%define release 0.adaptive.snap.%(echo %{tarversion} | sed 's/^.*-snap\.//').0%{?dist}}
%else
%define version %{tarversion}
%define release 1.adaptive%{?dist}
%endif
Name: @SPEC_NAME@
Version: %{version}
Release: %{release}
Summary: Tera-scale Open-source Resource and QUEue manager
License: OpenPBS License (ASF-like)
Group: Applications/System
URL: http://www.clusterresources.com/products/torque/
Packager: %{?_packager:%{_packager}}%{!?_packager:%{_vendor}}
Source: http://www.clusterresources.com/downloads/torque/%{name}-%{tarversion}.tar.gz
Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:%{_vendor}}
Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}}
#BuildSuggests: openssh-clients tcl-devel tclx tk-devel
BuildRequires: %{breq_cpuset} %{breq_gui} %{breq_numa} %{breq_munge} %{breq_pam} %{breq_readline} %{breq_scp} make openssl-devel libxml2-devel boost-devel
Conflicts: pbspro, openpbs, openpbs-oscar
Obsoletes: scatorque <= %{version}-%{release}, %{!?with_gui:%{name}-gui < %{version}-%{release}}
Provides: pbs, pbs-docs, pbs-pam, %{!?with_gui:%{name}-gui = %{version}-%{release}}
Provides: %{name}-docs = %{version}-%{release}
Prefix: %{_prefix}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%description
TORQUE is an open source resource manager providing control over batch
jobs and distributed compute nodes. It is a community effort based on
the original *PBS project and, with more than 5,200 patches, has
incorporated significant advances in the areas of scalability, fault
tolerance, and feature extensions contributed by NCSA, OSC, USC, the
U.S. Dept of Energy, Sandia, PNNL, U of Buffalo, TeraGrid, and many
other leading edge HPC organizations.
%package server
Summary: TORQUE Server
Group: Applications/System
Provides: pbs-server = %{version}-%{release}
%description server
Package for TORQUE server systems.
%package devel
Summary: TORQUE Development Files
Group: Applications/System
Requires: %{name} = %{version}-%{release}
Provides: pbs-devel = %{version}-%{release}
Provides: lib%{name}-devel = %{version}-%{release}
%description devel
Development headers and libraries for TORQUE
%package scheduler
Summary: TORQUE FIFO Scheduler
Group: Applications/System
Requires: %{name} = %{version}-%{release}
Provides: pbs-scheduler = %{version}-%{release}
%description scheduler
A simple FIFO scheduler for TORQUE
%package client
Summary: TORQUE Client
Group: Applications/System
Requires: %{name} = %{version}-%{release}
%if %{with cgroups}
Requires: %{req_cgroups}
%endif
Provides: pbs-client pbs-mom %{?with_pam:pbs-pam}
Provides: %{name}-mom = %{version}-%{release}
Obsoletes: %{name}-mom < %{version}-%{release}
%if %{with pam}
Provides: %{name}-pam = %{version}-%{release}
Obsoletes: %{name}-pam < %{version}-%{release}
%endif
%description client
Package for TORQUE client systems.
%if %{with gui}
%package gui
Summary: TORQUE GUI
Group: Applications/System
Requires: %{name}-client = %{version}-%{release}
Provides: pbs-gui = %{version}-%{release}, xpbs, xpbsmon
%description gui
Graphical clients for TORQUE
%endif
%if %{with drmaa}
%package drmaa
Summary: DRMAA 1.0 Implementation for TORQUE
Group: Applications/System
Provides: pbs-drmaa = %{version}-%{release}
%description drmaa
This package contains a DRMAA 1.0 implementation for use with TORQUE.
%endif
%prep
%setup -q -n %{name}-%{tarversion}
%build
CFLAGS="%{?cflags:%{cflags}}%{!?cflags:$RPM_OPT_FLAGS}"
CXXFLAGS="%{?cxxflags:%{cxxflags}}%{!?cxxflags:$RPM_OPT_FLAGS}"
LDFLAGS="%{?ldflags:%{ldflags}}%{!?ldflags:$RPM_LD_FLAGS}"
export CFLAGS CXXFLAGS LDFLAGS
# use cached configure DOXYGEN
export ac_cv_path_DOXYGEN=none
%configure --includedir=%{_includedir}/%{name} --with-default-server=%{torque_server} \
--with-server-home=%{torque_home} %{ac_with_debug} %{ac_with_libcpuset} \
--with-sendmail=%{sendmail_path} %{ac_with_numa} %{ac_with_memacct} %{ac_with_top} \
--with-trqauthd-sock-dir=%{ac_trqauthd_sock_dir} %{?xauth_path:--with-xauth=%{xauth_path}} \
--disable-dependency-tracking %{ac_with_gui} %{ac_with_scp} %{ac_with_syslog} \
--disable-gcc-warnings %{ac_with_munge} %{ac_with_pam} %{ac_with_drmaa} \
--disable-qsub-keep-override %{ac_with_blcr} %{ac_with_cpuset} %{ac_with_cgroups} %{ac_with_spool} %{?acflags}
%{__make} %{?_smp_mflags} %{?mflags}
%install
%{__make} install DESTDIR=$RPM_BUILD_ROOT %{?mflags_install}
%{__rm} -rf $RPM_BUILD_ROOT/%{_lib}/security/*a $RPM_BUILD_ROOT%{_sysconfdir}/modulefiles
%if %{?_unitdir:1}0
# systemd unit files
%{__mkdir_p} $RPM_BUILD_ROOT%{_unitdir}
for UNITFILE in pbs_mom.service pbs_sched.service pbs_server.service trqauthd.service ; do
%{__sed} -e 's|^PBS_HOME=.*|PBS_HOME=%{torque_home}|' \
-e 's|^BIN_PATH=.*|BIN_PATH=%{_bindir}|' \
-e 's|^SBIN_PATH=.*|SBIN_PATH=%{_sbindir}|' contrib/systemd/$UNITFILE \
> $RPM_BUILD_ROOT%{_unitdir}/$UNITFILE
done
%else
%if %{?_initrddir:1}0
# init.d scripts
%{__mkdir_p} $RPM_BUILD_ROOT%{_initrddir}
INIT_PREFIX=""
test -f /etc/SuSE-release && INIT_PREFIX="suse."
for PROG in pbs_mom pbs_sched pbs_server trqauthd ; do
%{__sed} -e 's|^PBS_HOME=.*|PBS_HOME=%{torque_home}|' \
-e 's|^BIN_PATH=.*|BIN_PATH=%{_bindir}|' \
-e 's|^SBIN_PATH=.*|SBIN_PATH=%{_sbindir}|' \
-e 's|^PBS_DAEMON=.*|PBS_DAEMON=%{_sbindir}/'$PROG'|' contrib/init.d/$INIT_PREFIX$PROG \
> $RPM_BUILD_ROOT%{_initrddir}/$PROG
%{__chmod} 0755 $RPM_BUILD_ROOT%{_initrddir}/$PROG
done
%endif
%endif
# Configuration
echo %{torque_server} > $RPM_BUILD_ROOT%{torque_home}/server_priv/nodes
echo '$pbsserver %{torque_server}' > $RPM_BUILD_ROOT%{torque_home}/mom_priv/config
# Moab requires libtorque.so.0, but works with libtorque.so.2, so fudge it.
%{__ln_s} libtorque.so.2 $RPM_BUILD_ROOT%{_libdir}/libtorque.so.0
%if %{with drmaa}
# Move DRMAA docs back to the source tree so we can install them properly.
if test -d $RPM_BUILD_ROOT%{_docdir}/*drmaa*/html ; then
mv $RPM_BUILD_ROOT%{_docdir}/*drmaa* drmaa-doc-dir
else
mkdir drmaa-doc-dir
echo "Doxygen is required to build DRMAA API docs but was not present at build time." > drmaa-doc-dir/README.drmaa_docs
fi
%endif
%post
/sbin/ldconfig
if [ $1 -eq 1 ]; then
chkconfig --add trqauthd >/dev/null 2>&1 || :
chkconfig trqauthd on >/dev/null 2>&1 || :
service trqauthd start >/dev/null 2>&1 || :
else
service trqauthd try-restart >/dev/null 2>&1 || :
fi
%preun
if [ $1 -eq 0 ]; then
chkconfig trqauthd off >/dev/null 2>&1 || :
service trqauthd stop >/dev/null 2>&1 || :
chkconfig --del trqauthd >/dev/null 2>&1 || :
fi
%postun -p /sbin/ldconfig
%post server
if [ $1 -eq 1 ]; then
grep '^%{torque_user}:' /etc/passwd >/dev/null 2>&1 || useradd -r %{torque_user} || :
grep 'PBS services' /etc/services >/dev/null 2>&1 || cat <<-EOF >>/etc/services
# Standard PBS services
pbs 15001/tcp # pbs server (pbs_server)
pbs 15001/udp # pbs server (pbs_server)
pbs_mom 15002/tcp # mom to/from server
pbs_mom 15002/udp # mom to/from server
pbs_resmom 15003/tcp # mom resource management requests
pbs_resmom 15003/udp # mom resource management requests
pbs_sched 15004/tcp # scheduler
pbs_sched 15004/udp # scheduler
trqauthd 15005/tcp # authorization daemon
trqauthd 15005/udp # authorization daemon
EOF
if [ ! -e %{torque_home}/server_priv/serverdb ]; then
if [ "%{torque_server}" = "localhost" ]; then
TORQUE_SERVER=`hostname`
perl -pi -e "s/localhost/$TORQUE_SERVER/g" %{torque_home}/server_name %{torque_home}/server_priv/nodes 2>/dev/null || :
else
TORQUE_SERVER="%{torque_server}"
fi
pbs_server -t create -f >/dev/null 2>&1 || :
sleep 1
qmgr -c "set server scheduling = true" >/dev/null 2>&1 || :
qmgr -c "set server managers += root@$TORQUE_SERVER" >/dev/null 2>&1 || :
qmgr -c "set server managers += %{torque_user}@$TORQUE_SERVER" >/dev/null 2>&1 || :
qmgr -c "create queue batch queue_type = execution" >/dev/null 2>&1 || :
qmgr -c "set queue batch started = true" >/dev/null 2>&1 || :
qmgr -c "set queue batch enabled = true" >/dev/null 2>&1 || :
qmgr -c "set queue batch resources_default.walltime = 1:00:00" >/dev/null 2>&1 || :
qmgr -c "set queue batch resources_default.nodes = 1" >/dev/null 2>&1 || :
qmgr -c "set server default_queue = batch" >/dev/null 2>&1 || :
qmgr -c "set node $TORQUE_SERVER state = free" >/dev/null 2>&1 || :
killall -TERM pbs_server >/dev/null 2>&1 || :
fi
chkconfig --add pbs_server >/dev/null 2>&1 || :
chkconfig pbs_server on >/dev/null 2>&1 || :
service pbs_server start >/dev/null 2>&1 || :
else
service pbs_server try-restart >/dev/null 2>&1 || :
fi
%preun server
if [ $1 -eq 0 ]; then
chkconfig pbs_server off >/dev/null 2>&1 || :
service pbs_server stop >/dev/null 2>&1 || :
chkconfig --del pbs_server >/dev/null 2>&1 || :
fi
%post client
if [ $1 -eq 1 ]; then
grep 'PBS services' /etc/services >/dev/null 2>&1 || cat <<-EOF >>/etc/services
# Standard PBS services
pbs 15001/tcp # pbs server (pbs_server)
pbs 15001/udp # pbs server (pbs_server)
pbs_mom 15002/tcp # mom to/from server
pbs_mom 15002/udp # mom to/from server
pbs_resmom 15003/tcp # mom resource management requests
pbs_resmom 15003/udp # mom resource management requests
pbs_sched 15004/tcp # scheduler
pbs_sched 15004/udp # scheduler
trqauthd 15005/tcp # authorization daemon
trqauthd 15005/udp # authorization daemon
EOF
if [ "%{torque_server}" = "localhost" ]; then
TORQUE_SERVER=`hostname`
perl -pi -e "s/localhost/$TORQUE_SERVER/g" %{torque_home}/mom_priv/config 2>/dev/null || :
fi
chkconfig --add pbs_mom >/dev/null 2>&1 || :
chkconfig pbs_mom on >/dev/null 2>&1 || :
service pbs_mom start >/dev/null 2>&1 || :
else
service pbs_mom try-restart >/dev/null 2>&1 || :
fi
%preun client
if [ $1 -eq 0 ]; then
chkconfig pbs_mom off >/dev/null 2>&1 || :
service pbs_mom stop >/dev/null 2>&1 || :
chkconfig --del pbs_mom >/dev/null 2>&1 || :
fi
%post scheduler
if [ $1 -eq 1 ]; then
chkconfig --add pbs_sched >/dev/null 2>&1 || :
chkconfig pbs_sched on >/dev/null 2>&1 || :
service pbs_sched start >/dev/null 2>&1 || :
else
service pbs_sched try-restart >/dev/null 2>&1 || :
fi
%preun scheduler
if [ $1 -eq 0 ]; then
chkconfig pbs_sched off >/dev/null 2>&1 || :
service pbs_sched stop >/dev/null 2>&1 || :
chkconfig --del pbs_sched >/dev/null 2>&1 || :
fi
%clean
test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%doc INSTALL INSTALL.GNU CHANGELOG PBS_License.txt README.* Release_Notes src/pam/README.pam
%doc doc/READ_ME doc/doc_fonts doc/soelim.c doc/ers
%config(noreplace) %{torque_home}/pbs_environment
%config(noreplace) /etc/ld.so.conf.d/torque.conf
%config(noreplace) /etc/profile.d/torque.sh
%config(noreplace) /etc/profile.d/torque.csh
%config(noreplace) %{torque_home}/server_name
%if %{?_unitdir:1}0
%{_unitdir}/trqauthd.service
%else
%if %{?_initrddir:1}0
%{_initrddir}/trqauthd
%endif
%endif
%{_bindir}/chk_tree
%{_bindir}/hostn
%{_bindir}/nqs2pbs
%{_bindir}/pbs_track
%{_bindir}/pbsdsh
%{_bindir}/pbsnodes
%{_bindir}/printjob
%{_bindir}/printserverdb
%{_bindir}/printtracking
%{_bindir}/q*
%{_bindir}/tracejob
%{_sbindir}/trqauthd
%if %{without scp}
%attr(4755, root, root) %{_sbindir}/pbs_rcp
%endif
%{_libdir}/lib%{name}.so*
%{torque_home}/aux
%{torque_home}/spool
%{torque_home}/checkpoint
%{_mandir}/man*/*
%files server
%defattr(-, root, root)
%doc torque.setup doc/admin_guide.ps
%dir %{torque_home}/server_priv
%config(noreplace) %{torque_home}/server_priv/nodes
%if %{?_unitdir:1}0
%{_unitdir}/pbs_server.service
%else
%if %{?_initrddir:1}0
%{_initrddir}/pbs_server
%endif
%endif
%{_sbindir}/momctl
%{_sbindir}/pbs_server
%{_sbindir}/qserverd
%{torque_home}/server_logs
%{torque_home}/server_priv/accounting
%{torque_home}/server_priv/acl*
%{torque_home}/server_priv/arrays
%{torque_home}/server_priv/credentials
%{torque_home}/server_priv/disallowed_types
%{torque_home}/server_priv/hostlist
%{torque_home}/server_priv/jobs
%{torque_home}/server_priv/queues
%files devel
%defattr(-, root, root)
%{_bindir}/pbs-config
%{_includedir}/%{name}
%{_libdir}/lib%{name}*a
%{_libdir}/lib%{name}*so
%files scheduler
%defattr(-, root, root)
%dir %{torque_home}/sched_priv
%config(noreplace) %{torque_home}/sched_priv/*
%{_sbindir}/pbs_sched
%{_sbindir}/qschedd
%if %{?_unitdir:1}0
%{_unitdir}/pbs_sched.service
%else
%if %{?_initrddir:1}0
%{_initrddir}/pbs_sched
%endif
%endif
%{torque_home}/sched_logs
%files client
%defattr(-, root, root)
%dir %{torque_home}/mom_priv
%config(noreplace) %{torque_home}/mom_priv/config
%if %{?_unitdir:1}0
%{_unitdir}/pbs_mom.service
%else
%if %{?_initrddir:1}0
%{_initrddir}/pbs_mom
%endif
%endif
%{_sbindir}/momctl
%{_sbindir}/pbs_demux
%{_sbindir}/pbs_mom
%{_sbindir}/qnoded
%if %{with pam}
/%{_lib}/security/pam_pbssimpleauth.so
%endif
%{torque_home}/mom_logs
%{torque_home}/mom_priv/jobs/
%{torque_home}/undelivered
%if %{with gui}
%files gui
%defattr(-, root, root)
%{_bindir}/pbs_tclsh
%{_bindir}/pbs_wish
%{_bindir}/xpbs*
%{_libdir}/xpbs*
%endif
%if %{with drmaa}
%files drmaa
%defattr(-, root, root)
%doc drmaa-doc-dir/*
%{_includedir}/%{name}/drmaa.h
%{_libdir}/libdrmaa.*
%endif
%changelog
* Sat Apr 07 2007 Mezzanine <mezzanine@kainx.org>
- Specfile auto-generated by Mezzanine