*/*: [QA] Remove redundant --docdir/--htmldir
[gentoo.git] / sys-cluster / slurm / slurm-19.05.4.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 if [[ ${PV} == *9999* ]]; then
7         EGIT_REPO_URI="https://github.com/SchedMD/slurm.git"
8         INHERIT_GIT="git-r3"
9         SRC_URI=""
10         KEYWORDS=""
11         MY_P="${P}"
12 else
13         if [[ ${PV} == *pre* || ${PV} == *rc* ]]; then
14                 MY_PV=$(ver_rs '-0.') # pre-releases or release-candidate
15         else
16                 MY_PV=$(ver_rs 1-3 '-') # stable releases
17         fi
18         MY_P="${PN}-${MY_PV}"
19         INHERIT_GIT=""
20         SRC_URI="https://github.com/SchedMD/slurm/archive/${MY_P}.tar.gz"
21         KEYWORDS="~amd64 ~x86"
22 fi
23
24 inherit autotools bash-completion-r1 pam perl-module prefix toolchain-funcs systemd ${INHERIT_GIT}
25
26 DESCRIPTION="A Highly Scalable Resource Manager"
27 HOMEPAGE="https://www.schedmd.com https://github.com/SchedMD/slurm"
28
29 LICENSE="GPL-2"
30 SLOT="0"
31 IUSE="debug hdf5 html ipmi json lua multiple-slurmd +munge mysql netloc numa ofed pam perl slurmdbd static-libs ucx torque X"
32
33 COMMON_DEPEND="
34         !sys-cluster/torque
35         !net-analyzer/slurm
36         !net-analyzer/sinfo
37         || ( sys-cluster/pmix[-pmi] >=sys-cluster/openmpi-2.0.0 )
38         mysql? (
39                 || ( dev-db/mariadb-connector-c dev-db/mysql-connector-c )
40                 slurmdbd? ( || ( dev-db/mariadb dev-db/mysql ) )
41                 )
42         munge? ( sys-auth/munge )
43         pam? ( sys-libs/pam )
44         lua? ( dev-lang/lua:0= )
45         !lua? ( !dev-lang/lua )
46         ipmi? ( sys-libs/freeipmi )
47         json? ( dev-libs/json-c:= )
48         amd64? ( netloc? ( sys-apps/netloc ) )
49         hdf5? ( sci-libs/hdf5:= )
50         numa? ( sys-process/numactl )
51         ofed? ( sys-fabric/ofed )
52         ucx? ( sys-cluster/ucx )
53         X? ( net-libs/libssh2 )
54         >=sys-apps/hwloc-1.1.1-r1
55         sys-libs/ncurses:0=
56         app-arch/lz4:0=
57         sys-libs/readline:0="
58 DEPEND="${COMMON_DEPEND}
59         html? ( sys-apps/man2html )"
60 RDEPEND="${OMMON_DEPEND}
61         acct-user/slurm
62         acct-group/slurm
63         dev-libs/libcgroup"
64
65 REQUIRED_USE="torque? ( perl )"
66
67 S="${WORKDIR}/${PN}-${MY_P}"
68
69 LIBSLURM_PERL_S="${S}/contribs/perlapi/libslurm/perl"
70 LIBSLURMDB_PERL_S="${S}/contribs/perlapi/libslurmdb/perl"
71
72 RESTRICT="test"
73
74 src_unpack() {
75         if [[ ${PV} == *9999* ]]; then
76                 git-r3_src_unpack
77         else
78                 default
79         fi
80 }
81
82 src_prepare() {
83         tc-ld-disable-gold
84         eapply "${FILESDIR}"/disable-sview.patch
85         default
86
87         # pids should go to /var/run/slurm
88         sed \
89                 -e 's:/tmp:/var/tmp:g' \
90                 -e "s:/var/run/slurmctld.pid:${EPREFIX}/run/slurm/slurmctld.pid:g" \
91                 -e "s:/var/run/slurmd.pid:${EPREFIX}/run/slurm/slurmd.pid:g" \
92                 -e "s:StateSaveLocation=.*:StateSaveLocation=${EPREFIX}/var/spool/slurm:g" \
93                 -e "s:SlurmdSpoolDir=.*:SlurmdSpoolDir=${EPREFIX}/var/spool/slurm/slurmd:g" \
94                 -i "${S}/etc/slurm.conf.example" \
95                 || die "Can't sed for /var/run/slurmctld.pid"
96         sed \
97                 -e "s:/var/run/slurmdbd.pid:${EPREFIX}/run/slurm/slurmdbd.pid:g" \
98                 -i "${S}/etc/slurmdbd.conf.example" \
99                 || die "Can't sed for /var/run/slurmdbd.pid"
100         # gentooify systemd services
101         sed \
102                 -e 's:sysconfig/.*:conf.d/slurm:g' \
103                 -e 's:var/run/:run/slurm/:g' \
104                 -e '/^EnvironmentFile=.*/d' \
105                 -i "${S}/etc"/*.service.in \
106                 || die "Can't sed systemd services for sysconfig or var/run/"
107
108         hprefixify auxdir/{ax_check_zlib,x_ac_{lz4,ofed,munge}}.m4
109         eautoreconf
110 }
111
112 src_configure() {
113         local myconf=(
114                 --sysconfdir="${EPREFIX}/etc/${PN}"
115                 --with-hwloc="${EPREFIX}/usr"
116                 --htmldir="${EPREFIX}/usr/share/doc/${PF}"
117         )
118         use pam && myconf+=( --with-pam_dir=$(getpam_mod_dir) )
119         use mysql || myconf+=( --without-mysql_config )
120         use amd64 && myconf+=( $(use_with netloc) )
121         econf "${myconf[@]}" \
122                 $(use_enable debug) \
123                 $(use_enable pam) \
124                 $(use_enable X x11) \
125                 $(use_with munge) \
126                 $(use_with json) \
127                 $(use_with hdf5) \
128                 $(use_with ofed) \
129                 $(use_with ucx) \
130                 $(use_enable static-libs static) \
131                 $(use_enable multiple-slurmd)
132
133         # --htmldir does not seems to propagate... Documentations are installed
134         # in /usr/share/doc/slurm-2.3.0/html
135         # instead of /usr/share/doc/slurm-2.3.0.2/html
136         sed \
137                 -e "s|htmldir = .*/html|htmldir = \${prefix}/share/doc/slurm-${PVR}/html|g" \
138                 -i doc/html/Makefile || die
139         if use perl ; then
140                 # small hack to make it compile
141                 mkdir -p "${S}/src/api/.libs" || die
142                 mkdir -p "${S}/src/db_api/.libs" || die
143                 touch "${S}/src/api/.libs/libslurm.so" || die
144                 touch "${S}/src/db_api/.libs/libslurmdb.so" || die
145                 cd "${LIBSLURM_PERL_S}" || die
146                 S="${LIBSLURM_PERL_S}" SRC_PREP="no" perl-module_src_configure
147                 cd "${LIBSLURMDB_PERL_S}" || die
148                 S="${LIBSLURMDB_PERL_S}" SRC_PREP="no" perl-module_src_configure
149                 cd "${S}" || die
150                 rm -rf "${S}/src/api/.libs" "${S}/src/db_api/.libs" || die
151         fi
152 }
153
154 src_compile() {
155         default
156         use pam && emake -C contribs/pam
157         if use perl ; then
158                 cd "${LIBSLURM_PERL_S}" || die
159                 S="${LIBSLURM_PERL_S}" perl-module_src_compile
160                 cd "${LIBSLURMDB_PERL_S}" || die
161                 S="${LIBSLURMDB_PERL_S}" perl-module_src_compile
162                 cd "${S}" || die
163         fi
164         use torque && emake -C contribs/torque
165 }
166
167 src_install() {
168         default
169         use pam && emake DESTDIR="${D}" -C contribs/pam install
170         if use perl; then
171                 cd "${LIBSLURM_PERL_S}" || die
172                 S="${LIBSLURM_PERL_S}" perl-module_src_install
173                 cd "${LIBSLURMDB_PERL_S}" || die
174                 S="${LIBSLURMDB_PERL_S}" perl-module_src_install
175                 cd "${S}" || die
176         fi
177         if use torque; then
178                 emake DESTDIR="${D}" -C contribs/torque
179                 rm -f "${D}"/usr/bin/mpiexec || die
180         fi
181         use static-libs || find "${ED}" -name '*.la' -exec rm {} +
182         # install sample configs
183         keepdir /etc/slurm
184         insinto /etc/slurm
185         doins \
186                 etc/bluegene.conf.example \
187                 etc/cgroup.conf.example \
188                 etc/slurm.conf.example \
189                 etc/slurmdbd.conf.example
190         exeinto /etc/slurm
191         keepdir /etc/slurm/layouts.d
192         insinto /etc/slurm/layouts.d
193         newins etc/layouts.d.power.conf.example power.conf.example
194         newins etc/layouts.d.power_cpufreq.conf.example power_cpufreq.conf.example
195         newins etc/layouts.d.unit.conf.example unit.conf.example
196         # install init.d files
197         newinitd "$(prefixify_ro "${FILESDIR}/slurmd.initd")" slurmd
198         newinitd "$(prefixify_ro "${FILESDIR}/slurmctld.initd")" slurmctld
199         newinitd "$(prefixify_ro "${FILESDIR}/slurmdbd.initd")" slurmdbd
200         # install conf.d files
201         newconfd "${FILESDIR}/slurm.confd" slurm
202         # install logrotate file
203         insinto /etc/logrotate.d
204         newins "${FILESDIR}/logrotate" slurm
205         # install bashcomp
206         newbashcomp contribs/slurm_completion_help/slurm_completion.sh scontrol
207         bashcomp_alias scontrol \
208                 sreport sacctmgr squeue scancel sshare sbcast sinfo \
209                 sprio sacct salloc sbatch srun sattach sdiag sstat
210         # install systemd files
211         systemd_newtmpfilesd "${FILESDIR}/slurm.tmpfiles" slurm.conf
212         systemd_dounit etc/slurmd.service etc/slurmctld.service etc/slurmdbd.service
213 }
214
215 pkg_preinst() {
216         if use munge; then
217                 sed -i 's,\(SLURM_USE_MUNGE=\).*,\11,' "${D}"/etc/conf.d/slurm || die
218         fi
219 }
220
221 create_folders_and_fix_permissions() {
222         einfo "Fixing permissions in ${@}"
223         mkdir -p ${@} || die
224         chown -R ${PN}:${PN} ${@} || die
225 }
226
227 pkg_postinst() {
228         paths=(
229                 "${EROOT}"/var/${PN}/checkpoint
230                 "${EROOT}"/var/${PN}
231                 "${EROOT}"/var/spool/${PN}/slurmd
232                 "${EROOT}"/var/spool/${PN}
233                 "${EROOT}"/var/log/${PN}
234                 /var/tmp/${PN}/${PN}d
235                 /var/tmp/${PN}
236                 /run/${PN}
237         )
238         local folder_path
239         for folder_path in ${paths[@]}; do
240                 create_folders_and_fix_permissions $folder_path
241         done
242         echo
243
244         elog "Please visit the file '/usr/share/doc/${P}/html/configurator.html"
245         elog "through a (javascript enabled) browser to create a configureation file."
246         elog "Copy that file to /etc/slurm/slurm.conf on all nodes (including the headnode) of your cluster."
247         echo
248         elog "For cgroup support, please see https://www.schedmd.com/slurmdocs/cgroup.conf.html"
249         elog "Your kernel must be compiled with the wanted cgroup feature:"
250         elog "    For the proctrack plugin:"
251         elog "        freezer"
252         elog "    For the task plugin:"
253         elog "        cpuset, memory, devices"
254         elog "    For the accounting plugin:"
255         elog "        cpuacct, memory, blkio"
256         elog "Then, set these options in /etc/slurm/slurm.conf:"
257         elog "    ProctrackType=proctrack/cgroup"
258         elog "    TaskPlugin=task/cgroup"
259         einfo
260         ewarn "Paths were created for slurm. Please use these paths in /etc/slurm/slurm.conf:"
261         for folder_path in ${paths[@]}; do
262                 ewarn "    ${folder_path}"
263         done
264 }