Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1source $stdenv/setup 2 3set -o pipefail 4 5objects=($objects) 6symlinks=($symlinks) 7suffices=($suffices) 8 9mkdir root 10 11# Needed for splash_helper, which gets run before init. 12mkdir root/dev 13mkdir root/sys 14mkdir root/proc 15 16 17for ((n = 0; n < ${#objects[*]}; n++)); do 18 object=${objects[$n]} 19 symlink=${symlinks[$n]} 20 suffix=${suffices[$n]} 21 if test "$suffix" = none; then suffix=; fi 22 23 mkdir -p $(dirname root/$symlink) 24 ln -s $object$suffix root/$symlink 25done 26 27 28# Get the paths in the closure of `object'. 29storePaths=$(perl $pathsFromGraph closure-*) 30 31 32# Paths in cpio archives *must* be relative, otherwise the kernel 33# won't unpack 'em. 34(cd root && cp -prP --parents $storePaths .) 35 36 37# Put the closure in a gzipped cpio archive. 38mkdir -p $out 39for PREP in $prepend; do 40 cat $PREP >> $out/initrd 41done 42(cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +) 43(cd root && find * .[^.*] -print0 | sort -z | bsdtar --uid 0 --gid 0 -cnf - -T - | bsdtar --null -cf - --format=newc @- | eval -- $compress >> "$out/initrd") 44 45if [ -n "$makeUInitrd" ]; then 46 mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img 47 # Compatibility symlink 48 ln -sf "initrd.img" "$out/initrd" 49else 50 ln -s "initrd" "$out/initrd$extension" 51fi