Commit 2ce4be51 authored by Natanael Copa's avatar Natanael Copa
Browse files

main/abuild: backport fix for amove

parent 3fa11771
From 5c542377a8f06d9c201d4ade3260dec0b6183630 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 23 Sep 2022 12:31:56 +0200
Subject: [PATCH] abuild: fix amove corner cases
fix `amove dir` (without leading or trailing /)
add various testcases for amove
---
abuild.in | 8 +++--
tests/abuild_test | 79 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 84 insertions(+), 3 deletions(-)
diff --git a/abuild.in b/abuild.in
index d013ab1..ac17067 100755
--- a/abuild.in
+++ b/abuild.in
@@ -79,11 +79,15 @@ amove() {
local pattern f
for pattern; do
for f in ${pattern#/}; do # let shell expand the pattern
- # only create dir if needed
+ # strip trailing /
+ f=${f%/}
if [ "${f%/*}" != "$f" ]; then
mkdir -p "$subpkgdir/${f%/*}"
+ mv -v "$pkgdir"/$f "$subpkgdir/${f%/*}"
+ else
+ mkdir -p "$subpkgdir"
+ mv -v "$pkgdir"/$f "$subpkgdir/"
fi
- mv -v "$pkgdir"/$f "$subpkgdir/${f%/*}"
# cleanup
rmdir -p "$f" 2>/dev/null || rmdir -p "${f%/*}" 2>/dev/null || true
done
diff --git a/tests/abuild_test b/tests/abuild_test
index f127abf..7fefae4 100755
--- a/tests/abuild_test
+++ b/tests/abuild_test
@@ -24,7 +24,8 @@ init_tests \
abuild_multiline_license \
abuild_git_ceiling \
abuild_package_size_zero \
- abuild_package_size_nonzero
+ abuild_package_size_nonzero \
+ abuild_amove
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
export ABUILD_CONF=/dev/null
@@ -517,3 +518,79 @@ abuild_package_size_nonzero_body() {
atf_check -o not-match:'^size = 1$' \
cat pkg/.control.test-size/.PKGINFO
}
+
+abuild_amove_body() {
+ init_keys
+ mkdir -p test-amove
+
+ cd test-amove
+ cat > APKBUILD <<-EOF
+ # Maintainer: Test User 123 <123@example.com>
+
+ # test package
+ pkgname="test-amove"
+ pkgver="1.0"
+ pkgrel=0
+ pkgdesc='Dummy test package - amove'
+ url='https://gitlab.alpinelinux.org/alpine/aports'
+ arch='noarch'
+ license='MIT'
+ subpackages="\$pkgname-file:_file
+ \$pkgname-etc:_etc
+ \$pkgname-bin:_bin
+ \$pkgname-sbin:_sbin
+ \$pkgname-var:_var
+ \$pkgname-usr:_usr"
+
+ package() {
+ mkdir -p "\$pkgdir"/etc \
+ "\$pkgdir"/bin \
+ "\$pkgdir"/sbin \
+ "\$pkgdir"/var/lib/\$pkgname \
+ "\$pkgdir"/usr/share
+ touch "\$pkgdir"/etc/file \
+ "\$pkgdir"/etc/\$pkgname.conf \
+ "\$pkgdir"/bin/hello \
+ "\$pkgdir"/sbin/shello \
+ "\$pkgdir"/var/lib/\$pkgname/testfile \
+ "\$pkgdir"/usr/share/a \
+ "\$pkgdir"/usr/share/b
+ }
+ _file() {
+ amove etc/file
+ }
+ _etc() {
+ # leading and trailing /
+ amove /etc/
+ }
+ _bin() {
+ # trailing /
+ amove bin/
+ }
+ _sbin() {
+ # no /
+ amove sbin/shello
+ }
+ _var() {
+ # leading /
+ amove /var/lib
+ }
+ _usr() {
+ # glob *
+ amove usr/share/*
+ }
+
+ EOF
+ abuild rootpkg || atf_fail "abuild rootpkg failed"
+ for i in \
+ test-amove-file/etc/file \
+ test-amove-etc/etc/test-amove.conf \
+ test-amove-bin/bin/hello \
+ test-amove-sbin/sbin/shello \
+ test-amove-var/var/lib/test-amove/testfile \
+ test-amove-usr/usr/share/a \
+ test-amove-usr/usr/share/b \
+ ; do \
+ test -f pkg/$i || atf_fail "$i failed"
+ done
+}
--
2.37.3
......@@ -2,7 +2,7 @@
pkgname=abuild
pkgver=3.10.0_rc1
_ver=${pkgver%_git*}
pkgrel=1
pkgrel=2
pkgdesc="Script to build Alpine Packages"
url="https://git.alpinelinux.org/cgit/abuild/"
arch="all"
......@@ -28,6 +28,7 @@ options="suid"
pkggroups="abuild"
source="https://gitlab.alpinelinux.org/alpine/abuild/-/archive/$pkgver/abuild-$pkgver.tar.gz
0001-make-increase-test-timeout.patch
0001-abuild-fix-amove-corner-cases.patch
"
builddir="$srcdir"/abuild-$pkgver
......@@ -87,4 +88,5 @@ _rootbld() {
sha512sums="
8dccc843cc6b3f53642bb2849d00cc00a283763f2b915c01600b0542ce16a96b2e265498b59ceff250a1c7be22c4a5aeb0cb0926c7498668ded897c64b83b9c0 abuild-3.10.0_rc1.tar.gz
605e17e99ba24388e278de3a378bf717f6061930a73197bbf5d3462b281fccc242262a7582d0c7106fcf92daa2166e4bc341d3a784868906527e493adfb9bf5f 0001-make-increase-test-timeout.patch
c979b3f926a4bd5aabe3996473151156f4573040c37a99aa4bf9042743952c46c08286581753c372196ce9da651971879a9e31eed124e65393dab71c96494df9 0001-abuild-fix-amove-corner-cases.patch
"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment