summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mylchreest <johnm@gentoo.org>2005-05-03 22:53:37 +0000
committerJohn Mylchreest <johnm@gentoo.org>2005-05-03 22:53:37 +0000
commit6500a09b6f1f168a5b331c259171de38d3ee9a6f (patch)
treea0c3e1d2ed39c5880389c190362f005473fccfbf /sys-kernel/module-rebuild
parentMultilib fixes. (diff)
downloadgentoo-2-6500a09b6f1f168a5b331c259171de38d3ee9a6f.tar.gz
gentoo-2-6500a09b6f1f168a5b331c259171de38d3ee9a6f.tar.bz2
gentoo-2-6500a09b6f1f168a5b331c259171de38d3ee9a6f.zip
Initial Import. fixes bug #34921, thanks go to Paul Varner for inspiration
(Portage version: 2.0.51.21)
Diffstat (limited to 'sys-kernel/module-rebuild')
-rw-r--r--sys-kernel/module-rebuild/ChangeLog10
-rw-r--r--sys-kernel/module-rebuild/files/digest-module-rebuild-0.10
-rwxr-xr-xsys-kernel/module-rebuild/files/module-rebuild-0.1202
-rw-r--r--sys-kernel/module-rebuild/metadata.xml16
-rw-r--r--sys-kernel/module-rebuild/module-rebuild-0.1.ebuild20
5 files changed, 248 insertions, 0 deletions
diff --git a/sys-kernel/module-rebuild/ChangeLog b/sys-kernel/module-rebuild/ChangeLog
new file mode 100644
index 000000000000..1179b9ad9c94
--- /dev/null
+++ b/sys-kernel/module-rebuild/ChangeLog
@@ -0,0 +1,10 @@
+# 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 $
+
+*module-rebuild-0.1 (03 May 2005)
+
+ 03 May 2005; John Mylchreest <johnm@gentoo.org> +files/module-rebuild-0.1,
+ +metadata.xml, +module-rebuild-0.1.ebuild:
+ Initial Import. fixes bug #34921, thanks go to Paul Varner for inspiration
+
diff --git a/sys-kernel/module-rebuild/files/digest-module-rebuild-0.1 b/sys-kernel/module-rebuild/files/digest-module-rebuild-0.1
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/sys-kernel/module-rebuild/files/digest-module-rebuild-0.1
diff --git a/sys-kernel/module-rebuild/files/module-rebuild-0.1 b/sys-kernel/module-rebuild/files/module-rebuild-0.1
new file mode 100755
index 000000000000..f822232b2c60
--- /dev/null
+++ b/sys-kernel/module-rebuild/files/module-rebuild-0.1
@@ -0,0 +1,202 @@
+#!/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.1"
+R_MODULES="${ROOT}/usr/share/module-rebuild/moduledb"
+R_PORTAGEQ="`which portageq 2>/dev/null`"
+[[ -n ${R_PORTAGEQ} ]] && R_PORTDIR=`${R_PORTAGEQ} portdir`
+
+if [[ -z ${R_PORTDIR} ]]; then
+ echo "** FATAL: Unable to find portdir."
+ exit 1
+fi
+
+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/:*}
+ [[ -z ${toggleto} ]] && [[ ${togglefrom} = 0 ]] && toggleto=1 || toggleto=0
+ echo "** Setting ${package}; rebuild=${toggleto}."
+ sed -ie "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 "** Module already exists in moduledb."
+ db_module_toggle ${package} 1
+ return 0
+ else
+ if package_exists ${package}; then
+ echo "** Adding ${package} to moduledb."
+ echo "m:1:${package}" >> ${R_MODULES}
+ return 0
+ else
+ echo "** Unable to locate an available ebuild for ${package}."
+ 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 autoload pkg a=0 b=0
+
+ for line in `<${R_MODULES}`; do
+ mode=${line:0:1}
+ pkg=${line#*:}
+ autoload=${pkg/:*}
+ pkg=${pkg/*:}
+
+ package_valid_strict ${pkg} && pkg="=${pkg}"
+ if [[ ${autoload} = 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 "** There are no known modules. Quitting."
+ exit 1
+ fi
+
+ echo "** Packages which I will emerge are:"
+ for pkg in ${tomerge[@]}; do
+ echo -e "\t${pkg}"
+ done
+
+ echo "** Packages which I will ignore are:"
+ for pkg in ${toignore[@]}; do
+ echo -e "\t${pkg}"
+ done
+}
+
+db_module_merge() {
+ local i pad
+
+ echo "** Preparing to merge modules:"
+ db_module_list >/dev/null
+
+ echo "** Packages which I will emerge are:"
+ for pkg in ${tomerge[@]}; do
+ echo -e "\t${pkg}"
+ done
+
+ for((i=1;i<6;i++)); do
+ echo -n "$((6 - ${i})) "
+ sleep 1
+ done
+
+ emerge ${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.
+
+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;;
+ *) phelp;;
+esac
diff --git a/sys-kernel/module-rebuild/metadata.xml b/sys-kernel/module-rebuild/metadata.xml
new file mode 100644
index 000000000000..0c33b6cbddfe
--- /dev/null
+++ b/sys-kernel/module-rebuild/metadata.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+
+<pkgmetadata>
+ <herd>x86-kernel</herd>
+ <maintainer>
+ <email>johnm@gentoo.org</email>
+ <name>John Mylchreest</name>
+ <description>Actively Maintained</description>
+ </maintainer>
+ <longdescription>
+ module-rebuild is a tool which tracks kernel module installs, and lets you
+ manually manage the rebuild of them. This will also automate a re-merge of
+ the package.
+ </longdescription>
+</pkgmetadata>
diff --git a/sys-kernel/module-rebuild/module-rebuild-0.1.ebuild b/sys-kernel/module-rebuild/module-rebuild-0.1.ebuild
new file mode 100644
index 000000000000..85576280296d
--- /dev/null
+++ b/sys-kernel/module-rebuild/module-rebuild-0.1.ebuild
@@ -0,0 +1,20 @@
+# 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.1.ebuild,v 1.1 2005/05/03 22:53:37 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=""
+RDEPEND=""
+
+src_install() {
+ newsbin ${FILESDIR}/${P} ${PN}
+}
+