nixpkgs/test/make-initrd.sh
Eelco Dolstra 3a70748bb5 * Show a splash screen during booting. The splash screen is displayed
by the program /sbin/splash_helper in the initrd and is called even
  before /init.
* make-initrd.nix: allow a list of FSOs to be placed in the initrd,
  with a symlink to each top-level FSO (e.g., /init,
  /sbin/splash_helper, /etc/splash).
* make-initrd.nix: pre-create /proc, /dev and /sys, because
  splash_helper needs them.

svn path=/nixu/trunk/; revision=7144
2006-11-27 01:35:34 +00:00

43 lines
1 KiB
Bash

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
# Get the paths in the closure of `object'.
closure=closure-$(basename $symlink)
if ! test -e $closure; then
echo 'Your Nix installation is too old! Upgrade to nix-0.11pre7038 or newer.'
exit 1
fi
storePaths=$($SHELL $pathsFromGraph $closure)
# Paths in cpio archives *must* be relative, otherwise the kernel
# won't unpack 'em.
(cd root && cp -prd --parents $storePaths .)
mkdir -p $(dirname root/$symlink)
ln -s $object$suffix root/$symlink
done
# Put the closure in a gzipped cpio archive.
ensureDir $out
(cd root && find * -print0 | cpio -ov -H newc --null | gzip -9 > $out/initrd)