Skip to content

Commit

Permalink
xbps-src: multiple performance improvements
Browse files Browse the repository at this point in the history
- use xbps-checkvers(1) to resolve dependencies.
- all dependencies are installed at once for the host and target.
- the show-build-deps target is now much faster.
- the update-bulk/show-repo-updates targets are now much faster.
- the update-sys/show-sys-updates targets are now much faster.
- the bootstrap target now works on musl hosts.
- simplified some loops.
- use cut(1) rather than awk(1) where applicable.
- multiple random changes to improve performance.

Based on work started by @Duncaen on #12433

Close #12433
Close #11282
  • Loading branch information
Juan RP committed Jul 10, 2019
1 parent 529a019 commit e4984d0
Show file tree
Hide file tree
Showing 15 changed files with 469 additions and 617 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ masterdir*
hostdir*
etc/conf
etc/virtual
.xbps-checkvers.plist
8 changes: 4 additions & 4 deletions common/hooks/do-pkg/00-gen-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ genpkg() {

_preserve=${preserve:+-p}
if [ -s ${PKGDESTDIR}/rdeps ]; then
_deps="$(cat ${PKGDESTDIR}/rdeps)"
_deps="$(<${PKGDESTDIR}/rdeps)"
fi
if [ -s ${PKGDESTDIR}/shlib-provides ]; then
_shprovides="$(cat ${PKGDESTDIR}/shlib-provides)"
_shprovides="$(<${PKGDESTDIR}/shlib-provides)"
fi
if [ -s ${PKGDESTDIR}/shlib-requires ]; then
_shrequires="$(cat ${PKGDESTDIR}/shlib-requires)"
_shrequires="$(<${PKGDESTDIR}/shlib-requires)"
fi
if [ -s ${XBPS_STATEDIR}/gitrev ]; then
_gitrevs="$(cat ${XBPS_STATEDIR}/gitrev)"
_gitrevs="$(<${XBPS_STATEDIR}/gitrev)"
fi

# Stripping whitespaces
Expand Down
41 changes: 14 additions & 27 deletions common/hooks/pre-pkg/04-generate-runtime-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# - Generates shlib-requires file for xbps-create(1)

add_rundep() {
local dep="$1" i= rpkgdep= _depname= _rdeps= found=
local dep="$1" i= rpkgdep= _depname= found=

_depname="$($XBPS_UHELPER_CMD getpkgdepname ${dep} 2>/dev/null)"
if [ -z "${_depname}" ]; then
Expand Down Expand Up @@ -68,26 +68,19 @@ hook() {
exec < $depsftmp
while read f; do
lf=${f#${PKGDESTDIR}}
if [ "${skiprdeps/${lf}/}" != "${skiprdeps}" ]; then
msg_normal "Skipping dependency scan for ${lf}\n"
continue
fi
if [ "${skiprdeps/${lf}/}" != "${skiprdeps}" ]; then
msg_normal "Skipping dependency scan for ${lf}\n"
continue
fi
case "$(file -bi "$f")" in
application/x-*executable*|application/x-sharedlib*)
for nlib in $($OBJDUMP -p "$f"|grep NEEDED|awk '{print $2}'); do
if [ -z "$verify_deps" ]; then
verify_deps="$nlib"
continue
fi
[ -z "$verify_deps" ] && verify_deps="$nlib" && continue
found=0
for j in ${verify_deps}; do
[ "$j" != "$nlib" ] && continue
found_dup=1
break
[[ $j == $nlib ]] && found=1 && break
done
if [ -z "$found_dup" ]; then
verify_deps="$verify_deps $nlib"
fi
unset found_dup
[[ $found -eq 0 ]] && verify_deps="$verify_deps $nlib"
done
;;
esac
Expand All @@ -97,13 +90,13 @@ hook() {

#
# Add required run time packages by using required shlibs resolved
# above, the mapping is done thru the mapping_shlib_binpkg.txt file.
# above, the mapping is done thru the common/shlibs file.
#
for f in ${verify_deps}; do
unset _f j rdep _rdep rdepcnt soname _pkgname _rdepver found
_f=$(echo "$f"|sed -E 's|\+|\\+|g')
rdep="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|awk '{print $2}')"
rdepcnt="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|awk '{print $2}'|wc -l)"
rdep="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2)"
rdepcnt="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2|wc -l)"
if [ -z "$rdep" ]; then
# Ignore libs by current pkg
soname=$(find ${PKGDESTDIR} -name "$f")
Expand All @@ -121,15 +114,9 @@ hook() {
_pkgname=$($XBPS_UHELPER_CMD getpkgname "$j")
# if there's a SONAME matching pkgname, use it.
for x in ${pkgname} ${subpackages}; do
if [ "${_pkgname}" = "${x}" ]; then
found=1
break
fi
[[ $_pkgname == $x ]] && found=1 && break
done
if [ -n "$found" ]; then
_rdep=$j
break
fi
[[ $found ]] && _rdep=$j && break
done
if [ -z "${_rdep}" ]; then
# otherwise pick up the first one.
Expand Down
4 changes: 2 additions & 2 deletions common/hooks/pre-pkg/99-pkglint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ hook() {
msg_red "${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n"
msg_red "${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n"
msg_red "${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n"
_revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|awk '{print $1}')
_revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|cut -d ' ' -f1)
for x in ${_revdeps}; do
msg_red " ${x%:}\n"
done
Expand All @@ -128,7 +128,7 @@ hook() {
# Try to match provided shlibs in virtual packages.
for f in ${provides}; do
_vpkgname="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)"
_spkgname="$(grep "^${filename}" $mapshlibs | awk '{print $2}')"
_spkgname="$(grep "^${filename}" $mapshlibs | cut -d ' ' -f2)"
_libpkgname="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)"
if [ -z "${_spkgname}" -o -z "${_libpkgname}" ]; then
continue
Expand Down
4 changes: 0 additions & 4 deletions common/xbps-src/libexec/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ if [ "$PKGNAME" != "$XBPS_TARGET_PKG" -o -z "$XBPS_SKIP_DEPS" ]; then
install_pkg_deps $PKGNAME $XBPS_TARGET_PKG pkg $XBPS_CROSS_BUILD $XBPS_CROSS_PREPARE || exit $?
fi

if [ -z "$XBPS_CROSS_PREPARE" ]; then
install_cross_pkg $XBPS_CROSS_BUILD || exit $?
fi

# Fetch distfiles after installing required dependencies,
# because some of them might be required for do_fetch().
$XBPS_LIBEXECDIR/xbps-src-dofetch.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
Expand Down
2 changes: 1 addition & 1 deletion common/xbps-src/libexec/xbps-src-doinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if [ ! -f $XBPS_SUBPKG_INSTALL_DONE ]; then
run_func pkg_install
fi
fi
setup_pkg_depends ${pkgname:=$PKGNAME}
setup_pkg_depends ${pkgname:=$PKGNAME} || exit 1
run_pkg_hooks post-install
touch -f $XBPS_SUBPKG_INSTALL_DONE
fi
Expand Down
2 changes: 1 addition & 1 deletion common/xbps-src/libexec/xbps-src-prepkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [ "$sourcepkg" != "$PKGNAME" ]; then
fi

source_file $XBPS_COMMONDIR/environment/build-style/${build_style}.sh
setup_pkg_depends $pkgname
setup_pkg_depends $pkgname || exit 1
run_pkg_hooks pre-pkg

touch -f $XBPS_PREPKG_DONE
Expand Down
Loading

0 comments on commit e4984d0

Please sign in to comment.