From aa86438443e5f591d024ae5db7c742f2735e9f3c Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 1 Oct 2019 16:25:45 +0100 Subject: abuild: add amove func to move from $pkgdir to $subpkgdir moving files and directories from $pkgdir to $subpkgdir is a common pattern, so make a helper function for this. usage: amove FILESPEC... FILESPEC is a list of files or patterns/globs that will be exanded by the shell. amove will clean up empty directories after moving the files/dirs. Example usage: amove 'usr/lib/lib*.a' amove 'etc/*.d' # moves both etc/conf.d and etc/init.d amove 'lib/*.so' 'usr/lib/*.so' cd "$pkgdir" find usr -name '*.h' | xargs amove This is based on the work of Chloe Kudryavtsev: https://github.com/alpinelinux/abuild/pull/92 --- abuild.in | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/abuild.in b/abuild.in index 38a6570..4746794 100644 --- a/abuild.in +++ b/abuild.in @@ -72,6 +72,29 @@ error() { logcmd "ERROR: $pkgname: $1" } +amove() { + [ -n "$subpkgdir" ] || return 1 + + # store directory + d="$(pwd -L)" + + cd "$pkgdir" + local pattern f + for pattern; do + for f in ${pattern#/}; do # let shell expand the pattern + # only create dir if needed + if [ "${f%/*}" != "$f" ]; then + mkdir -p "$subpkgdir/${f%/*}" + fi + mv -v "$pkgdir"/$f "$subpkgdir/${f%/*}" + # cleanup + rmdir -p "$f" || rmdir -p "${f%/*}" || true + done + done + + cd "$d" +} + cross_creating() { test "$CHOST" != "$CTARGET" -a -n "$CBUILDROOT" } -- cgit v1.2.3-60-g2f50