xbps-src: fix fetch phase with depends, performance improvements.

- The fetch phase *must* run after installing pkg dependencies,
  otherwise it could fail if we need them for fetching.

- Performance improvements for xbps-src. Only source shutils files
  at the start, not every time we use a function.
This commit is contained in:
Juan RP 2011-07-02 17:04:08 +02:00
parent 12b16e75a0
commit 7984b39928
10 changed files with 10 additions and 63 deletions

View file

@ -23,8 +23,6 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#- #-
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
install_pkg_from_repos() install_pkg_from_repos()
{ {
local cmd rval pkgdepname pkg="$1" local cmd rval pkgdepname pkg="$1"
@ -91,7 +89,6 @@ autoremove_pkg_dependencies()
continue continue
fi fi
# remove pkg. # remove pkg.
. ${XBPS_SHUTILSDIR}/pkgtarget_funcs.sh
msg_warn "removing package $pkgname installed from source...\n" msg_warn "removing package $pkgname installed from source...\n"
remove_pkg remove_pkg
fi fi

View file

@ -54,7 +54,6 @@ if [ "${chroot_cmd}" = "chroot" ]; then
fi fi
fi fi
. $XBPS_SHUTILSDIR/builddep_funcs.sh
check_installed_pkg base-chroot-0.11 check_installed_pkg base-chroot-0.11
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "${XBPS_MASTERDIR} has not been prepared for chroot operations." echo "${XBPS_MASTERDIR} has not been prepared for chroot operations."

View file

@ -141,7 +141,6 @@ msg_red()
msg_error() msg_error()
{ {
msg_red "$@" msg_red "$@"
. $XBPS_SHUTILSDIR/builddep_funcs.sh
autoremove_pkg_dependencies autoremove_pkg_dependencies
exit 1 exit 1

View file

@ -66,7 +66,6 @@ configure_src_phase()
# Apply patches if requested by template file # Apply patches if requested by template file
if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then
. $XBPS_SHUTILSDIR/patch_funcs.sh
apply_tmpl_patches apply_tmpl_patches
fi fi

View file

@ -49,7 +49,6 @@ xbps_write_metadata_pkg()
. $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template . $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template
pkgname=${subpkg} pkgname=${subpkg}
set_tmpl_common_vars set_tmpl_common_vars
. ${XBPS_SHUTILSDIR}/verify_rundeps.sh
verify_rundeps ${DESTDIR} verify_rundeps ${DESTDIR}
xbps_write_metadata_pkg_real xbps_write_metadata_pkg_real
done done
@ -66,7 +65,6 @@ xbps_write_metadata_pkg()
fi fi
setup_tmpl ${sourcepkg} setup_tmpl ${sourcepkg}
# Verify pkg deps. # Verify pkg deps.
. ${XBPS_SHUTILSDIR}/verify_rundeps.sh
verify_rundeps ${DESTDIR} verify_rundeps ${DESTDIR}
xbps_write_metadata_pkg_real xbps_write_metadata_pkg_real
} }
@ -412,7 +410,6 @@ _EOF
# Create the INSTALL/REMOVE scripts if package uses them # Create the INSTALL/REMOVE scripts if package uses them
# or uses any available trigger. # or uses any available trigger.
# #
. ${XBPS_SHUTILSDIR}/metadata_scripts.sh; \
xbps_write_metadata_scripts_pkg install; \ xbps_write_metadata_scripts_pkg install; \
xbps_write_metadata_scripts_pkg remove; \ xbps_write_metadata_scripts_pkg remove; \
} || return $? } || return $?

View file

