diff options
author | John Mylchreest <johnm@gentoo.org> | 2005-05-17 21:53:03 +0000 |
---|---|---|
committer | John Mylchreest <johnm@gentoo.org> | 2005-05-17 21:53:03 +0000 |
commit | 9b8e1a316b0a678452d80641146548b946886033 (patch) | |
tree | cee9cf3319d6ea278d2cd66c937384298a2bd002 /sys-kernel | |
parent | Added ~sparc keyword. (diff) | |
download | historical-9b8e1a316b0a678452d80641146548b946886033.tar.gz historical-9b8e1a316b0a678452d80641146548b946886033.tar.bz2 historical-9b8e1a316b0a678452d80641146548b946886033.zip |
adding support for 'populate', and cleaning a few little things up.
Diffstat (limited to 'sys-kernel')
-rw-r--r-- | sys-kernel/module-rebuild/ChangeLog | 8 | ||||
-rw-r--r-- | sys-kernel/module-rebuild/Manifest | 11 | ||||
-rw-r--r-- | sys-kernel/module-rebuild/files/digest-module-rebuild-0.2 | 0 | ||||
-rwxr-xr-x | sys-kernel/module-rebuild/files/module-rebuild-0.2 | 244 | ||||
-rw-r--r-- | sys-kernel/module-rebuild/module-rebuild-0.2.ebuild | 19 |
5 files changed, 277 insertions, 5 deletions
diff --git a/sys-kernel/module-rebuild/ChangeLog b/sys-kernel/module-rebuild/ChangeLog index 1179b9ad9c94..b1baf1838c54 100644 --- a/sys-kernel/module-rebuild/ChangeLog +++ b/sys-kernel/module-rebuild/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for sys-kernel/module-rebuild # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-kernel/module-rebuild/ChangeLog,v 1.1 2005/05/03 22:53:37 johnm Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-kernel/module-rebuild/ChangeLog,v 1.2 2005/05/17 21:53:03 johnm Exp $ + +*module-rebuild-0.2 (17 May 2005) + + 17 May 2005; John Mylchreest <johnm@gentoo.org> +files/module-rebuild-0.2, + +module-rebuild-0.2.ebuild: + adding support for 'populate', and cleaning a few little things up. *module-rebuild-0.1 (03 May 2005) diff --git a/sys-kernel/module-rebuild/Manifest b/sys-kernel/module-rebuild/Manifest index 122e6ad5779e..46fbdd19f8b5 100644 --- a/sys-kernel/module-rebuild/Manifest +++ b/sys-kernel/module-rebuild/Manifest @@ -1,15 +1,18 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 +MD5 df6dd7551f72ef6027415620e17f5722 module-rebuild-0.2.ebuild 471 MD5 ea0963c42faaa0ae11ab458207259875 module-rebuild-0.1.ebuild 472 -MD5 2e643fc59fee097acb1d448a525e65de ChangeLog 457 +MD5 f5f30b7514ad6a46e33df86dbf9bc5e7 ChangeLog 670 MD5 4f16a183ffde9bcb9ad32bc19fafa1aa metadata.xml 526 MD5 2a7d0f8657e4bd140b33d1cd4a6a81d9 files/module-rebuild-0.1 4381 +MD5 be437effac25aad429f612c4db2390e8 files/module-rebuild-0.2 5618 MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-module-rebuild-0.1 0 +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-module-rebuild-0.2 0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) -iD8DBQFCeEvbI1lqEGTUzyQRAnF9AKDa99KD8EoM1FV7yap0/c3CAsHEygCgoFo5 -HiaOersL/ga78mKivkhR7Wo= -=MvPd +iD8DBQFCimfOz7mlh8wQzGMRAjjEAJ9+bK1JC1wS///R2jHGkJcDQ5+xzwCdFl7Y +g6pBwCb5rfOejN5Xf56x7PU= +=0DmS -----END PGP SIGNATURE----- diff --git a/sys-kernel/module-rebuild/files/digest-module-rebuild-0.2 b/sys-kernel/module-rebuild/files/digest-module-rebuild-0.2 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/sys-kernel/module-rebuild/files/digest-module-rebuild-0.2 diff --git a/sys-kernel/module-rebuild/files/module-rebuild-0.2 b/sys-kernel/module-rebuild/files/module-rebuild-0.2 new file mode 100755 index 000000000000..42bdc7c035c1 --- /dev/null +++ b/sys-kernel/module-rebuild/files/module-rebuild-0.2 @@ -0,0 +1,244 @@ +#!/bin/bash +####################################### +# Inspiration from bug #34921 +# Thanks to Paul Varner + +# Distributed under the GPL v2 +# Written by John Mylchreest (johnm@gentoo.org) +# Copyright Gentoo Linux + +R_VERSION="0.2" +R_MODULES="${ROOT}/usr/share/module-rebuild/moduledb" +R_PORTAGEQ="`which portageq 2>/dev/null`" +if [[ -z ${R_PORTAGEQ} ]]; then + echo "** FATAL: Unable to find portageq." + exit 1 +fi +R_PORTDIR=`${R_PORTAGEQ} portdir` +R_VDBPATH=`${R_PORTAGEQ} vdb_path` + + +C_BOLD='\e[1m' +C_NORM='\e[0m' +C_GREEN='\e[32m' +C_RED='\e[31m' + +package_valid() { + local package=${1} + [[ -z ${package} ]] && return 1 + [[ -z ${package/*\/*} ]] && return 0 || return 1 +} + +package_valid_strict() { + local package=${1} + package_valid ${package} && [[ -z ${package//*-[0-9]*} ]] && return 0 || return 1 +} + +package_exists() { + local package=${1} + + package=${package//-[0-9]*} + if $(${R_PORTAGEQ} has_version / ${package}); then + return 0 + else + return 1 + fi +} + +db_module_exists() { + local line package=${1} + + for line in `<${R_MODULES}`; do + [[ -z ${line/*${package}*} ]] && return 0 + done + return 1 +} + +db_module_toggle() { + local package=${1} toggleto=${2} togglefrom line + + if db_module_exists ${package}; then + line=`grep ${package} ${R_MODULES}` + togglefrom=${line#*:} + togglefrom=${togglefrom/:*} + if [[ -z ${toggleto} ]]; then + [[ ${togglefrom} = 0 ]] && toggleto=1 || toggleto=0 + fi + echo "** Setting ${package}; rebuild=${toggleto}." + sed -i -e "s:\(.\:\)\([01]\)\(\:${package}\):\1${toggleto}\3:g" ${R_MODULES} + else + echo "** ${package} not found in moduledb." + fi +} + +db_module_add() { + local package=${1} + + if db_module_exists ${package}; then + echo -e "${C_BOLD}** Module already exists in moduledb.${C_NORM}" + db_module_toggle ${package} 1 + return 0 + else + if package_exists ${package}; then + echo -e "${C_BOLD}${C_GREEN}** Adding ${package} to moduledb.${C_NORM}" + echo "m:1:${package}" >> ${R_MODULES} + return 0 + else + echo -e "${C_RED}** Unable to locate an available ebuild for ${package}.${C_NORM}" + echo "** Please manually emerge ${package} first." + fi + fi + return 1 +} + +db_module_del() { + local package=${1} + + if db_module_exists ${package}; then + echo "** Removing ${package} from moduledb." + sed -ie "/.*${package/\//\\/}.*/d" ${R_MODULES} + return 0 + else + echo "** ${package} not found in moduledb." + return 1 + fi +} + +db_module_list() { + local line auto pkg a=0 b=0 + + for line in `<${R_MODULES}`; do + mode=${line:0:1} + pkg=${line#*:} + auto=${pkg/:*} + pkg=${pkg/*:} + + package_valid_strict ${pkg} && pkg="=${pkg}" + if [[ ${auto} = 1 ]]; then + tomerge[${a}]=${pkg} + a=$((${a} + 1)) + else + toignore[${b}]=${pkg} + b=$((${b} + 1)) + fi + done + + pkg="${tomerge[@]}${toignore[@]}" + if [[ -z ${pkg} ]]; then + echo -e "${C_BOLD}${C_RED}** There are no known modules. Quitting.${C_NORM}" + exit 1 + fi + + echo -e "${C_BOLD}${C_GREEN}** Packages which I will emerge are:${C_NORM}" + for pkg in ${tomerge[@]}; do + echo -e "\t${pkg}" + done + + echo -e "${C_BOLD}${C_GREEN}** Packages which I will ignore are:${C_NORM}" + for pkg in ${toignore[@]}; do + echo -e "\t${pkg}" + done +} + +db_module_populate() { + local i x=0 pkg version list pad + + # Lets find them all + # chances are we will get a few dupes in here. + version=`uname -r` + for pkg in `grep -i /lib/modules/${version}/.*o ${R_VDBPATH}/*/*/CONTENTS`; do + pad=""; x=0; + + if [[ -z ${pkg//${R_VDBPATH}*} ]]; then + for((i=0;i<=${#pkg};i++)); do + [[ ${pkg:${i}:1} = / ]] && x=$((${x} + 1)); + [[ ${x} == 4 ]] || [[ ${x} == 5 ]] && pad="${pad}${pkg:${i}:1}"; + done + # Remove any dupes + list=${list//${pad:1}} + list="${list} ${pad:1}" + fi + done + + for pkg in ${list}; do + db_module_add ${pkg}; + done +} + +db_module_merge() { + local i pkg + + echo -e "${C_BOLD}** Preparing to merge modules:${C_NORM}" + db_module_list >/dev/null + + if [[ -z ${tomerge[@]} ]]; then + echo -e "${C_BOLD}${C_RED}** No packages to merge. Quitting.${C_NORM}" + exit 1 + fi + + echo -e "${C_BOLD}${C_GREEN}** Packages which I will emerge are:"${C_NORM} + for pkg in ${tomerge[@]}; do + echo -e "\t${pkg}" + done + + for((i=1;i<6;i++)); do + echo -en "${C_BOLD}${C_RED}$((6 - ${i})) ${C_NORM}" + sleep 1 + done + echo + + emerge --oneshot --nodeps ${tomerge[@]} +} + +phelp() { +cat << EOF +module-rebuild action [category/package] +Version: ${R_VERSION} + +Where action is one of: + add - Add package to moduledb. + del - Delete a package from moduledb. + toggle - Toggle auto-rebuild of Package. + list - List packages to auto-rebuild. + rebuild - Rebuild packages. + populate - Populate the database with any + packages which currently install + drivers into the running kernel. + +EOF + +} + +if [[ `id -u` != 0 ]]; then + echo "This application must be ran as root." + exit 1 +fi + +if [[ ! -f ${ROOT}/usr/share/module-rebuild/moduledb ]]; then + [[ ! -d ${ROOT}/usr/share/module-rebuild/ ]] && mkdir ${ROOT}/usr/share/module-rebuild/ + touch ${ROOT}/usr/share/module-rebuild/moduledb +fi + +check_validity() { + local package=${1} strict=${2:-0} ret=1 + + [[ ${strict} = 0 ]] && package_valid ${package} && ret=0 + [[ ${strict} = 1 ]] && package_valid_strict ${package} && ret=0 + + if [[ ${ret} != 0 ]]; then + echo "** Please pass the fully qualified package. For example:" + echo "** media-video/nvidia-kernel-1.0.7174" + exit 1 + fi +} + +method="${1}" +case ${method} in + add) check_validity ${2} 1; db_module_add ${2};; + del) check_validity ${2}; db_module_del ${2};; + toggle) check_validity ${2}; db_module_toggle ${2};; + list) db_module_list;; + rebuild) db_module_merge;; + populate) db_module_populate;; + *) phelp;; +esac diff --git a/sys-kernel/module-rebuild/module-rebuild-0.2.ebuild b/sys-kernel/module-rebuild/module-rebuild-0.2.ebuild new file mode 100644 index 000000000000..8d72d168b879 --- /dev/null +++ b/sys-kernel/module-rebuild/module-rebuild-0.2.ebuild @@ -0,0 +1,19 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-kernel/module-rebuild/module-rebuild-0.2.ebuild,v 1.1 2005/05/17 21:53:03 johnm Exp $ + +DESCRIPTION="A utility to rebuild any kernel modules which you have installed." +HOMEPAGE="http://www.gentoo.org/" +SRC_URI="" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~x86" +IUSE="" + +DEPEND="" + +src_install() { + newsbin ${FILESDIR}/${P} ${PN} +} + |