2008-03-17 13:40:47 +03: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
|
|
|
|
|
|
|
|
|
2018-03-05 14:42:31 +03:00
|
|
|
# Get the paths in the closure of `object'.
|
|
|
|
storePaths=$(perl $pathsFromGraph closure-*)
|
|
|
|
|
|
|
|
|
2008-03-17 13:40:47 +03:00
|
|
|
# Paths in cpio archives *must* be relative, otherwise the kernel
|
|
|
|
# won't unpack 'em.
|
2022-01-29 06:28:16 +03:00
|
|
|
(cd root && cp -prP --parents $storePaths .)
|
2008-03-17 13:40:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
# Put the closure in a gzipped cpio archive.
|
2012-01-19 00:16:00 +04:00
|
|
|
mkdir -p $out
|
2015-03-25 22:03:03 +03:00
|
|
|
for PREP in $prepend; do
|
|
|
|
cat $PREP >> $out/initrd
|
|
|
|
done
|
2020-09-03 15:19:43 +03:00
|
|
|
(cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +)
|
2022-03-27 02:34:30 +03:00
|
|
|
(cd root && find * .[^.*] -print0 | sort -z | bsdtar --uid 0 --gid 0 -cnf - -T - | bsdtar --null -cf - --format=newc @- | eval -- $compress >> "$out/initrd")
|
2009-11-08 03:32:12 +03:00
|
|
|
|
|
|
|
if [ -n "$makeUInitrd" ]; then
|
2021-08-03 00:11:25 +03:00
|
|
|
mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img
|
2020-09-04 19:18:32 +03:00
|
|
|
# Compatibility symlink
|
2021-08-03 00:11:25 +03:00
|
|
|
ln -sf "initrd.img" "$out/initrd"
|
2020-09-04 19:18:32 +03:00
|
|
|
else
|
|
|
|
ln -s "initrd" "$out/initrd$extension"
|
2009-11-08 03:32:12 +03:00
|
|
|
fi
|