mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 10:53:11 +00:00
0f216e2578
Originally, we switched to bsdtar from libarchive to solve a reproducibility issue related to hardlinks As of gnu cpio 2.14 the --ignore-dirnlink option is introduced and now included in --reproducible, which solves this issue By switching back, we are in turn solving an issue in libarchive >=3.7.5 erroring out with "Error reading archive -: (null)" Change-Id: Ib6140d599b6547d8e941b0251ce996e303c41fa6
52 lines
1.2 KiB
Bash
52 lines
1.2 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
|
|
|
|
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 -prP --parents $storePaths .)
|
|
|
|
|
|
# Put the closure in a gzipped cpio archive.
|
|
mkdir -p $out
|
|
for PREP in $prepend; do
|
|
cat $PREP >> $out/initrd
|
|
done
|
|
(cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +)
|
|
(cd root && find * .[^.*] -print0 | sort -z | cpio --quiet -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd")
|
|
|
|
if [ -n "$makeUInitrd" ]; then
|
|
mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img
|
|
# Compatibility symlink
|
|
ln -sf "initrd.img" "$out/initrd"
|
|
else
|
|
ln -s "initrd" "$out/initrd$extension"
|
|
fi
|