diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2019-10-01 16:25:45 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2019-10-01 16:25:45 +0100 |
commit | aa86438443e5f591d024ae5db7c742f2735e9f3c (patch) | |
tree | de141497407be310f52d01244aad62868fa04145 | |
parent | 610f1982ef62e9596df64839414cb1199a3a64b6 (diff) | |
download | abuild-aa86438443e5f591d024ae5db7c742f2735e9f3c.tar.bz2 abuild-aa86438443e5f591d024ae5db7c742f2735e9f3c.tar.xz |
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
-rw-r--r-- | abuild.in | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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" } |