make more generic
authorBrad House <brad_mssw@gentoo.org>
Wed, 17 Dec 2003 00:52:20 +0000 (00:52 +0000)
committerBrad House <brad_mssw@gentoo.org>
Wed, 17 Dec 2003 00:52:20 +0000 (00:52 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@24 67a159dc-881f-0410-a524-ba9dfbe2cb84

gen_initrd.sh
generic/initrd.defaults [moved from x86_64/initrd.defaults with 92% similarity]
generic/initrd.scripts [moved from x86_64/initrd.scripts with 100% similarity]
generic/linuxrc [moved from x86_64/linuxrc with 100% similarity]
generic/modprobe [new file with mode: 0755]

index 18bb6bfbfb24a0daf0380d5840946e05bcb1ae58..70c67b07eefb3d4676b8cbf8c326c81ef481fe60 100644 (file)
@@ -61,7 +61,8 @@ create_base_initrd_sys() {
        fi
 
        bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not uncompress insmod.static"
-       chmod +x "${TEMP}/initrd-temp/bin/insmod.static"
+       mv "${TEMP}/initrd-temp/bin/insmod.static" "${TEMP}/initrd-temp/bin/insmod"
+       chmod +x "${TEMP}/initrd-temp/bin/insmod"
 
        cp "${DEVFSD_BINCACHE}" "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not copy devfsd executable from bincache"
        bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
@@ -120,10 +121,10 @@ create_initrd_modules() {
 #                                              -e "s/%%USB_MODULES%%/${USB_MODULES}/" \
 #                                              > ${TEMP}/initrd-temp/linuxrc
 
-       cp "${GK_SHARE}/${ARCH}/linuxrc" "${TEMP}/initrd-temp/linuxrc"
-       cp "${GK_SHARE}/${ARCH}/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
-       cp "${GK_SHARE}/${ARCH}/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
-       cp "${GK_SHARE}/${ARCH}/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
+       cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initrd-temp/linuxrc"
+       cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
+       cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
+       cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
        chmod +x "${TEMP}/initrd-temp/linuxrc"
        chmod +x "${TEMP}/initrd-temp/etc/initrd.scripts"
        chmod +x "${TEMP}/initrd-temp/etc/initrd.defaults"
similarity index 92%
rename from x86_64/initrd.defaults
rename to generic/initrd.defaults
index 02266c427f7c052ed6ab0ab10aeb27c49cb7c5b0..4ccbe2bdb96b22ffc3c9ff39da2f943600cf4ae4 100644 (file)
@@ -11,14 +11,14 @@ KMINOR=`echo $KV | cut -f2 -d.`
 KVER="${KMAJOR}.${KMINOR}"
 MISCOPTS="cdcache idebug detect"
 HWOPTS="scsi firewire ataraid pcmcia usb"
-MY_HWOPTS="usb"
+MY_HWOPTS="usb firewire"
 QUIET=1
 ROOT_LINKS="bin sbin lib lib64 boot usr opt"
 ROOT_TREES="etc root home var"
 if [ "$KMVER" = "2.6" ]
 then
        KSUFF=".ko"
-       INSMOD="insmod.static"
+       INSMOD="insmod"
 else
        KSUFF=".o"
        INSMOD="insmod"
similarity index 100%
rename from x86_64/initrd.scripts
rename to generic/initrd.scripts
similarity index 100%
rename from x86_64/linuxrc
rename to generic/linuxrc
diff --git a/generic/modprobe b/generic/modprobe
new file mode 100755 (executable)
index 0000000..7a53679
--- /dev/null
@@ -0,0 +1,130 @@
+#!/bin/ash
+
+#KV=`uname -r`
+#KMAJOR=`echo ${KV} | cut -d. -f1`
+#KMINOR=`echo ${KV} | cut -d. -f2`
+#INSMOD="insmod.static"
+
+#if [ "${KMINOR}" -gt "4" ]
+#then
+#      KEXT=".ko"
+#else
+#      KEXT=".o"
+#fi
+
+. /etc/initrd.defaults
+
+usage()
+{
+       echo "modprobe gentoo script v1.0"
+       echo "Usage:"
+       echo "  modprobe moduleprefix"
+       echo ""
+       echo "Ex:"
+       echo "  modprobe eepro100"
+       echo ""
+       echo "Note: Do not pass the suffix to modprobe"
+       exit 1
+}
+
+# Pass module name to this function
+modules_dep_list()
+{
+       if [ "$#" != "1" ]
+       then
+               echo "modules_dep_list(): improper usage"
+               exit 1
+       fi
+       cat /lib/modules/${KV}/modules.dep | grep ${1}${KEXT}\: | cut -d\:  -f2
+}
+
+
+# Pass module deps list
+strip_mod_paths()
+{
+       local x
+       local ret
+       local myret
+
+       [ "$#" -lt "1" ] && return
+
+       for x in ${*}
+       do
+               ret=`basename ${x} | cut -d. -f1`
+               myret="${myret} ${ret}"
+       done
+       echo "${myret}"
+}
+
+LOADED_MODULES=""
+
+is_module_already_loaded()
+{
+       local x
+       if [ "$#" != "1" ]
+       then
+               echo "is_module_already_loaded(): improper usage"
+       fi
+
+       for x in ${LOADED_MODULES}
+       do
+               if [ "${x}" == "${1}" ]
+               then
+                       # Yep, module is loaded
+                       return 0
+               fi
+       done
+       return 1
+}
+
+real_mod_path()
+{
+       find /lib/modules/${KV}/ -path "*${1}${KEXT}"
+}
+
+modprobe2()
+{
+       local x
+       if [ "$#" != "1" ]
+       then
+               echo "modprobe(): improper usage"
+       fi
+
+       modlist=`modules_dep_list ${1}`
+       if [ "${modlist}" != "" -a "${modlist}" != " " ]
+       then
+               deps=`strip_mod_paths ${modlist}`
+       else
+               deps=""
+       fi
+
+       echo "$1 -- DEPS=${deps}"
+       # Make sure we don't do any endless loops!
+
+       LOADED_MODULES="${LOADED_MODULES} ${1}"
+
+       for x in ${deps}
+       do
+               if ! is_module_already_loaded ${x}
+               then
+                       modprobe2 "${x}"
+               else
+                       echo "skipping ${x}, module already loaded by us"
+               fi
+       done
+
+       real_path=`real_mod_path ${1}`
+       echo "running insmod on ${real_path}"
+       ${INSMOD} ${real_path}  
+       return $?
+}
+
+
+if [ "$#" != "1" ]
+then
+       usage
+fi
+
+modprobe2 ${1}
+return $?
+