diff options
-rwxr-xr-x | src/librefetch/librefetch | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index db996b7..8225fc6 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -1,7 +1,7 @@ #!/usr/bin/env bash # librefetch # -# Copyright (C) 2013-2014 Luke Shumaker <lukeshu@sbcglobal.net> +# Copyright (C) 2013-2015 Luke Shumaker <lukeshu@sbcglobal.net> # # License: GNU GPLv3+ # @@ -24,8 +24,8 @@ . "$(librelib messages)" setup_traps -declare -r tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)" -trap "rm -rf -- $(printf '%q' "$tempdir")" EXIT +tmpfiles=() +trap "rm -f -- $(printf '%q ' "${tmpfiles[@]}")" EXIT cmd=${0##*/} usage() { @@ -324,13 +324,15 @@ tidy_install_purge() { modified_makepkg() { local makepkg_orig=$1 local makepkg_mine="$tempdir/makepkg" + local makepkg_mine="$(mktemp "${0##*/}.XXXXXXXXXXX.makepkg")" + tmpfiles+=("$makepkg_mine") { echo '#!/bin/bash' declare -f tidy_install_purge sed -r "$makepkg_modify" < "$makepkg_orig" } > "$makepkg_mine" chmod 755 "$makepkg_mine" - printf "%s\n" "$makepkg_mine" + realpath -es "$makepkg_mine" } # Modify PKGBUILD ############################################################## @@ -376,7 +378,8 @@ package() { cp -a "$srcdir"/*/ "$pkgdir/"; } modified_pkgbuild() { local pkgbuild=$1 - local srcbuild="$tempdir/SRCBUILD" + local srcbuild="$(mktemp "${0##*/}.XXXXXXXXXXX.PKGBUILD.2.SRCBUILD")" + tmpfiles+=("$srcbuild") printf '%s' "$pkgbuild_append" | cat "$pkgbuild" - > "$srcbuild" printf '%s\n' "$srcbuild" } @@ -386,7 +389,8 @@ modified_pkgbuild() { modified_srcbuild() { local orig=$1 - local new="$tempdir/SRCBUILD" + local srcbuild="$(mktemp "${0##*/}.XXXXXXXXXXX.SRCBUILD.2.SRCBUILD")" + tmpfiles+=("$srcbuild") sed -e '/PKGDEST=/d' -e '/PKGEXT=/d' < "$orig" > "$new" printf '%s\n' "$new" } |