2006-11-02 18:56:50 +01:00
|
|
|
source $stdenv/setup
|
|
|
|
|
2007-01-23 14:44:41 +01:00
|
|
|
sources_=($sources)
|
|
|
|
targets_=($targets)
|
|
|
|
|
|
|
|
objects=($objects)
|
|
|
|
symlinks=($symlinks)
|
|
|
|
|
2009-06-09 14:01:31 +02:00
|
|
|
|
|
|
|
# Remove the initial slash from a path, since genisofs likes it that way.
|
|
|
|
stripSlash() {
|
|
|
|
res="$1"
|
|
|
|
if test "${res:0:1}" = /; then res=${res:1}; fi
|
|
|
|
}
|
|
|
|
|
2014-10-26 22:47:15 +01:00
|
|
|
# Escape potential equal signs (=) with backslash (\=)
|
|
|
|
escapeEquals() {
|
|
|
|
echo "$1" | sed -e 's/\\/\\\\/g' -e 's/=/\\=/g'
|
|
|
|
}
|
|
|
|
|
|
|
|
# Queues an file/directory to be placed on the ISO.
|
|
|
|
# An entry consists of a local source path (2) and
|
|
|
|
# a destination path on the ISO (1).
|
|
|
|
addPath() {
|
|
|
|
target="$1"
|
|
|
|
source="$2"
|
|
|
|
echo "$(escapeEquals "$target")=$(escapeEquals "$source")" >> pathlist
|
|
|
|
}
|
|
|
|
|
2009-06-09 14:01:31 +02:00
|
|
|
stripSlash "$bootImage"; bootImage="$res"
|
|
|
|
|
|
|
|
|
2006-11-02 18:56:50 +01:00
|
|
|
if test -n "$bootable"; then
|
2007-02-07 16:23:19 +01:00
|
|
|
|
|
|
|
# The -boot-info-table option modifies the $bootImage file, so
|
|
|
|
# find it in `contents' and make a copy of it (since the original
|
|
|
|
# is read-only in the Nix store...).
|
|
|
|
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
2009-06-09 14:01:31 +02:00
|
|
|
stripSlash "${targets_[$i]}"
|
|
|
|
if test "$res" = "$bootImage"; then
|
2007-02-07 16:23:19 +01:00
|
|
|
echo "copying the boot image ${sources_[$i]}"
|
|
|
|
cp "${sources_[$i]}" boot.img
|
|
|
|
chmod u+w boot.img
|
|
|
|
sources_[$i]=boot.img
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2014-10-26 21:29:04 +01:00
|
|
|
isoBootFlags="-eltorito-boot ${bootImage}
|
|
|
|
-eltorito-catalog .boot.cat
|
2018-12-02 06:34:58 +01:00
|
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table
|
|
|
|
--sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
|
2014-10-26 21:29:04 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$usbBootable"; then
|
|
|
|
usbBootFlags="-isohybrid-mbr ${isohybridMbrImage}"
|
2006-11-02 18:56:50 +01:00
|
|
|
fi
|
|
|
|
|
2012-03-16 06:37:24 +01:00
|
|
|
if test -n "$efiBootable"; then
|
2014-10-26 21:29:04 +01:00
|
|
|
efiBootFlags="-eltorito-alt-boot
|
|
|
|
-e $efiBootImage
|
|
|
|
-no-emul-boot
|
|
|
|
-isohybrid-gpt-basdat"
|
2012-03-16 06:37:24 +01:00
|
|
|
fi
|
2009-06-09 14:01:31 +02:00
|
|
|
|
2008-01-15 16:39:34 +01:00
|
|
|
touch pathlist
|
2007-01-23 14:44:41 +01:00
|
|
|
|
2009-06-09 14:01:31 +02:00
|
|
|
|
2007-01-23 15:34:44 +01:00
|
|
|
# Add the individual files.
|
2006-11-04 00:41:57 +01:00
|
|
|
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
2009-06-09 14:01:31 +02:00
|
|
|
stripSlash "${targets_[$i]}"
|
2014-10-26 22:47:15 +01:00
|
|
|
addPath "$res" "${sources_[$i]}"
|
2006-11-04 00:41:57 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2007-01-23 15:34:44 +01:00
|
|
|
# Add the closures of the top-level store objects.
|
2018-02-07 16:50:47 +01:00
|
|
|
for i in $(< $closureInfo/store-paths); do
|
2014-10-26 22:47:15 +01:00
|
|
|
addPath "${i:1}" "$i"
|
2007-01-23 15:34:44 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2009-06-10 15:40:35 +02:00
|
|
|
# Also include a manifest of the closures in a format suitable for
|
|
|
|
# nix-store --load-db.
|
2018-02-07 16:50:47 +01:00
|
|
|
if [[ ${#objects[*]} != 0 ]]; then
|
|
|
|
cp $closureInfo/registration nix-path-registration
|
2014-10-26 22:47:15 +01:00
|
|
|
addPath "nix-path-registration" "nix-path-registration"
|
2010-05-28 08:27:31 +02:00
|
|
|
fi
|
2007-01-23 16:08:00 +01:00
|
|
|
|
|
|
|
|
2007-01-23 15:34:44 +01:00
|
|
|
# Add symlinks to the top-level store objects.
|
2007-01-23 14:44:41 +01:00
|
|
|
for ((n = 0; n < ${#objects[*]}; n++)); do
|
|
|
|
object=${objects[$n]}
|
|
|
|
symlink=${symlinks[$n]}
|
|
|
|
if test "$symlink" != "none"; then
|
|
|
|
mkdir -p $(dirname ./$symlink)
|
|
|
|
ln -s $object ./$symlink
|
2014-10-26 22:47:15 +01:00
|
|
|
addPath "$symlink" "./$symlink"
|
2007-01-23 14:44:41 +01:00
|
|
|
fi
|
2006-11-04 00:41:57 +01:00
|
|
|
done
|
|
|
|
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/iso
|
2014-10-26 21:29:04 +01:00
|
|
|
|
|
|
|
xorriso="xorriso
|
|
|
|
-as mkisofs
|
|
|
|
-iso-level 3
|
|
|
|
-volid ${volumeID}
|
|
|
|
-appid nixos
|
|
|
|
-publisher nixos
|
|
|
|
-graft-points
|
|
|
|
-full-iso9660-filenames
|
2020-04-10 02:06:32 +02:00
|
|
|
-joliet
|
2014-10-26 21:29:04 +01:00
|
|
|
${isoBootFlags}
|
|
|
|
${usbBootFlags}
|
|
|
|
${efiBootFlags}
|
|
|
|
-r
|
2014-10-26 22:47:15 +01:00
|
|
|
-path-list pathlist
|
2014-10-26 21:29:04 +01:00
|
|
|
--sort-weight 0 /
|
2018-12-02 06:34:58 +01:00
|
|
|
"
|
2014-10-26 21:29:04 +01:00
|
|
|
|
|
|
|
$xorriso -output $out/iso/$isoName
|
|
|
|
|
|
|
|
if test -n "$usbBootable"; then
|
|
|
|
echo "Making image hybrid..."
|
2015-11-28 06:55:47 +01:00
|
|
|
if test -n "$efiBootable"; then
|
|
|
|
isohybrid --uefi $out/iso/$isoName
|
|
|
|
else
|
|
|
|
isohybrid $out/iso/$isoName
|
|
|
|
fi
|
2008-06-05 15:42:18 +02:00
|
|
|
fi
|
2008-08-08 19:07:04 +02:00
|
|
|
|
2014-10-26 21:29:04 +01:00
|
|
|
if test -n "$compressImage"; then
|
|
|
|
echo "Compressing image..."
|
2020-04-24 18:12:42 +02:00
|
|
|
zstd -T$NIX_BUILD_CORES $out/iso/$isoName
|
2014-10-26 21:29:04 +01:00
|
|
|
fi
|
2006-11-04 13:00:05 +01:00
|
|
|
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/nix-support
|
2006-11-04 13:00:05 +01:00
|
|
|
echo $system > $out/nix-support/system
|
2020-04-24 18:12:42 +02:00
|
|
|
|
|
|
|
if test -n "$compressImage"; then
|
|
|
|
echo "file iso $out/iso/$isoName.zst" >> $out/nix-support/hydra-build-products
|
|
|
|
else
|
|
|
|
echo "file iso $out/iso/$isoName" >> $out/nix-support/hydra-build-products
|
|
|
|
fi
|