Commit b217bbb2 authored by Timo Teräs's avatar Timo Teräs

abuild: support subpackages="pkg:split:arch" syntax

For proper cross-build support, the subpackage arch needs to
be known before invoking the split function. This implements
a way to do that. This also changes to write the actual subpkg
arch to .PKGINFO - apk index --rewrite-arch still overwrites
index to have machine arch for noarch packages.
parent 26ec31c6
......@@ -441,6 +441,28 @@ cleancache() {
done
}
subpkg_unset() {
unset subpkgname subpkgsplit subpkgarch
}
subpkg_set() {
subpkgname=${1%%:*}
local _splitarch=${1#*:}
[ "$_splitarch" = "$1" ] && _splitarch=""
subpkgsplit=${_splitarch%%:*}
[ -z "$subpkgsplit" ] && subpkgsplit="${subpkgname##*-}"
subpkgarch=${_splitarch#*:}
if [ "$subpkgarch" = "$_splitarch" -o -z "$subpkgarch" ]; then
case "$subpkgname" in
*-doc | *-lang | *-lang-*) subpkgarch="noarch" ;;
*) subpkgarch="$pkgarch" ;;
esac
fi
}
listpkgnames() {
local i
for i in $pkgname $subpackages; do
......@@ -575,18 +597,6 @@ targz() {
tar -czf "$PKGDEST"/$pkgname-$pkgver-r$pkgrel.tar.gz *
}
get_split_func() {
# get the 'func' from "sub-pkg:func:arch"
local _splitarch=${1#*:}
[ "$_splitarch" = "$1" ] && _splitarch=""
local _split=${_splitarch%:*}
if [ -z "$_split" ]; then
local _name=${1%%:*}
_split="${_name##*-}"
fi
echo $_split
}
postcheck() {
local dir="$1" name="$2" i=
msg "Running postcheck for $name"
......@@ -678,20 +688,17 @@ pre_split() {
# the subpackages should not inherit those form main package
provides=""
install_if=""
apkbuild_arch="$arch"
}
prepare_subpackages() {
local i
cd "$startdir"
for i in $subpackages; do
local func=$(get_split_func $i)
# call abuild recursively, setting subpkg{dir,name}
msg "Running split function $func..."
local dir="$pkgbasedir/${i%%:*}" name="${i%%:*}"
( subpkgdir="$dir" subpkgname="$name" \
$0 pre_split $func prepare_package \
&& postcheck "$dir" "$name" ) || return 1
( subpkg_set "$i"; msg "Running split function $subpkgsplit..."; \
subpkgdir="$pkgbasedir/$subpkgname" subpkgname="$subpkgname" subpkgarch="$subpkgarch" \
$0 pre_split $subpkgsplit prepare_package \
&& postcheck "$pkgbasedir/$subpkgname" "$subpkgname" ) || return 1
done
postcheck "$pkgdir" "$pkgname" || return 1
# post check for /usr/share/locale
......@@ -704,7 +711,7 @@ prepare_subpackages() {
default_lang() {
pkgdesc="Languages for package $pkgname"
install_if="$pkgname=$pkgver-r$pkgrel lang"
arch="noarch"
local dir
for dir in ${langdir:-/usr/share/locale}; do
mkdir -p "$subpkgdir"/${dir%/*}
......@@ -722,8 +729,8 @@ default_lang_subpkg() {
return 1
fi
pkgdesc="$pkgname language pack for $lang"
arch="noarch"
install_if="$pkgname=$pkgver-r$pkgrel lang-$lang"
local dir
for dir in ${langdir:-/usr/share/locale}; do
mkdir -p "$subpkgdir"/$dir
......@@ -787,8 +794,8 @@ check_depends_dev() {
fi
local i
for i in $pkgname $subpackages; do
case "$i" in
*-dev) return 0 ;;
case "${i%%:*}" in
*-dev) return 0 ;;
esac
done
return 1
......@@ -808,16 +815,12 @@ prepare_metafiles() {
mkdir -p "$controldir"
local builddate=$(date -u "+%s")
local size=$(du -sk | awk '{print $1 * 1024}')
local parch="$CARCH"
# we need to wait with setting noarch til our build infra can handle it
# if [ "$arch" = "noarch" ]; then
# parch="noarch"
# fi
# save arch incase subpackages set it different than main pkg
if [ "${apkbuild_arch:-$arch}" != "$arch" ]; then
echo "$arch" > "$controldir"/.arch
if [ "$arch" != "$apkbuild_arch" ]; then
local msg="Split function set arch=\"$arch\" for $name, use subpackages=pkg:split:arch format instead"
[ "$arch" != "noarch" ] && die "$msg"
warning "$msg"
subpkgarch="$arch"
fi
echo "# Generated by $(basename $0) $program_version" >"$pkginfo"
......@@ -833,7 +836,7 @@ url = $url
builddate = $builddate
packager = ${PACKAGER:-"Unknown"}
size = $size
arch = $parch
arch = ${subpkgarch:-$pkgarch}
origin = $pkgname
EOF
local i deps
......@@ -904,7 +907,7 @@ EOF
prepare_trace_rpaths() {
local dir=${subpkgdir:-$pkgdir}
local etype= soname= file= sover=
[ "$arch" = "noarch" ] && return 0
[ "${subpkgarch:-$pkgarch}" = "noarch" ] && return 0
options_has "!tracedeps" && return 0
# lets tell all the places we should look for .so files - all rpaths
scanelf --quiet --recursive --rpath "$dir" \
......@@ -974,10 +977,10 @@ is_doc_pkg() {
archcheck() {
options_has "!archcheck" && return 0
if dir_has_arch_binaries "${subpkgdir:-$pkgdir}"; then
[ "$arch" != "noarch" ] && return 0
[ "${subpkgarch:-$pkgarch}" != "noarch" ] && return 0
error "Arch specific binaries found so arch must not be set to \"noarch\""
return 1
elif [ "$arch" != "noarch" ] && ! is_dev_pkg; then
elif [ "${subpkgarch:-$pkgarch}" != "noarch" ] && ! is_dev_pkg; then
# we dont want -dev package go to noarch
warning "No arch specific binaries found so arch should probably be set to \"noarch\""
fi
......@@ -1042,6 +1045,7 @@ trace_apk_deps() {
local name="$1"
local dir="$2"
local i= found= autodeps= deppkgs= missing=
msg "Tracing dependencies..."
# add pkgconfig if usr/lib/pkgconfig is found
if [ -d "$pkgbasedir"/$name/usr/lib/pkgconfig ] \
......@@ -1153,7 +1157,7 @@ scan_shared_objects() {
local name="$1" controldir="$2" datadir="$3"
local opt= i=
if [ "$arch" = "noarch" ] && ! [ -e "$controldir"/.arch ]; then
if [ "${subpkgarch:-$pkgarch}" = "noarch" ]; then
return 0
fi
......@@ -1430,7 +1434,6 @@ update_abuildrepo_index() {
default_doc() {
depends="$depends_doc"
pkgdesc="$pkgdesc (documentation)"
arch=${arch_doc:-"noarch"}
install_if="docs $pkgname=$pkgver-r$pkgrel"
local i
......@@ -1927,7 +1930,7 @@ checksum() {
stripbin() {
local bin
if options_has "!strip" || [ "$arch" = "noarch" ]; then
if options_has "!strip" || [ "${subpkgarch:-$pkgarch}" = "noarch" ]; then
return 0
fi
cd "${subpkgdir:-$pkgdir}" || return 1
......@@ -2271,7 +2274,12 @@ if [ -n "$subpkgname" ]; then
origsubpackages="$subpackages"
subpackages=
fi
apkbuild_arch="$arch"
pkgdir="$pkgbasedir/$pkgname"
if [ -z "$pkgarch" ]; then
pkgarch=$CARCH
list_has noarch $arch && pkgarch=noarch
fi
controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}
trap 'die "Aborted by user"' INT
......
Markdown is supported
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