summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-05-05 18:08:55 +0100
committerLeah Rowe <leah@libreboot.org>2025-05-05 18:08:55 +0100
commitdc9fe517cb04c1903ce7974267821c51640e0e60 (patch)
tree2175de4f17243ace933a292c2e3f5d860ab304ee
parent2be8d1c7982a37cb4e8e57b302c4039be4bc5bad (diff)
rom.sh: Safer cprom()
Don't insert special files like GRUB keymaps after copying to the final destination. Instead, copy the tmprom to /tmp and operate on that, in these instances. This is less efficient, depending on the user's configuration; if /tmp is on the same file system as the user's xbmkpwd, it should be fine. However, the actual performance hit isn't that bad in practise, on most setups. If the user's /tmp is a tmpfs, then that means using tmpfs, but it's one image at a time. It should be OK. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--include/rom.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/rom.sh b/include/rom.sh
index a92348bf..98b94926 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -241,16 +241,24 @@ add_uboot()
cprom()
{
+ cpcmd="cp"
+
tmpnew=""; newrom="bin/$target/${pname}_${target}_$initmode.rom"
[ -n "$displaymode" ] && newrom="${newrom%.rom}_$displaymode.rom"
[ $# -gt 0 ] && [ "${1%.gkb}" != "$1" ] && tmpnew="${1##*/}" && \
newrom="${newrom%.rom}_${tmpnew%.gkb}.rom"
- x_ mkdir -p "bin/$target"
- x_ cp "$tmprom" "$newrom" && [ $# -gt 0 ] && [ "${1%.gkb}" != "$1" ] \
- && cbfs "$newrom" "$grubdata/keymap/$tmpnew" keymap.gkb raw
+ irom="$tmprom"
+ [ $# -lt 1 ] || irom="`mktemp`" || err "!mk irom, $(echo "$@")"
+ [ $# -gt 0 ] && x_ cp "$tmprom" "$irom" && cpcmd="mv"
+
+ [ $# -gt 0 ] && [ "${1%.gkb}" != "$1" ] && \
+ cbfs "$irom" "$grubdata/keymap/$tmpnew" keymap.gkb raw
[ $# -gt 0 ] && [ "$1" = "seauboot" ] && \
- cbfs "$newrom" "$grubdata/bootorder_uboot" bootorder raw; :
+ cbfs "$irom" "$grubdata/bootorder_uboot" bootorder raw; :
+
+ x_ mkdir -p "bin/$target"
+ x_ $cpcmd "$irom" "$newrom"
}
cbfs()