torque-4.2.9-r2.ebuild 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # $Header: /var/cvsroot/gentoo-x86/sys-cluster/torque/torque-4.2.9-r2.ebuild,v 1.1 2014/12/16 03:33:43 jsbronder Exp $
  4. EAPI=5
  5. # AUTOTOOLS_AUTORECONF=yes
  6. inherit flag-o-matic eutils linux-info
  7. DESCRIPTION="Resource manager and queuing system based on OpenPBS"
  8. HOMEPAGE="http://www.adaptivecomputing.com/products/open-source/torque"
  9. # TODO: hopefully moving to github tags soon
  10. # http://www.supercluster.org/pipermail/torquedev/2013-May/004519.html
  11. SRC_URI="http://www.adaptivecomputing.com/index.php?wpfb_dl=2849 -> ${P}.tar.gz"
  12. LICENSE="torque-2.5"
  13. SLOT="0"
  14. KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
  15. IUSE="cpusets +crypt doc drmaa kernel_linux munge nvidia server +syslog tk ipc-isolation"
  16. DEPEND_COMMON="
  17. sys-libs/ncurses
  18. sys-libs/readline
  19. cpusets? ( sys-apps/hwloc )
  20. munge? ( sys-auth/munge )
  21. nvidia? ( >=x11-drivers/nvidia-drivers-275 )
  22. tk? ( dev-lang/tk )
  23. syslog? ( virtual/logger )
  24. !games-util/qstat"
  25. DEPEND="${DEPEND_COMMON}
  26. !sys-cluster/slurm"
  27. RDEPEND="${DEPEND_COMMON}
  28. crypt? ( net-misc/openssh )
  29. !crypt? ( net-misc/netkit-rsh )
  30. !dev-libs/uthash"
  31. # Torque should depend on dev-libs/uthash but that's pretty much impossible
  32. # to patch in as they ship with a broken configure such that files referenced
  33. # by the configure.ac and Makefile.am are missing.
  34. # http://www.supercluster.org/pipermail/torquedev/2014-October/004773.html
  35. pkg_setup() {
  36. PBS_SERVER_HOME="${PBS_SERVER_HOME:-/var/spool/${PN}}"
  37. # Find a Torque server to use. Check environment, then
  38. # current setup (if any), and fall back on current hostname.
  39. if [ -z "${PBS_SERVER_NAME}" ]; then
  40. if [ -f "${ROOT}${PBS_SERVER_HOME}/server_name" ]; then
  41. PBS_SERVER_NAME="$(<${ROOT}${PBS_SERVER_HOME}/server_name)"
  42. else
  43. PBS_SERVER_NAME=$(hostname -f)
  44. fi
  45. fi
  46. USE_CPUSETS="--disable-cpuset"
  47. if use cpusets; then
  48. if ! use kernel_linux; then
  49. einfo
  50. elog " Torque currently only has support for cpusets in linux."
  51. elog "Assuming you didn't really want this USE flag."
  52. einfo
  53. else
  54. linux-info_pkg_setup
  55. if ! linux_config_exists || ! linux_chkconfig_present CPUSETS; then
  56. einfo
  57. elog " Torque support for cpusets will require that you recompile"
  58. elog "your kernel with CONFIG_CPUSETS enabled."
  59. einfo
  60. fi
  61. USE_CPUSETS="--enable-cpuset"
  62. fi
  63. fi
  64. }
  65. src_prepare() {
  66. # Unused and causes breakage when switching from glibc to tirpc.
  67. # https://github.com/adaptivecomputing/torque/pull/148
  68. sed -i '/rpc\/rpc\.h/d' src/lib/Libnet/net_client.c || die
  69. # We install to a valid location, no need to muck with ld.so.conf
  70. # --without-loadlibfile is supposed to do this for us...
  71. sed -i '/mk_default_ld_lib_file || return 1/d' buildutils/pbs_mkdirs.in || die
  72. epatch "${FILESDIR}"/${P}-tcl8.6.patch
  73. # 524362
  74. epatch "${FILESDIR}"/TRQ-2885-limit-tm_adopt-to-only-adopt-a-session-id-t.patch
  75. #IPC_ISOLATION
  76. epatch "${FILESDIR}"/${P}-ipc-isolation.patch
  77. }
  78. src_configure() {
  79. local myconf="--with-rcp=mom_rcp"
  80. use crypt && myconf="--with-rcp=scp"
  81. econf \
  82. $(use_enable tk gui) \
  83. $(use_enable syslog) \
  84. $(use_enable server) \
  85. $(use_enable drmaa) \
  86. $(use_enable munge munge-library) \
  87. $(use_enable nvidia nvidia-gpus) \
  88. $(use_enable ipc-isolation) \
  89. --with-server-home=${PBS_SERVER_HOME} \
  90. --with-environ=/etc/pbs_environment \
  91. --with-default-server=${PBS_SERVER_NAME} \
  92. --disable-gcc-warnings \
  93. --with-tcp-retry-limit=2 \
  94. --without-loadlibfile \
  95. ${USE_CPUSETS} \
  96. ${myconf}
  97. }
  98. src_install() {
  99. local dir
  100. DOCS=( CHANGELOG README.* Release_Notes )
  101. use doc && DOCS+=( doc/admin_guide.ps doc/*.pdf )
  102. default
  103. # The build script isn't alternative install location friendly,
  104. # So we have to fix some hard-coded paths in tclIndex for xpbs* to work
  105. for file in $(find "${ED}" -iname tclIndex); do
  106. sed \
  107. -e "s/${ED//\// }/ /" \
  108. -i "${file}" || die
  109. done
  110. for dir in $(find "${ED}/${PBS_SERVER_HOME}" -type d); do
  111. keepdir "${dir#${ED}}"
  112. done
  113. if use server; then
  114. newinitd "${FILESDIR}"/pbs_server-init.d-munge pbs_server
  115. newinitd "${FILESDIR}"/pbs_sched-init.d pbs_sched
  116. fi
  117. newinitd "${FILESDIR}"/pbs_mom-init.d-munge pbs_mom
  118. newconfd "${FILESDIR}"/${PN}-conf.d-munge ${PN}
  119. newinitd "${FILESDIR}"/trqauthd-init.d trqauthd
  120. newenvd "${FILESDIR}"/${PN}-env.d 25${PN}
  121. }
  122. pkg_preinst() {
  123. if [[ -f "${ROOT}etc/pbs_environment" ]]; then
  124. cp "${ROOT}etc/pbs_environment" "${ED}"/etc/pbs_environment || die
  125. fi
  126. if use server && [[ -f "${ROOT}${PBS_SERVER_HOME}/server_priv/nodes" ]]; then
  127. cp \
  128. "${EROOT}${PBS_SERVER_HOME}/server_priv/nodes" \
  129. "${ED}/${PBS_SERVER_HOME}/server_priv/nodes" || die
  130. fi
  131. echo "${PBS_SERVER_NAME}" > "${ED}${PBS_SERVER_HOME}/server_name" || die
  132. # Fix up the env.d file to use our set server home.
  133. sed \
  134. -e "s:/var/spool/${PN}:${PBS_SERVER_HOME}:g" \
  135. -i "${ED}"/etc/env.d/25${PN} || die
  136. if use munge; then
  137. sed -i 's,\(PBS_USE_MUNGE=\).*,\11,' "${ED}"/etc/conf.d/${PN} || die
  138. fi
  139. }
  140. pkg_postinst() {
  141. elog " If this is the first time torque has been installed, then you are not"
  142. elog "ready to start the server. Please refer to the documentation located at:"
  143. elog "http://www.clusterresources.com/wiki/doku.php?id=torque:torque_wiki"
  144. echo ""
  145. elog " For a basic setup, you may use emerge --config ${PN}"
  146. echo ""
  147. if [[ -z "${REPLACING_VERSIONS}" ]] || [[ ${REPLACING_VERSIONS} < 4 ]]; then
  148. elog "Important 4.0+ updates"
  149. elog " - The on-wire protocol version has been changed."
  150. elog " Versions of Torque before 4.0.0 are no longer able to communicate."
  151. elog " - pbs_iff has been replaced by trqauthd, you will now need to add"
  152. elog " trqauthd to your default runlevel."
  153. fi
  154. }
  155. # root will be setup as the primary operator/manager, the local machine
  156. # will be added as a node and we'll create a simple queue, batch.
  157. pkg_config() {
  158. local h="$(echo "${ROOT}/${PBS_SERVER_HOME}" | sed 's:///*:/:g')"
  159. local rc=0
  160. ebegin "Configuring Torque"
  161. einfo "Using ${h} as the pbs homedir"
  162. einfo "Using ${PBS_SERVER_NAME} as the pbs_server"
  163. # Check for previous configuration and bail if found.
  164. if [ -e "${h}/server_priv/acl_svr/operators" ] \
  165. || [ -e "${h}/server_priv/nodes" ] \
  166. || [ -e "${h}/mom_priv/config" ]; then
  167. ewarn "Previous Torque configuration detected. Press Enter to"
  168. ewarn "continue or Control-C to abort now"
  169. read
  170. fi
  171. # pbs_mom configuration.
  172. echo "\$pbsserver ${PBS_SERVER_NAME}" > "${h}/mom_priv/config" || die
  173. echo "\$logevent 255" >> "${h}/mom_priv/config" || die
  174. if use server; then
  175. local qmgr="${EROOT}/usr/bin/qmgr -c"
  176. # pbs_server bails on repeated backslashes.
  177. if ! "${EROOT}"/usr/sbin/pbs_server -f -d "${h}" -t create; then
  178. eerror "Failed to start pbs_server"
  179. rc=1
  180. else
  181. ${qmgr} "set server operators = root@$(hostname -f)" ${PBS_SERVER_NAME} \
  182. && ${qmgr} "create queue batch" ${PBS_SERVER_NAME} \
  183. && ${qmgr} "set queue batch queue_type = Execution" ${PBS_SERVER_NAME} \
  184. && ${qmgr} "set queue batch started = True" ${PBS_SERVER_NAME} \
  185. && ${qmgr} "set queue batch enabled = True" ${PBS_SERVER_NAME} \
  186. && ${qmgr} "set server default_queue = batch" ${PBS_SERVER_NAME} \
  187. && ${qmgr} "set server resources_default.nodes = 1" ${PBS_SERVER_NAME} \
  188. && ${qmgr} "set server scheduling = True" ${PBS_SERVER_NAME} \
  189. || die
  190. "${EROOT}"/usr/bin/qterm -t quick ${PBS_SERVER_NAME} || rc=1
  191. # Add the local machine as a node.
  192. echo "$(hostname -f) np=1" > "${h}/server_priv/nodes" || die
  193. fi
  194. fi
  195. eend ${rc}
  196. }