nixos: iso-image: filename escaping in xorriso
This commit is contained in:
parent
8d092270d2
commit
16a936be90
|
@ -13,6 +13,20 @@ stripSlash() {
|
||||||
if test "${res:0:1}" = /; then res=${res:1}; fi
|
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"
|
stripSlash "$bootImage"; bootImage="$res"
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,14 +67,14 @@ touch pathlist
|
||||||
# Add the individual files.
|
# Add the individual files.
|
||||||
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
||||||
stripSlash "${targets_[$i]}"
|
stripSlash "${targets_[$i]}"
|
||||||
echo "$res=${sources_[$i]}" >> pathlist
|
addPath "$res" "${sources_[$i]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# Add the closures of the top-level store objects.
|
# Add the closures of the top-level store objects.
|
||||||
storePaths=$(perl $pathsFromGraph closure-*)
|
storePaths=$(perl $pathsFromGraph closure-*)
|
||||||
for i in $storePaths; do
|
for i in $storePaths; do
|
||||||
echo "${i:1}=$i" >> pathlist
|
addPath "${i:1}" "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +82,7 @@ done
|
||||||
# nix-store --load-db.
|
# nix-store --load-db.
|
||||||
if [ -n "$object" ]; then
|
if [ -n "$object" ]; then
|
||||||
printRegistration=1 perl $pathsFromGraph closure-* > nix-path-registration
|
printRegistration=1 perl $pathsFromGraph closure-* > nix-path-registration
|
||||||
echo "nix-path-registration=nix-path-registration" >> pathlist
|
addPath "nix-path-registration" "nix-path-registration"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,16 +93,10 @@ for ((n = 0; n < ${#objects[*]}; n++)); do
|
||||||
if test "$symlink" != "none"; then
|
if test "$symlink" != "none"; then
|
||||||
mkdir -p $(dirname ./$symlink)
|
mkdir -p $(dirname ./$symlink)
|
||||||
ln -s $object ./$symlink
|
ln -s $object ./$symlink
|
||||||
echo "$symlink=./$symlink" >> pathlist
|
addPath "$symlink" "./$symlink"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Escape filenames that contain '='.
|
|
||||||
# TODO: Handle this properly. This fails for filenames
|
|
||||||
# that contain multiple '=' symbols.
|
|
||||||
cat pathlist | sed -e 's/=\(.*\)=\(.*\)=/\\=\1=\2\\=/' | tee pathlist.safer
|
|
||||||
|
|
||||||
|
|
||||||
mkdir -p $out/iso
|
mkdir -p $out/iso
|
||||||
|
|
||||||
xorriso="xorriso
|
xorriso="xorriso
|
||||||
|
@ -103,7 +111,7 @@ xorriso="xorriso
|
||||||
${usbBootFlags}
|
${usbBootFlags}
|
||||||
${efiBootFlags}
|
${efiBootFlags}
|
||||||
-r
|
-r
|
||||||
-path-list pathlist.safer
|
-path-list pathlist
|
||||||
--sort-weight 0 /
|
--sort-weight 0 /
|
||||||
--sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
|
--sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue