Magellan Linux

Contents of /smage/trunk/core/systemd/systemd-195-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4206 - (show annotations) (download)
Fri Nov 9 10:48:00 2012 UTC (11 years, 7 months ago) by niro
File size: 20056 byte(s)
-parallel make install sometimes fails
1 # $Id$
2
3 PNAME="systemd"
4 PVER="195"
5 PBUILD="r1"
6
7 SPLIT_PACKAGES="libudev libudev-dev libgudev libgudev-dev udev udev-dev systemd systemd-dev systemd-tools"
8
9 PCAT="sys-apps"
10 HOMEPAGE="http://www.freedesktop.org/wiki/Software/systemd"
11
12 # enable or disable sysvinit support
13 # 1=yes, 0=no
14 SYSVINIT_SUPPORT=0
15
16 # enable or disable busybox support
17 # 1=yes, 0=no
18 BUSYBOX_SUPPORT=0
19
20 # disable gtk until build with libgee is fixed
21 # 1=yes, 0=no
22 ENABLE_GTK=0
23
24 # export this variables for preinstall
25 SPECIAL_VARS="SYSVINIT_SUPPORT BUSYBOX_SUPPORT"
26
27 GLIB2_DEPEND=">= dev-libs/glib2-2.34"
28 GLIBC_DEPEND=">= virtual/glibc"
29 COMMON_DEPEND="${GLIBC_DEPEND}
30 ${GLIB2_DEPEND}
31 >= virtual/sysvinit-tools
32 >= sys-apps/kmod-9"
33
34 LIBUDEV_DEPEND="${GLIBC_DEPEND}"
35 LIBGUDEV_DEPEND="${GLIBC_DEPEND}
36 ${GLIB2_DEPEND}"
37
38 # only /etc/os-release is supported from now on
39 SYSTEMD_DEPEND="${COMMON_DEPEND}
40 >= sys-apps/mage-release-1
41 >= sys-apps/dbus-1.6
42 >= dev-libs/dbus-glib-0.100
43 >= dev-libs/libgee-0.8
44 >= net-dns/nss-myhostname-0.3
45 >= virtual/xz-utils
46 >= sys-libs/libcap-2.22
47 >= virtual/shadow"
48
49 TOOLS_DEPEND=">= dev-python/dbus-python-1.1
50 >= sys-apps/polkit-0.107"
51
52 UDEV_DEPEND="${COMMON_DEPEND}
53 >= dev-libs/libusb-compat-0.1.4
54 >= virtual/usbutils
55 >= virtual/pciutils
56 >= sys-libs/libuuid-2.22"
57
58 if [[ ${ENABLE_GTK} = 1 ]]
59 then
60 TOOLS_DEPEND="${TOOLS_DEPEND}
61 >= x11-libs/gtk2+-2.24
62 >= dev-libs/libgee-0.8"
63 fi
64
65 # busybox supports requires sysvinit support
66 if [[ ${BUSYBOX_SUPPORT} = 1 ]]
67 then
68 [[ ${SYSVINIT_SUPPORT} != 1 ]] && SYSVINIT_SUPPORT=1
69 fi
70
71 if [[ ${SYSVINIT_SUPPORT} = 1 ]]
72 then
73 SYSTEMD_DEPEND="${SYSTEMD_DEPEND}
74 >= sys-apps/sysvinit-2.88"
75 fi
76
77 SDEPEND="${LIBUDEV_DEPEND}
78 ${LIBGUDEV_DEPEND}
79 ${SYSTEMD_DEPEND}
80 ${TOOLS_DEPEND}
81 ${UDEV_DEPEND}
82 >= app-crypt/libgcrypt-1.5
83 >= app-text/docbook-xsl-stylesheets-1.76
84 >= dev-libs/libcgroup-0.38
85 >= dev-libs/libxslt-1.1.26
86 >= dev-lang/vala-0.18
87 >= dev-util/intltool-0.50
88 >= dev-util/gperf-3
89 >= virtual/kernel-headers
90 >= x11-libs/libnotify-0.7"
91
92 SRCFILE="${PNAME}-${PVER}.tar.xz"
93 SRCDIR="${BUILDDIR}/${PNAME}-${PVER}"
94
95 UDEV_CONFIG_PVER="185-r4"
96 UDEV_CONFIG_SRCFILE="config-udev-${UDEV_CONFIG_PVER}.tar.bz2"
97 UDEV_CONFIG_SRCDIR="${BUILDDIR}/config-udev-${UDEV_CONFIG_PVER}"
98
99 if [[ ${ENABLE_GTK} = 1 ]]
100 then
101 UI_PVER="1"
102 UI_SRCFILE="${PNAME}-ui-${UI_PVER}.tar.xz"
103 UI_SRCDIR="${BUILDDIR}/${PNAME}-ui-${PVER}"
104 fi
105
106 sminclude mtools multilib cleanutils
107 msetfeature "!check"
108
109 SRC_URI=(
110 http://www.freedesktop.org/software/${PNAME}/${SRCFILE}
111 mirror://${PNAME}/${SRCFILE}
112 mirror://udev/${UDEV_CONFIG_SRCFILE}
113 mirror://${PNAME}/${PNAME}-188-magellan.patch
114 mirror://${PNAME}/${PNAME}-188-magellan-configurable-getty.patch
115 mirror://${PNAME}/login-manager.pamd
116 )
117
118 if [[ ${ENABLE_GTK} = 1 ]]
119 then
120 SRC_URI+=( http://www.freedesktop.org/software/${PNAME}/${UI_SRCFILE} )
121 fi
122
123 UP2DATE="updatecmd http://www.freedesktop.org/software/systemd/ | grep ${PNAME}-[0-9] | lasttarball xz"
124
125 split_info_libudev()
126 {
127 DESCRIPTION="Dynamic library to access udev device information."
128 DEPEND="${LIBUDEV_DEPEND}"
129 PCAT="sys-fs"
130 }
131
132 split_info_libudev-dev()
133 {
134 DESCRIPTION="Development files for libudev."
135 DEPEND="== sys-fs/libudev-${PVER}"
136 PCAT="sys-fs"
137 }
138
139 split_info_libgudev()
140 {
141 DESCRIPTION="Libraries for adding libudev support to applications that use glib2."
142 DEPEND="${LIBGUDEV_DEPEND}
143 == sys-fs/libudev-${PVER}"
144 PCAT="sys-fs"
145 }
146
147 split_info_libgudev-dev()
148 {
149 DESCRIPTION="Development files for libgudev."
150 DEPEND="== sys-fs/libgudev-${PVER}"
151 PCAT="sys-fs"
152 }
153
154 split_info_udev()
155 {
156 DESCRIPTION="A Userspace Implementation for dynamic /dev nodes."
157 DEPEND="${UDEV_DEPEND}
158 == sys-fs/libudev-${PVER}
159 == sys-fs/libgudev-${PVER}"
160 PCAT="sys-fs"
161 }
162
163 split_info_udev-dev()
164 {
165 DESCRIPTION="Development files for udev."
166 DEPEND="== sys-fs/udev-${PVER}"
167 PCAT="sys-fs"
168 }
169
170 split_info_systemd()
171 {
172 DESCRIPTION="System and Session Manager."
173 DEPEND="${SYSTEMD_DEPEND}
174 == sys-fs/udev-${PVER}"
175 # systemd >=195 provides now full syslog facilities
176 PROVIDE="virtual/syslog"
177 }
178
179 split_info_systemd-dev()
180 {
181 DESCRIPTION="Development files for systemd."
182 DEPEND="== sys-fs/systemd-${PVER}"
183 }
184
185 split_info_systemd-tools()
186 {
187 local gtkdesc
188 [[ ${ENABLE_GTK} = 1 ]] && gtkdesc="for gtk2/gnome and "
189
190 DESCRIPTION="Systemd utilites ${gtkdesc}for analysing the boot process."
191 DEPEND="== sys-apps/systemd-${PVER}
192 ${TOOLS_DEPEND}"
193 }
194
195 src_prepare()
196 {
197 munpack ${SRCFILE} || die
198 oldmunpack ${UDEV_CONFIG_SRCFILE} || die
199 if [[ ${ENABLE_GTK} = 1 ]]
200 then
201 SRCDIR="${UI_SRCDIR}" munpack ${UI_SRCFILE} || die
202 fi
203
204 # apply our magellan patch
205 mpatch ${PNAME}-188-magellan.patch || die
206
207 # magellan-only: use a configurable getty
208 mpatch ${PNAME}-188-magellan-configurable-getty.patch || die
209
210 # fix rootlink install location
211 sed -i "s:^\(udevdir=\).*:\1/usr/lib/udev:" ${UDEV_CONFIG_SRCDIR}/Makefile || die
212
213 # regen configure
214 mautoreconf || die
215 }
216
217 src_compile()
218 {
219 # disable plymouth in configure, to drop the .wants/ symlinks
220 # which are provided now by the plymouth package itself (>=plymouth-0.8.5.1)
221 mconfigure \
222 --with-distro=magellan \
223 --libexecdir=/usr/lib \
224 --localstatedir=/var \
225 --with-pamlibdir=/usr/'$(mlibdir)'/security \
226 --disable-ima \
227 --disable-audit \
228 --disable-selinux \
229 --disable-plymouth \
230 --disable-qrencode \
231 --disable-pam \
232 --disable-tcpwrap \
233 --disable-xz \
234 --disable-acl \
235 --disable-libcryptsetup \
236 --enable-gudev \
237 --disable-introspection \
238 --with-pci-ids-path=no \
239 --with-usb-ids-path=no \
240 --with-firmware-path=/usr/lib/firmware/updates:/usr/lib/firmware:/lib/firmware/updates:/lib/firmware \
241 || die
242
243 mmake || die
244
245 if [[ ${ENABLE_GTK} = 1 ]]
246 then
247 SRCDIR="${UI_SRCDIR}" mconfigure || die
248 SRCDIR="${UI_SRCDIR}" mmake || die
249 fi
250 }
251
252 src_install_systemd()
253 {
254 mmake -j1 DESTDIR=${BINDIR} install || die
255 if [[ ${ENABLE_GTK} = 1 ]]
256 then
257 SRCDIR="${UI_SRCDIR}" mmake DESTDIR=${BINDIR} install || die
258 fi
259
260 # keep some directories
261 mkeepdir /run || die
262 mkeepdir /etc/modules-load.d || die
263 mkeepdir /etc/sysctl.d || die
264 mkeepdir /etc/tmpfiles.d || die
265 mkeepdir /etc/binfmt.d || die
266
267 # make sure the shutdown/sleep drop-in dirs exist
268 mkeepdir /usr/lib/systemd/system-shutdown || die
269 mkeepdir /usr/lib/systemd/system-sleep || die
270
271 if [[ ${SYSVINIT_SUPPORT} != 1 ]]
272 then
273 echo "Include SysV init Compat symlinks"
274 # create SysV compatibility symlinks. systemctl/systemd are smart
275 # enough to detect in which way they are called.
276 minstalldir /usr/sbin || die
277 mlink ../lib/systemd/systemd /usr/sbin/init || die
278 local i
279 for i in reboot halt poweroff shutdown telinit runlevel
280 do
281 mlink ../bin/systemctl /usr/sbin/${i} || die
282 done
283 else
284 echo "Using sysvinit package for SysV compat"
285 fi
286
287 # do not package the kernel.core_pattern setting until systemd-coredump
288 # is a part of an actual systemd release and it's made clear how to get
289 # the core dumps out of the journal
290 rm ${BINDIR}/usr/lib/sysctl.d/coredump.conf || die
291 rm -r ${BINDIR}/usr/lib/sysctl.d || die
292
293 # we create all wants links manually at installation time to make sure
294 # they are not owned and hence overriden by mage after the user deleted
295 # them.
296 rm -r ${BINDIR}/etc/systemd/system/*.target.wants || die
297 # but make sure these directories are properly owned
298 mkeepdir /usr/lib/systemd/system/basic.target.wants || die
299 mkeepdir /usr/lib/systemd/system/default.target.wants || die
300 mkeepdir /usr/lib/systemd/system/dbus.target.wants || die
301 mkeepdir /usr/lib/systemd/system/syslog.target.wants || die
302 # make sure the user generators dir exists too
303 mkeepdir /usr/lib/systemd/user-generators || die
304 mkeepdir /usr/lib/systemd/system-generators || die
305
306 # login-manager pam policy - force register kdm, gdm etc with pam_systemd
307 all-abis minstallpam login-manager.pamd login-manager || die
308
309 # do not bother with non-existend services, mask them
310 mlink /dev/null /etc/systemd/system/syslog.service || die
311 mlink /dev/null /etc/systemd/system/rc-local.service || die
312 mlink /dev/null /etc/systemd/system/auditd.service || die
313
314 # we have no rpm, remove config macros
315 mdelete -r /etc/rpm || die
316
317 minstalldocs DISTRO_PORTING LICENSE README TODO || die
318
319 # remove files which are owned by other packages
320 if [[ ${ENABLE_GTK} = 1 ]]
321 then
322 mdelete /usr/bin/systemadm || die
323 mdelete /usr/bin/systemd-gnome-ask-password-agent || die
324 mdelete /usr/share/man/man1/systemadm.\* || die
325 fi
326 mdelete /usr/bin/systemd-analyze || die
327 mdelete -r /etc/udev || die
328 mdelete /usr/bin/udevadm || die
329 mdelete /usr/include/libudev.h || die
330 mdelete -r /usr/include/gudev-1.0 || die
331 mdelete /usr/lib/systemd/systemd-udevd || die
332 mdelete /usr/lib/systemd/system/systemd-udevd-control.socket || die
333 mdelete /usr/lib/systemd/system/systemd-udevd-kernel.socket || die
334 mdelete /usr/lib/systemd/system/systemd-udevd.service || die
335 mdelete /usr/lib/systemd/system/systemd-udev-settle.service || die
336 mdelete /usr/lib/systemd/system/systemd-udev-trigger.service || die
337 mdelete -r /usr/lib/udev || die
338 rm ${BINDIR}/usr/$(mlibdir)/libgudev* || die
339 rm ${BINDIR}/usr/$(mlibdir)/libudev* || die
340 mdelete -r /usr/$(mlibdir)/girepository-1.0 || die
341 mdelete /usr/$(mlibdir)/pkgconfig/gudev-1.0.pc || die
342 mdelete /usr/$(mlibdir)/pkgconfig/libudev.pc || die
343 if [[ $(mlibdir) != lib ]]
344 then
345 rm ${BINDIR}/usr/lib/libgudev* || die
346 rm ${BINDIR}/usr/lib/libudev* || die
347 mdelete -r /usr/lib/girepository-1.0 || die
348 mdelete /usr/lib/pkgconfig/gudev-1.0.pc || die
349 mdelete /usr/lib/pkgconfig/libudev.pc || die
350 fi
351 mdelete -r /usr/share/gir-1.0 || die
352 mdelete /usr/share/man/man7/udev.7 || die
353 mdelete /usr/share/man/man8/systemd-udevd.8 || die
354 mdelete /usr/share/man/man8/udevadm.8 || die
355 mdelete /usr/share/pkgconfig/udev.pc || die
356
357 # install udev rule for systemd
358 minstalludevrule rules/99-systemd.rules || die
359 }
360
361 src_install_systemd-tools()
362 {
363 cd ${SRCDIR}
364 if [[ ${ENABLE_GTK} = 1 ]]
365 then
366 all-abis minstallexec systemadm || die
367 all-abis minstallexec systemd-gnome-ask-password-agent || die
368 all-abis minstallman man/systemadm.1 || die
369 fi
370 all-abis minstallexec src/analyze/systemd-analyze || die
371 }
372
373 src_install_libudev()
374 {
375 mmake -j1 DESTDIR=${BINDIR} install || die
376
377 # cleanup all files but the libudev owned ones
378 zapmost ${BINDIR} \
379 usr/include/libudev.h \
380 usr/$(mlibdir)/libudev\* \
381 usr/$(mlibdir)/pkgconfig/libudev.pc \
382 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libudev*') \
383 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/pkgconfig/libudev.pc') \
384 || die
385 }
386
387 src_install_libgudev()
388 {
389 mmake -j1 DESTDIR=${BINDIR} install || die
390
391 # cleanup all files but the libgudev owned ones
392 zapmost ${BINDIR} \
393 usr/include/gudev-1.0 \
394 usr/$(mlibdir)/libgudev\* \
395 usr/$(mlibdir)/girepository-1.0 \
396 usr/$(mlibdir)/pkgconfig/gudev-1.0.pc \
397 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libgudev*') \
398 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/girepository-1.0') \
399 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/pkgconfig/gudev-1.0.pc') \
400 usr/share/gir-1.0 \
401 || die
402
403 }
404
405 src_install_udev()
406 {
407 mmake -j1 DESTDIR=${BINDIR} install || die
408
409 # cleanup all files but the udev owned ones
410 zapmost ${BINDIR} \
411 etc/udev \
412 usr/bin/udevadm \
413 usr/lib/systemd/systemd-udevd \
414 usr/lib/systemd/system/systemd-udevd-control.socket \
415 usr/lib/systemd/system/systemd-udevd-kernel.socket \
416 usr/lib/systemd/system/systemd-udevd.service \
417 usr/lib/systemd/system/systemd-udev-settle.service \
418 usr/lib/systemd/system/systemd-udev-trigger.service \
419 usr/lib/udev \
420 usr/share/man/man7/udev.7 \
421 usr/share/man/man8/systemd-udevd.8 \
422 usr/share/man/man8/udevadm.8 \
423 usr/share/pkgconfig/udev.pc \
424 || die
425
426 # remove udev rule for systemd
427 mdelete /usr/lib/udev/rules.d/99-systemd.rules || die
428
429 minstalldocs LICENSE* NEWS README TODO || die
430
431 # install our config
432 cd ${UDEV_CONFIG_SRCDIR}
433 make DESTDIR=${BINDIR} install || die
434 if [[ ${SYSVINIT_SUPPORT} = 1 ]]
435 then
436 # install sysvinit rc. script
437 make DESTDIR=${BINDIR} install-sysvinit || die
438 fi
439
440 # create symlinks for these utilities to /sbin
441 minstalldir /usr/sbin || die
442 # where multipath-tools expect them to be
443 mlink ../lib/udev/scsi_id /usr/sbin/ || die
444
445 # mark some dirs undeletable
446 mkeepdir /etc/udev/rules.d || die
447 mkeepdir /usr/lib/udev/state || die
448
449 # CONFIG_PROTECT_MASK for /etc/udev/rules.d
450 minstalldir /etc/env.d || die
451 echo "CONFIG_PROTECT_MASK=\"/etc/udev/rules.d\"" > ${BINDIR}/etc/env.d/02udev || die
452 }
453
454 preinstall_udev()
455 {
456 add_conf_prot_mask /etc/udev /etc/env.d /etc/rc.d/init.d /etc/modprobe.d
457
458 if [[ ! -z $(magequery -n hotplug) ]]
459 then
460 echo -e ${COLRED}
461 echo -e "Error: sys-apps/hotplug is installed!!"
462 echo -e "hotplug is now fully provided by udev itself and it is not recommend to use this anymore."
463 echo -e "Please uninstall sys-apps/hotplug first!"
464 echo -e ${COLDEFAULT}
465 die "sys-apps/hotplug found!"
466 fi
467
468 # move udev state
469 if [ ! -L ${MROOT}/lib ]
470 then
471 if [[ -d ${MROOT}/lib/udev-state ]]
472 then
473 mv -f ${MROOT}/lib/udev-state/* ${MROOT}/usr/lib/udev/state/
474 rm -r ${MROOT}/lib/udev-state
475 fi
476 if [[ -d ${MROOT}/lib/udev/state ]]
477 then
478 mv -f ${MROOT}/lib/udev/state/* ${MROOT}/usr/lib/udev/state/
479 rm -r ${MROOT}/lib/udev/state
480 fi
481 fi
482
483 # remove deprecated udev devices dir
484 if [[ -d ${MROOT}/lib/udev/devices ]]
485 then
486 rm -r ${MROOT}/lib/udev/devices
487 fi
488 if [[ -d ${MROOT}/usr/lib/udev/devices ]]
489 then
490 rm -r ${MROOT}/usr/lib/udev/devices
491 fi
492
493 if [[ -f ${MROOT}/etc/udev/udev.config ]] &&
494 [[ ! -f ${MROOT}/etc/udev/udev.rules ]]
495 then
496 mv -f ${MROOT}/etc/udev/udev.config ${MROOT}/etc/udev/udev.rules
497 fi
498
499 # delete the old udev.hotplug symlink if it is present
500 if [[ -h ${MROOT}/etc/hotplug.d/default/udev.hotplug ]]
501 then
502 rm -f ${MROOT}/etc/hotplug.d/default/udev.hotplug
503 fi
504
505 # delete the old wait_for_sysfs.hotplug symlink if it is present
506 if [[ -h ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]]
507 then
508 rm -f ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
509 fi
510
511 # delete the old 10-udev.hotplug symlink if it is present
512 if [[ -h ${MROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
513 then
514 rm -f ${MROOT}/etc/hotplug.d/default/10-udev.hotplug
515 fi
516
517 # delete the deprectated udev-late rc-script
518 [[ -x ${MROOT}/sbin/rc-config ]] && ${MROOT}/sbin/rc-config del udev-late
519
520 # delete obsolete hotplug.dev script
521 if [[ -f ${MROOT}/etc/dev.d/net/hotplug.dev ]]
522 then
523 rm -f ${MROOT}/etc/dev.d/net/hotplug.dev
524 fi
525
526 # delete deprecated pnp-aliases
527 if [[ -f ${MROOT}/etc/modprobe.d/pnp-aliases ]]
528 then
529 rm -f ${MROOT}/etc/modprobe.d/pnp-aliases
530 fi
531
532 # delete deprecated blacklist
533 if [[ -f ${MROOT}/etc/udev/blacklist ]]
534 then
535 rm -f ${MROOT}/etc/udev/blacklist
536 fi
537
538 # delete all udev.rules which are moved from /etc/udev to /lib/udev
539 local rule
540 for rule in 40-arch-s390.rules \
541 61-persistent-storage-edd.rules \
542 75-persistent-net-generator.rules \
543 64-md-raid.rules \
544 65-permissions.rules \
545 64-device-mapper.rules \
546 40-alsa.rules \
547 40-zaptel.rules \
548 60-persistent-input.rules \
549 40-arch-ia64.rules \
550 05-udev-early.rules \
551 40-arch-ppc.rules \
552 60-cdrom_id.rules \
553 40-pilot-links.rules \
554 95-udev-late.rules \
555 40-magellan.rules \
556 50-udev-default.rules \
557 80-drivers.rules \
558 30-kernel-compat.rules \
559 40-video.rules \
560 60-persistent-storage-tape.rules \
561 75-cd-aliases-generator.rules \
562 60-persistent-storage.rules
563 do
564 # delete obsolete hotplug.dev script
565 if [[ -f ${MROOT}/etc/udev/rules.d/${rule} ]]
566 then
567 rm -f ${MROOT}/etc/udev/rules.d/${rule}
568 fi
569 done
570 }
571
572 postinstall_udev()
573 {
574 [[ ! -d ${MROOT}/run ]] && install -d ${MROOT}/run
575
576 # systemd
577 if [[ -x /usr/bin/systemctl ]] && [[ -z ${MROOT} ]] && [[ ${MROOT} != / ]]
578 then
579 # reload config
580 systemctl daemon-reload
581
582 # try to kill
583 if ! systemctl stop systemd-udevd.service systemd-udevd-control.socket systemd-udevd-kernel.socket >/dev/null 2>&1
584 then
585 # kill daemon if we are not in a chroot
586 if [[ /proc/1/exe ]] && [[ -d /proc/1/root ]]
587 then
588 if [[ $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ]]
589 then
590 udevadm control --exit 2>&1
591 fi
592 fi
593 fi
594 # start the daemon
595 if ! systemctl start systemd-udevd.service >/dev/null 2>&1
596 then
597 # start daemon if we are not in a chroot
598 if [[ -f /proc/1/exe ]] && [[ -d /proc/1/root ]]
599 then
600 if [[ $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ]]
601 then
602 /usr/lib/systemd/systemd-udevd --daemon
603 fi
604 fi
605 fi
606
607 # sysV
608 else
609 # after install/uprade, udev *must* be reloaded if already running
610 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] &&
611 [[ -n $(pidof systemd-udevd) ]] && [[ ${MAGE_BOOTSTRAP} != true ]]
612 then
613 echo "MROOT=/; restarting udev daemon ..."
614 # support old installations too
615 killall -15 udevd &> /dev/null
616 killall -15 systemd-udevd &> /dev/null
617 sleep 1
618 killall -9 systemd-udevd &> /dev/null
619 killall -9 udevd &> /dev/null
620 /usr/lib/systemd/systemd-udevd --daemon
621 fi
622 fi
623 }
624
625 preinstall_systemd()
626 {
627 if [[ ${SYSVINIT_SUPPORT} != 1 ]]
628 then
629 if [[ ! -z $(magequery -n sysvinit) ]]
630 then
631 echo -e ${COLRED}
632 echo -e "Error: sys-apps/sysvinit is installed!!"
633 echo -e "sysvinit is now replaced by systemd which is the new default init system."
634 echo -e "Please uninstall sys-apps/sysvinit first!"
635 echo -e ${COLDEFAULT}
636 die "sys-apps/sysvinit found!"
637 fi
638 fi
639
640 # adding lock group
641 ${MLIBDIR}/mgroupadd -o "-g 54" lock
642
643 # fix broken systemd installations, where
644 # /usr/lib/systemd/systemd is a directory and not the daemon-exec
645 if [[ -d ${MROOT}/usr/lib/systemd/systemd ]]
646 then
647 rm -r ${MROOT}/usr/lib/systemd/systemd
648 fi
649
650 # rename configuration files that changed their names
651 if [[ -f ${MROOT}/etc/systemd/systemd-logind.conf ]]
652 then
653 mv -n ${MROOT}/etc/systemd/{systemd-,}logind.conf
654 fi
655 if [[ -f ${MROOT}/etc/systemd/systemd-journald.conf ]]
656 then
657 mv -n ${MROOT}/etc/systemd/{systemd-,}journald.conf
658 fi
659 }
660
661 postinstall_systemd()
662 {
663 # try to read default runlevel from the old inittab if it exists
664 local runlevel
665 runlevel=$(awk -F ':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' ${MROOT}/etc/inittab 2> /dev/null)
666 local target
667 if [[ -z ${runlevel} ]]
668 then
669 target="/usr/lib/systemd/system/graphical.target"
670 else
671 target="/usr/lib/systemd/system/runlevel${runlevel}.target"
672 fi
673 # and symlink what we found to the new-style default.target
674 ln -snf ${target} ${MROOT}/etc/systemd/system/default.target
675
676 # convert modules.autoload
677 if [ -f ${MROOT}/etc/modules.autoload ]
678 then
679 local modules
680 # get only lines which are not commented or empty;
681 # if we get any items than the modules.autoload is in use
682 modules=$(sed -e '/^#/d' -e '/^$/d' ${MROOT}/etc/modules.autoload)
683 if [[ ! -z ${modules} ]]
684 then
685 [ ! -d ${MROOT}/etc/modules-load.d ] && install -d ${MROOT}/etc/modules-load.d
686 echo -e "# Converted by systemd install from /etc/modules.autoload\n#\n#" \
687 > ${MROOT}/etc/modules-load.d/modules.autoload.conf
688 cat ${MROOT}/etc/modules.autoload \
689 >> ${MROOT}/etc/modules-load.d/modules.autoload.conf
690 fi
691 fi
692
693 # check mtab, and replace with a symlink if required
694 if [[ ! -L ${MROOT}/etc/mtab ]] || \
695 [[ $(readlink ${MROOT}/etc/mtab) != /proc/self/mounts ]]
696 then
697 ln -snf /proc/self/mounts ${MROOT}/etc/mtab
698 fi
699
700 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
701 then
702 # create machine-id
703 if [ ! -f /etc/machine-id ]
704 then
705 systemd-machine-id-setup
706 fi
707 # create a random-seed
708 /usr/lib/systemd/systemd-random-seed save
709
710 # allow detect-virt to be run by unprivileged code
711 setcap cap_dac_override,cap_sys_ptrace+ep /usr/bin/systemd-detect-virt
712
713 # restart systemd daemon
714 systemctl daemon-reexec
715
716 # restart systemd-logind daemon
717 systemctl try-restart systemd-logind.service
718
719 # enable the services we install by default.
720 systemctl enable \
721 getty@.service \
722 remote-fs.target \
723 systemd-readahead-replay.service \
724 systemd-readahead-collect.service
725 fi
726
727 if [[ ${SYSVINIT_SUPPORT} = 1 ]]
728 then
729 echo
730 echo "systemd has been installed to /usr/lib/systemd/systemd. Please ensure you append"
731 echo "init=/usr/lib/systemd/systemd to your kernel command line in your bootloader."
732 echo
733 fi
734 }