From f5e7391adc9845494bb4a812e0273ffdc2b66237 Mon Sep 17 00:00:00 2001
From: Michael Hanson <hansonorders@verizon.net>
Date: Wed, 1 Dec 2010 23:08:19 +0000
Subject: hwdetect: upgrade to latest

---
 abs/core/hwdetect/PKGBUILD |  23 ++-
 abs/core/hwdetect/hwdetect | 492 +++++++++++++++++++++++++++------------------
 2 files changed, 313 insertions(+), 202 deletions(-)

diff --git a/abs/core/hwdetect/PKGBUILD b/abs/core/hwdetect/PKGBUILD
index 14fd6a9..e386628 100644
--- a/abs/core/hwdetect/PKGBUILD
+++ b/abs/core/hwdetect/PKGBUILD
@@ -1,18 +1,19 @@
-# $Id: PKGBUILD 356 2008-04-18 22:56:27Z aaron $
+# $Id: PKGBUILD 86895 2010-08-06 20:29:04Z tpowa $
 # Maintainer: Tobias Powalowski <tpowa@archlinux.org>
 pkgname=hwdetect
-pkgver=0.9
-pkgrel=10
+pkgver=2010.08
+pkgrel=1
 pkgdesc="Hardware detection script with loading modules and mkinitcpio.conf / rc.conf support"
-arch=(i686 x86_64)
-license=('custom:none')
-groups=('base')
-backup=()
-depends=('sh' 'awk' 'grep' 'coreutils' 'sed')
+arch=(any)
+license=('GPL')
+depends=('sh' 'awk' 'grep' 'coreutils' 'sed' 'e2fsprogs')
+optdepends=('cryptsetup: for encrypt mkinitcpio config support'
+            'dmraid:     for dmraid mkinitcpio config support'
+            'lvm2:       for lvm2 mkinitcpio config support'
+            'mdadm:      for raid mkinitcpio config support')
 source=(hwdetect)
-md5sums=('bae2a26062c1ae8036b3a2173c8e3b51')
 
 build() {
-  install -D -m 755 $startdir/src/hwdetect $startdir/pkg/sbin/hwdetect
+  install -D -m 755 ${srcdir}/hwdetect ${pkgdir}/sbin/hwdetect
 }