@ -23,9 +23,6 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#- #-
. ${XBPS_SHUTILSDIR}/tmpl_funcs.sh
. ${XBPS_SHUTILSDIR}/common_funcs.sh
# #
# Installs a pkg by reading its build template file. # Installs a pkg by reading its build template file.
# #
@ -44,17 +41,9 @@ install_pkg()
pkg="$curpkgn-$version" pkg="$curpkgn-$version"
[ -n "$INSTALLING_DEPS" ] && setup_tmpl $curpkgn [ -n "$INSTALLING_DEPS" ] && setup_tmpl $curpkgn
#
# Fetch distfiles before checking its dependencies.
#
. $XBPS_SHUTILSDIR/fetch_funcs.sh
fetch_distfiles
# #
# Refuse to install the same package that is already installed. # Refuse to install the same package that is already installed.
# #
. $XBPS_SHUTILSDIR/builddep_funcs.sh
check_installed_pkg "$pkg" check_installed_pkg "$pkg"
if [ $? -eq 1 -o $? -eq 0 ]; then if [ $? -eq 1 -o $? -eq 0 ]; then
instver="$($XBPS_PKGDB_CMD version $pkgname)" instver="$($XBPS_PKGDB_CMD version $pkgname)"
@ -79,12 +68,15 @@ install_pkg()
msg_normal "Installing '$pkgname'...\n" msg_normal "Installing '$pkgname'...\n"
fi fi
#
# Fetch distfiles before checking its dependencies.
#
fetch_distfiles
# #
# Fetch, extract, build and install into the destination directory. # Fetch, extract, build and install into the destination directory.
# #
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
. $XBPS_SHUTILSDIR/extract_funcs.sh
extract_distfiles extract_distfiles
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_red "cannot extract distfiles for '$pkgname'!\n" msg_red "cannot extract distfiles for '$pkgname'!\n"
@ -93,7 +85,6 @@ install_pkg()
fi fi
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
. $XBPS_SHUTILSDIR/configure_funcs.sh
configure_src_phase configure_src_phase
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_red "cannot configure '$pkgname'!\n" msg_red "cannot configure '$pkgname'!\n"
@ -102,7 +93,6 @@ install_pkg()
fi fi
if [ ! -f "$XBPS_BUILD_DONE" ]; then if [ ! -f "$XBPS_BUILD_DONE" ]; then
. $XBPS_SHUTILSDIR/build_funcs.sh
build_src_phase build_src_phase
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_red "cannot build '$pkgname'!\n" msg_red "cannot build '$pkgname'!\n"
@ -121,12 +111,10 @@ install_pkg()
# Strip binaries/libraries. # Strip binaries/libraries.
if [ -z "$noarch" ]; then if [ -z "$noarch" ]; then
. $XBPS_SHUTILSDIR/strip_files.sh
strip_files strip_files
fi fi
# Always write metadata to package's destdir. # Always write metadata to package's destdir.
. $XBPS_SHUTILSDIR/metadata.sh
trap 'remove_pkgdestdir_sighandler ${pkgname}' INT trap 'remove_pkgdestdir_sighandler ${pkgname}' INT
xbps_write_metadata_pkg xbps_write_metadata_pkg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -139,7 +127,6 @@ install_pkg()
[ "$install_destdir_target" = "yes" ] && return 0 [ "$install_destdir_target" = "yes" ] && return 0
# Stow package into masterdir. # Stow package into masterdir.
. $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg_handler stow stow_pkg_handler stow
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_red "cannot stow '$pkgname'!\n" msg_red "cannot stow '$pkgname'!\n"
@ -174,7 +161,6 @@ install_pkg()
# Autoremove packages installed as dependencies if # Autoremove packages installed as dependencies if
# XBPS_PREFER_BINPKG_DEPS is set. # XBPS_PREFER_BINPKG_DEPS is set.
# #
. ${XBPS_SHUTILSDIR}/builddep_funcs.sh
autoremove_pkg_dependencies autoremove_pkg_dependencies
return $? return $?
@ -205,7 +191,6 @@ remove_pkg()
[ -z $pkgname ] && msg_error "unexistent package, aborting.\n" [ -z $pkgname ] && msg_error "unexistent package, aborting.\n"
ver=$($XBPS_PKGDB_CMD version $pkgname) ver=$($XBPS_PKGDB_CMD version $pkgname)
. $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg_handler unstow || return $? stow_pkg_handler unstow || return $?
for subpkg in ${subpackages}; do for subpkg in ${subpackages}; do

View file

