[pacman-dev] [PATCH] Use a bashism instead of mktemp's --tmpdir option.
I discovered that bacman and updpkgsums use --tmpdir while playing around in a busybox environment with pacman installed, as updpkgsums did not work. I've tested the attached patch in both that environment against pacman 4.2.1, and against a git checkout on a normal Arch system; both appear to work, but I may have misunderstood the reasoning behind using --tmpdir.
bacman and updpkgsums used GNU mktemp's --tmpdir option, which is not supported by some other implementations (including busybox). Replace that with a bashism, as used in the other scripts. Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com> --- contrib/bacman.sh.in | 2 +- contrib/updpkgsums.sh.in | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in index fcee6a0..b4bbbbb 100644 --- a/contrib/bacman.sh.in +++ b/contrib/bacman.sh.in @@ -147,7 +147,7 @@ fi # Begin # msg "Package: ${pkg_namver}" -work_dir=$(mktemp -d --tmpdir bacman.XXXXXXXXXX) +work_dir=$(mktemp -d "${TMPDIR:-/tmp}/bacman.XXXXXXXXXX") cd "$work_dir" || exit 1 # diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in index 7b92efe..aaed700 100644 --- a/contrib/updpkgsums.sh.in +++ b/contrib/updpkgsums.sh.in @@ -79,8 +79,8 @@ if [[ ! -w . ]]; then fi # Generate the new sums -export BUILDDIR=$(mktemp -d --tmpdir updpkgsums.XXXXXX) -newbuildfile=$(mktemp --tmpdir updpkgsums.XXXXXX) +export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") +newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT newsums=$(makepkg -g -p "$buildfile") || die 'Failed to generate new checksums' -- 2.6.4
On 31/12, Alastair Hughes wrote:
bacman and updpkgsums used GNU mktemp's --tmpdir option, which is not supported by some other implementations (including busybox). Replace that with a bashism, as used in the other scripts.
It's not a bashism actually, it's a POSIX sh-ism.
Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com> --- contrib/bacman.sh.in | 2 +- contrib/updpkgsums.sh.in | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in index fcee6a0..b4bbbbb 100644 --- a/contrib/bacman.sh.in +++ b/contrib/bacman.sh.in @@ -147,7 +147,7 @@ fi # Begin # msg "Package: ${pkg_namver}" -work_dir=$(mktemp -d --tmpdir bacman.XXXXXXXXXX) +work_dir=$(mktemp -d "${TMPDIR:-/tmp}/bacman.XXXXXXXXXX") cd "$work_dir" || exit 1
# diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in index 7b92efe..aaed700 100644 --- a/contrib/updpkgsums.sh.in +++ b/contrib/updpkgsums.sh.in @@ -79,8 +79,8 @@ if [[ ! -w . ]]; then fi
# Generate the new sums -export BUILDDIR=$(mktemp -d --tmpdir updpkgsums.XXXXXX) -newbuildfile=$(mktemp --tmpdir updpkgsums.XXXXXX) +export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") +newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX")
trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT newsums=$(makepkg -g -p "$buildfile") || die 'Failed to generate new checksums' -- 2.6.4
-- Sincerely, Johannes Löthberg PGP Key ID: 0x50FB9B273A9D0BB5 https://theos.kyriasis.com/~kyrias/
Ah, thanks. I was under the impression that *all* parameter expansions/substitutions were bashisms... Should I resend the patch with that fixed? Alastair Hughes On 12/31/15, Johannes Löthberg <johannes@kyriasis.com> wrote:
On 31/12, Alastair Hughes wrote:
bacman and updpkgsums used GNU mktemp's --tmpdir option, which is not supported by some other implementations (including busybox). Replace that with a bashism, as used in the other scripts.
It's not a bashism actually, it's a POSIX sh-ism.
Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com> --- contrib/bacman.sh.in | 2 +- contrib/updpkgsums.sh.in | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in index fcee6a0..b4bbbbb 100644 --- a/contrib/bacman.sh.in +++ b/contrib/bacman.sh.in @@ -147,7 +147,7 @@ fi # Begin # msg "Package: ${pkg_namver}" -work_dir=$(mktemp -d --tmpdir bacman.XXXXXXXXXX) +work_dir=$(mktemp -d "${TMPDIR:-/tmp}/bacman.XXXXXXXXXX") cd "$work_dir" || exit 1
# diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in index 7b92efe..aaed700 100644 --- a/contrib/updpkgsums.sh.in +++ b/contrib/updpkgsums.sh.in @@ -79,8 +79,8 @@ if [[ ! -w . ]]; then fi
# Generate the new sums -export BUILDDIR=$(mktemp -d --tmpdir updpkgsums.XXXXXX) -newbuildfile=$(mktemp --tmpdir updpkgsums.XXXXXX) +export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") +newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX")
trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT newsums=$(makepkg -g -p "$buildfile") || die 'Failed to generate new checksums' -- 2.6.4
-- Sincerely, Johannes Löthberg PGP Key ID: 0x50FB9B273A9D0BB5 https://theos.kyriasis.com/~kyrias/
On 01/01/16 05:47, Alastair Hughes wrote:
Ah, thanks. I was under the impression that *all* parameter expansions/substitutions were bashisms... Should I resend the patch with that fixed?
No - I will deal with it. A
participants (3)
-
Alastair Hughes
-
Allan McRae
-
Johannes Löthberg