xbps-src: refactor build logic into its own script (build.sh).
The build.sh script is now responsible to handle all the logic to build a source package and its subpackages, as well as all its required build dependencies. Thanks to this and subshells, dependencies are now built into its own child process, creating a process tree that can go nested as long as your system allows forking and has enough memory :-) This fixes some issues that have been while building pkgs that have lots of nested dependencies.
This commit is contained in:
parent
018e0086c4
commit
849d22e46d
10 changed files with 152 additions and 152 deletions
|
@ -24,106 +24,6 @@ check_pkg_arch() {
|
|||
fi
|
||||
}
|
||||
|
||||
install_pkg() {
|
||||
local target="$1" cross="$2" lrepo subpkg opkg
|
||||
|
||||
[ -z "$pkgname" ] && return 1
|
||||
|
||||
show_pkg_build_options
|
||||
check_pkg_arch $cross
|
||||
install_cross_pkg $cross
|
||||
|
||||
if [ -z "$XBPS_SKIP_DEPS" ]; then
|
||||
install_pkg_deps $sourcepkg $cross || return 1
|
||||
if [ "$TARGETPKG_PKGDEPS_DONE" ]; then
|
||||
setup_pkg $XBPS_TARGET_PKG $cross
|
||||
unset TARGETPKG_PKGDEPS_DONE
|
||||
install_cross_pkg $cross
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fetch distfiles after installing required dependencies,
|
||||
# because some of them might be required for do_fetch().
|
||||
$XBPS_LIBEXECDIR/xbps-src-dofetch.sh $sourcepkg $cross || exit 1
|
||||
[ "$target" = "fetch" ] && return 0
|
||||
|
||||
# Fetch, extract, build and install into the destination directory.
|
||||
$XBPS_LIBEXECDIR/xbps-src-doextract.sh $sourcepkg $cross || exit 1
|
||||
[ "$target" = "extract" ] && return 0
|
||||
|
||||
# Run configure phase
|
||||
$XBPS_LIBEXECDIR/xbps-src-doconfigure.sh $sourcepkg $cross || exit 1
|
||||
[ "$target" = "configure" ] && return 0
|
||||
|
||||
# Run build phase
|
||||
$XBPS_LIBEXECDIR/xbps-src-dobuild.sh $sourcepkg $cross || exit 1
|
||||
[ "$target" = "build" ] && return 0
|
||||
|
||||
# Install pkgs into destdir.
|
||||
$XBPS_LIBEXECDIR/xbps-src-doinstall.sh $sourcepkg $cross || exit 1
|
||||
|
||||
for subpkg in ${subpackages} ${sourcepkg}; do
|
||||
$XBPS_LIBEXECDIR/xbps-src-doinstall.sh $subpkg $cross || exit 1
|
||||
done
|
||||
for subpkg in ${subpackages} ${sourcepkg}; do
|
||||
$XBPS_LIBEXECDIR/xbps-src-prepkg.sh $subpkg $cross || exit 1
|
||||
done
|
||||
|
||||
for subpkg in ${subpackages} ${sourcepkg}; do
|
||||
if [ "$XBPS_TARGET_PKG" = "${subpkg}" -a "$target" = "install" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# If install went ok generate the binpkgs.
|
||||
for subpkg in ${subpackages} ${sourcepkg}; do
|
||||
$XBPS_LIBEXECDIR/xbps-src-dopkg.sh $subpkg "$XBPS_REPOSITORY" "$cross" || exit 1
|
||||
done
|
||||
|
||||
# pkg cleanup
|
||||
if declare -f do_clean >/dev/null; then
|
||||
run_func do_clean
|
||||
fi
|
||||
|
||||
opkg=$pkgver
|
||||
if [ -z "$XBPS_KEEP_ALL" ]; then
|
||||
remove_pkg_autodeps
|
||||
remove_pkg_wrksrc
|
||||
setup_pkg $sourcepkg $cross
|
||||
remove_pkg $cross
|
||||
remove_pkg_statedir
|
||||
fi
|
||||
|
||||
# If base-chroot not installed, install "base-files" into masterdir
|
||||
# from local repository; this is the only pkg required to be able to build
|
||||
# the bootstrap pkgs from scratch.
|
||||
if [ -z "$CHROOT_READY" -a "$pkgname" = "base-files" ]; then
|
||||
msg_normal "Installing $opkg into masterdir...\n"
|
||||
local _log=$(mktemp --tmpdir|| exit 1)
|
||||
if [ -n "$XBPS_BUILD_FORCEMODE" ]; then
|
||||
local _flags="-f"
|
||||
fi
|
||||
$XBPS_INSTALL_CMD ${_flags} -y $opkg >${_log} 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_red "Failed to install $opkg into masterdir, see below for errors:\n"
|
||||
cat ${_log}
|
||||
rm -f ${_log}
|
||||
msg_error "Cannot continue!"
|
||||
fi
|
||||
rm -f ${_log}
|
||||
fi
|
||||
|
||||
if [ "$XBPS_TARGET_PKG" = "$sourcepkg" ]; then
|
||||
if [ "$XBPS_TARGET" = "bootstrap" ]; then
|
||||
return 0
|
||||
fi
|
||||
# Package built successfully. Exit directly due to nested install_pkg
|
||||
# and install_pkg_deps functions.
|
||||
remove_cross_pkg $cross
|
||||
exit_and_cleanup
|
||||
fi
|
||||
}
|
||||
|
||||
remove_pkg_autodeps() {
|
||||
local rval= tmplogf=
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue