From 21d641cbc8b70fce762b6f6d5a402783745d9096 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 5 Jan 2015 18:58:55 -0500 Subject: librefetch: that's what I get for commiting a fix without a test --- src/librefetch/librefetch | 7 +++---- test/librefetch-test.sh | 29 ++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index e3897c7..e2300e0 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -323,8 +323,7 @@ tidy_install_purge() { modified_makepkg() { local makepkg_orig=$1 - local makepkg_mine="$tempdir/makepkg" - local makepkg_mine="$(mktemp "${0##*/}.XXXXXXXXXXX.makepkg")" + local makepkg_mine="$(mktemp --tmpdir "${0##*/}.XXXXXXXXXXX.makepkg")" tmpfiles+=("$makepkg_mine") { echo '#!/bin/bash' @@ -378,7 +377,7 @@ package() { cp -a "$srcdir"/*/ "$pkgdir/"; } modified_pkgbuild() { local pkgbuild=$1 - local srcbuild="$(mktemp "${0##*/}.XXXXXXXXXXX.PKGBUILD.2.SRCBUILD")" + local srcbuild="$(mktemp "${pkgbuild%/*}/${0##*/}.XXXXXXXXXXX.PKGBUILD.2.SRCBUILD")" tmpfiles+=("$srcbuild") printf '%s' "$pkgbuild_append" | cat "$pkgbuild" - > "$srcbuild" printf '%s\n' "$srcbuild" @@ -389,7 +388,7 @@ modified_pkgbuild() { modified_srcbuild() { local orig=$1 - local srcbuild="$(mktemp "${0##*/}.XXXXXXXXXXX.SRCBUILD.2.SRCBUILD")" + local srcbuild="$(mktemp "${orig%/*}/${0##*/}.XXXXXXXXXXX.SRCBUILD.2.SRCBUILD")" tmpfiles+=("$srcbuild") sed -e '/PKGDEST=/d' -e '/PKGEXT=/d' < "$orig" > "$new" printf '%s\n' "$new" diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index 806eeaf..f8bb226 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -7,13 +7,22 @@ describe librefetch before() { _before - mkdir -p "$XDG_CONFIG_HOME"/{pacman,libretools} - - printf '%s\n' \ - 'DLAGENTS=({https,libre}"::$(which librefetch) -p $(printf %q "${BUILDFILE:-$BUILDSCRIPT}") -- %u %o")' \ - 'BUILDDIR=""' \ - 'unset SRCDEST' \ - > "$XDG_CONFIG_HOME/pacman/makepkg.conf" + mkdir -p "$XDG_CONFIG_HOME"/{pacman,libretools} "$tmpdir/srcdest" + + cat < "$XDG_CONFIG_HOME/pacman/makepkg.conf" +DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' + 'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' + 'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' + 'rsync::/usr/bin/rsync --no-motd -z %u %o' + 'scp::/usr/bin/scp -C %u %o') +BUILDDIR="" +SRCDEST=$tmpdir/srcdest +. ${_librelib_conf_sh_pkgconfdir}/librefetch-makepkg.conf +EOF + sed -i 's,/usr/bin/librefetch,$(which librefetch),' \ + "${_librelib_conf_sh_pkgconfdir}/librefetch-makepkg.conf" + + export MAKEPKG_CONF="$XDG_CONFIG_HOME/pacman/makepkg.conf" printf '%s\n' \ 'MIRRORS=("phony://example.com/dir/")' \ @@ -32,7 +41,9 @@ it_displays_help() { empty $tmpdir/stderr } -# This test also does a rough test of file order in the PKGBUILD +# This test also does a rough test of file order in the PKGBUILD, as +# well as making sure that it correctly keeps track of $BUILDDIR, +# $startdir, and $SRCDEST. it_cleans_src_libre_first() { cp librefetch.d/* "$tmpdir/" cd "$tmpdir" @@ -45,6 +56,6 @@ it_cleans_src_libre_first() { makepkg -g srcball=testpkg-1.0.tar.gz - bsdtar tf "$srcball" > list-pkg.txt + bsdtar tf "$tmpdir/srcdest/$srcball" > list-pkg.txt diff -u list.txt list-pkg.txt } -- cgit v1.2.2