-
+md5sums=('cece9e167bb240c82855ffc3f632a5bb')
diff --git a/abs/core/hwdetect/hwdetect b/abs/core/hwdetect/hwdetect
index 4991210..280cafa 100755
--- a/abs/core/hwdetect/hwdetect
+++ b/abs/core/hwdetect/hwdetect
@@ -16,6 +16,7 @@ usage () {
 	echo "    --show-agp             show AGP modules"
 	echo "    --show-acpi            show ACPI modules"	
 	echo "    --show-ide             show IDE modules"
+	echo "    --show-pata            show PATA modules"
 	echo "    --show-scsi            show SCSI modules"
 	echo "    --show-sata            show SATA modules"
 	echo "    --show-usb             show USB modules"
@@ -26,29 +27,35 @@ usage () {
 	echo "    --show-isdn            show ISDN modules"
 	echo "    --show-pcmcia          show PCMCIA modules"
 	echo "    --show-sound           show SOUND modules"
+	echo "    --show-staging         show STAGING modules"
 	echo "    --show-video           show VIDEO modules"
 	echo "    --show-other           show OTHER modules"
 	echo ""
 	echo "  For /etc/mkinitcpio.conf use:"
+	echo "    --filesystem           add filesystems to MODULES="
 	echo "    --hostcontroller       show MODULES= for all hostcontrollers"
 	echo "    --vmware               add BusLogic to MODULES for vmware"
+	echo "    --ati-kms              add ati kernel mode setting" 
+	echo "    --intel-kms            add intel kernel mode setting"
+	echo "    --nvidia-kms           add nvidia kernel mode setting"
         echo "" 
+	echo "    --rootdevice=          autodetected advanced features of rootdevice"
+	echo "    --hooks-dir=           use this directory for HOOKS check"
+	echo "    --advanced             show autodetected advanced HOOKS"
 	echo "    --hooks                show HOOKS="
-	echo "    --hooks-dir            use this directory for HOOKS check"
-	echo "    --dsdt                 add dsdt to HOOKS="
-	echo "    --raid                 add raid to HOOKS="
-	echo "    --raid-partitions      add raid-partitions to HOOKS="
-	echo "    --encrypt              add encrypt to HOOKS="
-	echo "    --lvm2                 add lvm2 to HOOKS="
+	echo "    --dmraid               add dmraid to HOOKS="
 	echo "    --keymap               add keymap to HOOKS="
 	echo "    --usb                  add usb to HOOKS="
+	echo "    --usbinput             add usbinput to HOOKS="
 	echo "    --fw                   add fw to HOOKS="
 	echo "    --pcmcia               add pcmcia to HOOKS="
 	echo "    --nfs                  add net to HOOKS="
+	echo "    --btrfs                add btrfs to HOOKS="
 	echo ""
 	echo "  For /etc/rc.conf use:"
 	echo "    --net                  show network MODULES"
 	echo "    --sound                show sound MODULES"
+	echo "    --usbhost              show usb hostcontroller MODULES"
 	echo "    --modules              show all detected MODULES"
 	echo ""
 	exit 1
@@ -61,37 +68,34 @@ usage () {
 # setting kernel version
 case $1 in
 	--kernel_version=*)
-	KERNEL_VERSION="`echo $1 | awk -F= '{print $2;}'`"
+	KERNEL_VERSION="$(echo $1 | awk -F= '{print $2;}')"
+	;;
+	--rootdevice=*)
+	ROOTDEVICE="$(echo $1 | awk -F= '{print $2;}')"
 	;;
 esac
 
 if [ "$KERNEL_VERSION" = "" ]; then
-	KERNEL_VERSION="`uname -r`"
+	KERNEL_VERSION="$(uname -r)"
 fi
 
 # IDE/PATA switch
 [ "$(echo $* | grep '\-ide-legacy')" ] && IDE_LEGACY=1
 
-# dsdt switch
-[ "$(echo $* | grep '\-dsdt')" ] && DSDT=1
-
-# raid switch
-[ "$(echo $* | grep '\-raid-partition')" ] && RAID_PARTITIONS=1
-if ! [ "$RAID_PARTITIONS" = "1" ]; then
-	[ "$(echo $* | grep '\-raid')" ] && RAID=1
-fi
-
-# encrypt switch
-[ "$(echo $* | grep '\-encrypt')" ] && ENCRYPT=1
+# uvesafb switch
+[ "$(echo $* | grep '\-uvesafb')" ] && UVESAFB=1
 
-# lvm2 switch
-[ "$(echo $* | grep '\-lvm2')" ] && LVM2=1
+# dmraid switch
+[ "$(echo $* | grep '\-dmraid')" ] && DMRAID=1
 
 # keymap switch
 [ "$(echo $* | grep '\-keymap')" ] && KEYMAP=1
 
 # usb switch
-[ "$(echo $* | grep '\-usb')" ] && USB=1
+[ "$(echo $* | grep '\-usb ')" ] && USB=1
+
+# usbinput switch
+[ "$(echo $* | grep '\-usbinput')" ] && USBINPUT=1
 
 # fw switch
 [ "$(echo $* | grep '\-fw')" ] && FW=1
@@ -102,9 +106,115 @@ fi
 # nfs switch
 [ "$(echo $* | grep '\-nfs')" ] && NFS=1
 
+# nfs switch
+[ "$(echo $* | grep '\-btrfs')" ] && BTRFS=1
+
 # vmware switch
 [ "$(echo $* | grep '\-vmware')" ] && VMWARE=1
 
+# vmware switch
+[ "$(echo $* | grep '\-hooks')" ] && HOOKS=1
+
+ADVANCED=""
+# root device check
+if ! [ "$ROOTDEVICE" = "" ]; then
+        # check device mapper devices
+	if [ "$(echo "$ROOTDEVICE" | grep "/dev/mapper")" ]; then
+		# check if encryption is used
+		if [ "$(cryptsetup status $ROOTDEVICE 2>/dev/null)" ]; then
+			ADVANCED="encrypt"
+			# check on lvm
+			realdevice="$(cryptsetup status $ROOTDEVICE 2>/dev/null | grep "device:.*/dev/mapper/" | sed -e 's#.*\ ##g')"
+			if [ "$(lvs $realdevice 2>/dev/null)" ]; then
+				ADVANCED="lvm2 encrypt"
+				vg="$(echo $(lvs -o vg_name --noheading $realdevice))"
+				# check on raid
+				[ "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/md")" ] && ADVANCED="mdadm lvm2 encrypt"
+			fi
+			# check on raid
+			if [ "$(cryptsetup status $ROOTDEVICE 2>/dev/null | grep "device:.*/dev/md" | sed -e 's#.*\ ##g')" ]; then
+				ADVANCED="mdadm encrypt"
+				realdevice="$(cryptsetup status $ROOTDEVICE 2>/dev/null | grep "device:.*/dev/md" | sed -e 's#.*\ ##g')"
+				# check on lvm
+				[ "$(mdadm --detail $realdevice | grep "/dev/dm-")" ] && ADVANCED="lvm2 mdadm encrypt"
+			fi
+		fi
+		# check if lvm is used
+		if [ "$(lvs $ROOTDEVICE 2>/dev/null)" ]; then
+			ADVANCED="lvm2"
+			vg="$(echo $(lvs -o vg_name --noheading $ROOTDEVICE))"
+			# check on encrypt
+			if [ "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/dm-")" ]; then 
+				ADVANCED="encrypt lvm2"
+				# check on raid
+				[ "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/md")" ] && ADVANCED="mdadm encrypt lvm2"
+				for i in "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/dm-")"; do
+					realdevice="$(echo $i | cut -d ' ' -f1)"
+					#getsymlink="$(readlink $realdevice)"
+					#correctdevice="$(echo $getsymlink | sed -e 's#\.\.#/dev#g')"
+					[ "$(cryptsetup status $realdevice 2>/dev/null | grep "device:.*/dev/md")" ] && ADVANCED="mdadm encrypt lvm2"
+				done
+			fi
+			# check on raid
+			if [ "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/md")" ]; then
+				ADVANCED="mdadm lvm2"
+				#check on encrypt
+				[ "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/dm-")" ] && ADVANCED="encrypt mdadm lvm2"
+				for i in "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/md")"; do
+					realdevice="$(echo $i | cut -d ' ' -f1)"
+					[ "$(mdadm --detail $realdevice | grep "/dev/dm-")" ] && ADVANCED="encrypt mdadm lvm2"
+				done
+			fi
+		fi
+	fi
+	# check md device
+	if [ "$(echo "$ROOTDEVICE" | grep "/dev/md")" ]; then
+		ADVANCED="mdadm"
+		# raid partitions or raid?
+		if [ "$(echo "$ROOTDEVICE" | grep "/dev/md*p")" ]; then
+			realdevice="$(echo $ROOTDEVICE | sed -e 's#p.*##g' -e 's#/dev/##g')"
+			if ! [ "$(find /sys/block/$realdevice/slaves/ -name 'dm*' 2>/dev/null)" = "" ]; then
+				SET_LVM=""
+				SET_ENCRYPT=""
+				for k in $(find /sys/block/$realdevice/slaves/ -name 'dm*' 2>/dev/null); do
+					[ "$(lvs /dev/mapper/$(cat $k/dm/name) 2>/dev/null)" ] && SET_LVM="1"
+					[ "$(cryptsetup status $(cat $k/dm/name) 2>/dev/null)" ] && SET_ENCRYPT="1"
+					# check on lvm
+					[ "$(lvs /dev/mapper/$(cat $k/dm/name) 2>/dev/null)" ] && ADVANCED="lvm2 mdadm"
+					# check on encrypt
+					[ "$(cryptsetup status $(cat $k/dm/name) 2>/dev/null)" ] && ADVANCED="encrypt mdadm"
+					# check encrypted volume device
+					realdevice="$(cryptsetup status $(cat $k/dm/name) 2>/dev/null | grep "device:.*/dev/mapper/" | sed -e 's#.*\ ##g')"
+					[ "$(lvs $realdevice 2>/dev/null)" ] && ADVANCED="lvm2 encrypt mdadm"
+					vg="$(echo $(lvs -o vg_name --noheading /dev/mapper/$(cat $k/dm/name) 2>/dev/null))"
+					[ "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/dm-")" ] && ADVANCED="encrypt lvm2 mdadm"
+				done
+				[ "$SET_LVM" = "1" -a "$SET_ENCRYPT" = "1" ] && ADVANCED="lvm2 encrypt mdadm"
+			fi
+		else
+			realdevice="$(echo $ROOTDEVICE | sed -e 's#/dev/##g')"
+			if ! [ "$(find /sys/block/$realdevice/slaves/ -name 'dm*' 2>/dev/null)" = "" ]; then
+				SET_LVM=""
+				SET_ENCRYPT=""
+				for k in $(find /sys/block/$realdevice/slaves/ -name 'dm*' 2>/dev/null); do
+					[ "$(lvs /dev/mapper/$(cat $k/dm/name) 2>/dev/null)" ] && SET_LVM="1"
+					[ "$(cryptsetup status $(cat $k/dm/name) 2>/dev/null)" ] && SET_ENCRYPT="1"
+					# check on lvm
+					[ "$(lvs /dev/mapper/$(cat $k/dm/name) 2>/dev/null)" ] && ADVANCED="lvm2 mdadm"
+					# check on encrypt
+					[ "$(cryptsetup status $(cat $k/dm/name) 2>/dev/null)" ] && ADVANCED="encrypt mdadm"
+					# check encrypted volume device
+					realdevice="$(cryptsetup status $(cat $k/dm/name) 2>/dev/null | grep "device:.*/dev/mapper/" | sed -e 's#.*\ ##g')"
+					[ "$(lvs $realdevice 2>/dev/null)" ] && ADVANCED="lvm2 encrypt mdadm"
+					vg="$(echo $(lvs -o vg_name --noheading /dev/mapper/$(cat $k/dm/name) 2>/dev/null))"
+					[ "$(pvs -o pv_name,vg_name --noheading | grep "$vg$" | grep "/dev/dm-")" ] && ADVANCED="encrypt lvm2 mdadm"
+				done
+				[ "$SET_LVM" = "1" -a "$SET_ENCRYPT" = "1" ] && ADVANCED="lvm2 encrypt mdadm"
+			fi
+		fi
+	fi
+fi
+
 # checking /sys
 if ! [ -d /sys/ ]; then
 	echo "/sys/ is not present -- mount /sys first" >&2
