From 78ec379a920289eb7e717da8c936bb96c790f39c Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sat, 1 Oct 2011 23:01:01 -0500 Subject: [PATCH] script/makepkg: add caching and tree compression for port_bdep_tree and port_rdep_tree --- script/makepkg | 54 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/script/makepkg b/script/makepkg index 3797ddb..e33d009 100755 --- a/script/makepkg +++ b/script/makepkg @@ -261,28 +261,58 @@ leaf_ports() { # depend upon). Individual ports may appear more than # once, as it is a tree and not a list. port_bdep_tree() { + # Clear cache if first value isn't '-r' + [ "${1}" = '-r' ] && shift || { + [ ${VERBOSE_CACHE} ] && logf "**** bdep_tree cache cleared\n" + : > "${_port_bdep_tree_cache}" + } port="${1##/usr/ports/}" printf "%${2}s%s\n" "" "${port}" - ( chmake "${port}" build-depends-list - [ "${2:-0}" -gt 0 ] && chmake "${port}" run-depends-list - ) | sort -u | while read port - do - port_bdep_tree "${port}" $(( ${2:-0} + 1 )) - done + [ "${VERBOSE_CACHE}" ] && logf "**** bdep_tree cache %s: '%s'\n" "$(grep -q "${port}" \ + "${_port_bdep_tree_cache}" && echo "hit" || echo "miss")" "${port}" >&2 + + if ! grep -q "${port}" "${_port_bdep_tree_cache}" + then + ( chmake "${port}" build-depends-list + chmake "${port}" run-depends-list + ) | sort -u | while read port + do + port_bdep_tree -r "${port}" $(( ${2:-0} + 1 )) + echo "${port}" >> "${_port_bdep_tree_cache}" + done + else + printf "%${2}s %s\n" "" "..." + fi } # Display a tree of all runtime dependencies. Individual # ports may appear more than once, as it is a tree and # not a list. +# Cache already-visted branches into ... to eliminate recursion delays +# (x11-drivers/xorg-drivers computes forever!) port_rdep_tree() { + # Clear cache if first value isn't '-r' + [ "${1}" = '-r' ] && shift || { + [ ${VERBOSE_CACHE} ] && logf "**** rdep_tree cache cleared\n" + : > "${_port_rdep_tree_cache}" + } port="${1##/usr/ports/}" printf "%${2}s%s\n" "" "${port}" - - chmake "${port}" run-depends-list | sort -u | while read port - do - port_rdep_tree "${port}" $(( ${2:-0} + 1 )) - done + + [ "${VERBOSE_CACHE}" ] && logf "**** rdep_tree cache %s: '%s'\n" "$(grep -q "${port}" \ + "${_port_rdep_tree_cache}" && echo "hit" || echo "miss")" "${port}" >&2 + + if ! grep -q "${port}" "${_port_rdep_tree_cache}" + then + chmake "${port}" run-depends-list | sort -u | while read port + do + port_rdep_tree -r "${port}" $(( ${2:-0} + 1 )) + echo "${port}" >> "${_port_rdep_tree_cache}" + done + else + printf "%${2}s %s\n" "" "..." + fi } ######## @@ -540,6 +570,8 @@ chroot_bdeps_dir="${bdeps_dir##${chroot_dir}}" # Cache files to speed up recursive bdep/rdep scanning _port_all_bdeps_cache="${chroot_dir}/tmp/_port_all_bdeps_cache" _port_all_rdeps_cache="${chroot_dir}/tmp/_port_all_rdeps_cache" +_port_bdep_tree_cache="${chroot_dir}/tmp/_port_bdep_tree_cache" +_port_rdep_tree_cache="${chroot_dir}/tmp/_port_rdep_tree_cache" # Chroot environment chroot_env=" -- 2.42.0