reset_uki_cmdline: have non-empty cmdline for unsigned images

We want to disallow overriding the compiled in command line for UKI
images. However, we currently depend on this behavior for unsigned
images, because the command line isn't finalized yet at that time.

Instead of using an empty builtin cmdline for unsigned images, use
whatever the partition A cmdline is. This should allow the unsigned
image to function well enough for testing, and the signing process
will still update it to the correct final cmdline.

BUG=None
TEST=presubmit
RELEASE_NOTE=None

Change-Id: I0c478ff203d95de73c0d709b6d719067f0ce9975
Reviewed-on: https://cos-review.googlesource.com/c/third_party/platform/crosutils/+/226386
Reviewed-by: Dom Huh <domhuh@google.com>
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
diff --git a/reset_uki_cmdline.sh b/reset_uki_cmdline.sh
index 24f123c..6036a34 100755
--- a/reset_uki_cmdline.sh
+++ b/reset_uki_cmdline.sh
@@ -68,6 +68,9 @@
   fi
   local boot_efi="boot${efi_arch}.efi"
   local shim_efi="shim${efi_arch}.efi"
+  local cmdline
+  cmdline="$(PATH=$PATH:/sbin cos_kernel_args \
+    --vmlinux "${vmlinux}" show "${image}")"
 
   trap "check_full_disk ; unmount_image ; rm -r ${tmpdir}" EXIT
   mount_image "${image}" "${root_fs_dir}" "${stateful_fs_dir}" \
@@ -85,7 +88,7 @@
   trap - EXIT
 
   PATH=$PATH:/sbin cos_kernel_args --vmlinux "${vmlinux}" \
-    sed --command "s|.*||g" "${image}"
+    sed --command "s|.*|${cmdline}|g" "${image}"
 
   trap "check_full_disk ; unmount_image ; rm -r ${tmpdir}" EXIT
   mount_image "${image}" "${root_fs_dir}" "${stateful_fs_dir}" \