Magellan Linux

Contents of /branches/magellan-next/core/udev/udev-175-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9451 - (show annotations) (download)
Thu Dec 1 10:05:49 2011 UTC (12 years, 6 months ago) by niro
File size: 8563 byte(s)
-postinstall needs pidof from sys-apps/sysvinit-tools
1 # $Id$
2
3 PNAME="udev"
4 PVER="175"
5 PBUILD="r2"
6
7 PCATEGORIE="sys-fs"
8
9 DESCRIPTION="A Userspace Implementation for dynamic /dev nodes."
10 HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
11
12 DEPEND=">= virtual/glibc
13 >= dev-libs/libusb-compat-0.1.3
14 >= sys-apps/util-linux-2.19
15 >= sys-apps/acl-2.2
16 >= sys-apps/usbutils-003
17 >= sys-apps/pciutils-3.1
18 >= dev-libs/glib2-2.28
19 >= sys-apps/sysvinit-tools-2.88"
20
21 SDEPEND=">= virtual/kernel-sources
22 >= dev-util/gperf-3.0.4"
23
24 SRCFILE="${PNAME}-${PVER}.tar.bz2"
25 SRCDIR="${BUILDDIR}/${PNAME}-${PVER}"
26
27 CONFIG_SRCFILE="config-${PNAME}-173-r2.tar.bz2"
28 CONFIG_SRCDIR="${BUILDDIR}/config-${PNAME}-173-r2"
29
30 # global var: ${LINUX_SOURCES}
31 # location where they are
32 [[ -z ${LINUX_SOURCES} ]] && LINUX_SOURCES="/usr/src/linux"
33
34 sminclude mtools multilib
35
36 SRC_URI=(
37 http://www.kernel.org/pub/linux/utils/kernel/hotplug/${SRCFILE}
38 http://people.freedesktop.org/~kay/${PNAME}/${SRCFILE}
39 mirror://${PNAME}/${SRCFILE}
40 mirror://${PNAME}/${CONFIG_SRCFILE}
41 )
42
43 UP2DATE="updatecmd http://www.kernel.org/pub/linux/utils/kernel/hotplug | grep ${PNAME}- | lasttarball"
44
45 src_prepare()
46 {
47 munpack ${SRCFILE} || die
48 oldmunpack ${CONFIG_SRCFILE} || die
49 }
50
51 src_compile()
52 {
53 # using /lib/udev as libexecdir also on multilib systems
54 # to have one common rules/script directory!
55 # same with the systemd units dir!
56 #
57 # we set --exec-prefix --bindir and --sbindir to fix ${exec_prefix} issues in the systemd units
58 # variables are not allowed in the beginning of ExecStart
59 # see: http://cgit.freedesktop.org/systemd/commit/?id=d2f316345cfadd07025b1a1770f63804e33c4b50
60 mconfigure \
61 --exec-prefix= \
62 --bindir=/bin \
63 --sbindir=/sbin \
64 --with-libdir-name='$(mlibdir)' \
65 --libexecdir=/lib/udev \
66 --enable-logging \
67 --without-selinux \
68 --disable-introspection \
69 --enable-edd \
70 --enable-floppy \
71 --enable-action_modeswitch \
72 --enable-hwdb \
73 --enable-rule_generator \
74 --enable-udev_acl \
75 --enable-gudev \
76 --enable-keymap \
77 --with-systemdsystemunitdir=/lib/systemd/system \
78 --with-pci-ids-path=/usr/share/misc/pci.ids \
79 --with-usb-ids-path=/usr/share/misc/usb.ids \
80 || die
81
82 mmake || die
83 }
84
85 src_install()
86 {
87 mmake DESTDIR=${BINDIR} install || die
88 minstalldocs COPYING ChangeLog NEWS README TODO || die
89
90 # install our config
91 cd ${CONFIG_SRCDIR}
92 make DESTDIR=${BINDIR} install || die
93
94 # create symlinks for these utilities to /sbin
95 # where multipath-tools expect them to be
96 mlink ../lib/udev/scsi_id /sbin/ || die
97 # udevd is now installed to /lib/udev by upstream - we need compat symlinks
98 mlink ../lib/udev/udevd /sbin/udevd || die
99
100 # mark some dirs undeletable
101 mkeepdir /etc/udev/rules.d || die
102 mkeepdir /lib/udev/state || die
103 mkeepdir /lib/udev/devices || die
104 mkeepdir /lib/udev/devices/net || die
105 mkeepdir /lib/udev/devices/pts || die
106 mkeepdir /lib/udev/devices/shm || die
107 mkeepdir /lib/udev/devices/hugepages || die
108
109 # CONFIG_PROTECT_MASK for /etc/udev/rules.d
110 minstalldir /etc/env.d || die
111 echo "CONFIG_PROTECT_MASK=\"/etc/udev/rules.d\"" > ${BINDIR}/etc/env.d/02udev || die
112
113 # create some nodes that we know we need
114 mknod ${BINDIR}/lib/udev/devices/null c 1 3 || die
115 chmod 666 ${BINDIR}/lib/udev/devices/null || die
116 # hey, that's my birthday :)
117 touch -t 198002220222 ${BINDIR}/lib/udev/devices/null || die
118
119 mknod ${BINDIR}/lib/udev/devices/zero c 1 5 || die
120 chmod 666 ${BINDIR}/lib/udev/devices/zero || die
121 touch -t 198002220222 ${BINDIR}/lib/udev/devices/zero || die
122
123 mknod ${BINDIR}/lib/udev/devices/console c 5 1 || die
124 chmod 600 ${BINDIR}/lib/udev/devices/console || die
125 chown root:tty ${BINDIR}/lib/udev/devices/console || die
126 touch -t 198002220222 ${BINDIR}/lib/udev/devices/console || die
127
128 mknod ${BINDIR}/lib/udev/devices/urandom c 1 9 || die
129 chmod 666 ${BINDIR}/lib/udev/devices/urandom || die
130 touch -t 198002220222 ${BINDIR}/lib/udev/devices/urandom || die
131 }
132
133 preinstall()
134 {
135 if [[ ! -z $(magequery -n hotplug) ]]
136 then
137 echo -e ${COLRED}
138 echo -e "Error: sys-apps/hotplug is installed!!"
139 echo -e "hotplug is now fully provided by udev itself and it is not recommend to use this anymore."
140 echo -e "Please uninstall sys-apps/hotplug first!"
141 echo -e ${COLDEFAULT}
142 die "sys-apps/hotplug found!"
143 fi
144
145 if [[ -d ${MROOT}/lib/udev-state ]]
146 then
147 mv -f ${MROOT}/lib/udev-state/* ${MROOT}/lib/udev/state/
148 rm -r ${MROOT}/lib/udev-state
149 fi
150
151 if [[ -f ${MROOT}/etc/udev/udev.config ]] &&
152 [[ ! -f ${MROOT}/etc/udev/udev.rules ]]
153 then
154 mv -f ${MROOT}/etc/udev/udev.config ${MROOT}/etc/udev/udev.rules
155 fi
156
157 # delete the old udev.hotplug symlink if it is present
158 if [[ -h ${MROOT}/etc/hotplug.d/default/udev.hotplug ]]
159 then
160 rm -f ${MROOT}/etc/hotplug.d/default/udev.hotplug
161 fi
162
163 # delete the old wait_for_sysfs.hotplug symlink if it is present
164 if [[ -h ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]]
165 then
166 rm -f ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
167 fi
168
169 # delete the old 10-udev.hotplug symlink if it is present
170 if [[ -h ${MROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
171 then
172 rm -f ${MROOT}/etc/hotplug.d/default/10-udev.hotplug
173 fi
174
175 # delete the deprectated udev-late rc-script
176 [[ -x ${MROOT}/sbin/rc-config ]] && ${MROOT}/sbin/rc-config del udev-late
177
178 # delete obsolete hotplug.dev script
179 if [[ -f ${MROOT}/etc/dev.d/net/hotplug.dev ]]
180 then
181 rm -f ${MROOT}/etc/dev.d/net/hotplug.dev
182 fi
183
184 # delete deprecated pnp-aliases
185 if [[ -f ${MROOT}/etc/modprobe.d/pnp-aliases ]]
186 then
187 rm -f ${MROOT}/etc/modprobe.d/pnp-aliases
188 fi
189
190 # delete deprecated blacklist
191 if [[ -f ${MROOT}/etc/udev/blacklist ]]
192 then
193 rm -f ${MROOT}/etc/udev/blacklist
194 fi
195
196 # delete all udev.rules which are moved from /etc/udev to /lib/udev
197 local rule
198 for rule in 40-arch-s390.rules \
199 61-persistent-storage-edd.rules \
200 75-persistent-net-generator.rules \
201 64-md-raid.rules \
202 65-permissions.rules \
203 64-device-mapper.rules \
204 40-alsa.rules \
205 40-zaptel.rules \
206 60-persistent-input.rules \
207 40-arch-ia64.rules \
208 05-udev-early.rules \
209 40-arch-ppc.rules \
210 60-cdrom_id.rules \
211 40-pilot-links.rules \
212 95-udev-late.rules \
213 40-magellan.rules \
214 50-udev-default.rules \
215 80-drivers.rules \
216 30-kernel-compat.rules \
217 40-video.rules \
218 60-persistent-storage-tape.rules \
219 75-cd-aliases-generator.rules \
220 60-persistent-storage.rules
221 do
222 # delete obsolete hotplug.dev script
223 if [[ -f ${MROOT}/etc/udev/rules.d/${rule} ]]
224 then
225 rm -f ${MROOT}/etc/udev/rules.d/${rule}
226 fi
227 done
228 }
229
230 postinstall()
231 {
232 # create some nodes that we need if they not exist
233 [[ ! -e ${MROOT}/lib/udev/devices/null ]] &&
234 mknod ${MROOT}/lib/udev/devices/null c 1 3
235 chmod 666 ${MROOT}/lib/udev/devices/null
236 touch -t 198002220222 ${MROOT}/lib/udev/devices/null
237
238 [[ ! -e ${MROOT}/lib/udev/devices/zero ]] &&
239 mknod ${MROOT}/lib/udev/devices/zero c 1 5
240 chmod 666 ${MROOT}/lib/udev/devices/zero
241 touch -t 198002220222 ${MROOT}/lib/udev/devices/zero
242
243 [[ ! -e ${MROOT}/lib/udev/devices/console ]] &&
244 mknod ${MROOT}/lib/udev/devices/console c 5 1
245 chmod 600 ${MROOT}/lib/udev/devices/console
246 chown root:tty ${MROOT}/lib/udev/devices/console
247 touch -t 198002220222 ${MROOT}/lib/udev/devices/console
248
249 [[ ! -e ${MROOT}/lib/udev/devices/urandom ]] &&
250 mknod ${MROOT}/lib/udev/devices/urandom c 1 9
251 chmod 666 ${MROOT}/lib/udev/devices/urandom
252 touch -t 198002220222 ${MROOT}/lib/udev/devices/urandom
253
254 [[ ! -d ${MROOT}/run ]] && install -d ${MROOT}/run
255
256 # systemd
257 if [[ -x /bin/systemctl ]] && [[ -z ${MROOT} ]] && [[ ${MROOT} != / ]]
258 then
259 # reload config
260 systemctl daemon-reload
261
262 # try to kill
263 if ! systemctl stop udev.service udev-control.socket udev-kernel.socket >/dev/null 2>&1
264 then
265 # kill daemon if we are not in a chroot
266 if [[ /proc/1/exe ]] && [[ -d /proc/1/root ]]
267 then
268 if [[ $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ]]
269 then
270 udevadm control --exit 2>&1
271 fi
272 fi
273 fi
274 # start the daemon
275 if ! systemctl start udev.service >/dev/null 2>&1
276 then
277 # start daemon if we are not in a chroot
278 if [[ -f /proc/1/exe ]] && [[ -d /proc/1/root ]]
279 then
280 if [[ $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ]]
281 then
282 /sbin/udevd --daemon
283 fi
284 fi
285 fi
286
287 # sysV
288 else
289 # after install/uprade, udev *must* be reloaded if already running
290 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] &&
291 [[ -n $(pidof udevd) ]] && [[ ${MAGE_BOOTSTRAP} != true ]]
292 then
293 echo "MROOT=/; restarting udev daemon ..."
294 killall -15 udevd &> /dev/null
295 sleep 1
296 killall -9 udevd &> /dev/null
297 /sbin/udevd --daemon
298 fi
299 fi
300 }