@@ -115,9 +225,13 @@ fi
 : >/tmp/modules-stripped
 : >/tmp/modules-sorted
 : >/tmp/moduleslist
+: >/tmp/.blkid
+
+# generate blkid
+/sbin/blkid -c /dev/null -s TYPE > /tmp/.blkid
 
 # find pci aliases
-aliases=`find /sys/ -noleaf -name modalias  -exec cat {} +`
+aliases=$(find /sys/ -noleaf -name modalias  -exec cat {} +)
 
 # check for empty aliases
 if [ "$aliases" = "" ]; then
@@ -126,64 +240,42 @@ if [ "$aliases" = "" ]; then
 fi
 
 # generate files for the different actions
-modprobe -a --set-version=$KERNEL_VERSION --show-depends $aliases >> /tmp/modules-plain 2>/dev/null
-
-# fix evdev detection
-#if [ "`echo $aliases | grep 'serio:ty06pr*[id]*[ex]*'`" ]; then
-#	modprobe -i --set-version=$KERNEL_VERSION --show-depends evdev >> /tmp/modules-plain 2>/dev/null
-#fi
-# fix Intel536ep detection
-#if [ "`echo $aliases | grep 'pci:v00008086d00001040sv000016BEsd00001040bc07sc80i00'`" ]; then
-#	modprobe -i --set-version=$KERNEL_VERSION --show-depends Intel536 >> /tmp/modules-plain 2>/dev/null
-#fi
+modprobe -i -a --set-version=$KERNEL_VERSION --show-depends $aliases >> /tmp/modules-plain 2>/dev/null
 
 # fix ide cdrom detection on proliant 1600
-if [ "`echo $aliases | grep 'pci:v00000E11d00000001sv00000000sd00000000bc06sc02i00'`" ]; then
+if [ "$(echo $aliases | grep 'pci:v00000E11d00000001sv00000000sd00000000bc06sc02i00')" ]; then
 	modprobe -i --set-version=$KERNEL_VERSION --show-depends ide-generic >> /tmp/modules-plain 2>/dev/null
 fi
 
 # find PNP devices like parports, soundcards etc.
 #   (workaround for rtc, pcspkr, irtty-sir and analog are included)
-if [ "`find /sys/devices -noleaf -name 'id' | grep /pnp`" ]; then
-	for i in `find /sys/devices -noleaf -name "id" | grep /pnp`; do
-		devid=`cat $i | grep PNP`
+if [ "$(find /sys/devices -noleaf -name 'id' | grep /pnp)" ]; then
+	for i in $(find /sys/devices -noleaf -name "id" | grep /pnp); do
+		devid=$(cat $i | grep PNP)
 		[ "$devid" ] || continue
 	
 		modprobe -i --set-version=$KERNEL_VERSION --show-depends pnp:d${devid} >> /tmp/modules-plain 2>/dev/null
 	
