fcron-3.1.2-r2.ebuild 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. WANT_AUTOMAKE=none
  5. inherit cron pam eutils flag-o-matic user autotools systemd
  6. MY_P=${P/_/-}
  7. DESCRIPTION="A command scheduler with extended capabilities over cron and anacron"
  8. HOMEPAGE="http://fcron.free.fr/"
  9. SRC_URI="http://fcron.free.fr/archives/${MY_P}.src.tar.gz"
  10. LICENSE="GPL-2"
  11. KEYWORDS="amd64 arm hppa ia64 ~mips ppc ~ppc64 sparc x86 ~x86-fbsd"
  12. IUSE="debug pam selinux l10n_fr +mta +system-crontab readline"
  13. DEPEND="selinux? ( sys-libs/libselinux )
  14. mta? ( virtual/mta )
  15. pam? ( virtual/pam )
  16. readline? ( sys-libs/readline:= )"
  17. RDEPEND="${DEPEND}
  18. >=app-misc/editor-wrapper-3
  19. pam? ( >=sys-auth/pambase-20100310 )"
  20. S="${WORKDIR}/${MY_P}"
  21. pkg_setup() {
  22. enewgroup fcron
  23. enewuser fcron -1 -1 -1 fcron
  24. rootuser=$(egetent passwd 0 | cut -d ':' -f 1)
  25. [[ ${rootuser} ]] || rootuser=root
  26. rootgroup=$(egetent group 0 | cut -d ':' -f 1)
  27. [[ ${rootgroup} ]] || rootgroup=root
  28. }
  29. src_prepare() {
  30. # respect LDFLAGS
  31. sed -i "s:\(@LIBS@\):\$(LDFLAGS) \1:" Makefile.in || die "sed failed"
  32. sed -i -e 's:/etc/fcrontab:/etc/fcron/fcrontab:' script/check_system_crontabs.sh || die
  33. epatch "${FILESDIR}"/${PN}-3.1.1-noreadline.patch
  34. eautoconf
  35. }
  36. src_configure() {
  37. local myconf
  38. # Don't try to pass --with-debug as it'll play with cflags as
  39. # well, and run foreground which is a _very_ nasty idea for
  40. # Gentoo.
  41. use debug && append-flags -DDEBUG
  42. # bindir is used just for calling fcronsighup
  43. econf \
  44. --with-cflags="${CFLAGS}" \
  45. --bindir=/usr/libexec \
  46. --sbindir=/usr/libexec \
  47. $(use_with pam) \
  48. $(use_with mta sendmail) \
  49. $(use_with selinux) \
  50. $(use_with readline) \
  51. --without-audit \
  52. --sysconfdir=/etc/fcron \
  53. --with-username=fcron \
  54. --with-groupname=fcron \
  55. --with-piddir=/var/run \
  56. --with-spooldir=/var/spool/fcron \
  57. --with-fifodir=/var/run \
  58. --with-fcrondyn=yes \
  59. --disable-checks \
  60. --with-editor=/usr/libexec/editor \
  61. --with-shell=/bin/sh \
  62. --without-db2man --without-dsssl-dir \
  63. --with-rootname=${rootuser} \
  64. --with-rootgroup=${rootgroup} \
  65. $(systemd_with_unitdir)
  66. }
  67. src_compile() {
  68. default
  69. # bug #216460
  70. sed -i \
  71. -e 's:/usr/local/etc/fcron:/etc/fcron/fcron:g' \
  72. -e 's:/usr/local/etc:/etc:g' \
  73. -e 's:/usr/local/:/usr/:g' \
  74. doc/*/*/*.{txt,1,5,8,html} \
  75. || die "unable to fix documentation references"
  76. }
  77. src_install() {
  78. keepdir /var/spool/fcron
  79. exeinto /usr/libexec
  80. doexe fcron fcronsighup
  81. dobin fcrondyn fcrontab
  82. insinto /etc/fcron
  83. doins files/fcron.{allow,deny,conf}
  84. if use system-crontab; then
  85. dosym fcrontab /usr/bin/crontab
  86. exeinto /usr/libexec
  87. newexe script/check_system_crontabs.sh check_system_crontabs
  88. insinto /etc/fcron
  89. newins "${FILESDIR}"/fcrontab.2 fcrontab
  90. fowners ${rootuser}:fcron /etc/fcron/fcrontab
  91. fperms 0640 /etc/fcron/fcrontab
  92. insinto /etc
  93. doins "${FILESDIR}"/crontab
  94. fi
  95. fowners fcron:fcron \
  96. /var/spool/fcron \
  97. /usr/bin/fcron{dyn,tab}
  98. # fcronsighup needs to be suid root, because it sends a HUP to the
  99. # running fcron daemon, but only has to be called by the fcron group
  100. # anyway
  101. fowners ${rootuser}:fcron \
  102. /usr/libexec/fcronsighup \
  103. /etc/fcron/fcron.{allow,deny,conf} \
  104. /etc/fcron
  105. fperms 6770 /var/spool/fcron
  106. fperms 6775 /usr/bin/fcron{dyn,tab}
  107. fperms 4710 /usr/libexec/fcronsighup
  108. fperms 0750 /etc/fcron
  109. fperms 0640 /etc/fcron/fcron.{allow,deny,conf}
  110. pamd_mimic system-services fcron auth account session
  111. cat > "${T}"/fcrontab.pam <<- EOF
  112. # Don't ask for the user's password; fcrontab will only allow to
  113. # change user if running as root.
  114. auth sufficient pam_permit.so
  115. # Still use the system-auth stack for account and session as the
  116. # sysadmin might have set up stuff properly, and also avoids
  117. # sidestepping limits (since fcrontab will run \$EDITOR).
  118. account include system-auth
  119. session include system-auth
  120. EOF
  121. newpamd "${T}"/fcrontab.pam fcrontab
  122. newinitd "${FILESDIR}"/fcron.init.3 fcron
  123. systemd_newunit "${S}/script/fcron.init.systemd" fcron.service
  124. dodoc MANIFEST VERSION "${FILESDIR}"/crontab \
  125. doc/en/txt/{readme,thanks,faq,todo,relnotes,changes}.txt
  126. newdoc files/fcron.conf fcron.conf.sample
  127. dohtml doc/en/HTML/*.html
  128. doman doc/en/man/*.{1,5,8}
  129. for lang in fr; do
  130. use l10n_${lang} || continue
  131. doman -i18n=${lang} doc/${lang}/man/*.{1,5,8} || die
  132. docinto html/${lang}
  133. dohtml doc/${lang}/HTML/*.html || die
  134. done
  135. }
  136. pkg_postinst() {
  137. elog "If it's the first time you install fcron make sure to execute"
  138. elog " emerge --config ${CATEGORY}/${PN}"
  139. elog "to configure the proper settings."
  140. if ! use system-crontab; then
  141. echo ""
  142. ewarn "Remember that fcron will *not* use /etc/cron.d in this configuration"
  143. echo ""
  144. fi
  145. }
  146. pkg_config() {
  147. if [[ $(fcrontab -l -u systab 2>/dev/null) ]]; then
  148. eerror "We're not going to make any change to your systab as long as"
  149. eerror "it contains data; please clear it before proceeding."
  150. return 1
  151. fi
  152. if use system-crontab; then
  153. elog "This is going to set up fcron to execute check_system_crontabs."
  154. elog "In this configuration, you're no longer free to edit the systab"
  155. elog "at your leisure, as it'll be rewritten the moment the crontabs"
  156. elog "are modified."
  157. /usr/libexec/check_system_crontabs -v -i -f
  158. else
  159. elog "This is going to set up fcron to set up a default systab that"
  160. elog "executes /etc/cron.{hourly,daily,weekly,monthly}."
  161. fcrontab -u systab - <<- EOF
  162. 0 * * * * rm -f /var/spool/cron/lastrun/cron.hourly
  163. 1 3 * * * rm -f /var/spool/cron/lastrun/cron.daily
  164. 15 4 * * 6 rm -f /var/spool/cron/lastrun/cron.weekly
  165. 30 5 1 * * rm -f /var/spool/cron/lastrun/cron.monthly
  166. EOF
  167. fi
  168. }