2006-11-02 20:56:50 +03:00
|
|
|
source $stdenv/setup
|
|
|
|
|
2007-01-23 16:44:41 +03:00
|
|
|
sources_=($sources)
|
|
|
|
targets_=($targets)
|
|
|
|
|
|
|
|
objects=($objects)
|
|
|
|
symlinks=($symlinks)
|
|
|
|
|
2009-06-09 16:01:31 +04: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-27 00:47:15 +03: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 16:01:31 +04:00
|
|
|
stripSlash "$bootImage"; bootImage="$res"
|
|
|
|
|
|
|
|
|
2006-11-02 20:56:50 +03:00
|
|
|
if test -n "$bootable"; then
|
2007-02-07 18:23:19 +03: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 16:01:31 +04:00
|
|
|
stripSlash "${targets_[$i]}"
|
|
|
|
if test "$res" = "$bootImage"; then
|
2007-02-07 18:23:19 +03: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 23:29:04 +03:00
|
|
|
isoBootFlags="-eltorito-boot ${bootImage}
|
|
|
|
-eltorito-catalog .boot.cat
|
|
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$usbBootable"; then
|
|
|
|
usbBootFlags="-isohybrid-mbr ${isohybridMbrImage}"
|
2006-11-02 20:56:50 +03:00
|
|
|
fi
|
|
|
|
|
2012-03-16 09:37:24 +04:00
|
|
|
if test -n "$efiBootable"; then
|
2014-10-26 23:29:04 +03:00
|
|
|
efiBootFlags="-eltorito-alt-boot
|
|
|
|
-e $efiBootImage
|
|
|
|
-no-emul-boot
|
|
|
|
-isohybrid-gpt-basdat"
|
2012-03-16 09:37:24 +04:00
|
|
|
fi
|
2009-06-09 16:01:31 +04:00
|
|
|
|
2008-01-15 18:39:34 +03:00
|
|
|
touch pathlist
|
2007-01-23 16:44:41 +03:00
|
|
|
|
2009-06-09 16:01:31 +04:00
|
|
|
|
2007-01-23 17:34:44 +03:00
|
|
|
# Add the individual files.
|
2006-11-04 02:41:57 +03:00
|
|
|
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
2009-06-09 16:01:31 +04:00
|
|
|
stripSlash "${targets_[$i]}"
|
2014-10-27 00:47:15 +03:00
|
|
|
addPath "$res" "${sources_[$i]}"
|
2006-11-04 02:41:57 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2007-01-23 17:34:44 +03:00
|
|
|
# Add the closures of the top-level store objects.
|
|
|
|
storePaths=$(perl $pathsFromGraph closure-*)
|
|
|
|
for i in $storePaths; do
|
2014-10-27 00:47:15 +03:00
|
|
|
addPath "${i:1}" "$i"
|
2007-01-23 17:34:44 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2009-06-10 17:40:35 +04:00
|
|
|
# Also include a manifest of the closures in a format suitable for
|
|
|
|
# nix-store --load-db.
|
2010-06-22 02:00:48 +04:00
|
|
|
if [ -n "$object" ]; then
|
2010-05-28 10:27:31 +04:00
|
|
|
printRegistration=1 perl $pathsFromGraph closure-* > nix-path-registration
|
2014-10-27 00:47:15 +03:00
|
|
|
addPath "nix-path-registration" "nix-path-registration"
|
2010-05-28 10:27:31 +04:00
|
|
|
fi
|
2007-01-23 18:08:00 +03:00
|
|
|
|
|
|
|
|
2007-01-23 17:34:44 +03:00
|
|
|
# Add symlinks to the top-level store objects.
|
2007-01-23 16:44:41 +03: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-27 00:47:15 +03:00
|
|
|
addPath "$symlink" "./$symlink"
|
2007-01-23 16:44:41 +03:00
|
|
|
fi
|
2006-11-04 02:41:57 +03:00
|
|
|
done
|
|
|
|
|
2014-06-30 16:56:10 +04:00
|
|
|
mkdir -p $out/iso
|
2014-10-26 23:29:04 +03:00
|
|
|
|
|
|
|
xorriso="xorriso
|
|
|
|
-as mkisofs
|
|
|
|
-iso-level 3
|
|
|
|
-volid ${volumeID}
|
|
|
|
-appid nixos
|
|
|
|
-publisher nixos
|
|
|
|
-graft-points
|
|
|
|
-full-iso9660-filenames
|
|
|
|
${isoBootFlags}
|
|
|
|
${usbBootFlags}
|
|
|
|
${efiBootFlags}
|
|
|
|
-r
|
2014-10-27 00:47:15 +03:00
|
|
|
-path-list pathlist
|
2014-10-26 23:29:04 +03:00
|
|
|
--sort-weight 0 /
|
|
|
|
--sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
|
|
|
|
|
|
|
|
$xorriso -output $out/iso/$isoName
|
|
|
|
|
|
|
|
if test -n "$usbBootable"; then
|
|
|
|
echo "Making image hybrid..."
|
2015-11-28 08:55:47 +03:00
|
|
|
if test -n "$efiBootable"; then
|
|
|
|
isohybrid --uefi $out/iso/$isoName
|
|
|
|
else
|
|
|
|
isohybrid $out/iso/$isoName
|
|
|
|
fi
|
2008-06-05 17:42:18 +04:00
|
|
|
fi
|
2008-08-08 21:07:04 +04:00
|
|
|
|
2014-10-26 23:29:04 +03:00
|
|
|
if test -n "$compressImage"; then
|
|
|
|
echo "Compressing image..."
|
|
|
|
bzip2 $out/iso/$isoName
|
|
|
|
fi
|
2006-11-04 15:00:05 +03:00
|
|
|
|
2014-06-30 16:56:10 +04:00
|
|
|
mkdir -p $out/nix-support
|
2006-11-04 15:00:05 +03:00
|
|
|
echo $system > $out/nix-support/system
|
2016-03-15 15:48:45 +03:00
|
|
|
echo "file iso $out/iso/$isoName" >> $out/nix-support/hydra-build-products
|