X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Flive-premount%2F10driver_updates;h=0a88724b5c933275637dbfa63f550112d4210f0c;hb=fdd8036ba32ad88e83a61191cc4597ae060355d2;hp=546d3ca689775c56a4c97aca15941ff6d49e97be;hpb=140b179f0ff73f3cc1c081f6e6641417a5a0788d;p=live-boot-grml.git diff --git a/scripts/live-premount/10driver_updates b/scripts/live-premount/10driver_updates index 546d3ca..0a88724 100755 --- a/scripts/live-premount/10driver_updates +++ b/scripts/live-premount/10driver_updates @@ -1,110 +1,155 @@ #!/bin/sh +#set -e + +# initramfs-tools header + PREREQ="" -. /scripts/live-functions -. /scripts/live-helpers prereqs() { - echo "$PREREQ" + echo "${PREREQ}" } -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; +case "${1}" in + prereqs) + prereqs + exit 0 + ;; esac +# live-initramfs header + +if [ -n "${NOUSER}" ] +then + exit 0 +fi + +. /scripts/live-functions +. /scripts/live-helpers + +log_begin_msg "Adding live session user..." + +# live-initramfs script + mountpoint=/cdrom -is_updates_path() { +is_updates_path () +{ # Driver packages are stored in ubuntu-drivers// # subdirectory. Each package contains a module for a specific # kernel flavour. + path=$1 kbase=$(uname -r | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)-.*/\1/') update_dir="$path/ubuntu-drivers/$kbase" - if [ -d "$update_dir" ]; then + + if [ -d "$update_dir" ] + then if [ "$(echo $update_dir/*_$DPKG_ARCH.deb)" != \ - "$update_dir/*_$DPKG_ARCH.deb" ]; then + "$update_dir/*_$DPKG_ARCH.deb" ] + then echo "$update_dir" return 0; fi fi + return 1; } -is_nice_device() { - sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))"; then - return 0 - fi - return 1 +is_nice_device () +{ + sysfs_path="${1#/sys}" + + if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))" + then + return 0 + fi + + return 1 } -is_supported_fs () { - # FIXME: do something better like the scan of supported filesystems - fstype="${1}" - case ${fstype} in - vfat|iso9660|udf|ext2|ext3|ntfs) - return 0 - ;; - esac - return 1 +is_supported_fs () +{ + # FIXME: do something better like the scan of supported filesystems + fstype="${1}" + + case ${fstype} in + vfat|iso9660|udf|ext2|ext3|ntfs) + return 0 + ;; + esac + + return 1 } check_dev_updates () { - sysdev="${1}" - devname="${2}" - if [ -z "${devname}" ]; then - devname=$(sys2dev "${sysdev}") - fi - - fstype=$(get_fstype "${devname}") - if is_supported_fs ${fstype}; then - mount -t ${fstype} -o ro "${devname}" $mountpoint || continue - if is_updates_path $mountpoint; then - return 0 - else - umount $mountpoint - fi - fi - - return 1 -} + sysdev="${1}" + devname="${2}" + + if [ -z "${devname}" ] + then + devname=$(sys2dev "${sysdev}") + fi + + fstype=$(get_fstype "${devname}") + + if is_supported_fs ${fstype} + then + mount -t ${fstype} -o ro "${devname}" $mountpoint || continue + + if is_updates_path $mountpoint + then + return 0 + else + umount $mountpoint + fi + fi -find_driver_updates() { - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do - devname=$(sys2dev "${sysblock}") - fstype=$(get_fstype "${devname}") - if /lib/udev/cdrom_id ${devname} > /dev/null; then - if check_dev_updates "null" "${devname}" ; then - return 0 - fi - elif is_nice_device "${sysblock}" ; then - for dev in $(subdevices "${sysblock}"); do - if check_dev_updates "${dev}" ; then - return 0 - fi - done - fi - done - return 1 + return 1 } -pulsate() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "PULSATE" - fi +find_driver_updates () +{ + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram) + do + devname=$(sys2dev "${sysblock}") + fstype=$(get_fstype "${devname}") + + if /lib/udev/cdrom_id ${devname} > /dev/null + then + if check_dev_updates "null" "${devname}" + then + return 0 + fi + elif is_nice_device "${sysblock}" + then + for dev in $(subdevices "${sysblock}") + do + if check_dev_updates "${dev}" + then + return 0 + fi + done + fi + done + + return 1 } +pulsate () +{ + if [ -x /sbin/usplash_write ] + then + /sbin/usplash_write "PULSATE" + fi +} updates="false" -for x in $(cat /proc/cmdline); do +for x in $(cat /proc/cmdline) +do case $x in debian-installer/driver-update=*) updates=${x#debian-installer/driver-update=} @@ -112,22 +157,25 @@ for x in $(cat /proc/cmdline); do esac done -if [ "$updates" != "true" ]; then +if [ "$updates" != "true" ] +then log_end_msg exit 0 fi # Not sure what to do for network installs. I assume there isn't even a CD # for this anyway, so fail. -if [ -n "${NETBOOT}" ]; then +if [ -n "${NETBOOT}" ] +then log_end_msg exit 0; fi -#if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then -# GDMCONF=/etc/gdm/gdm-cdd.conf +#if chroot /root [ -f /etc/gdm/gdm-cdd.conf ] +#then +# GDMCONF=/etc/gdm/gdm-cdd.conf #else -# GDMCONF=/etc/gdm/gdm.conf +# GDMCONF=/etc/gdm/gdm.conf #fi if [ -x /usr/bin/eject ] @@ -139,17 +187,22 @@ log_wait_msg "Insert a driver CD and press ENTER ($DPKG_ARCH)" log_begin_msg "Looking for driver update CD" -for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do +for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 +do updates_root=$(find_driver_updates) - if [ "${updates_root}" ]; then + + if [ "${updates_root}" ] + then break; fi + sleep 1 done log_end_msg -if [ -z "${updates_root}" ]; then +if [ -z "${updates_root}" ] +then log_begin_msg "Could not find driver updates" log_wait_msg "Re-insert install CD and press ENTER" exit 0