-		[ "$devid" = "PNP0800" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends pcspkr 2>/dev/null >> /tmp/modules-plain  2>/dev/null
-		#[ "$devid" = "PNP0b00" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends rtc >> /tmp/modules-plain  2>/dev/null
-		[ "$devid" = "PNP0b00" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends rtc_proc 2>/dev/null >> /tmp/modules-plain  2>/dev/null
-		[ "$devid" = "PNP0b00" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends rtc_sysfs 2>/dev/null >> /tmp/modules-plain
-		[ "$devid" = "PNP0b00" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends rtc_dev 2>/dev/null >> /tmp/modules-plain
-		[ "$devid" = "PNP0510" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends irtty-sir 2>/dev/null >> /tmp/modules-plain 2>/dev/null
-		[ "$devid" = "PNP0511" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends irtty-sir 2>/dev/null >> /tmp/modules-plain 2>/dev/null
-		[ "$devid" = "PNPb02f" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends analog 2>/dev/null >> /tmp/modules-plain 2>/dev/null
+		[ "$devid" = "PNP0800" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends pcspkr >> /tmp/modules-plain  2>/dev/null
+		[ "$devid" = "PNP0b00" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends rtc_proc >> /tmp/modules-plain  2>/dev/null
+		[ "$devid" = "PNP0b00" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends rtc_sysfs >> /tmp/modules-plain 2>/dev/null
+		[ "$devid" = "PNP0b00" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends rtc_dev >> /tmp/modules-plain 2>/dev/null
+		[ "$devid" = "PNP0510" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends irtty-sir >> /tmp/modules-plain 2>/dev/null
+		[ "$devid" = "PNP0511" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends irtty-sir >> /tmp/modules-plain 2>/dev/null
+		[ "$devid" = "PNPb02f" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends analog >> /tmp/modules-plain 2>/dev/null
 
 		# load ppp-generic if serial ports are detected for modems
-		[ "$devid" = "PNP0501" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends ppp-generic 2>/dev/null >> /tmp/modules-plain 2>/dev/null
+		[ "$devid" = "PNP0501" ] && modprobe -i --set-version=$KERNEL_VERSION --show-depends ppp-generic >> /tmp/modules-plain 2>/dev/null
 	done
 fi
 
-# IDE disks/cdroms/floppy/tape
-#if [ "`find /proc/ide -noleaf -name 'media'`" ]; then
-#	for i in $(cat `find /proc/ide -noleaf -name "media"`); do
-#		case $i in
-#			cdrom)  modprobe -i --set-version=$KERNEL_VERSION --show-depends ide-cd >> /tmp/modules-plain 2>/dev/null ;;
-#			floppy) modprobe -i --set-version=$KERNEL_VERSION --show-depends ide-floppy >> /tmp/modules-plain 2>/dev/null ;;
-#			disk)   modprobe -i --set-version=$KERNEL_VERSION --show-depends ide-disk >> /tmp/modules-plain 2>/dev/null ;;
-#			tape)   modprobe -i --set-version=$KERNEL_VERSION --show-depends ide-tape >> /tmp/modules-plain 2>/dev/null ;;
-#		esac
-#	done
-#fi
-
 # SCSI disks/cdroms/tapes/generic devices
-if [ "`find /sys/devices -noleaf -name 'type'`" ]; then
-	for i in $(cat `find /sys/devices -noleaf -name "type"`); do
-		case $i in (4|5)       modprobe -i --set-version=$KERNEL_VERSION --show-depends sr-mod >> /tmp/modules-plain 2>/dev/null ;; esac
+if [ "$(find /sys/devices -noleaf -name 'type')" ]; then
+	for i in $(cat $(find /sys/devices -noleaf -name "type")); do
+		case $i in (4|5)       modprobe -i --set-version=$KERNEL_VERSION --show-depends sr_mod >> /tmp/modules-plain 2>/dev/null ;; esac
 		case $i in (2|3|6|8|9) modprobe -i --set-version=$KERNEL_VERSION --show-depends sg >> /tmp/modules-plain 2>/dev/null ;; esac
-		case $i in (0|7|14)	     modprobe -i --set-version=$KERNEL_VERSION --show-depends sd-mod >> /tmp/modules-plain 2>/dev/null ;; esac
-		case $i in (1)           modprobe -i --set-version=$KERNEL_VERSION --show-depends st >> /tmp/modules-plain 2>/dev/null ;; esac
+		case $i in (0|7|14)    modprobe -i --set-version=$KERNEL_VERSION --show-depends sd_mod >> /tmp/modules-plain 2>/dev/null ;; esac
+		case $i in (1)         modprobe -i --set-version=$KERNEL_VERSION --show-depends st >> /tmp/modules-plain 2>/dev/null ;; esac
 	done
 fi
 
@@ -192,60 +284,44 @@ if [ "$VMWARE" = "1" ]; then
 	 modprobe -i --set-version=$KERNEL_VERSION --show-depends BusLogic >> /tmp/modules-plain 2>/dev/null
 fi
 
-# Firewire disks/cdroms/network
-#if [ "`grep 'ohci1394' /tmp/modules-plain`" ]; then
-#	modprobe -i --set-version=$KERNEL_VERSION --show-depends sbp2 >> /tmp/modules-plain 2>/dev/null
-#	modprobe -i --set-version=$KERNEL_VERSION --show-depends eth1394 >> /tmp/modules-plain 2>/dev/null
-#fi
-
-# Modem devices
-#case $i in (Intel536|Intel537|ltmodem|ltserial|slamr|slusb) \ 
-#	grep "$i" /tmp/modules-plain && modprobe -i --set-version=$KERNEL_VERSION --show-depends ppp-generic >> /tmp/modules-plain 2>/dev/null ;; \
-#	esac
-
 # Parport modules
-if [ "`grep 'parport' /tmp/modules-plain`" ]; then
+if [ "$(grep 'parport' /tmp/modules-plain)" ]; then
 	modprobe -i --set-version=$KERNEL_VERSION --show-depends lp >> /tmp/modules-plain 2>/dev/null
 	modprobe -i --set-version=$KERNEL_VERSION --show-depends ppdev >> /tmp/modules-plain 2>/dev/null
 fi
 
 # Sound OSS compat modules
-if [ "`grep 'snd-pcm' /tmp/modules-plain`" ]; then
+if [ "$(grep 'snd-pcm' /tmp/modules-plain)" ]; then
 	modprobe -i --set-version=$KERNEL_VERSION --show-depends snd-pcm-oss >> /tmp/modules-plain 2>/dev/null
 fi
-if [ "`grep 'snd-seq' /tmp/modules-plain`" ]; then
+if [ "$(grep 'snd-seq' /tmp/modules-plain)" ]; then
 	modprobe -i --set-version=$KERNEL_VERSION --show-depends snd-seq-oss >> /tmp/modules-plain 2>/dev/null
 fi
 
-# USB modules
-#if [ "`grep 'usb/' /tmp/modules-plain`" ]; then
-#	modprobe -i --set-version=$KERNEL_VERSION --show-depends usbhid >> /tmp/modules-plain 2>/dev/null
-#	modprobe -i --set-version=$KERNEL_VERSION --show-depends usb-storage >> /tmp/modules-plain 2>/dev/null
-#	modprobe -i --set-version=$KERNEL_VERSION --show-depends usblp >> /tmp/modules-plain 2>/dev/null
-#fi
-
 sort -u /tmp/modules-plain >> /tmp/modules-stripped
 
 # OTHER modules loading first for speed up!
 grep -v "ide/" /tmp/modules-stripped | grep -v "scsi/" | grep -v "fusion/" | grep -v "block/sx8" | grep -v "message/fusion" | \
-	grep -v  "block/cciss" | grep -v "block/cpqarray" | grep -v "block/DAC960" | grep -v "ata/" | \
+	grep -v  "block/cciss" | grep -v "block/cpqarray" | grep -v "block/DAC960" | grep -v "block/virtio" | grep -v "ata/" | \
 	grep -v "net/" | grep -v "pcmcia/" | grep -v "usb/" | \
-	grep -v "ieee1394/" >> /tmp/modules-sorted
+	grep -v "firewire" | grep -v "ieee1394/" | grep -v "usbhid/" | grep -v "staging/" | grep -v "wireless/" | grep -v "virtio_pci" >> /tmp/modules-sorted
+# load virtio first!
+grep "virtio_pci" /tmp/modules-stripped  >> /tmp/modules-sorted
 # make a correct order for the modules, internal devices have priority!
 # only use old ide modules if boot parameter 'ide-legacy' is given
 if [ "$IDE_LEGACY" = "1" ]; then
-	grep "ide/" /tmp/modules-stripped >> /tmp/modules-sorted
+	grep "ide/" /tmp/modules-stripped  | grep -v "ide-pci-generic" >> /tmp/modules-sorted
 else
-	grep "ata/pata" /tmp/modules-stripped >> /tmp/modules-sorted
-	grep "ata/ata_generic" /tmp/modules-stripped >> /tmp/modules-sorted
+	grep "ata/pata" /tmp/modules-stripped | grep -v "pata_acpi" >> /tmp/modules-sorted
 fi
-grep "scsi/" /tmp/modules-stripped | grep -v "sd_mod" | grep -v "sr_mod" | grep -v "/sg.ko" | grep -v "/st.ko" >> /tmp/modules-sorted
-grep "block/" /tmp/modules-stripped | grep -v "sx8" | grep -v "nbd" | grep -v "pktcdvd" | grep -v "floppy" >> /tmp/modules-sorted
+grep "scsi/" /tmp/modules-stripped  | grep -v "sd_mod" | grep -v "sr_mod" | grep -v "/sg.ko" | grep -v "/st.ko" >> /tmp/modules-sorted
+grep "block/" /tmp/modules-stripped | grep -v "virtio_blk" | grep -v "sx8" | grep -v "nbd" | grep -v "pktcdvd" | grep -v "floppy" >> /tmp/modules-sorted
 grep "fusion/" /tmp/modules-stripped >> /tmp/modules-sorted
 grep "ata/"  /tmp/modules-stripped| grep -v "pata" | grep -v "ata_generic" | grep -v "libata" >> /tmp/modules-sorted
 grep "block/" /tmp/modules-stripped | grep "sx8" >> /tmp/modules-sorted
 grep "net/" /tmp/modules-stripped | grep -v "wireless/" | grep -v "usb/" >> /tmp/modules-sorted
 grep "wireless/" /tmp/modules-stripped >> /tmp/modules-sorted
+grep "staging/" /tmp/modules-stripped >> /tmp/modules-sorted
 grep "pcmcia/" /tmp/modules-stripped >> /tmp/modules-sorted
 
 # speed up usb module loading
@@ -256,7 +332,8 @@ grep "usb/" /tmp/modules-stripped | grep -v "usb-storage" | grep -v "usbhid" | g
 grep "firewire/" /tmp/modules-stripped >> /tmp/modules-sorted
 grep "ieee1394/" /tmp/modules-stripped >> /tmp/modules-sorted
 
-# add scsi device modules at the end
+# add scsi and virtio device modules at the end
+grep "virtio_blk" /tmp/modules-stripped >> /tmp/modules-sorted
 grep "sd_mod" /tmp/modules-stripped >> /tmp/modules-sorted
 grep "sr_mod" /tmp/modules-stripped >> /tmp/modules-sorted
 grep "/st.ko" /tmp/modules-stripped >> /tmp/modules-sorted
@@ -265,28 +342,6 @@ grep "/sg.ko" /tmp/modules-stripped >> /tmp/modules-sorted
 
 sed -ne "s#^insmod.*/\(.*\)\.ko.*#\1#p" /tmp/modules-sorted >> /tmp/moduleslist
 
-# blacklist framebuffer modules
-for x in $(echo /lib/modules/$(uname -r)/kernel/drivers/video/*/*fb*); do
-	BLACKLIST="$BLACKLIST $(/usr/bin/basename $x .ko)"
-done
-for x in $(echo /lib/modules/$(uname -r)/kernel/drivers/video/*fb*); do
-	BLACKLIST="$BLACKLIST $(/usr/bin/basename $x .ko)"
-done
-# delete modules that are blacklisted
-BLACKLIST="${BLACKLIST} $(echo ${disablemodules} | sed 's|-|_|g' | sed 's|,| |g')"
-for i in $BLACKLIST; do
-	[ "$i" ] || continue
-	sed -i -e "/^$i$/d" /tmp/moduleslist
-	# since '-' and '_' are interchangeable, we have to cover both
-	if [ "`echo $i | grep '-'`" ]; then
-		i="`echo $i | sed 's|-|_|g'`"
-		sed -i -e "/^$i$/d" /tmp/moduleslist
-	elif [ "`echo $i | grep '_'`" ]; then
-		i="`echo $i | sed 's|_|-|g'`"
-		sed -i -e "/^$i$/d" /tmp/moduleslist
-	fi
-done
-
 listmods() {
 	key=$1 ; shift
 	ex=
@@ -294,7 +349,7 @@ listmods() {
 		[ "$ex" ] && ex="$ex|$1" || ex="$1"
 		shift
 	done
-	for ln in `grep "$key" /tmp/modules-sorted | sed 's|^insmod ||g'`; do
+	for ln in $(grep "$key" /tmp/modules-sorted | sed 's|^insmod ||g'); do
 		if [ "$ex" ]; then
 			echo $ln | egrep -v "$ex" | sed -ne "s#^/.*/\(.*\)\.ko.*#\1#p"
 		else
@@ -333,82 +388,150 @@ while [ $# -gt 0 ]; do
 			 ;;
 		--load-modules)
 			# load all detected pci modules
-			for i in `cat /tmp/moduleslist`; do
-				modprobe $i > /dev/null 2>&1
+			for i in $(cat /tmp/moduleslist); do
+				if [ -e /lib/udev/load-modules.sh ]; then 
+					/lib/udev/load-modules.sh $i > /dev/null 2>&1
+				else
+					modprobe $i > /dev/null 2>&1
+				fi
 			done
 			;;
 
 		--unload-modules)
 			# load all detected pci modules
-			for i in `cat /tmp/moduleslist`; do
+			for i in $(cat /tmp/moduleslist); do
 				modprobe -r $i > /dev/null 2>&1
 			done
 			;;
 
 		--show-modules)
-			showlist "AGP    " `listmods agp/`
-			showlist "ACPI   " `listmods acpi/`
-			showlist "IDE    " `listmods ide/`
-			showlist "PATA   " `listmods ata/pata` `listmods ata/ata_generic`
-			showlist "SCSI   " `listmods scsi/` `listmods message/fusion/` `listmods drivers/block/ nbd pktcdvd sx8 floppy`
-			showlist "SATA   " `listmods ata/ pata ata_generic` `listmods drivers/block/sx8`
-			showlist "USB    " `listmods usb/ usb/input`
-			showlist "FW     " `listmods firewire/` `listmods ieee1394/`
-			showlist "NET    " `listmods net/ irda/`
-			showlist "INPUT  " `listmods input/` `listmods hid/`
-			showlist "IRDA   " `listmods irda/`
-			showlist "ISDN   " `listmods isdn/`
-			showlist "PCMCIA " `listmods pcmcia/`
-			showlist "SOUND  " `listmods sound/`
-			showlist "VIDEO  " `listmods video/`
-			showlist "OTHER  " `listmods modules/ agp/ acpi/ ide/ scsi/ message/fusion block/sx8 block/cciss block/cpqarray block/DAC960 ata/ usb/ ieee1394 net/ isdn/ input/ irda/ pcmcia/ sound/ video/ firewire/ hid/`
+			showlist "AGP    " $(listmods agp/)
+			showlist "ACPI   " $(listmods acpi/)
+			showlist "IDE    " $(listmods ide/ ide-)
+			showlist "PATA   " $(listmods ata/pata pata_acpi) $(listmods ata/ata_piix)
+			showlist "SCSI   " $(listmods virtio/virtio_pci) $(listmods scsi/) $(listmods message/fusion/) $(listmods drivers/block/ nbd pktcdvd sx8 floppy)
+			showlist "SATA   " $(listmods ata/ pata ata_generic) $(listmods drivers/block/sx8)
+			showlist "USB    " $(listmods usb/ usb/input)
+			showlist "FW     " $(listmods firewire/) $(listmods ieee1394/)
+			showlist "NET    " $(listmods net/ irda/)
+			showlist "INPUT  " $(listmods input/ pcspkr) $(listmods hid/)
+			showlist "IRDA   " $(listmods irda/)
+			showlist "ISDN   " $(listmods isdn/)
+			showlist "PCMCIA " $(listmods pcmcia/)
+			showlist "SOUND  " $(listmods pcspkr) $(listmods sound/)
+			showlist "STAGING" $(listmods staging/)
+			showlist "VIDEO  " $(listmods video/)
+			showlist "OTHER  " $(listmods modules/ agp/ acpi/ ide/ scsi/ message/fusion block/sx8 block/cciss block/cpqarray block/DAC960 block/virtio virtio/virtio_pci ata/ usb/ ieee1394 net/ isdn/ input/ irda/ pcmcia/ sound/ video/ firewire/ hid/ staging/)
 			;;
 
 		--show-modules-order)
-			showlist "MODULES ORDER" `listmods modules/`
+			showlist "MODULES ORDER" $(listmods modules/)
 			;;
 
-		--show-agp)    showlist "AGP    " `listmods agp/` ;;
-		--show-acpi)   showlist "ACPI   " `listmods acpi/` ;;
-		--show-ide)    showlist "IDE    " `listmods ide/` ;;
-		--show-pata)   showlist "PATA   " `listmods ata/pata` `listmods ata/ata_generic`;;
-		--show-scsi)   showlist "SCSI   " `listmods scsi/` `listmods message/fusion/` `listmods drivers/block/ nbd pktcdvd sx8 floppy`;;
-		--show-sata)   showlist "SATA   " `listmods ata/ pata ata_generic` `listmods drivers/block/sx8` ;;
-		--show-usb)    showlist "USB    " `listmods usb/ usb/input` ;;
-		--show-fw)     showlist "FW     " `listmods firewire/` `listmods ieee1394/` ;;
-		--show-net)    showlist "NET    " `listmods net/ irda/` ;;
-		--show-input)  showlist "INPUT  " `listmods input/` `listmods hid/` ;;
-		--show-irda)   showlist "IRDA   " `listmods irda/` ;;
-		--show-isdn)   showlist "ISDN   " `listmods isdn/` ;;
-		--show-pcmcia) showlist "PCMCIA " `listmods pcmcia/` ;;
-		--show-sound)  showlist "SOUND  " `listmods sound/` ;;
-		--show-video)  showlist "VIDEO  " `listmods video/` ;;
-		--show-other)  showlist "OTHER  " `listmods .ko agp/ acpi/ ide/ scsi/ message/fusion block/sx8 block/cciss block/cpqarray block/DAC960 ata/ usb/ ieee1394 net/ isdn/ input/ irda/ pcmcia/ sound/ video/ firewire/ hid/` ;;
-		--hostcontroller)  showlist2 "MODULES" \"`listmods ide/pci` `listmods ata/pata` `listmods ata/ata_generic` `listmods scsi/ /sg.ko /st.ko sr_mod sd_mod` `listmods message/fusion/` `listmods drivers/block/  nbd pktcdvd sx8 floppy` `listmods ata/ pata ata_generic` `listmods drivers/block/sx8`\" | sed -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
+		--show-agp)    showlist "AGP    " $(listmods agp/) ;;
+		--show-acpi)   showlist "ACPI   " $(listmods acpi/) ;;
+		--show-ide)    showlist "IDE    " $(listmods ide/ ide-) ;;
+		--show-pata)   showlist "PATA   " $(listmods ata/pata pata_acpi) $(listmods ata/ata_piix) ;;
+		--show-scsi)   showlist "SCSI   " $(listmods virtio/virtio_pci) $(listmods scsi/) $(listmods message/fusion/) $(listmods drivers/block/ nbd pktcdvd sx8 floppy) ;;
+		--show-sata)   showlist "SATA   " $(listmods ata/ pata ata_generic) $(listmods drivers/block/sx8) ;;
+		--show-usb)    showlist "USB    " $(listmods usb/ usb/input) ;;
+		--show-fw)     showlist "FW     " $(listmods firewire/) $(listmods ieee1394/) ;;
+		--show-net)    showlist "NET    " $(listmods net/ irda/) ;;
+		--show-input)  showlist "INPUT  " $(listmods input/ pcspkr) $(listmods hid/) ;;
+		--show-irda)   showlist "IRDA   " $(listmods irda/) ;;
+		--show-isdn)   showlist "ISDN   " $(listmods isdn/) ;;
+		--show-pcmcia) showlist "PCMCIA " $(listmods pcmcia/) ;;
+		--show-sound)  showlist "SOUND  " $(listmods pcspkr) $(listmods sound/) ;;
+		--show-staging) showlist "STAGING" $(listmods staging/) ;;
+		--show-video)  showlist "VIDEO  " $(listmods video/) ;;
+		--show-other)  showlist "OTHER  " $(listmods .ko agp/ acpi/ ide/ scsi/ message/fusion block/sx8 block/cciss block/cpqarray block/DAC960 block/virtio virtio/virtio_pci ata/ usb/ ieee1394 net/ isdn/ input/ irda/ pcmcia/ sound/ video/ firewire/ hid/ staging/) ;;
+		--filesystem)   FILESYSTEM="ext2 ext3 ext4 nilfs2 btrfs reiserfs xfs jfs vfat"
+				for i in $FILESYSTEM; do
+					 [ "$(grep $i /tmp/.blkid)" ] && FS="$FS $i"
+				done
+				[ "$(echo $FS | grep btrfs)" ] && FS="$FS crc32c"
+				MODULES_INITRAMFS="$MODULES_INITRAMFS $FS"
+				showlist2 "MODULES" \"$MODULES_INITRAMFS\" | sed -e 's/(\  /(/g' -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
+				;;
+		--hostcontroller)HOSTCONTROLLER="$(listmods virtio/virtio_pci) $(listmods ide/ ide-) $(listmods ata/pata pata_acpi) $(listmods scsi/ /sg.ko /st.ko scsi_mod sr_mod sd_mod) $(listmods message/fusion/) $(listmods drivers/block/ virtio_blk nbd pktcdvd sx8 floppy) $(listmods ata/ pata ata_generic) $(listmods drivers/block/sx8) $(listmods ehci-hcd) $(listmods uhci-hcd) $(listmods ohci-hcd) $(listmods virtio_blk)"
+				 MODULES_INITRAMFS="$MODULES_INITRAMFS $HOSTCONTROLLER"
+				 showlist2 "MODULES" \"$MODULES_INITRAMFS\" | sed -e 's/(\  /(/g' -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
+				 ;;
+		--ati-kms) 	KMS="radeon"
+				MODULES_INITRAMFS="$KMS $MODULES_INITRAMFS"
+				showlist2 "MODULES" \"$MODULES_INITRAMFS\" | sed -e 's/(\  /(/g' -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
+				;;
+		--intel-kms) 	KMS="i915"
+				MODULES_INITRAMFS="$KMS $MODULES_INITRAMFS"
+				showlist2 "MODULES" \"$MODULES_INITRAMFS\" | sed -e 's/(\  /(/g' -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
+				;;
+		--nvidia-kms) 	KMS="nouveau"
+				MODULES_INITRAMFS="$KMS $MODULES_INITRAMFS"
+				showlist2 "MODULES" \"$MODULES_INITRAMFS\" | sed -e 's/(\  /(/g' -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
+				;;
+		--uvesafb) 	FB="uvesafb"
+				MODULES_INITRAMFS="$FB $MODULES_INITRAMFS"
+				! [ "$HOOKS" = "1" ] && showlist2 "MODULES" \"$MODULES_INITRAMFS\" | sed -e 's/(\  /(/g' -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
 				;;
