qlog: 0.39.0 -> 0.40.0 (#358767)
[NixPkgs.git] / pkgs / build-support / kernel / make-initrd.sh
blob0149c5d487ace82c82add9123022c63fa8376aa3
1 source $stdenv/setup
3 set -o pipefail
5 objects=($objects)
6 symlinks=($symlinks)
7 suffices=($suffices)
9 mkdir root
11 # Needed for splash_helper, which gets run before init.
12 mkdir root/dev
13 mkdir root/sys
14 mkdir root/proc
17 for ((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
23 mkdir -p $(dirname root/$symlink)
24 ln -s $object$suffix root/$symlink
25 done
28 # Get the paths in the closure of `object'.
29 storePaths=$(perl $pathsFromGraph closure-*)
32 # Paths in cpio archives *must* be relative, otherwise the kernel
33 # won't unpack 'em.
34 (cd root && cp -prP --parents $storePaths .)
37 # Put the closure in a gzipped cpio archive.
38 mkdir -p $out
39 for PREP in $prepend; do
40 cat $PREP >> $out/initrd
41 done
42 (cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +)
43 (cd root && find * .[^.*] -print0 | sort -z | cpio --quiet -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd")
45 if [ -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"
49 else
50 ln -s "initrd" "$out/initrd$extension"