Magellan Linux

Contents of /trunk/core/systemd/systemd-188-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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