Skip to content

Commit

Permalink
pesign-rpmbuild-helper: add inplace edit support for %pesign macro
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Ignatov <[email protected]>
  • Loading branch information
Blarse authored and vathpela committed Nov 14, 2023
1 parent d4cede0 commit 23fd0ce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pesign-rpmbuild-helper.in
Original file line number Diff line number Diff line change
Expand Up @@ -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="" || :
Expand Down Expand Up @@ -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 "${@}"
Expand Down

0 comments on commit 23fd0ce

Please sign in to comment.