* Moved to Nixpkgs.
svn path=/nixos/trunk/; revision=11155
This commit is contained in:
parent
6354623143
commit
52aed402db
|
@ -1,31 +0,0 @@
|
|||
# Create an initial ramdisk containing the closure of the specified
|
||||
# file system objects. An initial ramdisk is used during the initial
|
||||
# stages of booting a Linux system. It is loaded by the boot loader
|
||||
# along with the kernel image. It's supposed to contain everything
|
||||
# (such as kernel modules) necessary to allow us to mount the root
|
||||
# file system. Once the root file system is mounted, the `real' boot
|
||||
# script can be called.
|
||||
#
|
||||
# An initrd is really just a gzipped cpio archive.
|
||||
#
|
||||
# Symlinks are created for each top-level file system object. E.g.,
|
||||
# `contents = {object = ...; symlink = /init;}' is a typical
|
||||
# argument.
|
||||
|
||||
{stdenv, perl, cpio, contents}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "initrd";
|
||||
builder = ./make-initrd.sh;
|
||||
buildInputs = [perl cpio];
|
||||
|
||||
# !!! should use XML.
|
||||
objects = map (x: x.object) contents;
|
||||
symlinks = map (x: x.symlink) contents;
|
||||
suffices = map (x: if x ? suffix then x.suffix else "none") contents;
|
||||
|
||||
# For obtaining the closure of `contents'.
|
||||
exportReferencesGraph =
|
||||
map (x: [("closure-" + baseNameOf x.symlink) x.object]) contents;
|
||||
pathsFromGraph = ../helpers/paths-from-graph.pl;
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
source $stdenv/setup
|
||||
|
||||
set -o pipefail
|
||||
|
||||
objects=($objects)
|
||||
symlinks=($symlinks)
|
||||
suffices=($suffices)
|
||||
|
||||
mkdir root
|
||||
|
||||
# Needed for splash_helper, which gets run before init.
|
||||
mkdir root/dev
|
||||
mkdir root/sys
|
||||
mkdir root/proc
|
||||
|
||||
|
||||
for ((n = 0; n < ${#objects[*]}; n++)); do
|
||||
object=${objects[$n]}
|
||||
symlink=${symlinks[$n]}
|
||||
suffix=${suffices[$n]}
|
||||
if test "$suffix" = none; then suffix=; fi
|
||||
|
||||
mkdir -p $(dirname root/$symlink)
|
||||
ln -s $object$suffix root/$symlink
|
||||
done
|
||||
|
||||
|
||||
# Get the paths in the closure of `object'.
|
||||
storePaths=$(perl $pathsFromGraph closure-*)
|
||||
|
||||
|
||||
# Paths in cpio archives *must* be relative, otherwise the kernel
|
||||
# won't unpack 'em.
|
||||
(cd root && cp -prd --parents $storePaths .)
|
||||
|
||||
|
||||
# Put the closure in a gzipped cpio archive.
|
||||
ensureDir $out
|
||||
(cd root && find * -print0 | cpio -ov -H newc --null | gzip -9 > $out/initrd)
|
|
@ -48,5 +48,5 @@ stdenv.mkDerivation {
|
|||
map (x: [("closure-" + baseNameOf x.object) x.object]) storeContents;
|
||||
exportBuildReferencesGraph =
|
||||
map (x: [("closure-build-" + baseNameOf x.object) x.object]) buildStoreContents;
|
||||
pathsFromGraph = ./paths-from-graph.pl;
|
||||
pathsFromGraph = ../../nixpkgs/pkgs/build-support/kernel/paths-from-graph.pl;
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
# Given a kernel build (with modules in $kernel/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, rootModules, module_init_tools}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = kernel.name + "-shrunk";
|
||||
builder = ./modules-closure.sh;
|
||||
inherit kernel rootModules module_init_tools;
|
||||
allowedReferences = ["out"];
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
source $stdenv/setup
|
||||
|
||||
set -o pipefail
|
||||
|
||||
PATH=$module_init_tools/sbin:$PATH
|
||||
|
||||
version=$(cd $kernel/lib/modules && ls -d *)
|
||||
|
||||
echo "kernel version is $version"
|
||||
|
||||
export MODULE_DIR=$kernel/lib/modules/
|
||||
|
||||
# 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" \
|
||||
| sed 's/^insmod //')
|
||||
#for i in $deps; do echo $i; done
|
||||
closure="$closure $deps"
|
||||
done
|
||||
|
||||
echo "closure:"
|
||||
ensureDir $out
|
||||
for module in $closure; do
|
||||
target=$(echo $module | sed "s^$kernel^$out^")
|
||||
if test -e "$target"; then continue; fi
|
||||
echo $module
|
||||
mkdir -p $(dirname $target)
|
||||
cp $module $target
|
||||
grep "^$module" $kernel/lib/modules/$version/modules.dep \
|
||||
| sed "s^$kernel^$out^g" \
|
||||
>> $out/lib/modules/$version/modules.dep
|
||||
echo $target >> $out/insmod-list
|
||||
done
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
use strict;
|
||||
use File::Basename;
|
||||
|
||||
my %storePaths;
|
||||
my %refs;
|
||||
|
||||
foreach my $graph (@ARGV) {
|
||||
open GRAPH, "<$graph" or die;
|
||||
|
||||
while (<GRAPH>) {
|
||||
chomp;
|
||||
my $storePath = "$_";
|
||||
$storePaths{$storePath} = 1;
|
||||
|
||||
my $deriver = <GRAPH>; chomp $deriver;
|
||||
my $count = <GRAPH>; chomp $count;
|
||||
|
||||
my @refs = ();
|
||||
for (my $i = 0; $i < $count; ++$i) {
|
||||
my $ref = <GRAPH>; chomp $ref;
|
||||
push @refs, $ref;
|
||||
}
|
||||
$refs{$storePath} = \@refs;
|
||||
|
||||
}
|
||||
|
||||
close GRAPH;
|
||||
}
|
||||
|
||||
|
||||
if ($ENV{"printManifest"} eq "1") {
|
||||
print "version {\n";
|
||||
print " ManifestVersion: 3\n";
|
||||
print "}\n";
|
||||
|
||||
foreach my $storePath (sort (keys %storePaths)) {
|
||||
my $base = basename $storePath;
|
||||
print "localPath {\n";
|
||||
print " StorePath: $storePath\n";
|
||||
print " CopyFrom: /tmp/inst-store/$base\n";
|
||||
print " References: ";
|
||||
foreach my $ref (@{$refs{$storePath}}) {
|
||||
print "$ref ";
|
||||
}
|
||||
print "\n";
|
||||
print "}\n";
|
||||
}
|
||||
}
|
||||
|
||||
elsif ($ENV{"printRegistration"} eq "1") {
|
||||
# This is the format used by `nix-store --register-validity
|
||||
# --hash-given' / `nix-store --load-db'.
|
||||
foreach my $storePath (sort (keys %storePaths)) {
|
||||
print "$storePath\n";
|
||||
print "0000000000000000000000000000000000000000000000000000000000000000\n"; # !!! fix
|
||||
print "\n"; # don't care about preserving the deriver
|
||||
print scalar(@{$refs{$storePath}}), "\n";
|
||||
foreach my $ref (@{$refs{$storePath}}) {
|
||||
print "$ref\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
foreach my $storePath (sort (keys %storePaths)) {
|
||||
print "$storePath\n";
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ in
|
|||
inherit nix;
|
||||
nixpkgsURL = config.installer.nixpkgsURL;
|
||||
|
||||
pathsFromGraph = ../helpers/paths-from-graph.pl;
|
||||
pathsFromGraph = ../../nixpkgs/pkgs/build-support/kernel/paths-from-graph.pl;
|
||||
|
||||
nixClosure = pkgs.runCommand "closure"
|
||||
{exportReferencesGraph = ["refs" nix];}
|
||||
|
|
|
@ -41,8 +41,7 @@ rec {
|
|||
|
||||
|
||||
# Determine the set of modules that we need to mount the root FS.
|
||||
modulesClosure = import ../helpers/modules-closure.nix {
|
||||
inherit (pkgs) stdenv module_init_tools;
|
||||
modulesClosure = pkgs.makeModulesClosure {
|
||||
inherit rootModules;
|
||||
kernel = modulesTree;
|
||||
};
|
||||
|
@ -60,9 +59,9 @@ rec {
|
|||
lvm2 = if config.boot.initrd.lvm then pkgs.lvm2Static else null;
|
||||
allowedReferences = []; # prevent accidents like glibc being included in the initrd
|
||||
}
|
||||
"
|
||||
''
|
||||
ensureDir $out/bin
|
||||
if test -n \"$devicemapper\"; then
|
||||
if test -n "$devicemapper"; then
|
||||
cp $devicemapper/sbin/dmsetup.static $out/bin/dmsetup
|
||||
cp $lvm2/sbin/lvm.static $out/bin/lvm
|
||||
fi
|
||||
|
@ -70,7 +69,7 @@ rec {
|
|||
cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $out/bin
|
||||
cp $udev/sbin/udevd $udev/sbin/udevtrigger $udev/sbin/udevsettle $out/bin
|
||||
nuke-refs $out/bin/*
|
||||
";
|
||||
'';
|
||||
|
||||
|
||||
# The init script of boot stage 1 (loading kernel modules for
|
||||
|
@ -95,17 +94,16 @@ rec {
|
|||
|
||||
# The closure of the init script of boot stage 1 is what we put in
|
||||
# the initial RAM disk.
|
||||
initialRamdisk = import ../boot/make-initrd.nix {
|
||||
inherit (pkgs) perl stdenv cpio;
|
||||
initialRamdisk = pkgs.makeInitrd {
|
||||
contents = [
|
||||
{ object = bootStage1;
|
||||
symlink = "/init";
|
||||
}
|
||||
] ++ (if config.boot.initrd.enableSplashScreen then [
|
||||
{ object = pkgs.runCommand "splashutils" {} "
|
||||
{ object = pkgs.runCommand "splashutils" {} ''
|
||||
ensureDir $out/bin
|
||||
cp ${pkgs.splashutils}/bin/splash_helper $out/bin
|
||||
";
|
||||
'';
|
||||
suffix = "/bin/splash_helper";
|
||||
symlink = "/sbin/splash_helper";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue