/[gentoo-x86]/sys-apps/openrc/openrc-0.10.4.ebuild
Gentoo

Contents of /sys-apps/openrc/openrc-0.10.4.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Mon Jul 2 20:56:33 2012 UTC (10 months, 3 weeks ago) by williamh
Branch: MAIN
version bump

(Portage version: 2.2.0_alpha114/cvs/Linux i686)

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sys-apps/openrc/openrc-0.10.3.ebuild,v 1.1 2012/06/11 22:53:09 williamh Exp $
4
5 EAPI=4
6
7 EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/${PN}.git"
8 [[ ${PV} == "9999" ]] && SCM_ECLASS="git-2"
9 inherit eutils flag-o-matic multilib pam toolchain-funcs ${SCM_ECLASS}
10 unset SCM_ECLASS
11
12 DESCRIPTION="OpenRC manages the services, startup and shutdown of a host"
13 HOMEPAGE="http://www.gentoo.org/proj/en/base/openrc/"
14 if [[ ${PV} != "9999" ]] ; then
15 SRC_URI="mirror://gentoo/${P}.tar.bz2"
16 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
17 fi
18
19 LICENSE="BSD-2"
20 SLOT="0"
21 IUSE="debug elibc_glibc ncurses pam selinux static-libs unicode kernel_linux kernel_FreeBSD"
22
23 RDEPEND="virtual/init
24 kernel_FreeBSD? ( || ( >=sys-freebsd/freebsd-ubin-9.0_rc sys-process/fuser-bsd ) )
25 elibc_glibc? ( >=sys-libs/glibc-2.5 )
26 ncurses? ( sys-libs/ncurses )
27 pam? ( sys-auth/pambase )
28 >=sys-apps/baselayout-2.1-r1
29 kernel_linux? (
30 sys-process/psmisc
31 )
32 !<sys-fs/udev-133"
33 DEPEND="${RDEPEND}
34 virtual/os-headers"
35
36 make_args() {
37 unset LIBDIR #266688
38
39 MAKE_ARGS="${MAKE_ARGS} LIBNAME=$(get_libdir) LIBEXECDIR=/$(get_libdir)/rc"
40
41 local brand="Unknown"
42 if use kernel_linux ; then
43 MAKE_ARGS="${MAKE_ARGS} OS=Linux"
44 brand="Linux"
45 elif use kernel_FreeBSD ; then
46 MAKE_ARGS="${MAKE_ARGS} OS=FreeBSD"
47 brand="FreeBSD"
48 fi
49 if use selinux; then
50 MAKE_ARGS="${MAKE_ARGS} MKSELINUX=yes"
51 fi
52 export BRANDING="Gentoo ${brand}"
53 if ! use static-libs; then
54 MAKE_ARGS="${MAKE_ARGS} MKSTATICLIBS=no"
55 fi
56 }
57
58 pkg_setup() {
59 export DEBUG=$(usev debug)
60 export MKPAM=$(usev pam)
61 export MKTERMCAP=$(usev ncurses)
62 }
63
64 src_prepare() {
65 sed -i 's:0444:0644:' mk/sys.mk || die
66 sed -i "/^DIR/s:/openrc:/${PF}:" doc/Makefile || die #241342
67
68 if [[ ${PV} == "9999" ]] ; then
69 local ver="git-${EGIT_VERSION:0:6}"
70 sed -i "/^GITVER[[:space:]]*=/s:=.*:=${ver}:" mk/git.mk || die
71 fi
72
73 # Allow user patches to be applied without modifying the ebuild
74 epatch_user
75 }
76
77 src_compile() {
78 make_args
79
80 tc-export CC AR RANLIB
81 emake ${MAKE_ARGS}
82 }
83
84 # set_config <file> <option name> <yes value> <no value> test
85 # a value of "#" will just comment out the option
86 set_config() {
87 local file="${D}/$1" var=$2 val com
88 eval "${@:5}" && val=$3 || val=$4
89 [[ ${val} == "#" ]] && com="#" && val='\2'
90 sed -i -r -e "/^#?${var}=/{s:=([\"'])?([^ ]*)\1?:=\1${val}\1:;s:^#?:${com}:}" "${file}"
91 }
92
93 set_config_yes_no() {
94 set_config "$1" "$2" YES NO "${@:3}"
95 }
96
97 src_install() {
98 make_args
99 emake ${MAKE_ARGS} DESTDIR="${D}" install
100
101 # move the shared libs back to /usr so ldscript can install
102 # more of a minimal set of files
103 # disabled for now due to #270646
104 #mv "${D}"/$(get_libdir)/lib{einfo,rc}* "${D}"/usr/$(get_libdir)/ || die
105 #gen_usr_ldscript -a einfo rc
106 gen_usr_ldscript libeinfo.so
107 gen_usr_ldscript librc.so
108
109 if ! use kernel_linux; then
110 keepdir /$(get_libdir)/rc/init.d
111 fi
112 keepdir /$(get_libdir)/rc/tmp
113
114 # Backup our default runlevels
115 dodir /usr/share/"${PN}"
116 cp -PR "${D}"/etc/runlevels "${D}"/usr/share/${PN} || die
117 rm -rf "${D}"/etc/runlevels
118
119 # Install the default net configuration
120 doconfd conf.d/net
121
122 # Setup unicode defaults for silly unicode users
123 set_config_yes_no /etc/rc.conf unicode use unicode
124
125 # Cater to the norm
126 set_config_yes_no /etc/conf.d/keymaps windowkeys '(' use x86 '||' use amd64 ')'
127
128 # On HPPA, do not run consolefont by default (bug #222889)
129 if use hppa; then
130 rm -f "${D}"/usr/share/openrc/runlevels/boot/consolefont
131 fi
132
133 # Support for logfile rotation
134 insinto /etc/logrotate.d
135 newins "${FILESDIR}"/openrc.logrotate openrc
136
137 # install the gentoo pam.d file
138 newpamd "${FILESDIR}"/start-stop-daemon.pam start-stop-daemon
139 }
140
141 add_boot_init() {
142 local initd=$1
143 local runlevel=${2:-boot}
144 # if the initscript is not going to be installed and is not
145 # currently installed, return
146 [[ -e ${D}/etc/init.d/${initd} || -e ${ROOT}/etc/init.d/${initd} ]] \
147 || return
148 [[ -e ${ROOT}/etc/runlevels/${runlevel}/${initd} ]] && return
149
150 # if runlevels dont exist just yet, then create it but still flag
151 # to pkg_postinst that it needs real setup #277323
152 if [[ ! -d ${ROOT}/etc/runlevels/${runlevel} ]] ; then
153 mkdir -p "${ROOT}"/etc/runlevels/${runlevel}
154 touch "${ROOT}"/etc/runlevels/.add_boot_init.created
155 fi
156
157 elog "Auto-adding '${initd}' service to your ${runlevel} runlevel"
158 ln -snf /etc/init.d/${initd} "${ROOT}"/etc/runlevels/${runlevel}/${initd}
159 }
160 add_boot_init_mit_config() {
161 local config=$1 initd=$2
162 if [[ -e ${ROOT}${config} ]] ; then
163 if [[ -n $(sed -e 's:#.*::' -e '/^[[:space:]]*$/d' "${ROOT}"/${config}) ]] ; then
164 add_boot_init ${initd}
165 fi
166 fi
167 }
168
169 pkg_preinst() {
170 local f LIBDIR=$(get_libdir)
171
172 # default net script is just comments, so no point in biting people
173 # in the ass by accident. we save in preinst so that the package
174 # manager doesnt go throwing etc-update crap at us -- postinst is
175 # too late to prevent that. this behavior also lets us keep the
176 # file in the CONTENTS for binary packages.
177 [[ -e ${ROOT}/etc/conf.d/net ]] && cp "${ROOT}"/etc/conf.d/net "${D}"/etc/conf.d/
178
179 # avoid default thrashing in conf.d files when possible #295406
180 if [[ -e ${ROOT}/etc/conf.d/hostname ]] ; then
181 (
182 unset hostname HOSTNAME
183 source "${ROOT}"/etc/conf.d/hostname
184 : ${hostname:=${HOSTNAME}}
185 [[ -n ${hostname} ]] && set_config /etc/conf.d/hostname hostname "${hostname}"
186 )
187 fi
188
189 # upgrade timezone file ... do it before moving clock
190 if [[ -e ${ROOT}/etc/conf.d/clock && ! -e ${ROOT}/etc/timezone ]] ; then
191 (
192 unset TIMEZONE
193 source "${ROOT}"/etc/conf.d/clock
194 [[ -n ${TIMEZONE} ]] && echo "${TIMEZONE}" > "${ROOT}"/etc/timezone
195 )
196 fi
197
198 # /etc/conf.d/clock moved to /etc/conf.d/hwclock
199 local clock
200 use kernel_FreeBSD && clock="adjkerntz" || clock="hwclock"
201 if [[ -e ${ROOT}/etc/conf.d/clock ]] ; then
202 mv "${ROOT}"/etc/conf.d/clock "${ROOT}"/etc/conf.d/${clock}
203 fi
204 if [[ -e ${ROOT}/etc/init.d/clock ]] ; then
205 rm -f "${ROOT}"/etc/init.d/clock
206 fi
207 if [[ -L ${ROOT}/etc/runlevels/boot/clock ]] ; then
208 rm -f "${ROOT}"/etc/runlevels/boot/clock
209 ln -snf /etc/init.d/${clock} "${ROOT}"/etc/runlevels/boot/${clock}
210 fi
211 if [[ -L ${ROOT}${LIBDIR}/rc/init.d/started/clock ]] ; then
212 rm -f "${ROOT}${LIBDIR}"/rc/init.d/started/clock
213 ln -snf /etc/init.d/${clock} "${ROOT}${LIBDIR}"/rc/init.d/started/${clock}
214 fi
215
216 # /etc/conf.d/rc is no longer used for configuration
217 if [[ -e ${ROOT}/etc/conf.d/rc ]] ; then
218 elog "/etc/conf.d/rc is no longer used for configuration."
219 elog "Please migrate your settings to /etc/rc.conf as applicable"
220 elog "and delete /etc/conf.d/rc"
221 fi
222
223 # force net init.d scripts into symlinks
224 for f in "${ROOT}"/etc/init.d/net.* ; do
225 [[ -e ${f} ]] || continue # catch net.* not matching anything
226 [[ ${f} == */net.lo ]] && continue # real file now
227 [[ ${f} == *.openrc.bak ]] && continue
228 if [[ ! -L ${f} ]] ; then
229 elog "Moved net service '${f##*/}' to '${f##*/}.openrc.bak' to force a symlink."
230 elog "You should delete '${f##*/}.openrc.bak' if you don't need it."
231 mv "${f}" "${f}.openrc.bak"
232 ln -snf net.lo "${f}"
233 fi
234 done
235
236 # termencoding was added in 0.2.1 and needed in boot
237 has_version ">=sys-apps/openrc-0.2.1" || add_boot_init termencoding
238
239 # swapfiles was added in 0.9.9 and needed in boot (february 2012)
240 has_version ">=sys-apps/openrc-0.9.9" || add_boot_init swapfiles
241
242 # set default interactive shell to sulogin if it exists
243 set_config /etc/rc.conf rc_shell /sbin/sulogin "#" test -e /sbin/sulogin
244
245 has_version sys-apps/openrc || migrate_from_baselayout_1
246 has_version ">=sys-apps/openrc-0.4.0" || migrate_udev_init_script
247 }
248
249 # >=openrc-0.4.0 no longer loads the udev addon
250 migrate_udev_init_script() {
251 # make sure udev is in sysinit if it was enabled before
252 local enable_udev=false
253 local rc_devices=$(
254 [[ -f /etc/rc.conf ]] && source /etc/rc.conf
255 [[ -f /etc/conf.d/rc ]] && source /etc/conf.d/rc
256 echo "${rc_devices:-${RC_DEVICES:-auto}}"
257 )
258 case ${rc_devices} in
259 udev|auto)
260 enable_udev=true
261 ;;
262 esac
263
264 if $enable_udev; then
265 add_boot_init udev sysinit
266 add_boot_init udev-postmount default
267 fi
268 }
269
270 migrate_from_baselayout_1() {
271 # baselayout boot init scripts have been split out
272 for f in $(cd "${D}"/usr/share/${PN}/runlevels/boot || exit; echo *) ; do
273 # baselayout-1 is always "old" net, so ignore "new" net
274 [[ ${f} == "network" ]] && continue
275
276 add_boot_init ${f}
277 done
278
279 # Try to auto-add some addons when possible
280 add_boot_init_mit_config /etc/conf.d/cryptfs dmcrypt
281 add_boot_init_mit_config /etc/conf.d/dmcrypt dmcrypt
282 add_boot_init_mit_config /etc/mdadm.conf mdraid
283 add_boot_init_mit_config /etc/evms.conf evms
284 [[ -e ${ROOT}/sbin/dmsetup ]] && add_boot_init device-mapper
285 [[ -e ${ROOT}/sbin/vgscan ]] && add_boot_init lvm
286 elog "Add on services (such as RAID/dmcrypt/LVM/etc...) are now stand alone"
287 elog "init.d scripts. If you use such a thing, make sure you have the"
288 elog "required init.d scripts added to your boot runlevel."
289
290 # Upgrade our state for baselayout-1 users
291 if [[ ! -e ${ROOT}${LIBDIR}/rc/init.d/started ]] ; then
292 (
293 [[ -e ${ROOT}/etc/conf.d/rc ]] && source "${ROOT}"/etc/conf.d/rc
294 svcdir=${svcdir:-/var/lib/init.d}
295 if [[ ! -d ${ROOT}${svcdir}/started ]] ; then
296 ewarn "No state found, and no state exists"
297 elog "You should reboot this host"
298 else
299 mkdir -p "${ROOT}${LIBDIR}/rc/init.d"
300 einfo "Moving state from ${ROOT}${svcdir} to ${ROOT}${LIBDIR}/rc/init.d"
301 mv "${ROOT}${svcdir}"/* "${ROOT}${LIBDIR}"/rc/init.d
302 rm -rf "${ROOT}${LIBDIR}"/rc/init.d/daemons \
303 "${ROOT}${LIBDIR}"/rc/init.d/console
304 umount "${ROOT}${svcdir}" 2>/dev/null
305 rm -rf "${ROOT}${svcdir}"
306 fi
307 )
308 fi
309
310 # Handle the /etc/modules.autoload.d -> /etc/conf.d/modules transition
311 if [[ -d ${ROOT}/etc/modules.autoload.d ]] ; then
312 elog "Converting your /etc/modules.autoload.d/ files to /etc/conf.d/modules"
313 rm -f "${ROOT}"/etc/modules.autoload.d/.keep*
314 rmdir "${ROOT}"/etc/modules.autoload.d 2>/dev/null
315 if [[ -d ${ROOT}/etc/modules.autoload.d ]] ; then
316 local f v
317 for f in "${ROOT}"/etc/modules.autoload.d/* ; do
318 v=${f##*/}
319 v=${v#kernel-}
320 v=${v//[^[:alnum:]]/_}
321 gawk -v v="${v}" -v f="${f##*/}" '
322 BEGIN { print "\n### START: Auto-converted from " f "\n" }
323 {
324 if ($0 ~ /^[^#]/) {
325 print "modules_" v "=\"${modules_" v "} " $1 "\""
326 gsub(/[^[:alnum:]]/, "_", $1)
327 printf "module_" $1 "_args_" v "=\""
328 for (i = 2; i <= NF; ++i) {
329 if (i > 2)
330 printf " "
331 printf $i
332 }
333 print "\"\n"
334 } else
335 print
336 }
337 END { print "\n### END: Auto-converted from " f "\n" }
338 ' "${f}" >> "${D}"/etc/conf.d/modules
339 done
340 rm -f "${f}"
341 rmdir "${ROOT}"/etc/modules.autoload.d 2>/dev/null
342 fi
343 fi
344 }
345
346 pkg_postinst() {
347 local LIBDIR=$(get_libdir)
348
349 # Remove old baselayout links
350 rm -f "${ROOT}"/etc/runlevels/boot/{check{fs,root},rmnologin}
351 rm -f "${ROOT}"/etc/init.d/{depscan,runscript}.sh
352
353 # Make our runlevels if they don't exist
354 if [[ ! -e ${ROOT}/etc/runlevels ]] || [[ -e ${ROOT}/etc/runlevels/.add_boot_init.created ]] ; then
355 einfo "Copying across default runlevels"
356 cp -RPp "${ROOT}"/usr/share/${PN}/runlevels "${ROOT}"/etc
357 rm -f "${ROOT}"/etc/runlevels/.add_boot_init.created
358 else
359 if [[ ! -e ${ROOT}/etc/runlevels/sysinit/devfs ]] ; then
360 mkdir -p "${ROOT}"/etc/runlevels/sysinit
361 cp -RPp "${ROOT}"/usr/share/${PN}/runlevels/sysinit/* \
362 "${ROOT}"/etc/runlevels/sysinit
363 fi
364 if [[ ! -e ${ROOT}/etc/runlevels/shutdown/mount-ro ]] ; then
365 mkdir -p "${ROOT}"/etc/runlevels/shutdown
366 cp -RPp "${ROOT}"/usr/share/${PN}/runlevels/shutdown/* \
367 "${ROOT}"/etc/runlevels/shutdown
368 fi
369 fi
370
371 # /etc/conf.d/net.example is no longer valid
372 local NET_EXAMPLE="${ROOT}/etc/conf.d/net.example"
373 local NET_MD5='8ebebfa07441d39eb54feae0ee4c8210'
374 if [[ -e "${NET_EXAMPLE}" ]] ; then
375 if [[ $(md5sum "${NET_EXAMPLE}") == ${NET_MD5}* ]]; then
376 rm -f "${NET_EXAMPLE}"
377 elog "${NET_EXAMPLE} has been removed."
378 else
379 sed -i '1i# This file is obsolete.\n' "${NET_EXAMPLE}"
380 elog "${NET_EXAMPLE} should be removed."
381 fi
382 elog "The new file is ${ROOT}/usr/share/doc/${PF}/net.example"
383 fi
384
385 # /etc/conf.d/wireless.example is no longer valid
386 local WIRELESS_EXAMPLE="${ROOT}/etc/conf.d/wireless.example"
387 local WIRELESS_MD5='d1fad7da940bf263c76af4d2082124a3'
388 if [[ -e "${WIRELESS_EXAMPLE}" ]] ; then
389 if [[ $(md5sum "${WIRELESS_EXAMPLE}") == ${WIRELESS_MD5}* ]]; then
390 rm -f "${WIRELESS_EXAMPLE}"
391 elog "${WIRELESS_EXAMPLE} is deprecated and has been removed."
392 else
393 sed -i '1i# This file is obsolete.\n' "${WIRELESS_EXAMPLE}"
394 elog "${WIRELESS_EXAMPLE} is deprecated and should be removed."
395 fi
396 elog "If you are using the old style network scripts,"
397 elog "Configure wireless settings in ${ROOT}/etc/conf.d/net"
398 elog "after reviewing ${ROOT}/usr/share/doc/${PF}/net.example"
399 fi
400
401 if [[ -d ${ROOT}/etc/modules.autoload.d ]] ; then
402 ewarn "/etc/modules.autoload.d is no longer used. Please convert"
403 ewarn "your files to /etc/conf.d/modules and delete the directory."
404 fi
405
406 if use hppa; then
407 elog "Setting the console font does not work on all HPPA consoles."
408 elog "You can still enable it by running:"
409 elog "# rc-update add consolefont boot"
410 fi
411
412 # Handle the conf.d/local.{start,stop} -> local.d transition
413 if path_exists -o "${ROOT}"etc/conf.d/local.{start,stop} ; then
414 elog "Moving your ${ROOT}etc/conf.d/local.{start,stop}"
415 elog "files to ${ROOT}etc/local.d"
416 mv "${ROOT}"etc/conf.d/local.start "${ROOT}"etc/local.d/baselayout1.start
417 mv "${ROOT}"etc/conf.d/local.stop "${ROOT}"etc/local.d/baselayout1.stop
418 chmod +x "${ROOT}"etc/local.d/*{start,stop}
419 fi
420
421 if use kernel_linux && [[ "${ROOT}" = "/" ]]; then
422 if ! /$(get_libdir)/rc/sh/migrate-to-run.sh; then
423 ewarn "The dependency data could not be migrated to /run/openrc."
424 ewarn "This means you need to reboot your system."
425 fi
426 fi
427
428 # update the dependency tree after touching all files #224171
429 [[ "${ROOT}" = "/" ]] && "${ROOT}/${LIBDIR}"/rc/bin/rc-depend -u
430
431 elog "You should now update all files in /etc, using etc-update"
432 elog "or equivalent before restarting any services or this host."
433 elog
434 elog "Please read the migration guide available at:"
435 elog "http://www.gentoo.org/doc/en/openrc-migration.xml"
436 }

  ViewVC Help
Powered by ViewVC 1.1.13