public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Fabio Erculiani" <lxnay@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/
Date: Thu, 25 Apr 2013 06:22:30 +0000 (UTC)	[thread overview]
Message-ID: <1366874394.3a054014e880e5b1ff28e3d87767c45a073da6b5.lxnay@gentoo> (raw)

commit:     3a054014e880e5b1ff28e3d87767c45a073da6b5
Author:     Fabio Erculiani <lxnay <AT> sabayon <DOT> org>
AuthorDate: Tue Apr 23 15:21:53 2013 +0000
Commit:     Fabio Erculiani <lxnay <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 07:19:54 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=3a054014

Drop our own /sbin/modprobe and use busybox built-in applet instead

Our modprobe is an ancient heritage from the past, probably dating to
a time where busybox's modprobe features were limited. There is no reason
at all to keep using our own version instead of the busybox one.
This commit also makes modules_scan 15% faster.

---
 defaults/initrd.defaults |    8 +--
 defaults/initrd.scripts  |   35 ++++++-----
 defaults/modprobe        |  147 ----------------------------------------------
 gen_initramfs.sh         |   25 +++++---
 4 files changed, 36 insertions(+), 179 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 90f73f4..8ff5510 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -58,13 +58,7 @@ fi
 QUIET='1'
 ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt emul'
 ROOT_TREES='etc root home var'
-INSMOD='insmod'
-if [ "${KMAJOR}" -ge 3 ] || [ "${KMAJOR}" -eq 2 -a "${KMINOR}" -gt '4' ]
-then
-	KSUFF='.ko'
-else
-	KSUFF='.o'
-fi
+KSUFF='.ko'
 
 REAL_ROOT=''
 CONSOLE='/dev/console'

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 2e8e744..7ec5c94 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,10 +2,6 @@
 
 . /etc/initrd.defaults
 
