summaryrefslogtreecommitdiffstats
path: root/install/autodetect
blob: 70dc779f8389cc49261c6b6e22717c94ca716801 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# vim: set ft=sh:

install ()
{
    msg ":: Autodetecting modules"
    #blegh, we'll let /tmp clean itself up
    modtmp=$( mktemp /tmp/initcpio_modules.XXXXXX )
    modall=$( mktemp /tmp/initcpio_modulesall.XXXXXX )
    AUTODETECT=" $(auto_modules "/scsi/" | grep -v "imm"| grep -v "pcmcia" | grep -v "ide" && echo "sd_mod sr_mod") 
                 $(auto_modules "/block/" && echo "sd_mod sr_mod")
                 $(auto_modules "/fusion/" && echo "sd_mod sr_mod")
                 $(auto_modules "/usb/" && echo "usb_storage usbhid sd_mod sr_mod")
                 $(auto_modules "/ide/")
                 $(auto_modules "/ieee1394/" && echo "sbp2 sd_mod sr_mod")
                 $(auto_modules "/cdrom/") 
                 $(cat /proc/filesystems | grep -v nodev) "
              
    for m in $AUTODETECT; do
        echo $(basename ${m//\.ko/}) >> $modtmp
        # fixing missing depends for filesystems
        [ "$m" == "ext3" ] && echo "jbd" >> $modtmp
        [ "$m" == "afs" ] && echo "rxrpc" >> $modtmp
        [ "$m" == "cramfs" ] && echo "zlib_inflate" >> $modtmp
        [ "$m" == "isofs" ] && echo "zlib_inflate" >> $modtmp
        [ "$m" == "msdos" ] && echo "fat" >> $modtmp
        [ "$m" == "vfat" ] && echo "fat" >> $modtmp
        [ "$m" == "ocfs2" ] && echo "ocfs2_dlm" >> $modtmp
        [ "$m" == "ocfs2" ] && echo "jbd" >> $modtmp
        [ "$m" == "ocfs2" ] && echo "ocfs2_nodemanager" >> $modtmp
        [ "$m" == "ocfs2" ] && echo "configfs" >> $modtmp
    done

    grep "file /lib/modules" ${FILELIST} >>$modall
	for i in `cat $modtmp`; do
        sed -i -e "\=/$i=d" $modall
    done
	for i in `grep "file /lib/modules" $modall | awk '{print $2}'`; do
        sed -i -e "\=$i=d" ${FILELIST}
	done
	msg "Included MODULES:"
	msg "-----------------"
	msg "$(grep "file /lib/modules/" ${FILELIST} | awk '{print $2}')"
	msg "-----------------"
    BINARIES=""
    FILES=""
    SCRIPT=""
}

help ()
{
cat <<HELPEOF
  This hook shrinks your initramdisk to a smaller size 
  by autodetecting your needed modules. 
  Please take a look at the included modules for completeness,
  else your system might be unbootable.
  Valid Hooks are: base,udev,ide,scsi,sata,usb,fw,filesystems
  Put this hook at the end of your valid hooks. 
  Put other hooks behind autodetect hook.
HELPEOF
}