-		--net)  if [ "$(showlist2 "MODULES"  \(`listmods drivers/net/ irda ppp_generic slhc` `listmods drivers/usb/net/`\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g' | grep '8139cp')" ] ; then
-				if [ "$(dmesg | grep '"8139too"')" ]; then
-						MODULES_EXPORTED="$MODULES_EXPORTED $(listmods drivers/net/ irda ppp_generic slhc` `listmods drivers/usb/net/)"
-					 showlist2 "MODULES"  \($MODULES_EXPORTED\) | sed -e 's/8139cp//g' -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
+		--fbmodule) 	FB=""
+				for i in $(cat /etc/modprobe.d/framebuffer_blacklist.conf); do
+				    i=$(echo $i | sed -e 's/blacklist //g')
+				    # check if already in FB array, to avoid double entries
+				    if [ "$(cat /proc/modules | grep ^$i)" ]; then
+					! [ "$(grep -w $FB)" ] && FB="$i"
+				    fi
+                                done
+				MODULES_INITRAMFS="$FB $MODULES_INITRAMFS "
+				! [ "$HOOKS" = "1" ] && showlist2 "MODULES" \"$MODULES_INITRAMFS\" | sed -e 's/(\  /(/g' -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
+				;;
+		--net)  if [ "$(showlist2 "MODULES"  \($(listmods drivers/net/ irda ppp_generic slhc) $(listmods drivers/usb/net/) $(listmods drivers/staging/) \) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g' | grep '8139cp')" ] ; then
+				if [ "$(dmesg | grep 'use 8139too')" ]; then
+					MODULES_EXPORTED="$MODULES_EXPORTED $(listmods drivers/net/ irda ppp_generic slhc) $(listmods drivers/usb/net/) $(listmods drivers/staging/)"
+					MODULES_EXPORTED="$(echo $MODULES_EXPORTED | sed -e 's/8139cp//g')"
+					BLACKLIST_UDEV="!8139cp"
+					for i in $MODULES_EXPORTED; do
+						BLACKLIST_UDEV="$BLACKLIST_UDEV !$i"
+					done
+					showlist2 "MODULES"  \($BLACKLIST_UDEV $MODULES_EXPORTED\) | sed -e 's/(\  /(/g' -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
 				else
