1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/hwdetection.sh,v 1.8 2008-09-22 22:06:46 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/hwdetection.sh,v 1.9 2008-09-24 10:15:46 niro Exp $ |
3 |
|
|
4 |
## hwdetection, needs >= sys-apps/hwinfo |
## hwdetection, needs >= sys-apps/hwinfo |
5 |
|
|
139 |
# default config path is /etc/conf.d/mkinitrd |
# default config path is /etc/conf.d/mkinitrd |
140 |
create_initrd() |
create_initrd() |
141 |
{ |
{ |
142 |
local initrd="$1" |
local initrd |
143 |
local kernel="$2" |
local kernel |
144 |
local config="$3" |
local config |
145 |
|
local chroot |
146 |
|
#local root |
147 |
local modules |
local modules |
148 |
|
|
149 |
|
# very basic getops |
150 |
|
for i in $* |
151 |
|
do |
152 |
|
case $1 in |
153 |
|
#--root|-r) shift; root="$1" ;; |
154 |
|
--initrd|-i) shift; initrd="$1" ;; |
155 |
|
--config|-c) shift; config="$1" ;; |
156 |
|
--kernelversion|-v) shift; kernel="$1" ;; |
157 |
|
esac |
158 |
|
shift |
159 |
|
done |
160 |
|
|
161 |
[[ -z ${initrd} ]] && initrd="/boot/initrd-$(uname -r).img" |
[[ -z ${initrd} ]] && initrd="/boot/initrd-$(uname -r).img" |
162 |
[[ -z ${kernel} ]] && kernel="$(uname -r)" |
[[ -z ${kernel} ]] && kernel="$(uname -r)" |
163 |
[[ -z ${config} ]] && config="/etc/conf.d/mkinitrd" |
[[ -z ${config} ]] && config="/etc/conf.d/mkinitrd" |
164 |
|
|
165 |
|
if [[ ! -z ${INSTALL_ROOT} ]] |
166 |
|
then |
167 |
|
config="${INSTALL_ROOT}/${config}" |
168 |
|
chroot="chrooted" |
169 |
|
fi |
170 |
|
|
171 |
# get various modules needed to boot |
# get various modules needed to boot |
172 |
modules="${modules} $(get_driver_modules disk)" |
modules="$(get_driver_modules disk)" |
173 |
modules="${modules} $(get_driver_modules scsi)" |
modules+=" $(get_driver_modules scsi)" |
174 |
modules="${modules} $(get_driver_modules cdrom)" |
modules+=" $(get_driver_modules cdrom)" |
175 |
|
|
176 |
|
# check for special ide_disk drivers (ata support) |
177 |
|
if [[ ! -z $(echo ${modules} | grep ide_disk) ]] |
178 |
|
then |
179 |
|
modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" |
180 |
|
fi |
181 |
|
|
182 |
# remove all duplicate modules |
# remove all duplicate modules |
183 |
modules="$(remove_duplicates ${modules})" |
modules="$(remove_duplicates ${modules})" |
187 |
echo "MODULES=\"${modules}\"" >> ${config} |
echo "MODULES=\"${modules}\"" >> ${config} |
188 |
echo "IMAGE_TYPE=\"initramfs\"" >> ${config} |
echo "IMAGE_TYPE=\"initramfs\"" >> ${config} |
189 |
|
|
190 |
mkinitrd -f ${initrd} ${kernel} |
${chroot} mkinitrd -f ${initrd} ${kernel} |
191 |
|
} |
192 |
|
|
193 |
|
chrooted() |
194 |
|
{ |
195 |
|
local cmd="$@" |
196 |
|
|
197 |
|
mount -t sysfs sysfs ${INSTALL_ROOT}/sys |
198 |
|
mount -t proc proc ${INSTALL_ROOT}/proc |
199 |
|
mount -o bind /dev ${INSTALL_ROOT}/dev |
200 |
|
|
201 |
|
chroot ${INSTALL_ROOT} ${cmd} |
202 |
|
|
203 |
|
umount ${INSTALL_ROOT}/dev |
204 |
|
umount ${INSTALL_ROOT}/proc |
205 |
|
umount ${INSTALL_ROOT}/sys |
206 |
} |
} |
207 |
|
|
208 |
# special: memory (size), floppy (modprobe floppy), smp (support y/n) |
# special: memory (size), floppy (modprobe floppy), smp (support y/n) |