2020-04-24 23:36:52 +00:00
|
|
|
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.
|
|
|
|
mkdir -p $out
|
|
|
|
for PREP in $prepend; do
|
|
|
|
cat $PREP >> $out/initrd
|
|
|
|
done
|
2020-12-25 13:55:36 +00:00
|
|
|
(cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +)
|
|
|
|
(cd root && find * .[^.*] -print0 | sort -z | cpio -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd")
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
if [ -n "$makeUInitrd" ]; then
|
2021-08-10 14:31:46 +00:00
|
|
|
mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img
|
2020-12-25 13:55:36 +00:00
|
|
|
# Compatibility symlink
|
2021-08-10 14:31:46 +00:00
|
|
|
ln -sf "initrd.img" "$out/initrd"
|
2020-12-25 13:55:36 +00:00
|
|
|
else
|
|
|
|
ln -s "initrd" "$out/initrd$extension"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|