-					MODULES_EXPORTED="$MODULES_EXPORTED $(listmods drivers/net/ irda ppp_generic slhc` `listmods drivers/usb/net/)"
-					showlist2 "MODULES"  \($MODULES_EXPORTED\) | sed -e 's/8139too//g' -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
+					MODULES_EXPORTED="$MODULES_EXPORTED $(listmods drivers/net/ irda ppp_generic slhc) $(listmods drivers/usb/net/) $(listmods drivers/staging/)"
+					MODULES_EXPORTED="$(echo $MODULES_EXPORTED | sed -e 's/8139too//g')"
+					BLACKLIST_UDEV="!8139too"
+					for i in $MODULES_EXPORTED; do
+						BLACKLIST_UDEV="$BLACKLIST_UDEV !$i"
+					done
+					showlist2 "MODULES"  \($BLACKLIST_UDEV $MODULES_EXPORTED\) | sed -e 's/(\  /(/g' -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
 				fi
 			else
-				MODULES_EXPORTED="$MODULES_EXPORTED $(listmods drivers/net/ irda ppp_generic slhc` `listmods drivers/usb/net/)"
-				showlist2 "MODULES"  \($MODULES_EXPORTED\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
+				MODULES_EXPORTED="$MODULES_EXPORTED $(listmods drivers/net/ irda ppp_generic slhc) $(listmods drivers/usb/net/) $(listmods drivers/staging/)"
+				BLACKLIST_UDEV=""
+				for i in $MODULES_EXPORTED; do
+					BLACKLIST_UDEV="$BLACKLIST_UDEV !$i"
+				done
+				showlist2 "MODULES"  \($BLACKLIST_UDEV $MODULES_EXPORTED\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
 			fi
 			;;
-		--sound) MODULES_EXPORTED="$MODULES_EXPORTED $(listmods sound/)"
-			showlist2 "MODULES" \($MODULES_EXPORTED\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
+		--sound) MODULES_EXPORTED="$MODULES_EXPORTED $(listmods pcspkr) $(listmods sound/)"
+			 BLACKLIST_UDEV=""
+			 for i in $MODULES_EXPORTED; do
+				BLACKLIST_UDEV="$BLACKLIST_UDEV !$i"
+			 done
+			 showlist2 "MODULES" \($BLACKLIST_UDEV $MODULES_EXPORTED\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
+			 ;;
+		--usbhost) MODULES_EXPORTED="$MODULES_EXPORTED $(listmods ehci-hcd) $(listmods uhci-hcd) $(listmods ohci-hcd)"
+			 BLACKLIST_UDEV=""
+			 for i in $MODULES_EXPORTED; do
+				BLACKLIST_UDEV="$BLACKLIST_UDEV !$i"
+			 done
+			 showlist2 "MODULES" \($BLACKLIST_UDEV $MODULES_EXPORTED\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
 			 ;;
-		--modules) showlist2 "MODULES" \(`listmods modules/`\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
+		--modules) showlist2 "MODULES" \($(listmods modules/)\) | sed -e 's/(\ /(/g' -e 's/\ )/)/g' -e 's/\ \ /\ /g'
 			 ;;
 		--hooks) 
 			if [ "$HOOKS_DIR" = "" ]; then
 				HOOKS_DIR="/lib/initcpio/install"
 			fi