@ -23,8 +23,6 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#- #-
. ${XBPS_SHUTILSDIR}/builddep_funcs.sh
stow_pkg_handler() stow_pkg_handler()
{ {
local action="$1" subpkg spkgrev local action="$1" subpkg spkgrev

View file

@ -23,8 +23,6 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#- #-
. ${XBPS_SHUTILSDIR}/tmpl_funcs.sh
strip_files() strip_files()
{ {
local subpkg local subpkg

View file

@ -66,7 +66,6 @@ info_tmpl()
done done
echo "$long_desc" echo "$long_desc"
echo echo
. $XBPS_SHUTILSDIR/builddep_funcs.sh
check_build_depends_pkg check_build_depends_pkg
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "This package requires the following build-time dependencies:" echo "This package requires the following build-time dependencies:"
@ -284,8 +283,6 @@ set_tmpl_common_vars()
{ {
[ -z "$pkgname" ] && return 1 [ -z "$pkgname" ] && return 1
. ${XBPS_SHUTILSDIR}/install_files.sh
FILESDIR=$XBPS_SRCPKGDIR/$pkgname/files FILESDIR=$XBPS_SRCPKGDIR/$pkgname/files
PATCHESDIR=$XBPS_SRCPKGDIR/$pkgname/patches PATCHESDIR=$XBPS_SRCPKGDIR/$pkgname/patches
DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version} DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version}

View file

@ -212,14 +212,17 @@ if [ -n "${_MASTERDIR}" ]; then
fi fi
. @@XBPS_INSTALL_SHAREDIR@@/shutils/init_funcs.sh . @@XBPS_INSTALL_SHAREDIR@@/shutils/init_funcs.sh
set_defvars set_defvars
for f in $(echo @@XBPS_INSTALL_SHAREDIR@@/shutils/*.sh); do
if [ -r "$f" -a "$(basename $f)" != "chroot.sh" ]; then
. $f
fi
done
# #
# Check for required utilities in host system. # Check for required utilities in host system.
# #
check_reqhost_utils check_reqhost_utils
. $XBPS_SHUTILSDIR/common_funcs.sh
# #
# Fix up some vars when XBPS_USE_CAPABILITIES is set. # Fix up some vars when XBPS_USE_CAPABILITIES is set.
# #
@ -263,8 +266,6 @@ export PATH="$MYPATH"
# #
case "$target" in case "$target" in
bootstrap) bootstrap)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
[ ! -d $XBPS_SRCPKGDIR/base-chroot ] && \ [ ! -d $XBPS_SRCPKGDIR/base-chroot ] && \
msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot directory!\n" msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot directory!\n"
cd $XBPS_SRCPKGDIR/base-chroot && _ORIGINPKG="$(basename_cwd)" cd $XBPS_SRCPKGDIR/base-chroot && _ORIGINPKG="$(basename_cwd)"
@ -285,8 +286,6 @@ build|configure)
_ORIGINPKG="${_pkgname}" _ORIGINPKG="${_pkgname}"
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
# If pkg has dependencies, install them first. # If pkg has dependencies, install them first.
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
. $XBPS_SHUTILSDIR/builddep_funcs.sh
install_dependencies_pkg "$pkgname-$version" install_dependencies_pkg "$pkgname-$version"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_red "cannot install required deps for $pkgname.\n" msg_red "cannot install required deps for $pkgname.\n"
@ -294,28 +293,21 @@ build|configure)
fi fi
# All deps were installed, continue with the origin pkg... # All deps were installed, continue with the origin pkg...
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
. $XBPS_SHUTILSDIR/fetch_funcs.sh
fetch_distfiles fetch_distfiles
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
. $XBPS_SHUTILSDIR/extract_funcs.sh
extract_distfiles extract_distfiles
fi fi
if [ "$target" = "configure" ]; then if [ "$target" = "configure" ]; then
. $XBPS_SHUTILSDIR/configure_funcs.sh
configure_src_phase configure_src_phase
else else
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
. $XBPS_SHUTILSDIR/configure_funcs.sh
configure_src_phase configure_src_phase
fi fi
. $XBPS_SHUTILSDIR/build_funcs.sh
build_src_phase build_src_phase
fi fi
fi fi
;; ;;
build-pkg) build-pkg)
. $XBPS_SHUTILSDIR/make-binpkg.sh
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -n "${_PACKAGEDIR}" ]; then if [ -n "${_PACKAGEDIR}" ]; then
export XBPS_PACKAGESDIR=${_PACKAGEDIR} export XBPS_PACKAGESDIR=${_PACKAGEDIR}
fi fi
@ -337,8 +329,6 @@ build-pkg)
fi fi
;; ;;
checkvers) checkvers)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
. $XBPS_SHUTILSDIR/check_installed_packages.sh
check_installed_packages check_installed_packages
;; ;;
chroot) chroot)
@ -346,7 +336,6 @@ chroot)
xbps_chroot_handler chroot dummy xbps_chroot_handler chroot dummy
;; ;;
clean) clean)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
@ -355,24 +344,19 @@ clean)
remove_tmpl_wrksrc $wrksrc remove_tmpl_wrksrc $wrksrc
;; ;;
extract|fetch|info) extract|fetch|info)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
fi fi
setup_tmpl ${_pkgname} setup_tmpl ${_pkgname}
if [ "$target" = "info" ]; then if [ "$target" = "info" ]; then
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
info_tmpl info_tmpl
exit $? exit $?
fi fi
. $XBPS_SHUTILSDIR/fetch_funcs.sh
fetch_distfiles $update_checksum fetch_distfiles $update_checksum
. $XBPS_SHUTILSDIR/extract_funcs.sh
extract_distfiles extract_distfiles
;; ;;
install|install-destdir) install|install-destdir)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
@ -386,7 +370,6 @@ install|install-destdir)
. $XBPS_SHUTILSDIR/chroot.sh . $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_ORIGINPKG} $dontrm_builddir xbps_chroot_handler $target ${_ORIGINPKG} $dontrm_builddir
else else
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
install_pkg $pkgname install_pkg $pkgname
fi fi
@ -396,7 +379,6 @@ list|listfiles)
$XBPS_BIN_CMD list $XBPS_BIN_CMD list
exit $? exit $?
fi fi
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
list_pkg_files $2 list_pkg_files $2
;; ;;
make-repoidx) make-repoidx)
@ -411,7 +393,6 @@ make-repoidx)
[ $? -eq 0 ] && echo "=> done." [ $? -eq 0 ] && echo "=> done."
;; ;;
remove) remove)
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
if [ -z "${_pkgname}" ]; then if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
@ -426,13 +407,11 @@ remove)
;; ;;
stow) stow)
stow_flag=yes stow_flag=yes
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
fi fi
setup_tmpl ${_pkgname} setup_tmpl ${_pkgname}
. $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg_handler stow stow_pkg_handler stow
;; ;;
unstow) unstow)
@ -442,7 +421,6 @@ unstow)
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
fi fi
setup_tmpl ${_pkgname} setup_tmpl ${_pkgname}
. $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg_handler unstow stow_pkg_handler unstow
;; ;;
*) *)