summaryrefslogtreecommitdiffstats
path: root/nixos/lib
diff options
context:
space:
mode:
authorNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-04-03 23:12:12 +0200
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-04-03 23:12:12 +0200
commit6de931a0f898bc132d73a67059326b6886cc84b1 (patch)
treea494d3f90da826fa983bfbd93e0ee2cff5f22ce8 /nixos/lib
parent7f1a782d91c537eb6972b8acd83e1957a65a93e4 (diff)
parenta8d0614a602fd00d2e23e0e86fc748cc51c6f696 (diff)
Merge rename.nix changes.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/make-iso9660-image.nix13
-rw-r--r--nixos/lib/make-iso9660-image.sh70
-rw-r--r--nixos/lib/test-driver/Machine.pm4
3 files changed, 69 insertions, 18 deletions
diff --git a/nixos/lib/make-iso9660-image.nix b/nixos/lib/make-iso9660-image.nix
index 5ad546e9534d..b2409c6006bc 100644
--- a/nixos/lib/make-iso9660-image.nix
+++ b/nixos/lib/make-iso9660-image.nix
@@ -1,4 +1,4 @@
-{ stdenv, perl, cdrkit, pathsFromGraph
+{ stdenv, perl, pathsFromGraph, xorriso, syslinux
, # The file name of the resulting ISO image.
isoName ? "cd.iso"
@@ -22,12 +22,18 @@
, # Whether this should be an efi-bootable El-Torito CD.
efiBootable ? false
+, # Wheter this should be an hybrid CD (bootable from USB as well as CD).
+ usbBootable ? false
+
, # The path (in the ISO file system) of the boot image.
bootImage ? ""
, # The path (in the ISO file system) of the efi boot image.
efiBootImage ? ""
+, # The path (outside the ISO file system) of the isohybrid-mbr image.
+ isohybridMbrImage ? ""
+
, # Whether to compress the resulting ISO image with bzip2.
compressImage ? false
@@ -38,13 +44,14 @@
assert bootable -> bootImage != "";
assert efiBootable -> efiBootImage != "";
+assert usbBootable -> isohybridMbrImage != "";
stdenv.mkDerivation {
name = "iso9660-image";
builder = ./make-iso9660-image.sh;
- buildInputs = [perl cdrkit];
+ buildInputs = [perl xorriso syslinux];
- inherit isoName bootable bootImage compressImage volumeID pathsFromGraph efiBootImage efiBootable;
+ inherit isoName bootable bootImage compressImage volumeID pathsFromGraph efiBootImage efiBootable isohybridMbrImage usbBootable;
# !!! should use XML.
sources = map (x: x.source) contents;
diff --git a/nixos/lib/make-iso9660-image.sh b/nixos/lib/make-iso9660-image.sh
index 675b5bb35148..c9a373794692 100644
--- a/nixos/lib/make-iso9660-image.sh
+++ b/nixos/lib/make-iso9660-image.sh
@@ -13,6 +13,20 @@ stripSlash() {
if test "${res:0:1}" = /; then res=${res:1}; fi
}
+# 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
+}
+
stripSlash "$bootImage"; bootImage="$res"
@@ -31,11 +45,20 @@ if test -n "$bootable"; then
fi
done
- bootFlags="-b $bootImage -c .boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
+ 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}"
fi
if test -n "$efiBootable"; then
- bootFlags="$bootFlags -eltorito-alt-boot -e $efiBootImage -no-emul-boot"
+ efiBootFlags="-eltorito-alt-boot
+ -e $efiBootImage
+ -no-emul-boot
+ -isohybrid-gpt-basdat"
fi
touch pathlist
@@ -44,14 +67,14 @@ touch pathlist
# Add the individual files.
for ((i = 0; i < ${#targets_[@]}; i++)); do
stripSlash "${targets_[$i]}"
- echo "$res=${sources_[$i]}" >> pathlist
+ addPath "$res" "${sources_[$i]}"
done
# Add the closures of the top-level store objects.
storePaths=$(perl $pathsFromGraph closure-*)
for i in $storePaths; do
- echo "${i:1}=$i" >> pathlist
+ addPath "${i:1}" "$i"
done
@@ -59,7 +82,7 @@ done
# nix-store --load-db.
if [ -n "$object" ]; then
printRegistration=1 perl $pathsFromGraph closure-* > nix-path-registration
- echo "nix-path-registration=nix-path-registration" >> pathlist
+ addPath "nix-path-registration" "nix-path-registration"
fi
@@ -70,22 +93,39 @@ for ((n = 0; n < ${#objects[*]}; n++)); do
if test "$symlink" != "none"; then
mkdir -p $(dirname ./$symlink)
ln -s $object ./$symlink
- echo "$symlink=./$symlink" >> pathlist
+ addPath "$symlink" "./$symlink"
fi
done
-# !!! what does this do?
-cat pathlist | sed -e 's/=\(.*\)=\(.*\)=/\\=\1=\2\\=/' | tee pathlist.safer
-
-
mkdir -p $out/iso
-genCommand="genisoimage -iso-level 4 -r -J $bootFlags -hide-rr-moved -graft-points -path-list pathlist.safer ${volumeID:+-V $volumeID}"
-if test -z "$compressImage"; then
- $genCommand -o $out/iso/$isoName
-else
- $genCommand | bzip2 > $out/iso/$isoName.bz2
+
+xorriso="xorriso
+ -as mkisofs
+ -iso-level 3
+ -volid ${volumeID}
+ -appid nixos
+ -publisher nixos
+ -graft-points
+ -full-iso9660-filenames
+ ${isoBootFlags}
+ ${usbBootFlags}
+ ${efiBootFlags}
+ -r
+ -path-list pathlist
+ --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..."
+ isohybrid --uefi $out/iso/$isoName
fi
+if test -n "$compressImage"; then
+ echo "Compressing image..."
+ bzip2 $out/iso/$isoName
+fi
mkdir -p $out/nix-support
echo $system > $out/nix-support/system
diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm
index 85c2bfa88e1a..e0791692d3ef 100644
--- a/nixos/lib/test-driver/Machine.pm
+++ b/nixos/lib/test-driver/Machine.pm
@@ -37,6 +37,10 @@ sub new {
if defined $args->{hda};
$startCommand .= "-cdrom $args->{cdrom} "
if defined $args->{cdrom};
+ $startCommand .= "-device piix3-usb-uhci -drive id=usbdisk,file=$args->{usb},if=none,readonly -device usb-storage,drive=usbdisk "
+ if defined $args->{usb};
+ $startCommand .= "-bios $args->{bios} "
+ if defined $args->{bios};
$startCommand .= $args->{qemuFlags} || "";
} else {
$startCommand = Cwd::abs_path $startCommand;