-			START_HOOKS="base udev dsdt autodetect ide pata scsi sata usb fw pcmcia net raid raid-partitions usbinput keymap encrypt lvm2 filesystems"
+			START_HOOKS="base v86d udev keymap autodetect ide pata scsi sata usb fw pcmcia net dmraid usbinput $ADVANCED btrfs filesystems"
 			# remove the ones that don't exist on the system
 			for i in ${START_HOOKS}; do
 				if ! [ -e "${HOOKS_DIR}/$i" ]; then 
@@ -421,36 +544,17 @@ while [ $# -gt 0 ]; do
 			else
 				START_HOOKS=$(echo $START_HOOKS | sed -e "s/ide//g")
 			fi
-			# usbinput, check for usbhid
-			if ! [ "$(cat /proc/modules | grep usbhid)" ]; then
+			if !  [ "$USBINPUT" = "1" ]; then
 				START_HOOKS=$(echo $START_HOOKS | sed -e "s/usbinput//g")
 			fi
-			# keymap, check rc.conf for KEYMAP="us"
-			if [ "$(grep '^KEYMAP="us"' /etc/rc.conf)" ]; then
-				if ! [ "${KEYMAP}" = "1" ]; then
+			if ! [ "$KEYMAP" = "1" ]; then 
 				START_HOOKS=$(echo $START_HOOKS | sed -e "s/keymap//g")
-				fi
-			fi
-			### TODO raid, check for presence of md devices in /dev
-			#if ! [ "$(ls /dev/md* > /dev/null 2>&1 )" ]; then
-			#	START_HOOKS=$(echo $START_HOOKS | sed -e "s/raid//g")
-			#fi
-			if ! [ "$RAID" = "1" ] ; then 
-				START_HOOKS=$(echo $START_HOOKS | sed -e "s/raid\ //g")
-			fi
-			if ! [ "$RAID_PARTITIONS" = "1" ] ; then 
-				START_HOOKS=$(echo $START_HOOKS | sed -e "s/raid-partitions\ //g")
 			fi
-			### TODO lvm2, encrypt check
-			# encrypt, check for presence of mapper/root
-			#if ! [ "$(ls /dev/mapper/root > /dev/null 2>&1 )" ]; then
-			#	START_HOOKS=$(echo $START_HOOKS | sed -e "s/encrypt//g")
-			#fi
-			if ! [ "$ENCRYPT" = "1" ] ; then
-				START_HOOKS=$(echo $START_HOOKS | sed -e "s/encrypt//g")
+			if ! [ "$UVESAFB" = "1" ]; then 
+				START_HOOKS=$(echo $START_HOOKS | sed -e "s/v86d//g")
 			fi
-			if ! [ "$LVM2" = "1" ]; then
-				START_HOOKS=$(echo $START_HOOKS | sed -e "s/lvm2//g")
+			if ! [ "$DMRAID" = "1" ]; then 
+				START_HOOKS=$(echo $START_HOOKS | sed -e "s/dmraid//g")
 			fi
 			if ! [ "$USB" = "1" ]; then
 				START_HOOKS=$(echo $START_HOOKS | sed -e "s/usb\ //g")
@@ -464,11 +568,17 @@ while [ $# -gt 0 ]; do
 			if ! [ "$NFS" = "1" ]; then
 				START_HOOKS=$(echo $START_HOOKS | sed -e "s/net//g")
 			fi
-			if ! [ "$DSDT" = "1" ]; then
-				START_HOOKS=$(echo $START_HOOKS | sed -e "s/dsdt//g")
+			if ! [ "$BTRFS" = "1" ]; then
+				START_HOOKS=$(echo $START_HOOKS | sed -e "s/btrfs//g")
 			fi
 			echo "HOOKS=\"$START_HOOKS\"" | sed -e 's/"\ /"/g' -e 's/\ "/"/g' -e 's/\ \ /\ /g'
 		;;
+		--advanced) ADVANCED_ARCHBOOT=""
+			    for i in $ADVANCED; do
+				ADVANCED_ARCHBOOT="$ADVANCED_ARCHBOOT $(echo arch_$i)"
+			    done
+			    echo "$ADVANCED_ARCHBOOT"
+			    ;;
 	esac
 	shift
 done
-- 
cgit v0.12