-backup() {
-	echo -ne "\033[0G\033[0K"
-}
-
 modules_load() {
 	for module in $*
 	do
@@ -17,30 +13,37 @@ modules_load() {
 
 modules_scan() {
 	local MODS
-	[ -d "/etc/modules/${1}" ] || touch /etc/modules/${1}
+	local loaded
+
+	MODS=$(cat /etc/modules/${1} 2>/dev/null)
+	[ -n "${MODS}" ] && echo -ne "${BOLD}   ::${NORMAL} "
+	[ -n "${MODS}" ] && echo -ne "Loading from ${1}: "
 
-	[ -f "/etc/modules/${1}" ] && MODS=`cat /etc/modules/${1}`
 	for x in ${MODS}
 	do
-		MLOAD=`echo ${MLIST} | sed -e "s/.*${x}.*/${x}/"`
+		MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/")
 		if [ "${MLOAD}" = "${x}" ] # Only module to no-load
 		then
 			echo -e "${BOLD}   ::${NORMAL} Skipping ${x}..."
-		elif [ "${MLOAD}" = "${MLIST}" ] # == No change == No specified no-load
+		elif [ "${MLOAD}" = "${MLIST}" ]
 		then
-			[ -n "${DEBUG}" ] && echo -ne "${BOLD}   ::${NORMAL} Checking for ${x}..."
-			# find -name does not work since the return status is always zero
-			if find /lib/modules/${KV} | grep /"${x}${KSUFF}" >/dev/null 2>&1
-			then
-				echo -ne "${BOLD}   ::${NORMAL} Scanning for ${x}..."
-				modprobe ${x} -n
-				backup
-				echo -ne "${NORMAL}"
+			if [ -n "${DEBUG}" ]; then
+				echo -ne "${BOLD}   ::${NORMAL} "
+				echo -ne "Scanning for ${x}..."
 			fi
+			modprobe ${x} > /dev/null 2>&1
+			loaded=${?}
+			[ -n "${DEBUG}" -a "${loaded}" = "0" ] && \
+				echo "loaded"
+			[ -n "${DEBUG}" -a "${loaded}" != "0" ] && \
+				echo "not loaded"
+			[ -z "${DEBUG}" -a "${loaded}" = "0" ] && \
+				echo -en "${x} "
 		else
 			echo -e "${BOLD}   ::${NORMAL} Skipping ${x}..."
 		fi
 	done
+	[ -n "${MODS}" ] && echo
 }
 
 uppercase(){

diff --git a/defaults/modprobe b/defaults/modprobe
deleted file mode 100755
index 6bbe7e4..0000000
--- a/defaults/modprobe
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/bin/ash
-# Apparently, this is required for proper functionality with busybox 1.1.3
-# Check out bug #197730 for more details.
-
-. /etc/initrd.defaults
-
-usage() {
-	echo 'Usage:'
-	echo '  modprobe moduleprefix'
-	echo
-	echo 'Example:'
-	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 [ "$#" -lt '1' ]
-	then
-		echo 'modules_dep_list(): Improper usage!'
-		exit 1
-	fi
-	cat /lib/modules/${KV}/modules.dep | grep /"${1}${KSUFF}:" | 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 -name is no good since the return status is always zero
-	find "/lib/modules/${KV}" | grep /"${1}${KSUFF}"
-}
-
-modprobe2() {
-	local x
-	local deps
-	local real_path
-	local modlist
-	local ret
-
-	local echoAppend
-	local echoFlags
-
-	if [ "$#" -lt '1' ]
-	then
-		usage
-		exit 1
-	fi
-	real_path=`real_mod_path ${1}`
-	if [ "${real_path}" = '' -o "${real_path}" = ' ' ]
-	then
-		[ "${2}" = '-n' ] && echo -n " -> $1"
-		echo ' module not found.'
-		exit 2
-	fi
-	modlist=`modules_dep_list ${1}`
-	if [ "${modlist}" != '' -a "${modlist}" != ' ' ]
-	then
-		deps=`strip_mod_paths ${modlist}`
-	else
-		deps=''
-	fi
-	# 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
-			if [ "${x}" != '' -a "${x}" != ' ' ]
-			then
-				modprobe2 "${x}" -n
-			fi
-		else
-			filler=1
-		fi
-	done
-	# placing options into x
-	x="${real_path##*/}"
-	x="`cat "/etc/module_options/${x%.ko*}".* 2>/dev/null`"
-	${INSMOD} ${real_path} ${x} > /dev/null 2>&1
-	ret=$?
-	if [ ${ret} -eq 0 ]
-	then
-		echoAppend=' loaded.'
-		[ "${2}" = '-n' ] && echoFlags='-n' && echoAppend=', '
-		echo ${echoFlags} "${1}${echoAppend}"
-	fi
-	return $ret
-}
-
-if [ "$#" -lt '1' ]
-then
-	usage
-fi
-
-[ -f '/modules.cache' ] || touch /modules.cache
-for x in `cat /modules.cache`
-do
-	LOADED_MODULES="${LOADED_MODULES} ${x}"
-done
-
-modprobe2 ${1}
-modprobe_ret=$?
-
-[ -f '/modules.cache' ] && rm -f /modules.cache > /dev/null 2>&1
-for x in ${LOADED_MODULES}
-do
-	echo $x >> /modules.cache
-done
-
-exit $modprobe_ret

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index af6dff6..784c0cc 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -120,12 +120,26 @@ append_busybox() {
 	chmod +x "${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/default.script"
 
 	# Set up a few default symlinks
-	for i in ${BUSYBOX_APPLETS:-[ ash sh mount uname echo cut cat}; do
-		rm -f ${TEMP}/initramfs-busybox-temp/bin/$i > /dev/null
+	local default_applets="[ ash sh mount uname echo cut cat"
+	for i in ${BUSYBOX_APPLETS:-${default_applets}}; do
+		rm -f ${TEMP}/initramfs-busybox-temp/bin/$i
 		ln -s busybox ${TEMP}/initramfs-busybox-temp/bin/$i ||
 			gen_die "Busybox error: could not link ${i}!"
 	done
 
+	local mod_applets="sbin/modprobe sbin/insmod sbin/rmmod bin/lsmod"
+	local dir=
+	local name=
+	for i in ${mod_applets}; do
+		dir=$(dirname $i)
+		name=$(basename $i)
+		rm -f ${TEMP}/initramfs-busybox-temp/$dir/$name
+		mkdir -p ${TEMP}/initramfs-busybox-temp/$dir ||
+			gen_die "Busybox error: could not create dir: $dir"
+		ln -s ../bin/busybox ${TEMP}/initramfs-busybox-temp/$dir/$name ||
+			gen_die "Busybox error: could not link ${i}!"
+	done
+
 	cd "${TEMP}/initramfs-busybox-temp/"
 	log_future_cpio_content
 	find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
@@ -705,12 +719,6 @@ append_auxilary() {
 	done
 	echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
 
-	if [ -f "${GK_SHARE}/arch/${ARCH}/modprobe" ]
-	then
-		cp "${GK_SHARE}/arch/${ARCH}/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
-	else
-		cp "${GK_SHARE}/defaults/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
-	fi
 	if isTrue $CMD_DOKEYMAPAUTO
 	then
 		echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
@@ -728,7 +736,6 @@ append_auxilary() {
 	chmod +x "${TEMP}/initramfs-aux-temp/init"
 	chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
 	chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
-	chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe"
 
 	if isTrue ${NETBOOT}
 	then


             reply	other threads:[~2013-04-25  6:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-25  6:22 Fabio Erculiani [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-07-23 23:57 [gentoo-commits] proj/genkernel:master commit in: /, defaults/ Thomas Deutschmann
2019-11-26 13:50 Thomas Deutschmann
2019-07-21 16:26 Thomas Deutschmann
2017-09-04  5:36 Robin H. Johnson
2017-01-08  1:57 Robin H. Johnson
2017-01-07 23:50 Robin H. Johnson
2017-01-02 23:25 Robin H. Johnson
2016-05-16  6:55 Robin H. Johnson
2016-01-05 19:39 Robin H. Johnson
2016-01-05 19:39 Robin H. Johnson
2013-06-06  3:36 [gentoo-commits] proj/genkernel:ryao " Richard Yao
2013-06-03 23:49 ` [gentoo-commits] proj/genkernel:master " Richard Yao
2012-10-16  0:03 Robin H. Johnson
2012-10-03 16:24 Sebastian Pipping
2012-08-30 16:20 Fabio Erculiani
2012-08-12 19:04 Sebastian Pipping
2012-07-24 18:01 Robin H. Johnson
2012-07-24 17:29 Robin H. Johnson
2012-07-24  8:29 Robin H. Johnson
2012-07-19 20:12 Richard Yao
2012-07-09 17:51 Sebastian Pipping
2012-07-08 17:05 Sebastian Pipping
2012-05-17 18:34 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-03-17  1:27 Sebastian Pipping
2012-02-20  6:58 Robin H. Johnson
2012-02-09  7:42 Robin H. Johnson
2012-02-06  9:35 Robin H. Johnson
2012-02-06  8:19 Robin H. Johnson
2012-01-14 23:22 Sebastian Pipping
2012-01-13 23:19 Sebastian Pipping
2012-01-13 23:19 Sebastian Pipping
2012-01-06  6:37 Robin H. Johnson
2011-11-08 17:21 Sebastian Pipping
2011-10-08 21:22 Fabio Erculiani
2011-09-13  9:54 Fabio Erculiani
2011-09-11  7:40 Fabio Erculiani
2011-08-30 15:34 Sebastian Pipping
2011-07-27 17:38 Sebastian Pipping
2011-05-31 10:58 Sebastian Pipping

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1366874394.3a054014e880e5b1ff28e3d87767c45a073da6b5.lxnay@gentoo \
    --to=lxnay@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox