Commit ca65c4b7 authored by Natanael Copa's avatar Natanael Copa

abuild: prepare pkg dirs/meta files and create packages separately. Dependency speedup.

Run all subpackage functions and prepare the dirs first and create the
package itself later on. This will make it possible to automatically trace
the dependencies.

Also, speed up the detection of which makedeps are installed and which needs
to be built/installed. this requires apk-tools_pre11.
parent 3d79fb70
......@@ -269,7 +269,7 @@ get_split_func() {
echo $func
}
subpkg() {
prepare_subpackages() {
if [ -z "$subpackages" ]; then
return 0
fi
......@@ -280,11 +280,11 @@ subpkg() {
# call abuild recursively, setting subpkg{dir,name}
msg "Running split function $func..."
subpkgdir="$pkgdirbase/${i%:*}" subpkgname="${i%:*}" \
$0 $func package || return 1
$0 $func prepare_package || return 1
done
}
package_apk() {
prepare_metafiles() {
local name=${subpkgname:-$pkgname}
[ -z "${name##* *}" ] && die "package name contains spaces"
local dir=${subpkgdir:-$pkgdir}
......@@ -361,15 +361,33 @@ EOF
chmod +x "$dir/$script"
metafiles="$metafiles $script"
done
set *
[ "$1" = '*' ] && set --
( cd "$dir" && tar -zcf "$PKGDEST/$pkg" $metafiles $@ )
echo $metafiles | tr ' ' '\n' > "$dir"/.metafiles
}
package() {
prepare_package() {
options_has "!strip" || stripbin
package_apk
prepare_metafiles
}
pkginfo_val() {
local key="$1"
local file="$2"
awk -F ' = ' "\$1 == \"$key\" {print \$2}" "$file"
}
create_apks() {
local file
for file in "$pkgdirbase"/*/.PKGINFO; do
local dir="${file%/.PKGINFO}"
local name=$(pkginfo_val pkgname $file)
local ver=$(pkginfo_val pkgver $file)
local apk="$PKGDEST"/$name-$ver.apk
(
set *
[ "$1" = '*' ] && set --
cd "$dir" && tar -zcf "$apk" $(cat .metafiles) $@
)
done
}
# predefined splitfunc doc
......@@ -446,7 +464,7 @@ dev() {
rootpkg() {
cd "$startdir"
msg "Entering fakeroot..."
fakeroot $0 build subpkg package
fakeroot $0 build prepare_subpackages prepare_package create_apks
}
srcpkg() {
......@@ -557,21 +575,23 @@ deptrace() {
# build and install dependencies
builddeps() {
local deps alldeps pkg i dir ver missing
msg "Building dependencies..."
local deps alldeps pkg i dir ver missing installed_deps
msg "Analyzing dependencies..."
deps="$BUILD_BASE $makedepends"
# add depends unless it is a subpackage
for i in $depends; do
subpackages_has $i || deps="$deps $i"
done
installed_deps=$(apk info -e $deps)
# find which deps are missing
for i in $deps; do
if [ "${i#\!}" != "$i" ]; then
apk info -e ${i#\!} \
list_has ${i#\!} $installed_deps \
&& die "Conflicting package ${i#\!} is installed."
elif ! apk info -e $i; then
elif ! list_has $i $installed_deps; then
if [ -z "$install_deps" ] && [ -z "$recursive" ]; then
die "Missing dependency $i. Use -r to autoinstall or -R to build"
fi
......
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