diff options
Diffstat (limited to 'pkgs/build-support/kernel/make-initrd.sh')
-rw-r--r-- | pkgs/build-support/kernel/make-initrd.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pkgs/build-support/kernel/make-initrd.sh b/pkgs/build-support/kernel/make-initrd.sh new file mode 100644 index 000000000000..d930e51a03f9 --- /dev/null +++ b/pkgs/build-support/kernel/make-initrd.sh @@ -0,0 +1,39 @@ +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) |