From 23fd0cef8388142a59f1f6763e1246e545cf1f03 Mon Sep 17 00:00:00 2001 From: Egor Ignatov Date: Thu, 13 Jul 2023 13:37:30 +0300 Subject: [PATCH] pesign-rpmbuild-helper: add inplace edit support for %pesign macro Signed-off-by: Egor Ignatov --- src/pesign-rpmbuild-helper.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pesign-rpmbuild-helper.in b/src/pesign-rpmbuild-helper.in index 9dee56e..30d5441 100644 --- a/src/pesign-rpmbuild-helper.in +++ b/src/pesign-rpmbuild-helper.in @@ -169,6 +169,14 @@ main() { return 0 fi + local inplace=0 || : + if [[ -n "${input[*]}" ]] && [[ -z "${output[*]}" ]] \ + || [[ "${input[1]}" = "${output[1]}" ]]; then + inplace=1 + output[0]=-o + output[1]="$(mktemp -u pesign-XXXXXXX.efi)" + fi + USERNAME="${USERNAME:-$(id -un)}" local socket="" || : @@ -235,6 +243,11 @@ main() { if [[ "${#output[@]}" -eq 2 ]] ; then error_on_empty "${output[1]}" fi + + if [[ "$inplace" -eq 1 ]] ; then + chmod 644 "${output[1]}" + mv "${output[1]}" "${input[1]}" + fi } main "${@}"