1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 if [[ ${PV} == *9999* ]]; then
7 EGIT_REPO_URI="https://github.com/SchedMD/slurm.git"
13 if [[ ${PV} == *pre* || ${PV} == *rc* ]]; then
14 MY_PV=$(ver_rs '-0.') # pre-releases or release-candidate
16 MY_PV=$(ver_rs 1-3 '-') # stable releases
20 SRC_URI="https://github.com/SchedMD/slurm/archive/${MY_P}.tar.gz"
21 KEYWORDS="~amd64 ~x86"
24 inherit autotools bash-completion-r1 pam perl-module prefix toolchain-funcs systemd ${INHERIT_GIT}
26 DESCRIPTION="A Highly Scalable Resource Manager"
27 HOMEPAGE="https://www.schedmd.com https://github.com/SchedMD/slurm"
31 IUSE="debug hdf5 html ipmi json lua multiple-slurmd +munge mysql netloc numa ofed pam perl slurmdbd static-libs ucx torque X"
37 || ( sys-cluster/pmix[-pmi] >=sys-cluster/openmpi-2.0.0 )
39 || ( dev-db/mariadb-connector-c dev-db/mysql-connector-c )
40 slurmdbd? ( || ( dev-db/mariadb dev-db/mysql ) )
42 munge? ( sys-auth/munge )
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
58 DEPEND="${COMMON_DEPEND}
59 html? ( sys-apps/man2html )"
60 RDEPEND="${OMMON_DEPEND}
65 REQUIRED_USE="torque? ( perl )"
67 S="${WORKDIR}/${PN}-${MY_P}"
69 LIBSLURM_PERL_S="${S}/contribs/perlapi/libslurm/perl"
70 LIBSLURMDB_PERL_S="${S}/contribs/perlapi/libslurmdb/perl"
75 if [[ ${PV} == *9999* ]]; then
84 eapply "${FILESDIR}"/disable-sview.patch
87 # pids should go to /var/run/slurm
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"
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
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/"
108 hprefixify auxdir/{ax_check_zlib,x_ac_{lz4,ofed,munge}}.m4
114 --sysconfdir="${EPREFIX}/etc/${PN}"
115 --with-hwloc="${EPREFIX}/usr"
116 --htmldir="${EPREFIX}/usr/share/doc/${PF}"
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) \
124 $(use_enable X x11) \
130 $(use_enable static-libs static) \
131 $(use_enable multiple-slurmd)
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
137 -e "s|htmldir = .*/html|htmldir = \${prefix}/share/doc/slurm-${PVR}/html|g" \
138 -i doc/html/Makefile || die
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
150 rm -rf "${S}/src/api/.libs" "${S}/src/db_api/.libs" || die
156 use pam && emake -C contribs/pam
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
164 use torque && emake -C contribs/torque
169 use pam && emake DESTDIR="${D}" -C contribs/pam install
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
178 emake DESTDIR="${D}" -C contribs/torque
179 rm -f "${D}"/usr/bin/mpiexec || die
181 use static-libs || find "${ED}" -name '*.la' -exec rm {} +
182 # install sample configs
186 etc/bluegene.conf.example \
187 etc/cgroup.conf.example \
188 etc/slurm.conf.example \
189 etc/slurmdbd.conf.example
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
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
217 sed -i 's,\(SLURM_USE_MUNGE=\).*,\11,' "${D}"/etc/conf.d/slurm || die
221 create_folders_and_fix_permissions() {
222 einfo "Fixing permissions in ${@}"
224 chown -R ${PN}:${PN} ${@} || die
229 "${EROOT}"/var/${PN}/checkpoint
231 "${EROOT}"/var/spool/${PN}/slurmd
232 "${EROOT}"/var/spool/${PN}
233 "${EROOT}"/var/log/${PN}
234 /var/tmp/${PN}/${PN}d
239 for folder_path in ${paths[@]}; do
240 create_folders_and_fix_permissions $folder_path
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."
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:"
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"
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}"