11 |
yes|y|true|1) use_sudo=sudo ;; |
yes|y|true|1) use_sudo=sudo ;; |
12 |
esac |
esac |
13 |
|
|
14 |
LC_ALL=C ${use_sudo} /usr/sbin/hwinfo $@ |
${use_sudo} /usr/sbin/hwinfo $@ |
15 |
} |
} |
16 |
|
|
17 |
# get_hwinfo $hw_item |
# get_hwinfo $hw_item |
165 |
local variable="$2" |
local variable="$2" |
166 |
local method |
local method |
167 |
|
|
|
local use_sudo="" |
|
|
case ${SUDO} in |
|
|
yes|y|true|1) use_sudo=sudo ;; |
|
|
esac |
|
|
|
|
168 |
case $1 in |
case $1 in |
169 |
--uuid|-u) shift; method="-U"; partition="$1"; variable="$2" ;; |
--uuid|-u) shift; method="-U"; partition="$1"; variable="$2" ;; |
170 |
--label|-l) shift; method="-L"; partition="$1"; variable="$2" ;; |
--label|-l) shift; method="-L"; partition="$1"; variable="$2" ;; |
182 |
return 1 |
return 1 |
183 |
fi |
fi |
184 |
|
|
185 |
LC_ALL=C ${use_sudo} blkid -o value -s "${variable}" "${method}" "${partition}" |
blkid -o value -s "${variable}" "${method}" "${partition}" |
186 |
} |
} |
187 |
|
|
188 |
get_fstype() |
get_fstype() |
215 |
get_blkid_information ${partition} UUID |
get_blkid_information ${partition} UUID |
216 |
} |
} |
217 |
|
|
218 |
|
# create_initrd {/path/to/initrd kernelversion </path/to/config>} |
219 |
|
# when nothing given then /boot/initrd-$(uname -r).img $(uname -r) will be used |
220 |
|
# default config path is /etc/conf.d/mkinitrd |
221 |
|
create_initrd() |
222 |
|
{ |
223 |
|
local initrd |
224 |
|
local kernel |
225 |
|
local config |
226 |
|
local chroot |
227 |
|
#local root |
228 |
|
local modules |
229 |
|
# enabled framebuffer modules as default |
230 |
|
local framebuffer=1 |
231 |
|
local uvesafb_config="/etc/modprobe.d/uvesafb.conf" |
232 |
|
|
233 |
|
# very basic getops |
234 |
|
for i in $* |
235 |
|
do |
236 |
|
case $1 in |
237 |
|
--initrd|-i) shift; initrd="$1" ;; |
238 |
|
--config|-c) shift; config="$1" ;; |
239 |
|
--kernelversion|-v) shift; kernel="$1" ;; |
240 |
|
--nofb) shift; framebuffer=0 |
241 |
|
esac |
242 |
|
shift |
243 |
|
done |
244 |
|
|
245 |
|
[[ -z ${initrd} ]] && initrd="/boot/initrd-$(uname -r).img" |
246 |
|
[[ -z ${kernel} ]] && kernel="$(uname -r)" |
247 |
|
[[ -z ${config} ]] && config="/etc/conf.d/mkinitrd" |
248 |
|
|
249 |
|
if [[ ! -z ${INSTALL_ROOT} ]] |
250 |
|
then |
251 |
|
config="${INSTALL_ROOT}/${config}" |
252 |
|
uvesafb_config="${INSTALL_ROOT}/${uvesafb_config}" |
253 |
|
chroot="chrooted" |
254 |
|
fi |
255 |
|
|
256 |
|
# get various modules needed to boot |
257 |
|
modules="$(get_driver_modules disk)" |
258 |
|
modules+=" $(get_driver_modules scsi)" |
259 |
|
modules+=" $(get_driver_modules cdrom)" |
260 |
|
|
261 |
|
# check for special ide_disk drivers (ata support) |
262 |
|
if [[ ! -z $(echo ${modules} | grep ide_disk) ]] |
263 |
|
then |
264 |
|
modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" |
265 |
|
fi |
266 |
|
|
267 |
|
# check for usb-storage and add usb host drivers |
268 |
|
if [[ ! -z $(echo ${modules} | grep usb[_-]storage) ]] |
269 |
|
then |
270 |
|
# add usb1, usb1.1, usb2 and ubs3 hosts |
271 |
|
modules+=" uhci-hcd ohci-hcd ehci-hcd xhci-hcd" |
272 |
|
fi |
273 |
|
|
274 |
|
# add some generic modules |
275 |
|
modules+=" sg_mod sg loop sr_mod sd_mod ide-cd ide-cd_mod ide-disk" |
276 |
|
|
277 |
|
# add generic framebuffer modules |
278 |
|
if [[ ${framebuffer} = 1 ]] |
279 |
|
then |
280 |
|
modules+=" uvesafb" |
281 |
|
|
282 |
|
# setup modprobe conf too |
283 |
|
[[ ! -d $(dirname ${uvesafb_config}) ]] && install -d $(dirname ${uvesafb_config}) |
284 |
|
cat > ${uvesafb_config} << EOF |
285 |
|
# This file sets the parameters for uvesafb module. |
286 |
|
# The following format should be used: |
287 |
|
# options uvesafb mode_option=<xres>x<yres>[-<bpp>][@<refresh>] scroll=<ywrap|ypan|redraw> ... |
288 |
|
# |
289 |
|
# For more details see: |
290 |
|
# http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/fb/uvesafb.txt |
291 |
|
# |
292 |
|
EOF |
293 |
|
# fix a issues with virtualbox and 'ywrap' |
294 |
|
if [[ ! -z $(hwinfo --bios | grep -i virtualbox) ]] |
295 |
|
then |
296 |
|
# use redraw on virtualbox |
297 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=redraw" >> ${uvesafb_config} |
298 |
|
else |
299 |
|
# default config 1024x768 and 60 HZ |
300 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" >> ${uvesafb_config} |
301 |
|
fi |
302 |
|
fi |
303 |
|
|
304 |
|
# remove all duplicate modules |
305 |
|
modules="$(remove_duplicates ${modules})" |
306 |
|
|
307 |
|
# hotfix for usb-storage |
308 |
|
modules="${modules/usb_storage/usb-storage}" |
309 |
|
|
310 |
|
# create the config and an initrd |
311 |
|
echo "# autogenerated config file" > ${config} |
312 |
|
echo "MODULES=\"${modules}\"" >> ${config} |
313 |
|
echo "IMAGE_TYPE=\"initramfs\"" >> ${config} |
314 |
|
|
315 |
|
${chroot} mkinitrd -f ${initrd} ${kernel} |
316 |
|
} |
317 |
|
|
318 |
is_mounted() |
is_mounted() |
319 |
{ |
{ |
320 |
local item |
local item |
349 |
[[ $(cat ${interface}/carrier) = 1 ]] || return 1 |
[[ $(cat ${interface}/carrier) = 1 ]] || return 1 |
350 |
} |
} |
351 |
|
|
352 |
# device_minimum_size [drive] [size-in-mb] |
hdd_size_below_256mb() |
|
device_minimum_size() |
|
353 |
{ |
{ |
354 |
local device="$1" |
local hdd="$1" |
|
local minimum_size="$2" |
|
355 |
local size |
local size |
356 |
|
local retval |
357 |
|
[[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!" |
358 |
|
|
359 |
local use_sudo="" |
size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
360 |
case ${SUDO} in |
if [[ ${size} -le 257000000 ]] |
361 |
yes|y|true|1) use_sudo=sudo ;; |
then |
362 |
esac |
retval="0" |
363 |
|
else |
364 |
[[ -z ${device} ]] && dialog_die "Error: device_minimum_size() no \$device given!" |
retval="1" |
365 |
[[ -z ${minimum_size} ]] && dialog_die "Error: device_minimum_size() no \$minium_size given!" |
fi |
|
|
|
|
# convert to bytes |
|
|
minimum_size=$(( ${minimum_size}*1024*1024 )) |
|
|
|
|
|
size=$(LC_ALL=C ${use_sudo} fdisk -l ${device} | grep "Disk.*${device}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
|
|
[[ ${size} -ge ${minimum_size} ]] || return 1 |
|
366 |
|
|
367 |
return 0 |
return "${retval}" |
368 |
} |
} |
369 |
|
|
370 |
chrooted() |
chrooted() |
371 |
{ |
{ |
372 |
local cmd="$@" |
local cmd="$@" |
373 |
|
|
|
local use_sudo="" |
|
|
case ${SUDO} in |
|
|
yes|y|true|1) use_sudo=sudo ;; |
|
|
esac |
|
|
|
|
374 |
is_mounted --location ${INSTALLROOT}/sys || mount -t sysfs sysfs ${INSTALLROOT}/sys |
is_mounted --location ${INSTALLROOT}/sys || mount -t sysfs sysfs ${INSTALLROOT}/sys |
375 |
is_mounted --location ${INSTALLROOT}/proc || mount -t proc proc ${INSTALLROOT}/proc |
is_mounted --location ${INSTALLROOT}/proc || mount -t proc proc ${INSTALLROOT}/proc |
376 |
is_mounted --location ${INSTALLROOT}/dev || mount -o bind /dev ${INSTALLROOT}/dev |
is_mounted --location ${INSTALLROOT}/dev || mount -o bind /dev ${INSTALLROOT}/dev |
377 |
|
|
378 |
LC_ALL=C ${use_sudo} chroot ${INSTALLROOT} ${cmd} |
chroot ${INSTALLROOT} ${cmd} |
379 |
|
|
380 |
is_mounted --location ${INSTALLROOT}/dev && umount ${INSTALLROOT}/dev |
is_mounted --location ${INSTALLROOT}/dev && umount ${INSTALLROOT}/dev |
381 |
is_mounted --location ${INSTALLROOT}/proc && umount ${INSTALLROOT}/proc |
is_mounted --location ${INSTALLROOT}/proc && umount ${INSTALLROOT}/proc |