From 73cc75b3e0faa37c58a9f3d1ba693f4744baeaaf Mon Sep 17 00:00:00 2001 From: Sertonix Date: Tue, 12 Dec 2023 21:38:22 +0000 Subject: [PATCH] abuild: amove: allow spaces in pattern --- abuild.in | 6 +++--- tests/abuild_test | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/abuild.in b/abuild.in index 4a89d77..95801fb 100644 --- a/abuild.in +++ b/abuild.in @@ -78,17 +78,17 @@ amove() { d="$(pwd -L)" cd "$pkgdir" - local pattern f + local pattern f IFS="" for pattern; do for f in ${pattern#/}; do # let shell expand the pattern # strip trailing / f=${f%/} if [ "${f%/*}" != "$f" ]; then mkdir -p "$subpkgdir/${f%/*}" - mv -v "$pkgdir"/$f "$subpkgdir/${f%/*}" + mv -v "$pkgdir/$f" "$subpkgdir/${f%/*}" else mkdir -p "$subpkgdir" - mv -v "$pkgdir"/$f "$subpkgdir/" + mv -v "$pkgdir/$f" "$subpkgdir/" fi # cleanup rmdir -p "$f" 2>/dev/null || rmdir -p "${f%/*}" 2>/dev/null || true diff --git a/tests/abuild_test b/tests/abuild_test index 890ed8b..c6d9ea2 100755 --- a/tests/abuild_test +++ b/tests/abuild_test @@ -667,7 +667,8 @@ abuild_amove_body() { \$pkgname-bin:_bin \$pkgname-sbin:_sbin \$pkgname-var:_var - \$pkgname-usr:_usr" + \$pkgname-usr:_usr + \$pkgname-space:_space" package() { mkdir -p "\$pkgdir"/etc \ @@ -679,6 +680,7 @@ abuild_amove_body() { "\$pkgdir"/etc/\$pkgname.conf \ "\$pkgdir"/bin/hello \ "\$pkgdir"/sbin/shello \ + "\$pkgdir"/sbin/space' ' \ "\$pkgdir"/var/lib/\$pkgname/testfile \ "\$pkgdir"/usr/share/a \ "\$pkgdir"/usr/share/b @@ -706,6 +708,10 @@ abuild_amove_body() { # glob * amove usr/share/* } + _space() { + # with space + amove sbin/space' ' + } EOF abuild rootpkg || atf_fail "abuild rootpkg failed" @@ -717,8 +723,9 @@ abuild_amove_body() { test-amove-var/var/lib/test-amove/testfile \ test-amove-usr/usr/share/a \ test-amove-usr/usr/share/b \ + test-amove-space/sbin/space' ' \ ; do \ - test -f pkg/$i || atf_fail "$i failed" + test -f pkg/"$i" || atf_fail "$i failed" done }