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