abuild: provide a default_static() and static() functions

- Also check for static archives and warn on lack of static subpackage
This commit is contained in:
Leo 2019-04-26 21:23:27 -03:00 committed by Natanael Copa
parent f83d19ce79
commit b849aae4b9

View File

@ -695,6 +695,12 @@ postcheck() {
&& ! is_openrc_pkg "$name"; then && ! is_openrc_pkg "$name"; then
warning "Found OpenRC directory (/etc/conf.d or /etc/init.d) but name doesn't end with -openrc" warning "Found OpenRC directory (/etc/conf.d or /etc/init.d) but name doesn't end with -openrc"
fi fi
# look for static archives
if ! is_static_pkg "$name"; then
for i in $(find "$dir"/lib "$dir"/usr/lib -name '*.a' 2>/dev/null); do
warning "Found static archive on ${i##*$dir/} but name doesn't end with -static"
done
fi
# look for /usr/share/doc # look for /usr/share/doc
if [ -e "$dir"/usr/share/doc ] \ if [ -e "$dir"/usr/share/doc ] \
&& ! is_doc_pkg "$name"; then && ! is_doc_pkg "$name"; then
@ -1108,6 +1114,11 @@ is_dev_pkg() {
test "${subpkgname%-dev}" != "$subpkgname" test "${subpkgname%-dev}" != "$subpkgname"
} }
# returns true if this is the -static package
is_static_pkg() {
test "${1%-static}" != "$1"
}
# returns true if this is the -doc package # returns true if this is the -doc package
is_doc_pkg() { is_doc_pkg() {
test "${1%-doc}" != "$1" test "${1%-doc}" != "$1"
@ -1125,7 +1136,7 @@ archcheck() {
[ "${subpkgarch:-$pkgarch}" != "noarch" ] && return 0 [ "${subpkgarch:-$pkgarch}" != "noarch" ] && return 0
error "Arch specific binaries found so arch must not be set to \"noarch\"" error "Arch specific binaries found so arch must not be set to \"noarch\""
return 1 return 1
elif [ "${subpkgarch:-$pkgarch}" != "noarch" ] && ! is_dev_pkg; then elif [ "${subpkgarch:-$pkgarch}" != "noarch" ] && ! is_dev_pkg && ! is_static_pkg "$subpkgname"; then
# we dont want -dev package go to noarch # we dont want -dev package go to noarch
warning "No arch specific binaries found so arch should probably be set to \"noarch\"" warning "No arch specific binaries found so arch should probably be set to \"noarch\""
fi fi
@ -1705,7 +1716,9 @@ default_dev() {
usr/lib/qt*/mkspecs \ usr/lib/qt*/mkspecs \
usr/lib/cmake \ usr/lib/cmake \
$(find . -name include -type d) \ $(find . -name include -type d) \
$(find $libdirs -name '*.[acho]' \ $([ -z "${subpackages##*$pkgname-static*}" ] && find $libdirs \
-name '*.a' 2>/dev/null) \
$(find $libdirs -name '*.[cho]' \
-o -name '*.prl' 2>/dev/null); do -o -name '*.prl' 2>/dev/null); do
if [ -e "$pkgdir/$i" ] || [ -L "$pkgdir/$i" ]; then if [ -e "$pkgdir/$i" ] || [ -L "$pkgdir/$i" ]; then
d="$subpkgdir/${i%/*}" # dirname $i d="$subpkgdir/${i%/*}" # dirname $i
@ -1728,6 +1741,28 @@ dev() {
default_dev default_dev
} }
# predefined splitfunc static
default_static() {
local i=
depends=""
pkgdesc="$pkgdesc (static library)"
cd "$pkgdir" || return 0
local libdirs=usr/lib
[ -d lib/ ] && libdirs="lib/ $libdirs"
# move *.a static library
for i in $(find $libdir -name '*.a'); do
mkdir -p "$subpkgdir"/"${i%/*}"
mv "$i" "$subpkgdir/$i" || return 1
done
return 0
}
static() {
default_static
}
# predefined splitfunc libs # predefined splitfunc libs
default_libs() { default_libs() {
depends="$depends_libs" depends="$depends_libs"