Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4210 - (hide annotations) (download)
Fri Nov 9 12:06:27 2012 UTC (11 years, 6 months ago) by niro
File size: 23922 byte(s)
-keep sysctl
1 niro 4198 # $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 niro 4205 >= app-crypt/libgcrypt-1.5
83 niro 4198 >= 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 niro 4205
213     # regen configure
214     mautoreconf || die
215 niro 4198 }
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 niro 4201 --disable-xz \
234 niro 4198 --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 niro 4206 mmake -j1 DESTDIR=${BINDIR} install || die
255 niro 4198
256 niro 4208 # alx
257     mdelete -r /etc/bash_completion.d || die
258     mdelete -r /usr/include || die
259     mdelete -r /usr/share/doc || die
260     mdelete -r /usr/share/man || die
261     mdelete -r /usr/share/pkgconfig || die
262     zapmost ${BINDIR}/usr/$(mlibdir) \
263     binfmt.d \
264     modules-load.d \
265 niro 4210 sysctl.d \
266 niro 4208 systemd \
267     tmpfiles.d \
268     libsystemd\*.so.* \
269     || die
270    
271 niro 4198 # keep some directories
272     mkeepdir /run || die
273     mkeepdir /etc/modules-load.d || die
274     mkeepdir /etc/sysctl.d || die
275     mkeepdir /etc/tmpfiles.d || die
276     mkeepdir /etc/binfmt.d || die
277    
278     # make sure the shutdown/sleep drop-in dirs exist
279     mkeepdir /usr/lib/systemd/system-shutdown || die
280     mkeepdir /usr/lib/systemd/system-sleep || die
281    
282     if [[ ${SYSVINIT_SUPPORT} != 1 ]]
283     then
284     echo "Include SysV init Compat symlinks"
285     # create SysV compatibility symlinks. systemctl/systemd are smart
286     # enough to detect in which way they are called.
287     minstalldir /usr/sbin || die
288     mlink ../lib/systemd/systemd /usr/sbin/init || die
289     local i
290     for i in reboot halt poweroff shutdown telinit runlevel
291     do
292     mlink ../bin/systemctl /usr/sbin/${i} || die
293     done
294     else
295     echo "Using sysvinit package for SysV compat"
296     fi
297    
298     # do not package the kernel.core_pattern setting until systemd-coredump
299     # is a part of an actual systemd release and it's made clear how to get
300     # the core dumps out of the journal
301 niro 4210 rm ${BINDIR}/usr/lib/sysctl.d/coredump.conf || die
302 niro 4198 rm -r ${BINDIR}/usr/lib/sysctl.d || die
303    
304     # we create all wants links manually at installation time to make sure
305     # they are not owned and hence overriden by mage after the user deleted
306     # them.
307     rm -r ${BINDIR}/etc/systemd/system/*.target.wants || die
308     # but make sure these directories are properly owned
309     mkeepdir /usr/lib/systemd/system/basic.target.wants || die
310     mkeepdir /usr/lib/systemd/system/default.target.wants || die
311     mkeepdir /usr/lib/systemd/system/dbus.target.wants || die
312     mkeepdir /usr/lib/systemd/system/syslog.target.wants || die
313     # make sure the user generators dir exists too
314     mkeepdir /usr/lib/systemd/user-generators || die
315     mkeepdir /usr/lib/systemd/system-generators || die
316    
317     # login-manager pam policy - force register kdm, gdm etc with pam_systemd
318 niro 4208 #all-abis minstallpam login-manager.pamd login-manager || die
319 niro 4198
320     # do not bother with non-existend services, mask them
321     mlink /dev/null /etc/systemd/system/syslog.service || die
322     mlink /dev/null /etc/systemd/system/rc-local.service || die
323     mlink /dev/null /etc/systemd/system/auditd.service || die
324    
325     # we have no rpm, remove config macros
326     mdelete -r /etc/rpm || die
327    
328     # remove files which are owned by other packages
329     if [[ ${ENABLE_GTK} = 1 ]]
330     then
331     mdelete /usr/bin/systemadm || die
332     mdelete /usr/bin/systemd-gnome-ask-password-agent || die
333     mdelete /usr/share/man/man1/systemadm.\* || die
334     fi
335     mdelete /usr/bin/systemd-analyze || die
336     mdelete -r /etc/udev || die
337     mdelete /usr/bin/udevadm || die
338     mdelete /usr/include/libudev.h || die
339     mdelete -r /usr/include/gudev-1.0 || die
340     mdelete /usr/lib/systemd/systemd-udevd || die
341     mdelete /usr/lib/systemd/system/systemd-udevd-control.socket || die
342     mdelete /usr/lib/systemd/system/systemd-udevd-kernel.socket || die
343     mdelete /usr/lib/systemd/system/systemd-udevd.service || die
344     mdelete /usr/lib/systemd/system/systemd-udev-settle.service || die
345     mdelete /usr/lib/systemd/system/systemd-udev-trigger.service || die
346     mdelete -r /usr/lib/udev || die
347     rm ${BINDIR}/usr/$(mlibdir)/libgudev* || die
348     rm ${BINDIR}/usr/$(mlibdir)/libudev* || die
349 niro 4207 #mdelete -r /usr/$(mlibdir)/girepository-1.0 || die
350 niro 4198 mdelete /usr/$(mlibdir)/pkgconfig/gudev-1.0.pc || die
351     mdelete /usr/$(mlibdir)/pkgconfig/libudev.pc || die
352     if [[ $(mlibdir) != lib ]]
353     then
354     rm ${BINDIR}/usr/lib/libgudev* || die
355     rm ${BINDIR}/usr/lib/libudev* || die
356 niro 4207 #mdelete -r /usr/lib/girepository-1.0 || die
357 niro 4198 mdelete /usr/lib/pkgconfig/gudev-1.0.pc || die
358     mdelete /usr/lib/pkgconfig/libudev.pc || die
359     fi
360 niro 4207 #mdelete -r /usr/share/gir-1.0 || die
361 niro 4198 mdelete /usr/share/man/man7/udev.7 || die
362     mdelete /usr/share/man/man8/systemd-udevd.8 || die
363     mdelete /usr/share/man/man8/udevadm.8 || die
364     mdelete /usr/share/pkgconfig/udev.pc || die
365    
366     # install udev rule for systemd
367     minstalludevrule rules/99-systemd.rules || die
368     }
369    
370 niro 4208 src_install_systemd-dev()
371     {
372     mmake -j1 DESTDIR=${BINDIR} install || die
373     if [[ ${ENABLE_GTK} = 1 ]]
374     then
375     SRCDIR="${UI_SRCDIR}" mmake DESTDIR=${BINDIR} install || die
376     fi
377    
378     # do not package the kernel.core_pattern setting until systemd-coredump
379     # is a part of an actual systemd release and it's made clear how to get
380     # the core dumps out of the journal
381     rm ${BINDIR}/usr/lib/sysctl.d/coredump.conf || die
382     rm -r ${BINDIR}/usr/lib/sysctl.d || die
383    
384     # we create all wants links manually at installation time to make sure
385     # they are not owned and hence overriden by mage after the user deleted
386     # them.
387     rm -r ${BINDIR}/etc/systemd/system/*.target.wants || die
388    
389     # we have no rpm, remove config macros
390     mdelete -r /etc/rpm || die
391    
392     minstalldocs DISTRO_PORTING LICENSE README TODO || die
393    
394     # remove files which are owned by other packages
395     if [[ ${ENABLE_GTK} = 1 ]]
396     then
397     mdelete /usr/bin/systemadm || die
398     mdelete /usr/bin/systemd-gnome-ask-password-agent || die
399     mdelete /usr/share/man/man1/systemadm.\* || die
400     fi
401     mdelete /usr/bin/systemd-analyze || die
402     mdelete -r /etc/udev || die
403     mdelete /usr/bin/udevadm || die
404     mdelete /usr/include/libudev.h || die
405     mdelete -r /usr/include/gudev-1.0 || die
406     mdelete /usr/lib/systemd/systemd-udevd || die
407     mdelete /usr/lib/systemd/system/systemd-udevd-control.socket || die
408     mdelete /usr/lib/systemd/system/systemd-udevd-kernel.socket || die
409     mdelete /usr/lib/systemd/system/systemd-udevd.service || die
410     mdelete /usr/lib/systemd/system/systemd-udev-settle.service || die
411     mdelete /usr/lib/systemd/system/systemd-udev-trigger.service || die
412     mdelete -r /usr/lib/udev || die
413     rm ${BINDIR}/usr/$(mlibdir)/libgudev* || die
414     rm ${BINDIR}/usr/$(mlibdir)/libudev* || die
415     #mdelete -r /usr/$(mlibdir)/girepository-1.0 || die
416     mdelete /usr/$(mlibdir)/pkgconfig/gudev-1.0.pc || die
417     mdelete /usr/$(mlibdir)/pkgconfig/libudev.pc || die
418     if [[ $(mlibdir) != lib ]]
419     then
420     rm ${BINDIR}/usr/lib/libgudev* || die
421     rm ${BINDIR}/usr/lib/libudev* || die
422     #mdelete -r /usr/lib/girepository-1.0 || die
423     mdelete /usr/lib/pkgconfig/gudev-1.0.pc || die
424     mdelete /usr/lib/pkgconfig/libudev.pc || die
425     fi
426     #mdelete -r /usr/share/gir-1.0 || die
427     mdelete /usr/share/man/man7/udev.7 || die
428     mdelete /usr/share/man/man8/systemd-udevd.8 || die
429     mdelete /usr/share/man/man8/udevadm.8 || die
430     mdelete /usr/share/pkgconfig/udev.pc || die
431    
432     # alx
433     zapmost ${BINDIR}/etc bash_completion.d || die
434     zapmost ${BINDIR}/usr/$(mlibdir) \
435     libsystemd.so \
436     libsystemd.la \
437     libsystemd.a \
438     || die
439     mdelete /usr/bin || die
440     mdelete /usr/bin || die
441     mdelete /usr/share/dbus-1 || die
442     mdelete /usr/share/polkit-1 || die
443     mdelete /usr/share/systemd || die
444     }
445    
446 niro 4198 src_install_systemd-tools()
447     {
448     cd ${SRCDIR}
449     if [[ ${ENABLE_GTK} = 1 ]]
450     then
451     all-abis minstallexec systemadm || die
452     all-abis minstallexec systemd-gnome-ask-password-agent || die
453     all-abis minstallman man/systemadm.1 || die
454     fi
455     all-abis minstallexec src/analyze/systemd-analyze || die
456     }
457 niro 4208 src_install_libudev()
458     {
459     mmake -j1 DESTDIR=${BINDIR} install || die
460 niro 4198
461 niro 4208 # cleanup all files but the libudev owned ones
462     zapmost ${BINDIR} \
463     usr/$(mlibdir)/libudev\*.so.\* \
464     $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libudev*.so.*') \
465     || die
466     }
467    
468 niro 4198 src_install_libudev()
469     {
470 niro 4206 mmake -j1 DESTDIR=${BINDIR} install || die
471 niro 4198
472     # cleanup all files but the libudev owned ones
473     zapmost ${BINDIR} \
474     usr/include/libudev.h \
475 niro 4208 usr/$(mlibdir)/libudev.so \
476     usr/$(mlibdir)/libudev.la \
477     usr/$(mlibdir)/libudev.a \
478 niro 4198 usr/$(mlibdir)/pkgconfig/libudev.pc \
479 niro 4208 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libudev.so') \
480     $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libudev.la') \
481     $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libudev.a') \
482 niro 4198 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/pkgconfig/libudev.pc') \
483     || die
484     }
485    
486     src_install_libgudev()
487     {
488 niro 4206 mmake -j1 DESTDIR=${BINDIR} install || die
489 niro 4198
490     # cleanup all files but the libgudev owned ones
491     zapmost ${BINDIR} \
492 niro 4208 usr/$(mlibdir)/libgudev\*.so.\* \
493     $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libgudev*.so.*') \
494     || die
495     }
496    
497     src_install_libgudev-dev()
498     {
499     mmake -j1 DESTDIR=${BINDIR} install || die
500    
501     # cleanup all files but the libgudev owned ones
502     zapmost ${BINDIR} \
503 niro 4198 usr/include/gudev-1.0 \
504 niro 4208 usr/$(mlibdir)/libgudev.so \
505     usr/$(mlibdir)/libgudev.la \
506     usr/$(mlibdir)/libgudev.a \
507 niro 4198 usr/$(mlibdir)/pkgconfig/gudev-1.0.pc \
508 niro 4208 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libgudev.so') \
509     $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libgudev.la') \
510     $([[ $(mlibdir) != lib ]] && echo 'usr/lib/libgudev.a') \
511 niro 4198 $([[ $(mlibdir) != lib ]] && echo 'usr/lib/pkgconfig/gudev-1.0.pc') \
512     || die
513    
514 niro 4207 #usr/$(mlibdir)/girepository-1.0
515     #$([[ $(mlibdir) != lib ]] && echo 'usr/lib/girepository-1.0')
516     # usr/share/gir-1.0
517 niro 4198 }
518    
519     src_install_udev()
520     {
521 niro 4206 mmake -j1 DESTDIR=${BINDIR} install || die
522 niro 4198
523     # cleanup all files but the udev owned ones
524     zapmost ${BINDIR} \
525     etc/udev \
526     usr/bin/udevadm \
527     usr/lib/systemd/systemd-udevd \
528     usr/lib/systemd/system/systemd-udevd-control.socket \
529     usr/lib/systemd/system/systemd-udevd-kernel.socket \
530     usr/lib/systemd/system/systemd-udevd.service \
531     usr/lib/systemd/system/systemd-udev-settle.service \
532     usr/lib/systemd/system/systemd-udev-trigger.service \
533     usr/lib/udev \
534     || die
535    
536     # remove udev rule for systemd
537     mdelete /usr/lib/udev/rules.d/99-systemd.rules || die
538    
539     # install our config
540     cd ${UDEV_CONFIG_SRCDIR}
541     make DESTDIR=${BINDIR} install || die
542     if [[ ${SYSVINIT_SUPPORT} = 1 ]]
543     then
544     # install sysvinit rc. script
545     make DESTDIR=${BINDIR} install-sysvinit || die
546     fi
547    
548     # create symlinks for these utilities to /sbin
549     minstalldir /usr/sbin || die
550     # where multipath-tools expect them to be
551     mlink ../lib/udev/scsi_id /usr/sbin/ || die
552    
553     # mark some dirs undeletable
554     mkeepdir /etc/udev/rules.d || die
555     mkeepdir /usr/lib/udev/state || die
556    
557     # CONFIG_PROTECT_MASK for /etc/udev/rules.d
558     minstalldir /etc/env.d || die
559     echo "CONFIG_PROTECT_MASK=\"/etc/udev/rules.d\"" > ${BINDIR}/etc/env.d/02udev || die
560     }
561    
562 niro 4208 src_install_udev-dev()
563     {
564     mmake -j1 DESTDIR=${BINDIR} install || die
565    
566     # cleanup all files but the udev owned ones
567     zapmost ${BINDIR} \
568     usr/share/man/man7/udev.7 \
569     usr/share/man/man8/systemd-udevd.8 \
570     usr/share/man/man8/udevadm.8 \
571     usr/share/pkgconfig/udev.pc \
572     || die
573    
574     minstalldocs LICENSE* NEWS README TODO || die
575     }
576    
577 niro 4198 preinstall_udev()
578     {
579     add_conf_prot_mask /etc/udev /etc/env.d /etc/rc.d/init.d /etc/modprobe.d
580    
581     if [[ ! -z $(magequery -n hotplug) ]]
582     then
583     echo -e ${COLRED}
584     echo -e "Error: sys-apps/hotplug is installed!!"
585     echo -e "hotplug is now fully provided by udev itself and it is not recommend to use this anymore."
586     echo -e "Please uninstall sys-apps/hotplug first!"
587     echo -e ${COLDEFAULT}
588     die "sys-apps/hotplug found!"
589     fi
590    
591     # move udev state
592     if [ ! -L ${MROOT}/lib ]
593     then
594     if [[ -d ${MROOT}/lib/udev-state ]]
595     then
596     mv -f ${MROOT}/lib/udev-state/* ${MROOT}/usr/lib/udev/state/
597     rm -r ${MROOT}/lib/udev-state
598     fi
599     if [[ -d ${MROOT}/lib/udev/state ]]
600     then
601     mv -f ${MROOT}/lib/udev/state/* ${MROOT}/usr/lib/udev/state/
602     rm -r ${MROOT}/lib/udev/state
603     fi
604     fi
605    
606     # remove deprecated udev devices dir
607     if [[ -d ${MROOT}/lib/udev/devices ]]
608     then
609     rm -r ${MROOT}/lib/udev/devices
610     fi
611     if [[ -d ${MROOT}/usr/lib/udev/devices ]]
612     then
613     rm -r ${MROOT}/usr/lib/udev/devices
614     fi
615    
616     if [[ -f ${MROOT}/etc/udev/udev.config ]] &&
617     [[ ! -f ${MROOT}/etc/udev/udev.rules ]]
618     then
619     mv -f ${MROOT}/etc/udev/udev.config ${MROOT}/etc/udev/udev.rules
620     fi
621    
622     # delete the old udev.hotplug symlink if it is present
623     if [[ -h ${MROOT}/etc/hotplug.d/default/udev.hotplug ]]
624     then
625     rm -f ${MROOT}/etc/hotplug.d/default/udev.hotplug
626     fi
627    
628     # delete the old wait_for_sysfs.hotplug symlink if it is present
629     if [[ -h ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]]
630     then
631     rm -f ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
632     fi
633    
634     # delete the old 10-udev.hotplug symlink if it is present
635     if [[ -h ${MROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
636     then
637     rm -f ${MROOT}/etc/hotplug.d/default/10-udev.hotplug
638     fi
639    
640     # delete the deprectated udev-late rc-script
641     [[ -x ${MROOT}/sbin/rc-config ]] && ${MROOT}/sbin/rc-config del udev-late
642    
643     # delete obsolete hotplug.dev script
644     if [[ -f ${MROOT}/etc/dev.d/net/hotplug.dev ]]
645     then
646     rm -f ${MROOT}/etc/dev.d/net/hotplug.dev
647     fi
648    
649     # delete deprecated pnp-aliases
650     if [[ -f ${MROOT}/etc/modprobe.d/pnp-aliases ]]
651     then
652     rm -f ${MROOT}/etc/modprobe.d/pnp-aliases
653     fi
654    
655     # delete deprecated blacklist
656     if [[ -f ${MROOT}/etc/udev/blacklist ]]
657     then
658     rm -f ${MROOT}/etc/udev/blacklist
659     fi
660    
661     # delete all udev.rules which are moved from /etc/udev to /lib/udev
662     local rule
663     for rule in 40-arch-s390.rules \
664     61-persistent-storage-edd.rules \
665     75-persistent-net-generator.rules \
666     64-md-raid.rules \
667     65-permissions.rules \
668     64-device-mapper.rules \
669     40-alsa.rules \
670     40-zaptel.rules \
671     60-persistent-input.rules \
672     40-arch-ia64.rules \
673     05-udev-early.rules \
674     40-arch-ppc.rules \
675     60-cdrom_id.rules \
676     40-pilot-links.rules \
677     95-udev-late.rules \
678     40-magellan.rules \
679     50-udev-default.rules \
680     80-drivers.rules \
681     30-kernel-compat.rules \
682     40-video.rules \
683     60-persistent-storage-tape.rules \
684     75-cd-aliases-generator.rules \
685     60-persistent-storage.rules
686     do
687     # delete obsolete hotplug.dev script
688     if [[ -f ${MROOT}/etc/udev/rules.d/${rule} ]]
689     then
690     rm -f ${MROOT}/etc/udev/rules.d/${rule}
691     fi
692     done
693     }
694    
695     postinstall_udev()
696     {
697     [[ ! -d ${MROOT}/run ]] && install -d ${MROOT}/run
698    
699     # systemd
700     if [[ -x /usr/bin/systemctl ]] && [[ -z ${MROOT} ]] && [[ ${MROOT} != / ]]
701     then
702     # reload config
703     systemctl daemon-reload
704    
705     # try to kill
706     if ! systemctl stop systemd-udevd.service systemd-udevd-control.socket systemd-udevd-kernel.socket >/dev/null 2>&1
707     then
708     # kill daemon if we are not in a chroot
709     if [[ /proc/1/exe ]] && [[ -d /proc/1/root ]]
710     then
711     if [[ $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ]]
712     then
713     udevadm control --exit 2>&1
714     fi
715     fi
716     fi
717     # start the daemon
718     if ! systemctl start systemd-udevd.service >/dev/null 2>&1
719     then
720     # start daemon if we are not in a chroot
721     if [[ -f /proc/1/exe ]] && [[ -d /proc/1/root ]]
722     then
723     if [[ $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ]]
724     then
725     /usr/lib/systemd/systemd-udevd --daemon
726     fi
727     fi
728     fi
729    
730     # sysV
731     else
732     # after install/uprade, udev *must* be reloaded if already running
733     if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] &&
734     [[ -n $(pidof systemd-udevd) ]] && [[ ${MAGE_BOOTSTRAP} != true ]]
735     then
736     echo "MROOT=/; restarting udev daemon ..."
737     # support old installations too
738     killall -15 udevd &> /dev/null
739     killall -15 systemd-udevd &> /dev/null
740     sleep 1
741     killall -9 systemd-udevd &> /dev/null
742     killall -9 udevd &> /dev/null
743     /usr/lib/systemd/systemd-udevd --daemon
744     fi
745     fi
746     }
747    
748     preinstall_systemd()
749     {
750     if [[ ${SYSVINIT_SUPPORT} != 1 ]]
751     then
752     if [[ ! -z $(magequery -n sysvinit) ]]
753     then
754     echo -e ${COLRED}
755     echo -e "Error: sys-apps/sysvinit is installed!!"
756     echo -e "sysvinit is now replaced by systemd which is the new default init system."
757     echo -e "Please uninstall sys-apps/sysvinit first!"
758     echo -e ${COLDEFAULT}
759     die "sys-apps/sysvinit found!"
760     fi
761     fi
762    
763     # adding lock group
764     ${MLIBDIR}/mgroupadd -o "-g 54" lock
765    
766     # fix broken systemd installations, where
767     # /usr/lib/systemd/systemd is a directory and not the daemon-exec
768     if [[ -d ${MROOT}/usr/lib/systemd/systemd ]]
769     then
770     rm -r ${MROOT}/usr/lib/systemd/systemd
771     fi
772    
773     # rename configuration files that changed their names
774     if [[ -f ${MROOT}/etc/systemd/systemd-logind.conf ]]
775     then
776     mv -n ${MROOT}/etc/systemd/{systemd-,}logind.conf
777     fi
778     if [[ -f ${MROOT}/etc/systemd/systemd-journald.conf ]]
779     then
780     mv -n ${MROOT}/etc/systemd/{systemd-,}journald.conf
781     fi
782     }
783    
784     postinstall_systemd()
785     {
786     # try to read default runlevel from the old inittab if it exists
787     local runlevel
788     runlevel=$(awk -F ':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' ${MROOT}/etc/inittab 2> /dev/null)
789     local target
790     if [[ -z ${runlevel} ]]
791     then
792     target="/usr/lib/systemd/system/graphical.target"
793     else
794     target="/usr/lib/systemd/system/runlevel${runlevel}.target"
795     fi
796     # and symlink what we found to the new-style default.target
797     ln -snf ${target} ${MROOT}/etc/systemd/system/default.target
798    
799     # convert modules.autoload
800     if [ -f ${MROOT}/etc/modules.autoload ]
801     then
802     local modules
803     # get only lines which are not commented or empty;
804     # if we get any items than the modules.autoload is in use
805     modules=$(sed -e '/^#/d' -e '/^$/d' ${MROOT}/etc/modules.autoload)
806     if [[ ! -z ${modules} ]]
807     then
808     [ ! -d ${MROOT}/etc/modules-load.d ] && install -d ${MROOT}/etc/modules-load.d
809     echo -e "# Converted by systemd install from /etc/modules.autoload\n#\n#" \
810     > ${MROOT}/etc/modules-load.d/modules.autoload.conf
811     cat ${MROOT}/etc/modules.autoload \
812     >> ${MROOT}/etc/modules-load.d/modules.autoload.conf
813     fi
814     fi
815    
816     # check mtab, and replace with a symlink if required
817     if [[ ! -L ${MROOT}/etc/mtab ]] || \
818     [[ $(readlink ${MROOT}/etc/mtab) != /proc/self/mounts ]]
819     then
820     ln -snf /proc/self/mounts ${MROOT}/etc/mtab
821     fi
822    
823     if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
824     then
825     # create machine-id
826     if [ ! -f /etc/machine-id ]
827     then
828     systemd-machine-id-setup
829     fi
830     # create a random-seed
831     /usr/lib/systemd/systemd-random-seed save
832    
833     # allow detect-virt to be run by unprivileged code
834     setcap cap_dac_override,cap_sys_ptrace+ep /usr/bin/systemd-detect-virt
835    
836     # restart systemd daemon
837     systemctl daemon-reexec
838    
839     # restart systemd-logind daemon
840     systemctl try-restart systemd-logind.service
841    
842     # enable the services we install by default.
843     systemctl enable \
844     getty@.service \
845     remote-fs.target \
846     systemd-readahead-replay.service \
847     systemd-readahead-collect.service
848     fi
849    
850     if [[ ${SYSVINIT_SUPPORT} = 1 ]]
851     then
852     echo
853     echo "systemd has been installed to /usr/lib/systemd/systemd. Please ensure you append"
854     echo "init=/usr/lib/systemd/systemd to your kernel command line in your bootloader."
855     echo
856     fi
857     }