Skip to content

Commit

Permalink
makeInitrd: Use closureInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Feb 23, 2018
1 parent d12c991 commit 776a5e6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkgs/build-support/closure-info.nix
Expand Up @@ -4,7 +4,7 @@
# "nix-store --load-db" and "nix-store --register-validity
# --hash-given".

{ stdenv, coreutils, jq, perl, pathsFromGraph }:
{ stdenv, coreutils, jq }:

{ rootPaths }:

Expand Down
9 changes: 3 additions & 6 deletions pkgs/build-support/kernel/make-initrd.nix
Expand Up @@ -12,7 +12,7 @@
# `contents = {object = ...; symlink = /init;}' is a typical
# argument.

{ stdenv, perl, cpio, contents, compressor, prepend, ubootTools
{ stdenv, closureInfo, cpio, contents, compressor, prepend, ubootTools
, hostPlatform
}:

Expand All @@ -22,18 +22,15 @@ stdenv.mkDerivation rec {

makeUInitrd = hostPlatform.platform.kernelTarget == "uImage";

nativeBuildInputs = [ perl cpio ]
nativeBuildInputs = [ cpio ]
++ stdenv.lib.optional makeUInitrd ubootTools;

# !!! 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 = ./paths-from-graph.pl;
closure = closureInfo { rootPaths = (map (x: x.object) contents); };

inherit compressor prepend;
}
6 changes: 1 addition & 5 deletions pkgs/build-support/kernel/make-initrd.sh
Expand Up @@ -25,13 +25,9 @@ for ((n = 0; n < ${#objects[*]}; n++)); do
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 .)
(cd root && cp -prd --parents $(cat $closure/store-paths) .)


# Put the closure in a gzipped cpio archive.
Expand Down
2 changes: 2 additions & 0 deletions pkgs/build-support/kernel/paths-from-graph.pl
@@ -1,3 +1,5 @@
# NOTE: this script is deprecated. Use closureInfo instead.

# Parses a /nix/store/*-closure file and prints
# various information.
# By default, the nodes in the graph are printed to stdout.
Expand Down

0 comments on commit 776a5e6

Please sign in to comment.