/[gentoo-x86]/eclass/cron.eclass
Gentoo

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations) (download)
Wed Apr 20 17:49:19 2011 UTC (7 years, 7 months ago) by ulm
Branch: MAIN
Changes since 1.12: +7 -5 lines
Don't PROVIDE virtual/cron, bug 360109.
Replace blocker against virtual/cron by explicit blockers against packages.

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

  ViewVC Help
Powered by ViewVC 1.1.20