Skip to content

Commit

Permalink
Rewrite modules-related packaging
Browse files Browse the repository at this point in the history
* Replace module-init-tools by kmod
* Drop MODULE_DIR patch

We'll maintain /lib/modules/modversion symlink instead. This way both
module-init-tools and libkmod will work without patches.

svn path=/nixpkgs/branches/kmod-MODULE_DIR/; revision=33428
  • Loading branch information
urkud committed Mar 26, 2012
1 parent d465b07 commit 0fe84d6
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 259 deletions.
3 changes: 1 addition & 2 deletions pkgs/applications/virtualization/virtualbox/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ stdenv.mkDerivation {
# Install kernel module
cd src
kernelVersion=$(cd ${kernel}/lib/modules; ls)
export MODULE_DIR=$out/lib/modules/$kernelVersion/misc
export MODULE_DIR=$out/lib/modules/${kernel.modDirVersion}/misc
# Remove root ownership stuff, since this does not work in a chroot environment
for i in `find . -name Makefile`; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,11 @@ stdenv.mkDerivation {
for i in *
do
cd $i
kernelVersion=$(cd ${kernel}/lib/modules; ls)
export MODULE_DIR=$out/lib/modules/$kernelVersion/misc
find . -type f | xargs sed -i -e "s|-o root||g" \
-e "s|-g root||g"
make install
cd ..
export MODULE_DIR=$out/lib/modules/${kernel.modDirVersion}/misc
find . -type f | xargs sed -i -e "s|-o root||g" \
-e "s|-g root||g"
make install
cd ..
done
'';

Expand Down
10 changes: 5 additions & 5 deletions pkgs/build-support/kernel/modules-closure.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Given a kernel build (with modules in $kernel/lib/modules/VERSION),
# Given a modules tree (with modules in $modulesTree/lib/modules/VERSION),
# produce a module tree in $out/lib/modules/VERSION that contains only
# the modules identified by `rootModules', plus their dependencies.
# Also generate an appropriate modules.dep.

{ stdenv, kernel, nukeReferences, rootModules
, module_init_tools, allowMissing ? false }:
{ stdenv, modulesTree, nukeReferences, rootModules
, kmod, allowMissing ? false }:

stdenv.mkDerivation {
name = kernel.name + "-shrunk";
name = modulesTree.name + "-shrunk";
builder = ./modules-closure.sh;
buildInputs = [nukeReferences];
inherit kernel rootModules module_init_tools allowMissing;
inherit modulesTree rootModules kmod allowMissing;
allowedReferences = ["out"];
}
12 changes: 5 additions & 7 deletions pkgs/build-support/kernel/modules-closure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ source $stdenv/setup

set -o pipefail

PATH=$module_init_tools/sbin:$PATH

version=$(cd $kernel/lib/modules && ls -d *)
PATH=$kmod/sbin:$PATH
version=$(cd $modulesTree/lib/modules && ls -d *)

echo "kernel version is $version"

export MODULE_DIR=$(readlink -f $kernel/lib/modules/)

mkdir empty
# Determine the dependencies of each root module.
closure=
for module in $rootModules; do
echo "root module: $module"
deps=$(modprobe --config /dev/null --set-version "$version" --show-depends "$module" \
deps=$(modprobe -S "$version" -d "$modulesTree" --show-depends "$module" \
| sed 's/^insmod //') \
|| if test -z "$allowMissing"; then exit 1; fi
#for i in $deps; do echo $i; done
Expand All @@ -41,4 +39,4 @@ for module in $closure; do
echo $target >> $out/insmod-list
done

MODULE_DIR=$out/lib/modules/ depmod -a $version
depmod -b $out -a $version
8 changes: 1 addition & 7 deletions pkgs/os-specific/linux/kernel/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,8 @@ installPhase() {
cp vmlinux $out

if grep -q "CONFIG_MODULES=y" .config; then
# Install the modules in $out/lib/modules with matching paths
# in modules.dep (i.e., refererring to $out/lib/modules, not
# /lib/modules). The depmod_opts= is to prevent the kernel
# from passing `-b PATH' to depmod.
export MODULE_DIR=$out/lib/modules/
substituteInPlace Makefile --replace '-b $(INSTALL_MOD_PATH)' ''
make modules_install \
DEPMOD=$module_init_tools/sbin/depmod depmod_opts= \
DEPMOD=$module_init_tools/sbin/depmod \
$makeFlags "${makeFlagsArray[@]}" \
$installFlags "${installFlagsArray[@]}"

Expand Down
4 changes: 0 additions & 4 deletions pkgs/os-specific/linux/kernel/linux-3.0.nix
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@ import ./generic.nix (
rec {
version = "3.0.24";

preConfigure = ''
substituteInPlace scripts/depmod.sh --replace '-b "$INSTALL_MOD_PATH"' ""
'';

src = fetchurl {
url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.bz2";
sha256 = "0j783ivlgg66jvasxaapimyzaqyn61jlz4abhkynckr4h5hrpvw4";
Expand Down
4 changes: 0 additions & 4 deletions pkgs/os-specific/linux/kernel/linux-3.1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@ import ./generic.nix (
rec {
version = "3.1.10";

preConfigure = ''
substituteInPlace scripts/depmod.sh --replace '-b "$INSTALL_MOD_PATH"' ""
'';

src = fetchurl {
url = "mirror://kernel/linux/kernel/v3.x/linux-${version}.tar.bz2";
sha256 = "1vcpbh7wnc9smw2l5ci27a5p0rgmc1a5dc6a1aljm6f6wcfic8lz";
Expand Down
4 changes: 0 additions & 4 deletions pkgs/os-specific/linux/kernel/linux-3.2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ import ./generic.nix (

modDirVersion = version;

preConfigure = ''
substituteInPlace scripts/depmod.sh --replace '-b "$INSTALL_MOD_PATH"' ""
'';

src = fetchurl {
url = "mirror://kernel/linux/kernel/v3.0/${if testing then "testing/" else ""}linux-${version}.tar.bz2";
sha256 = "1hacfmf08ydzf4xlg6wkkckl5icj7w9h3nh17myz1s67bp7q61qs";
Expand Down
4 changes: 0 additions & 4 deletions pkgs/os-specific/linux/kernel/linux-3.3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ import ./generic.nix (

modDirVersion = "3.3.0";

preConfigure = ''
substituteInPlace scripts/depmod.sh --replace '-b "$INSTALL_MOD_PATH"' ""
'';

src = fetchurl {
url = "mirror://kernel/linux/kernel/v3.0/${if testing then "testing/" else ""}linux-${version}.tar.bz2";
sha256 = "0czk8bj46r3r95iz6gi7xkavhjx847s5p9248vabi0c1wjs6kmlg";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{stdenv, module_init_tools, modules, buildEnv}:
{stdenv, kmod, modules, buildEnv}:

buildEnv {
name = "kernel-modules";
Expand All @@ -21,7 +21,8 @@ buildEnv {
# kernel version number, otherwise depmod will use `uname -r'.
if test -w $out/lib/modules/$kernelVersion; then
rm -f $out/lib/modules/$kernelVersion/modules.*
MODULE_DIR=$out/lib/modules/ ${module_init_tools}/sbin/depmod -a $kernelVersion
echo ${kmod}/sbin/depmod -b $out -a $kernelVersion
${kmod}/sbin/depmod -b $out -a $kernelVersion
fi
'';
}
10 changes: 9 additions & 1 deletion pkgs/os-specific/linux/kmod/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ stdenv.mkDerivation {
sha256 = "1xvsy2zcfdimj4j5b5yyxaqx2byabmwq8qlzjm0hqzpyxxgfw1lq";
};

buildInputs = [ pkgconfig xz zlib ];
buildInputs = [ xz zlib ];
buildNativeInputs = [ pkgconfig ];

configureFlags = [ "--with-xz" "--with-zlib" ];

postInstall = ''
mkdir -p $out/sbin
for i in depmod insmod lsmod modinfo modprobe rmmod; do
ln -sv ../bin/kmod $out/sbin/$i
done
'';

meta = {
homepage = http://www.kernel.org/pub/linux/utils/kernel/kmod/;
description = "Tools for loading and managing Linux kernel modules";
Expand Down
34 changes: 0 additions & 34 deletions pkgs/os-specific/linux/module-init-tools/default.nix

This file was deleted.

12 changes: 0 additions & 12 deletions pkgs/os-specific/linux/module-init-tools/docbook2man.patch

This file was deleted.

161 changes: 0 additions & 161 deletions pkgs/os-specific/linux/module-init-tools/module-dir.patch

This file was deleted.

Loading

0 comments on commit 0fe84d6

Please sign in to comment.