Magellan Linux

Contents of /smage/trunk/core/udev/udev-165-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1160 - (show annotations) (download)
Thu Jan 27 23:04:40 2011 UTC (13 years, 3 months ago) by niro
File size: 7418 byte(s)
-set udev as default devicemanager in postinstall() or reset back to mdev in postremove()
1 # $Id: udev-151-r2.smage2 5611 2010-07-14 13:23:26Z niro $
2
3 PNAME="udev"
4 PVER="165"
5 PBUILD="r1"
6
7 PCATEGORIE="sys-fs"
8 STATE="unstable"
9
10 DESCRIPTION="A Userspace Implementation for dynamic /dev nodes."
11 HOMEPAGE="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
12
13 DEPEND=">= virtual/glibc
14 >= sys-apps/util-linux-2.18
15 >= virtual/initscripts"
16
17 SDEPEND=">= virtual/kernel-sources"
18
19 SRCFILE="${PNAME}-${PVER}.tar.bz2"
20 SRCDIR="${BUILDDIR}/${PNAME}-${PVER}"
21
22 CONFIG_SRCFILE="config-${PNAME}-${PVER}-${PBUILD}.tar.bz2"
23 CONFIG_SRCDIR="${BUILDDIR}/config-${PNAME}-${PVER}-${PBUILD}"
24
25 # global var: ${LINUX_SOURCES}
26 # location where they are
27 [[ -z ${LINUX_SOURCES} ]] && LINUX_SOURCES="/usr/src/linux"
28
29 MCORE_ONLY_KEEP="etc lib $(mlibdir) sbin usr/$(mlibdir)/*.so usr/$(mlibdir)/*.so.*"
30 sminclude mtools multilib mcore-split
31
32 SRC_URI=(
33 http://www.kernel.org/pub/linux/utils/kernel/hotplug/${SRCFILE}
34 mirror://${PNAME}/${SRCFILE}
35 mirror://${PNAME}/${CONFIG_SRCFILE}
36 )
37
38 UP2DATE="updatecmd http://www.kernel.org/pub/linux/utils/kernel/hotplug | grep ${PNAME}- | lasttarball"
39
40 src_prepare()
41 {
42 munpack ${SRCFILE} || die
43 oldmunpack ${CONFIG_SRCFILE} || die
44 }
45
46 src_compile()
47 {
48 # using /lib/udev as libexecdir also on multilib systems
49 # to have one common rules/script directory!
50 # same with the systemd units dir!
51 #
52 # we set --exec-prefix --bindir and --sbindir to fix ${exec_prefix} issues in the systemd units
53 # variables are not allowd in the beginning of ExecStart
54 # see: http://cgit.freedesktop.org/systemd/commit/?id=d2f316345cfadd07025b1a1770f63804e33c4b50
55 mconfigure \
56 --exec-prefix= \
57 --bindir=/bin \
58 --sbindir=/sbin \
59 --with-libdir-name='$(mlibdir)' \
60 --libexecdir=/lib/udev \
61 --enable-logging \
62 --without-selinux \
63 --disable-introspection \
64 --disable-extras \
65 --with-systemdsystemunitdir=/lib/systemd/system \
66 || die
67
68 mmake || die
69 }
70
71 mcore_generic_src_install()
72 {
73 mmake DESTDIR=${BINDIR} install || die
74 minstalldocs COPYING ChangeLog NEWS README TODO || die
75
76 # install our config
77 cd ${CONFIG_SRCDIR}
78 make DESTDIR=${BINDIR} install-basic-files || die
79
80 # create symlinks for these utilities to /sbin
81 # where multipath-tools expect them to be
82 mlink ../lib/udev/scsi_id /sbin/ || die
83
84 # mark some dirs undeletable
85 mkeepdir /etc/udev/rules.d || die
86 mkeepdir /lib/udev/state || die
87 mkeepdir /lib/udev/devices || die
88
89 # CONFIG_PROTECT_MASK for /etc/udev/rules.d
90 minstalldir /etc/env.d || die
91 echo "CONFIG_PROTECT_MASK=\"/etc/udev/rules.d\"" > ${BINDIR}/etc/env.d/02udev || die
92
93 # create some nodes that we know we need
94 mknod ${BINDIR}/lib/udev/devices/null c 1 3 || die
95 chmod 666 ${BINDIR}/lib/udev/devices/null || die
96 # hey, that's my birthday :)
97 touch -t 198002220222 ${BINDIR}/lib/udev/devices/null || die
98
99 mknod ${BINDIR}/lib/udev/devices/zero c 1 5 || die
100 chmod 666 ${BINDIR}/lib/udev/devices/zero || die
101 touch -t 198002220222 ${BINDIR}/lib/udev/devices/zero || die
102
103 mknod ${BINDIR}/lib/udev/devices/console c 5 1 || die
104 chmod 600 ${BINDIR}/lib/udev/devices/console || die
105 chown root:tty ${BINDIR}/lib/udev/devices/console || die
106 touch -t 198002220222 ${BINDIR}/lib/udev/devices/console || die
107
108 mknod ${BINDIR}/lib/udev/devices/urandom c 1 9 || die
109 chmod 666 ${BINDIR}/lib/udev/devices/urandom || die
110 touch -t 198002220222 ${BINDIR}/lib/udev/devices/urandom || die
111 }
112
113 preinstall()
114 {
115 if [[ ! -z $(magequery -n hotplug) ]]
116 then
117 echo -e ${COLRED}
118 echo -e "Error: sys-apps/hotplug is installed!!"
119 echo -e "hotplug is now fully provided by udev itself and it is not recommend to use this anymore."
120 echo -e "Please uninstall sys-apps/hotplug first!"
121 echo -e ${COLDEFAULT}
122 die "sys-apps/hotplug found!"
123 fi
124
125 if [[ -d ${MROOT}/lib/udev-state ]]
126 then
127 mv -f ${MROOT}/lib/udev-state/* ${MROOT}/lib/udev/state/
128 rm -r ${MROOT}/lib/udev-state
129 fi
130
131 if [[ -f ${MROOT}/etc/udev/udev.config ]] &&
132 [[ ! -f ${MROOT}/etc/udev/udev.rules ]]
133 then
134 mv -f ${MROOT}/etc/udev/udev.config ${MROOT}/etc/udev/udev.rules
135 fi
136
137 # delete the old udev.hotplug symlink if it is present
138 if [[ -h ${MROOT}/etc/hotplug.d/default/udev.hotplug ]]
139 then
140 rm -f ${MROOT}/etc/hotplug.d/default/udev.hotplug
141 fi
142
143 # delete the old wait_for_sysfs.hotplug symlink if it is present
144 if [[ -h ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug ]]
145 then
146 rm -f ${MROOT}/etc/hotplug.d/default/05-wait_for_sysfs.hotplug
147 fi
148
149 # delete the old 10-udev.hotplug symlink if it is present
150 if [[ -h ${MROOT}/etc/hotplug.d/default/10-udev.hotplug ]]
151 then
152 rm -f ${MROOT}/etc/hotplug.d/default/10-udev.hotplug
153 fi
154
155 # delete the deprectated udev-late rc-script
156 [[ -x ${MROOT}/sbin/rc-config ]] && ${MROOT}/sbin/rc-config del udev-late
157
158 # delete obsolete hotplug.dev script
159 if [[ -f ${MROOT}/etc/dev.d/net/hotplug.dev ]]
160 then
161 rm -f ${MROOT}/etc/dev.d/net/hotplug.dev
162 fi
163
164 # delete deprecated pnp-aliases
165 if [[ -f ${MROOT}/etc/modprobe.d/pnp-aliases ]]
166 then
167 rm -f ${MROOT}/etc/modprobe.d/pnp-aliases
168 fi
169
170 # delete all udev.rules which are moved from /etc/udev to /lib/udev
171 local rule
172 for rule in 40-arch-s390.rules \
173 61-persistent-storage-edd.rules \
174 75-persistent-net-generator.rules \
175 64-md-raid.rules \
176 65-permissions.rules \
177 64-device-mapper.rules \
178 40-alsa.rules \
179 40-zaptel.rules \
180 60-persistent-input.rules \
181 40-arch-ia64.rules \
182 05-udev-early.rules \
183 40-arch-ppc.rules \
184 60-cdrom_id.rules \
185 40-pilot-links.rules \
186 95-udev-late.rules \
187 40-magellan.rules \
188 50-udev-default.rules \
189 80-drivers.rules \
190 30-kernel-compat.rules \
191 40-video.rules \
192 60-persistent-storage-tape.rules \
193 75-cd-aliases-generator.rules \
194 60-persistent-storage.rules
195 do
196 # delete obsolete hotplug.dev script
197 if [[ -f ${MROOT}/etc/udev/rules.d/${rule} ]]
198 then
199 rm -f ${MROOT}/etc/udev/rules.d/${rule}
200 fi
201 done
202 }
203
204 postinstall()
205 {
206 # create some nodes that we need if they not exist
207 [[ ! -e ${MROOT}/lib/udev/devices/null ]] &&
208 mknod ${MROOT}/lib/udev/devices/null c 1 3
209 chmod 666 ${MROOT}/lib/udev/devices/null
210 touch -t 198002220222 ${MROOT}/lib/udev/devices/null
211
212 [[ ! -e ${MROOT}/lib/udev/devices/zero ]] &&
213 mknod ${MROOT}/lib/udev/devices/zero c 1 5
214 chmod 666 ${MROOT}/lib/udev/devices/zero
215 touch -t 198002220222 ${MROOT}/lib/udev/devices/zero
216
217 [[ ! -e ${MROOT}/lib/udev/devices/console ]] &&
218 mknod ${MROOT}/lib/udev/devices/console c 5 1
219 chmod 600 ${MROOT}/lib/udev/devices/console
220 chown root:tty ${MROOT}/lib/udev/devices/console
221 touch -t 198002220222 ${MROOT}/lib/udev/devices/console
222
223 [[ ! -e ${MROOT}/lib/udev/devices/urandom ]] &&
224 mknod ${MROOT}/lib/udev/devices/urandom c 1 9
225 chmod 666 ${MROOT}/lib/udev/devices/urandom
226 touch -t 198002220222 ${MROOT}/lib/udev/devices/urandom
227
228 # after install/uprade, udev *must* be reloaded if already running
229 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] &&
230 [[ -n $(pidof udevd) ]] && [[ ${MAGE_BOOTSTRAP} != true ]]
231 then
232 echo "MROOT=/; restarting udev daemon ..."
233 killall -15 udevd &> /dev/null
234 sleep 1
235 killall -9 udevd &> /dev/null
236 /sbin/udevd --daemon
237 fi
238
239 # converting databases
240 echo "MROOT=/; converting udev database ..."
241 /sbin/udevadm info --convert-db
242
243 # set udev to the default devicemanager
244 sed 's:^\(RC_DEVICEMANAGER=\).*:\1udev:' /etc/conf.d/kernel
245 }
246
247 postremove()
248 {
249 if [[ -x /sbin/mdev ]] && [[ ! -x /sbin/udevd ]]
250 then
251 # restore mdev as default devicemanager
252 sed 's:^\(RC_DEVICEMANAGER=\).*:\1mdev:' /etc/conf.d/kernel
253 fi
254 }