dev-lua/luarocks: version bump to 3.2.1
[gentoo.git] / sys-process / runit / runit-2.1.2.ebuild
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit toolchain-funcs flag-o-matic versionator
7
8 DESCRIPTION="A UNIX init scheme with service supervision"
9 HOMEPAGE="http://smarden.org/runit/"
10 SRC_URI="http://smarden.org/runit/${P}.tar.gz"
11
12 LICENSE="BSD"
13 SLOT="0"
14 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
15 IUSE="static"
16
17 S=${WORKDIR}/admin/${P}/src
18
19 src_prepare() {
20         # we either build everything or nothing static
21         sed -i -e 's:-static: :' Makefile
22
23         # see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=726008
24         [[ ${COMPILER} == "diet" ]] &&
25                 use ppc &&
26                 filter-flags "-mpowerpc-gpopt"
27 }
28
29 src_configure() {
30         use static && append-ldflags -static
31
32         echo "$(tc-getCC) ${CFLAGS}"  > conf-cc
33         echo "$(tc-getCC) ${LDFLAGS}" > conf-ld
34 }
35
36 src_install() {
37         into /
38         dobin $(<../package/commands)
39         dodir /sbin
40         mv "${ED}"/bin/{runit-init,runit,utmpset} "${ED}"/sbin/ || die "dosbin"
41         dosym ../etc/runit/2 /sbin/runsvdir-start
42         into /usr
43
44         cd ..
45         dodoc package/{CHANGES,README,THANKS,TODO}
46         dohtml doc/*.html
47         doman man/*.[18]
48
49 dodir /etc/runit
50         exeinto /etc/runit
51         doexe "${FILESDIR}"/{1,ctrlaltdel}
52         newexe "${FILESDIR}"/2-${PV} 2
53         newexe "${FILESDIR}"/3-${PV} 3
54
55         dodir /etc/sv
56         for tty in tty1 tty2 tty3 tty4 tty5 tty6; do
57                 exeinto /etc/sv/getty-$tty/
58                 newexe "${FILESDIR}"/finish.getty finish
59                 newexe "${FILESDIR}"/run.getty-${PV} run
60                 for script in finish run; do
61                         sed -i -e "s:TTY:${tty}:g" "${ED}"/etc/sv/getty-$tty/$script
62                 done
63         done
64
65         # make sv command work
66         cat <<-EOF > "${T}"/env.d
67                 #/etc/env.d/20runit
68                 SVDIR="/etc/service/"
69         EOF
70         insinto /etc/env.d
71         newins "${T}"/env.d 20runit
72 }
73
74 pkg_preinst() {
75         if has_version 'sys-process/runit' &&
76                 has_version '<sys-process/runit-2.1.2' &&
77                 [ -d "${EROOT}"etc/runit/runsvdir/all ]; then
78                 if [ -e "${EROOT}"etc/sv ]; then
79                         mv -f "${EROOT}"etc/sv "${EROOT}"etc/sv.bak || die
80                         ewarn "${EROOT}etc/sv was moved to ${EROOT}etc/sv.bak"
81                 fi
82                 mv "${EROOT}"etc/runit/runsvdir/all "${EROOT}"etc/sv|| die
83                 ln -sf "${EROOT}"etc/sv "${EROOT}"etc/runit/runsvdir/all || die
84                 cp -a "${EROOT}"etc/runit/runsvdir "${T}" || die
85                 touch "${T}"/make_var_service || die
86         fi
87 }
88
89 default_config() {
90         local sv="${EROOT}"etc/sv
91         local service="${EROOT}"etc/service
92         mkdir -p "${service}" || die
93         for x in tty1 tty2 tty3 tty4 tty5 tty6; do
94         ln -sf "${sv}"/getty-$x "${service}"/getty-$x || die
95         done
96         einfo "The links to services runit will supervise are installed"
97         einfo "in $service."
98         einfo "If you need multiple runlevels, please see the documentation"
99         einfo "for how to set them up."
100         einfo
101 }
102
103 migrate_from_211() {
104         # Create /etc/service and /var/service if requested
105         if [ -e "${T}"/make_var_service ]; then
106                 ln -sf "${EROOT}"etc/runit/runsvdir/current "${EROOT}"etc/service || die
107                 ln -sf "${EROOT}"etc/runit/runsvdir/current "${EROOT}"var/service || die
108         fi
109         if [ -d "${T}"/runsvdir ]; then
110                 cp -a "${T}"/runsvdir "${EROOT}"etc/runit || die
111         fi
112         return 0
113 }
114
115 pkg_postinst() {
116         if [ -z "$REPLACING_VERSIONS" ]; then
117                 default_config
118         elif [ ! version_is_at_least 2.1.2 $REPLACING_VERSIONS ]; then
119                 migrate_from_211
120         fi
121
122         ewarn "To make sure sv works correctly in your currently open"
123         ewarn "shells, please run the following command:"
124         ewarn
125         ewarn "source /etc/profile"
126         ewarn
127
128         if [ -L "${EROOT}"var/service ]; then
129                 ewarn "Once this version of runit is active, please remove the"
130                 ewarn "compatibility symbolic link at ${EROOT}var/service"
131                 ewarn "The correct path now is ${EROOT}etc/service"
132                 ewarn
133         fi
134
135         if [ -L "${EROOT}"etc/runit/runsvdir/all ]; then
136                 ewarn "${EROOT}etc/runit/runsvdir/all has moved to"
137                 iewarn "${EROOT}etc/sv."
138                 ewarn "Any symbolic links under ${EROOT}etc/runit/runsvdir"
139                 ewarn "which point to services through ../all should be updated to"
140                 ewarn "point to them through ${EROOT}etc/sv."
141                 ewarn "Once that is done, ${EROOT}etc/runit/runsvdir/all should be"
142                 ewarn "removed."
143                 ewarn
144         fi
145 }