/[gentoo-alt]/trunk/eclass/cron.eclass
Gentoo

Contents of /trunk/eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 370 - (show annotations) (download)
Sat May 14 13:57:17 2005 UTC (9 years, 2 months ago) by flameeyes
File size: 3230 byte(s)
Added cron eclass fixed as per bug #92591.

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header$
4
5 # Original Author: Aaron Walker <ka0ttic@gentoo.org>
6 #
7 # Purpose: The main motivation for this eclass was to simplify
8 # the jungle known as src_install() in cron ebuilds. Using these
9 # functions also ensures that permissions are *always* reset,
10 # preventing the accidental installation of files with wrong perms.
11 #
12 # NOTE on defaults: the default settings in the below functions were
13 # chosen based on the most common setting among cron ebuilds.
14 #
15 # Please assign any bugs regarding this eclass to cron-bugs@gentoo.org.
16
17 inherit eutils flag-o-matic
18
19 ECLASS="cron"
20 INHERITED="$INHERITED $ECLASS"
21 EXPORT_FUNCTIONS pkg_postinst
22
23 SLOT="0"
24
25 DEPEND="${DEPEND}
26 virtual/libc
27 >=sys-apps/sed-4.0.5"
28
29 RDEPEND="${RDEPEND}
30 !virtual/cron
31 virtual/mta
32 >=sys-process/cronbase-0.2.1-r3"
33
34 PROVIDE="virtual/cron"
35
36 # docrondir [ dir ] [ perms ]
37 #
38 # Creates crontab directory
39 #
40 # Both arguments are optional. Everything after 'dir' is considered
41 # the permissions (same format as insopts).
42 #
43 # ex: docrondir /some/dir -m 0770 -o root -g cron
44 # docrondir /some/dir (uses default perms)
45 # docrondir -m0700 (uses default dir)
46
47 docrondir() {
48 # defaults
49 local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs"
50
51 if [[ -n "$1" ]] ; then
52 case "$1" in
53 */*)
54 dir="$1"
55 shift
56 [[ -n "$1" ]] && perms="$@"
57 ;;
58 *)
59 perms="$@"
60 ;;
61 esac
62 fi
63
64 diropts ${perms}
65 keepdir ${dir}
66
67 # reset perms to default
68 diropts -m0755
69 }
70
71 # docron [ exe ] [ perms ]
72 #
73 # Install cron executable
74 #
75 # Both arguments are optional.
76 #
77 # ex: docron -m 0700 -o root -g wheel ('exe' defaults to "cron")
78 # docron crond -m 0110
79
80 docron() {
81 local cron="cron" perms="-m 0750 -o root -g wheel"
82
83 if [[ -n "$1" ]] ; then
84 case "$1" in
85 -*)
86 perms="$@"
87 ;;
88 *)
89 cron="$1"
90 shift
91 [[ -n "$1" ]] && perms="$@"
92 ;;
93 esac
94 fi
95
96 exeopts ${perms}
97 exeinto /usr/sbin
98 doexe ${cron} || die "failed to install ${cron}"
99
100 # reset perms to default
101 exeopts -m0755
102 }
103
104 # docrontab [ exe ] [ perms ]
105 #
106 # Install crontab executable
107 #
108 # Uses same semantics as docron.
109
110 docrontab() {
111 local crontab="crontab" perms="-m 4750 -o root -g cron"
112
113 if [[ -n "$1" ]] ; then
114 case "$1" in
115 -*)
116 perms="$@"
117 ;;
118 *)
119 crontab="$1"
120 shift
121 [[ -n "$1" ]] && perms="$@"
122 ;;
123 esac
124 fi
125
126 exeopts ${perms}
127 exeinto /usr/bin
128 doexe ${crontab} || die "failed to install ${crontab}"
129
130 # reset perms to default
131 exeopts -m0755
132
133 # users expect /usr/bin/crontab to exist...
134 if [[ "${crontab##*/}" != "crontab" ]] ; then
135 dosym ${crontab##*/} /usr/bin/crontab || \
136 die "failed to create /usr/bin/crontab symlink"
137 fi
138 }
139
140 cron_pkg_postinst() {
141 echo
142 # vixie is the only daemon that has a true system crontab
143 if [[ "${PN}" != "vixie-cron" ]] ; then
144 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:"
145 einfo " crontab /etc/crontab"
146 einfo
147 einfo "!!! That will replace root's current crontab !!!"
148 einfo
149 fi
150
151 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be"
152 einfo "found online at:"
153 einfo " http://www.gentoo.org/doc/en/cron-guide.xml"
154 echo
155 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20