1 |
Signed-off-by: David Seifert <soap@g.o> |
2 |
--- |
3 |
eclass/cron.eclass | 85 ++++++++++++++++++++++------------------------ |
4 |
1 file changed, 41 insertions(+), 44 deletions(-) |
5 |
|
6 |
diff --git a/eclass/cron.eclass b/eclass/cron.eclass |
7 |
index 3198c181f21b..ebf8ea1e824a 100644 |
8 |
--- a/eclass/cron.eclass |
9 |
+++ b/eclass/cron.eclass |
10 |
@@ -1,4 +1,4 @@ |
11 |
-# Copyright 1999-2022 Gentoo Authors |
12 |
+# Copyright 1999-2023 Gentoo Authors |
13 |
# Distributed under the terms of the GNU General Public License v2 |
14 |
|
15 |
# @ECLASS: cron.eclass |
16 |
@@ -6,11 +6,11 @@ |
17 |
# maintainer-needed@g.o |
18 |
# @AUTHOR: |
19 |
# Original Author: Aaron Walker <ka0ttic@g.o> |
20 |
-# @SUPPORTED_EAPIS: 6 7 |
21 |
+# @SUPPORTED_EAPIS: 6 7 8 |
22 |
# @BLURB: Some functions for cron |
23 |
# @DESCRIPTION: |
24 |
# Purpose: The main motivation for this eclass was to simplify |
25 |
-# the jungle known as src_install() in cron ebuilds. Using these |
26 |
+# the jungle known as src_install() in cron ebuilds. Using these |
27 |
# functions also ensures that permissions are *always* reset, |
28 |
# preventing the accidental installation of files with wrong perms. |
29 |
# |
30 |
@@ -18,26 +18,23 @@ |
31 |
# chosen based on the most common setting among cron ebuilds. |
32 |
|
33 |
case ${EAPI} in |
34 |
- [67]) inherit eutils ;; |
35 |
- *) die "EAPI=${EAPI:-0} is not supported" ;; |
36 |
+ 6|7|8) ;; |
37 |
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; |
38 |
esac |
39 |
|
40 |
-inherit flag-o-matic |
41 |
- |
42 |
-EXPORT_FUNCTIONS pkg_postinst |
43 |
- |
44 |
if [[ -z ${_CRON_ECLASS} ]]; then |
45 |
_CRON_ECLASS=1 |
46 |
|
47 |
-SLOT="0" |
48 |
+inherit flag-o-matic |
49 |
|
50 |
RDEPEND=">=sys-process/cronbase-0.3.2" |
51 |
-for pn in vixie-cron bcron cronie dcron fcron; do |
52 |
- [[ ${pn} == "${PN}" ]] || RDEPEND="${RDEPEND} !sys-process/${pn}" |
53 |
+for pn in bcron cronie dcron fcron; do |
54 |
+ [[ ${pn} == "${PN}" ]] || RDEPEND+=" !sys-process/${pn}" |
55 |
done |
56 |
+unset pn |
57 |
|
58 |
# @FUNCTION: docrondir |
59 |
-# @USAGE: [ dir ] [ perms ] |
60 |
+# @USAGE: [dir] [perms] |
61 |
# @DESCRIPTION: |
62 |
# Creates crontab directory |
63 |
# |
64 |
@@ -49,12 +46,13 @@ done |
65 |
# docrondir -m0700 (uses default dir) |
66 |
docrondir() { |
67 |
# defaults |
68 |
- local perms="-m0750 -o 0 -g cron" dir="/var/spool/cron/crontabs" |
69 |
+ local perms="-m0750 -o 0 -g cron" |
70 |
+ local dir="/var/spool/cron/crontabs" |
71 |
|
72 |
if [[ -n $1 ]] ; then |
73 |
- case "$1" in |
74 |
+ case $1 in |
75 |
*/*) |
76 |
- dir=$1 |
77 |
+ dir="$1" |
78 |
shift |
79 |
[[ -n $1 ]] && perms="$@" |
80 |
;; |
81 |
@@ -64,15 +62,14 @@ docrondir() { |
82 |
esac |
83 |
fi |
84 |
|
85 |
- diropts ${perms} |
86 |
- keepdir ${dir} |
87 |
- |
88 |
- # reset perms to default |
89 |
- diropts -m0755 |
90 |
+ ( |
91 |
+ diropts ${perms} |
92 |
+ keepdir ${dir} |
93 |
+ ) |
94 |
} |
95 |
|
96 |
# @FUNCTION: docron |
97 |
-# @USAGE: [ exe ] [ perms ] |
98 |
+# @USAGE: [exe] [perms] |
99 |
# @DESCRIPTION: |
100 |
# Install cron executable |
101 |
# |
102 |
@@ -81,40 +78,41 @@ docrondir() { |
103 |
# ex: docron -m 0700 -o 0 -g root ('exe' defaults to "cron") |
104 |
# docron crond -m 0110 |
105 |
docron() { |
106 |
- local cron="cron" perms="-m 0750 -o 0 -g wheel" |
107 |
+ local cron="cron" |
108 |
+ local perms="-m 0750 -o 0 -g wheel" |
109 |
|
110 |
if [[ -n $1 ]] ; then |
111 |
- case "$1" in |
112 |
+ case $1 in |
113 |
-*) |
114 |
perms="$@" |
115 |
;; |
116 |
*) |
117 |
- cron=$1 |
118 |
+ cron="$1" |
119 |
shift |
120 |
[[ -n $1 ]] && perms="$@" |
121 |
;; |
122 |
esac |
123 |
fi |
124 |
|
125 |
- exeopts ${perms} |
126 |
- exeinto /usr/sbin |
127 |
- doexe ${cron} || die "failed to install ${cron}" |
128 |
- |
129 |
- # reset perms to default |
130 |
- exeopts -m0755 |
131 |
+ ( |
132 |
+ exeopts ${perms} |
133 |
+ exeinto /usr/sbin |
134 |
+ doexe ${cron} |
135 |
+ ) |
136 |
} |
137 |
|
138 |
# @FUNCTION: docrontab |
139 |
-# @USAGE: [ exe ] [ perms ] |
140 |
+# @USAGE: [exe] [perms] |
141 |
# @DESCRIPTION: |
142 |
# Install crontab executable |
143 |
# |
144 |
# Uses same semantics as docron. |
145 |
docrontab() { |
146 |
- local crontab="crontab" perms="-m 4750 -o 0 -g cron" |
147 |
+ local crontab="crontab" |
148 |
+ local perms="-m 4750 -o 0 -g cron" |
149 |
|
150 |
if [[ -n $1 ]] ; then |
151 |
- case "$1" in |
152 |
+ case $1 in |
153 |
-*) |
154 |
perms="$@" |
155 |
;; |
156 |
@@ -126,15 +124,14 @@ docrontab() { |
157 |
esac |
158 |
fi |
159 |
|
160 |
- exeopts ${perms} |
161 |
- exeinto /usr/bin |
162 |
- doexe ${crontab} || die "failed to install ${crontab}" |
163 |
- |
164 |
- # reset perms to default |
165 |
- exeopts -m0755 |
166 |
+ ( |
167 |
+ exeopts ${perms} |
168 |
+ exeinto /usr/bin |
169 |
+ doexe ${crontab} |
170 |
+ ) |
171 |
|
172 |
# users expect /usr/bin/crontab to exist... |
173 |
- if [[ "${crontab##*/}" != "crontab" ]] ; then |
174 |
+ if [[ ${crontab##*/} != crontab ]] ; then |
175 |
dosym ${crontab##*/} /usr/bin/crontab || \ |
176 |
die "failed to create /usr/bin/crontab symlink" |
177 |
fi |
178 |
@@ -145,9 +142,8 @@ docrontab() { |
179 |
# Outputs a message about system crontabs |
180 |
# daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes" |
181 |
cron_pkg_postinst() { |
182 |
- echo |
183 |
# daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes" |
184 |
- if [ "${CRON_SYSTEM_CRONTAB:-no}" != "yes" ] ; then |
185 |
+ if [[ ${CRON_SYSTEM_CRONTAB:-no} != yes ]] ; then |
186 |
einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:" |
187 |
einfo " crontab /etc/crontab" |
188 |
einfo |
189 |
@@ -158,7 +154,8 @@ cron_pkg_postinst() { |
190 |
einfo "You may wish to read the Gentoo Linux Cron Guide, which can be" |
191 |
einfo "found online at:" |
192 |
einfo " https://wiki.gentoo.org/wiki/Cron" |
193 |
- echo |
194 |
} |
195 |
|
196 |
fi |
197 |
+ |
198 |
+EXPORT_FUNCTIONS pkg_postinst |
199 |
-- |
200 |
2.40.0 |