2009-06-09 13:01:31 +01: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 21:47:15 +00: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 13:01:31 +01:00
|
|
|
stripSlash "$bootImage"; bootImage="$res"
|
|
|
|
|
|
|
|
|
2006-11-02 17:56:50 +00:00
|
|
|
if test -n "$bootable"; then
|
2007-02-07 15:23:19 +00: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...).
|
2023-02-03 14:28:04 +00:00
|
|
|
for ((i = 0; i < ${#targets[@]}; i++)); do
|
|
|
|
stripSlash "${targets[$i]}"
|
2009-06-09 13:01:31 +01:00
|
|
|
if test "$res" = "$bootImage"; then
|
2023-02-03 14:28:04 +00:00
|
|
|
echo "copying the boot image ${sources[$i]}"
|
|
|
|
cp "${sources[$i]}" boot.img
|
2007-02-07 15:23:19 +00:00
|
|
|
chmod u+w boot.img
|
2023-02-03 14:28:04 +00:00
|
|
|
sources[$i]=boot.img
|
2007-02-07 15:23:19 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2014-10-26 20:29:04 +00:00
|
|
|
isoBootFlags="-eltorito-boot ${bootImage}
|
|
|
|
-eltorito-catalog .boot.cat
|
2018-12-02 05:34:58 +00: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 20:29:04 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$usbBootable"; then
|
|
|
|
usbBootFlags="-isohybrid-mbr ${isohybridMbrImage}"
|
2006-11-02 17:56:50 +00:00
|
|
|
fi
|
|
|
|
|
2012-03-16 05:37:24 +00:00
|
|
|
if test -n "$efiBootable"; then
|
2014-10-26 20:29:04 +00:00
|
|
|
efiBootFlags="-eltorito-alt-boot
|
|
|
|
-e $efiBootImage
|
|
|
|
-no-emul-boot
|
|
|
|
-isohybrid-gpt-basdat"
|
2012-03-16 05:37:24 +00:00
|
|
|
fi
|
2009-06-09 13:01:31 +01:00
|
|
|
|
2008-01-15 15:39:34 +00:00
|
|
|
touch pathlist
|
2007-01-23 13:44:41 +00:00
|
|
|
|
2009-06-09 13:01:31 +01:00
|
|
|
|
2007-01-23 14:34:44 +00:00
|
|
|
# Add the individual files.
|
2023-02-03 14:28:04 +00:00
|
|
|
for ((i = 0; i < ${#targets[@]}; i++)); do
|
|
|
|
stripSlash "${targets[$i]}"
|
|
|
|
addPath "$res" "${sources[$i]}"
|
2006-11-03 23:41:57 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2007-01-23 14:34:44 +00:00
|
|
|
# Add the closures of the top-level store objects.
|
2018-02-07 15:50:47 +00:00
|
|
|
for i in $(< $closureInfo/store-paths); do
|
2014-10-26 21:47:15 +00:00
|
|
|
addPath "${i:1}" "$i"
|
2007-01-23 14:34:44 +00:00
|
|
|
done
|
|
|
|
|
2024-03-11 19:27:48 +00:00
|
|
|
# If needed, build a squashfs and add that
|
|
|
|
if [[ -n "$squashfsCommand" ]]; then
|
|
|
|
(out="nix-store.squashfs" eval "$squashfsCommand")
|
|
|
|
addPath "nix-store.squashfs" "nix-store.squashfs"
|
|
|
|
fi
|
2007-01-23 14:34:44 +00:00
|
|
|
|
2009-06-10 14:40:35 +01:00
|
|
|
# Also include a manifest of the closures in a format suitable for
|
|
|
|
# nix-store --load-db.
|
2018-02-07 15:50:47 +00:00
|
|
|
if [[ ${#objects[*]} != 0 ]]; then
|
|
|
|
cp $closureInfo/registration nix-path-registration
|
2014-10-26 21:47:15 +00:00
|
|
|
addPath "nix-path-registration" "nix-path-registration"
|
2010-05-28 07:27:31 +01:00
|
|
|
fi
|
2007-01-23 15:08:00 +00:00
|
|
|
|
|
|
|
|
2007-01-23 14:34:44 +00:00
|
|
|
# Add symlinks to the top-level store objects.
|
2007-01-23 13:44:41 +00: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 21:47:15 +00:00
|
|
|
addPath "$symlink" "./$symlink"
|
2007-01-23 13:44:41 +00:00
|
|
|
fi
|
2006-11-03 23:41:57 +00:00
|
|
|
done
|
|
|
|
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/iso
|
2014-10-26 20:29:04 +00:00
|
|
|
|
2019-11-25 17:33:33 +00:00
|
|
|
# daed2280-b91e-42c0-aed6-82c825ca41f3 is an arbitrary namespace, to prevent
|
|
|
|
# independent applications from generating the same UUID for the same value.
|
|
|
|
# (the chance of that being problematic seem pretty slim here, but that's how
|
|
|
|
# version-5 UUID's work)
|
2014-10-26 20:29:04 +00:00
|
|
|
xorriso="xorriso
|
2019-11-25 17:33:33 +00:00
|
|
|
-boot_image any gpt_disk_guid=$(uuid -v 5 daed2280-b91e-42c0-aed6-82c825ca41f3 $out | tr -d -)
|
2022-01-03 22:20:00 +00:00
|
|
|
-volume_date all_file_dates =$SOURCE_DATE_EPOCH
|
2014-10-26 20:29:04 +00:00
|
|
|
-as mkisofs
|
|
|
|
-iso-level 3
|
|
|
|
-volid ${volumeID}
|
|
|
|
-appid nixos
|
|
|
|
-publisher nixos
|
|
|
|
-graft-points
|
|
|
|
-full-iso9660-filenames
|
2020-04-10 01:06:32 +01:00
|
|
|
-joliet
|
2014-10-26 20:29:04 +00:00
|
|
|
${isoBootFlags}
|
|
|
|
${usbBootFlags}
|
|
|
|
${efiBootFlags}
|
|
|
|
-r
|
2014-10-26 21:47:15 +00:00
|
|
|
-path-list pathlist
|
2014-10-26 20:29:04 +00:00
|
|
|
--sort-weight 0 /
|
2018-12-02 05:34:58 +00:00
|
|
|
"
|
2014-10-26 20:29:04 +00:00
|
|
|
|
|
|
|
$xorriso -output $out/iso/$isoName
|
|
|
|
|
|
|
|
if test -n "$compressImage"; then
|
|
|
|
echo "Compressing image..."
|
2020-06-13 23:19:11 +01:00
|
|
|
zstd -T$NIX_BUILD_CORES --rm $out/iso/$isoName
|
2014-10-26 20:29:04 +00:00
|
|
|
fi
|
2006-11-04 12:00:05 +00:00
|
|
|
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/nix-support
|
2006-11-04 12:00:05 +00:00
|
|
|
echo $system > $out/nix-support/system
|
2020-04-24 17:12:42 +01: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
|