From a6f9af354a9cd2c7b06ebe9c5b4958d527291810 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 21 Aug 2020 21:19:02 +0100 Subject: [PATCH 1/1] stdlib/fedora.gl: Simpler quicker way to work out dependencies. This removes the O(n^3) loop. --- stdlib/fedora.gl | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/stdlib/fedora.gl b/stdlib/fedora.gl index 8bcc09a..999c55f 100644 --- a/stdlib/fedora.gl +++ b/stdlib/fedora.gl @@ -143,26 +143,16 @@ pure function fedora-source-dependencies (pkg) returning strings = @{ # We will require the mapping of all source packages to the # list of binary packages they build, so work this out in advance. - declare -A binpkgs + declare -A bin2src for p in %fedora-source-packages; do - binpkgs[$p]="$( - rpmspec -q --provides %fedora-dir/$p/%fedora-branch/$p.spec 2>/dev/null | - awk '{print $1}' - )" + for b in $(rpmspec -q --provides %fedora-dir/$p/%fedora-branch/$p.spec 2>/dev/null | awk '{print $1}'); do + bin2src[$b]=$p + done done - for r in $(rpmspec -q --buildrequires $specfile 2>/dev/null | + for b in $(rpmspec -q --buildrequires $specfile 2>/dev/null | awk '{print $1}'); do - # Now we examine each *other* source package to see - # if any will create this dependency when they build. - for p in %fedora-source-packages; do - if [ "$p" != %pkg ]; then - for f in ${binpkgs[$p]}; do - if [ "$f" = "$r" ]; then - echo "$p" - fi - done - fi - done - done | sort -u + # Find the source package that produces these binary requirements. + echo ${bin2src[$b]} + done | grep -v '^$' | sort -u } -- 1.8.3.1