Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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