commit:     70d25281d0c76654142dd60038b9b0a285455444
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 17 22:04:10 2023 +0000
Commit:     David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Fri Mar 17 22:04:10 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70d25281

cron.eclass: add EAPI 8

Signed-off-by: David Seifert <soap <AT> gentoo.org>

 eclass/cron.eclass | 85 ++++++++++++++++++++++++++----------------------------
 1 file changed, 41 insertions(+), 44 deletions(-)

diff --git a/eclass/cron.eclass b/eclass/cron.eclass
index 3198c181f21b..ebf8ea1e824a 100644
--- a/eclass/cron.eclass
+++ b/eclass/cron.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: cron.eclass
@@ -6,11 +6,11 @@
 # maintainer-nee...@gentoo.org
 # @AUTHOR:
 # Original Author: Aaron Walker <ka0t...@gentoo.org>
-# @SUPPORTED_EAPIS: 6 7
+# @SUPPORTED_EAPIS: 6 7 8
 # @BLURB: Some functions for cron
 # @DESCRIPTION:
 # Purpose: The main motivation for this eclass was to simplify
-# the jungle known as src_install() in cron ebuilds. Using these
+# the jungle known as src_install() in cron ebuilds.  Using these
 # functions also ensures that permissions are *always* reset,
 # preventing the accidental installation of files with wrong perms.
 #
@@ -18,26 +18,23 @@
 # chosen based on the most common setting among cron ebuilds.
 
 case ${EAPI} in
-       [67]) inherit eutils ;;
-       *) die "EAPI=${EAPI:-0} is not supported" ;;
+       6|7|8) ;;
+       *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
-inherit flag-o-matic
-
-EXPORT_FUNCTIONS pkg_postinst
-
 if [[ -z ${_CRON_ECLASS} ]]; then
 _CRON_ECLASS=1
 
-SLOT="0"
+inherit flag-o-matic
 
 RDEPEND=">=sys-process/cronbase-0.3.2"
-for pn in vixie-cron bcron cronie dcron fcron; do
-       [[ ${pn} == "${PN}" ]] || RDEPEND="${RDEPEND} !sys-process/${pn}"
+for pn in bcron cronie dcron fcron; do
+       [[ ${pn} == "${PN}" ]] || RDEPEND+=" !sys-process/${pn}"
 done
+unset pn
 
 # @FUNCTION: docrondir
-# @USAGE: [ dir ] [ perms ]
+# @USAGE: [dir] [perms]
 # @DESCRIPTION:
 # Creates crontab directory
 #
@@ -49,12 +46,13 @@ done
 #     docrondir -m0700 (uses default dir)
 docrondir() {
        # defaults
-       local perms="-m0750 -o 0 -g cron" dir="/var/spool/cron/crontabs"
+       local perms="-m0750 -o 0 -g cron"
+       local dir="/var/spool/cron/crontabs"
 
        if [[ -n $1 ]] ; then
-               case "$1" in
+               case $1 in
                        */*)
-                               dir=$1
+                               dir="$1"
                                shift
                                [[ -n $1 ]] && perms="$@"
                                ;;
@@ -64,15 +62,14 @@ docrondir() {
                esac
        fi
 
-       diropts ${perms}
-       keepdir ${dir}
-
-       # reset perms to default
-       diropts -m0755
+       (
+               diropts ${perms}
+               keepdir ${dir}
+       )
 }
 
 # @FUNCTION: docron
-# @USAGE: [ exe ] [ perms ]
+# @USAGE: [exe] [perms]
 # @DESCRIPTION:
 # Install cron executable
 #
@@ -81,40 +78,41 @@ docrondir() {
 # ex: docron -m 0700 -o 0 -g root ('exe' defaults to "cron")
 #     docron crond -m 0110
 docron() {
-       local cron="cron" perms="-m 0750 -o 0 -g wheel"
+       local cron="cron"
+       local perms="-m 0750 -o 0 -g wheel"
 
        if [[ -n $1 ]] ; then
-               case "$1" in
+               case $1 in
                        -*)
                                perms="$@"
                                ;;
                         *)
-                               cron=$1
+                               cron="$1"
                                shift
                                [[ -n $1 ]] && perms="$@"
                                ;;
                esac
        fi
 
-       exeopts ${perms}
-       exeinto /usr/sbin
-       doexe ${cron} || die "failed to install ${cron}"
-
-       # reset perms to default
-       exeopts -m0755
+       (
+               exeopts ${perms}
+               exeinto /usr/sbin
+               doexe ${cron}
+       )
 }
 
 # @FUNCTION: docrontab
-# @USAGE: [ exe ] [ perms ]
+# @USAGE: [exe] [perms]
 # @DESCRIPTION:
 # Install crontab executable
 #
 #   Uses same semantics as docron.
 docrontab() {
-       local crontab="crontab" perms="-m 4750 -o 0 -g cron"
+       local crontab="crontab"
+       local perms="-m 4750 -o 0 -g cron"
 
        if [[ -n $1 ]] ; then
-               case "$1" in
+               case $1 in
                        -*)
                                perms="$@"
                                ;;
@@ -126,15 +124,14 @@ docrontab() {
                esac
        fi
 
-       exeopts ${perms}
-       exeinto /usr/bin
-       doexe ${crontab} || die "failed to install ${crontab}"
-
-       # reset perms to default
-       exeopts -m0755
+       (
+               exeopts ${perms}
+               exeinto /usr/bin
+               doexe ${crontab}
+       )
 
        # users expect /usr/bin/crontab to exist...
-       if [[ "${crontab##*/}" != "crontab" ]] ; then
+       if [[ ${crontab##*/} != crontab ]] ; then
                dosym ${crontab##*/} /usr/bin/crontab || \
                        die "failed to create /usr/bin/crontab symlink"
        fi
@@ -145,9 +142,8 @@ docrontab() {
 # Outputs a message about system crontabs
 # daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
 cron_pkg_postinst() {
-       echo
        #  daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
-       if [ "${CRON_SYSTEM_CRONTAB:-no}" != "yes" ] ; then
+       if [[ ${CRON_SYSTEM_CRONTAB:-no} != yes ]] ; then
                einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} 
please run:"
                einfo " crontab /etc/crontab"
                einfo
@@ -158,7 +154,8 @@ cron_pkg_postinst() {
        einfo "You may wish to read the Gentoo Linux Cron Guide, which can be"
        einfo "found online at:"
        einfo "    https://wiki.gentoo.org/wiki/Cron";
-       echo
 }
 
 fi
+
+EXPORT_FUNCTIONS pkg_postinst

Reply via email to