1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/include/hwdetection.sh,v 1.1 2008-09-24 10:54:00 niro Exp $ |
# $Id$ |
3 |
|
|
4 |
## hwdetection, needs >= sys-apps/hwinfo |
## hwdetection, needs >= sys-apps/hwinfo |
5 |
|
|
95 |
do |
do |
96 |
eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:,:\ :") |
eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:,:\ :") |
97 |
done |
done |
98 |
echo "${modules}" |
remove_duplicates "${modules}" |
99 |
} |
} |
100 |
|
|
101 |
# remove_duplicates $list |
# remove_duplicates $list |
117 |
|
|
118 |
# remove all ':' and show the cleaned list |
# remove all ':' and show the cleaned list |
119 |
# this way fixes double spaces also |
# this way fixes double spaces also |
120 |
|
local counter |
121 |
|
declare -i counter=0 |
122 |
for i in $(echo ${fixed_list} | sed "s|:| |g") |
for i in $(echo ${fixed_list} | sed "s|:| |g") |
123 |
do |
do |
124 |
list+=" ${i}" |
(( counter++ )) |
125 |
|
if [[ ${counter} -eq 1 ]] |
126 |
|
then |
127 |
|
list="${i}" |
128 |
|
else |
129 |
|
list+=" ${i}" |
130 |
|
fi |
131 |
done |
done |
132 |
|
|
133 |
echo "${list}" |
echo "${list}" |
136 |
get_x11_driver_modules() |
get_x11_driver_modules() |
137 |
{ |
{ |
138 |
local modules |
local modules |
139 |
modules="$(hwinfo --gfxcard | grep "XFree86 v4 Server Module:" | cut -d: -f2)" |
modules="$(hwinfo --gfxcard | grep 'XFree86 v4 Server Module:' | sed 's/.*Module:\ \(.*\)/\1/')" |
140 |
|
|
141 |
# remove duplicates from list and show it |
# remove duplicates from list and show it |
142 |
remove_duplicates "${modules}" |
remove_duplicates "${modules}" |
143 |
} |
} |
144 |
|
|
145 |
|
get_evdev_device_path() |
146 |
|
{ |
147 |
|
local device="$1" |
148 |
|
local path |
149 |
|
|
150 |
|
case ${device} in |
151 |
|
mouse|keyboard) true;; |
152 |
|
*) die "unkown device";; |
153 |
|
esac |
154 |
|
|
155 |
|
path="$(hwinfo --${device} | grep 'Device Files:' | sed 's:.*\(/dev/input/event[0-5]\).*:\1:')" |
156 |
|
echo "${path}" |
157 |
|
} |
158 |
|
|
159 |
|
# get_netcard_driver_modules device |
160 |
|
# e.g. get_netcard_driver_modules eth0 |
161 |
|
get_netcard_driver_modules() |
162 |
|
{ |
163 |
|
local device="$1" |
164 |
|
local modules |
165 |
|
|
166 |
|
if [[ -z ${device} ]] |
167 |
|
then |
168 |
|
echo "Error: get_netcard_driver_module(): no device given" |
169 |
|
return 1 |
170 |
|
fi |
171 |
|
|
172 |
|
modules=$(hwinfo --netcard | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q') |
173 |
|
remove_duplicates "${modules}" |
174 |
|
} |
175 |
|
|
176 |
|
get_blkid_information() |
177 |
|
{ |
178 |
|
local partition="$1" |
179 |
|
local variable="$2" |
180 |
|
local method |
181 |
|
|
182 |
|
case $1 in |
183 |
|
--uuid|-u) shift; method="-U"; partition="$1"; variable="$2" ;; |
184 |
|
--label|-l) shift; method="-L"; partition="$1"; variable="$2" ;; |
185 |
|
esac |
186 |
|
|
187 |
|
if [[ -z ${partition} ]] |
188 |
|
then |
189 |
|
echo "Error: get_get_blkid_information()(): no partition given" |
190 |
|
return 1 |
191 |
|
fi |
192 |
|
|
193 |
|
if [[ -z ${variable} ]] |
194 |
|
then |
195 |
|
echo "Error: get_get_blkid_information()(): no variable given" |
196 |
|
return 1 |
197 |
|
fi |
198 |
|
|
199 |
|
blkid -o value -s "${variable}" "${method}" "${partition}" |
200 |
|
} |
201 |
|
|
202 |
|
get_fstype() |
203 |
|
{ |
204 |
|
local partition="$1" |
205 |
|
if [[ -z ${partition} ]] |
206 |
|
then |
207 |
|
echo "Error: get_fstype(): no partition given" |
208 |
|
return 1 |
209 |
|
fi |
210 |
|
|
211 |
|
# does not work with uuids |
212 |
|
#mount -f --guess-fstype ${partition} |
213 |
|
|
214 |
|
get_blkid_information ${partition} TYPE |
215 |
|
} |
216 |
|
|
217 |
|
get_uuid() |
218 |
|
{ |
219 |
|
local partition="$1" |
220 |
|
if [[ -z ${partition} ]] |
221 |
|
then |
222 |
|
echo "Error: get_uuid(): no partition given" |
223 |
|
return 1 |
224 |
|
fi |
225 |
|
|
226 |
|
# does not work with uuids |
227 |
|
#mount -f --guess-fstype ${partition} |
228 |
|
|
229 |
|
get_blkid_information ${partition} UUID |
230 |
|
} |
231 |
|
|
232 |
# create_initrd {/path/to/initrd kernelversion </path/to/config>} |
# create_initrd {/path/to/initrd kernelversion </path/to/config>} |
233 |
# when nothing given then /boot/initrd-$(uname -r).img $(uname -r) will be used |
# when nothing given then /boot/initrd-$(uname -r).img $(uname -r) will be used |
234 |
# default config path is /etc/conf.d/mkinitrd |
# default config path is /etc/conf.d/mkinitrd |
240 |
local chroot |
local chroot |
241 |
#local root |
#local root |
242 |
local modules |
local modules |
243 |
|
# enabled framebuffer modules as default |
244 |
|
local framebuffer=1 |
245 |
|
local uvesafb_config="/etc/modprobe.d/uvesafb.conf" |
246 |
|
|
247 |
# very basic getops |
# very basic getops |
248 |
for i in $* |
for i in $* |
252 |
--initrd|-i) shift; initrd="$1" ;; |
--initrd|-i) shift; initrd="$1" ;; |
253 |
--config|-c) shift; config="$1" ;; |
--config|-c) shift; config="$1" ;; |
254 |
--kernelversion|-v) shift; kernel="$1" ;; |
--kernelversion|-v) shift; kernel="$1" ;; |
255 |
|
--nofb) shift; framebuffer=0 |
256 |
esac |
esac |
257 |
shift |
shift |
258 |
done |
done |
264 |
if [[ ! -z ${INSTALL_ROOT} ]] |
if [[ ! -z ${INSTALL_ROOT} ]] |
265 |
then |
then |
266 |
config="${INSTALL_ROOT}/${config}" |
config="${INSTALL_ROOT}/${config}" |
267 |
|
uvesafb_config="${INSTALL_ROOT}/${uvesafb_config}" |
268 |
chroot="chrooted" |
chroot="chrooted" |
269 |
fi |
fi |
270 |
|
|
279 |
modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" |
modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" |
280 |
fi |
fi |
281 |
|
|
282 |
|
# add some generic modules |
283 |
|
modules+=" sg_mod sg loop sr_mod sd_mod ide-cd ide-cd_mod ide-disk" |
284 |
|
|
285 |
|
# add generic framebuffer modules |
286 |
|
if [[ ${framebuffer} = 1 ]] |
287 |
|
then |
288 |
|
modules+=" uvesafb" |
289 |
|
|
290 |
|
# setup modprobe conf too |
291 |
|
[[ ! -d $(dirname ${uvesafb_config}) ]] && install -d $(dirname ${uvesafb_config}) |
292 |
|
cat > ${uvesafb_config} << EOF |
293 |
|
# This file sets the parameters for uvesafb module. |
294 |
|
# The following format should be used: |
295 |
|
# options uvesafb mode_option=<xres>x<yres>[-<bpp>][@<refresh>] scroll=<ywrap|ypan|redraw> ... |
296 |
|
# |
297 |
|
# For more details see: |
298 |
|
# http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/fb/uvesafb.txt |
299 |
|
# |
300 |
|
EOF |
301 |
|
# default config 1024x768 and 60 HZ |
302 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" >> ${uvesafb_config} |
303 |
|
fi |
304 |
|
|
305 |
# remove all duplicate modules |
# remove all duplicate modules |
306 |
modules="$(remove_duplicates ${modules})" |
modules="$(remove_duplicates ${modules})" |
307 |
|
|