From 45ac92c03729f9e9806027be27513dca4b1d6e7f Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Tue, 31 Oct 2017 21:12:43 +0100 Subject: Fix resolve_deps() and make_pkgorder() - Change resolve_deps such that the `parent' package is known. - Use that to exclusively add AUR-dependencies. --- auria.sh | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/auria.sh b/auria.sh index 60e9eb0..094ed5b 100755 --- a/auria.sh +++ b/auria.sh @@ -219,7 +219,7 @@ function install_full #inform "Fetching package information from AUR..." inform "Resolving dependencies..." - resolve_deps "$pkg" $itype || return $? + resolve_deps "$pkg" $itype '' || return $? make_pkgorder || return $? for pkg in "${aur_pkgorder[@]}" @@ -420,13 +420,16 @@ function present_files # non-explicit ones. # $1 package: name [. pkgver-comparator . version string] # $2 installation type: (dep|explicit|update) +# $3 direct reverse dependency (caller): (name|) # interactive (<- get_pkgbase). function resolve_deps { - local itype pkgstr pkg pkgbase pkgver rst rst_kind rst_ver existed new + local itype pkgstr pkg pkgbase pkgver rst rst_kind rst_ver existed new \ + abovepkg pkgstr="$1" itype=$2 + abovepkg="$3" # Check for version restriction. rst=( $(print_restriction "$pkgstr") ) @@ -454,6 +457,7 @@ function resolve_deps else error "[RPC] ${retstr}" fi + return 2 fi get_pkgbase "$pkg" "$pkgstr" "${tmp}/json" $itype || return $? @@ -472,6 +476,13 @@ function resolve_deps return 2 fi + # Add edges to the tree if the dep will be taken from the AUR. + if test -n "$abovepkg" + then + aur_deps["$abovepkg"]+=" $pkg " + aur_revdeps["$pkg"]+=" $abovepkg " + fi + if $new then local deps makedeps @@ -480,20 +491,17 @@ function resolve_deps makedeps=( $(jq -r ".results[$i].MakeDepends[]?" "${tmp}/json" \ || return 4) ) - aur_deps["$pkg"]="$(printf " %s " "${deps[@]}" "${makedeps[@]}")" + # Recurse. + local dep + for dep in "${deps[@]}" "${makedeps[@]}" + do + #echo $dep + resolve_deps "$dep" dep "$pkg" || return $? + done - if (( ${#deps} + ${#makedeps} == 0 )) + if test -z "${aur_deps["$pkg"]}" then aur_pkgorder+=("$pkg") - else - # Recurse. - local dep - for dep in "${deps[@]}" "${makedeps[@]}" - do - #echo $dep - aur_revdeps["$dep"]+=" $pkg " - resolve_deps "$dep" dep - done fi fi } @@ -503,7 +511,11 @@ function make_pkgorder { local pkg - test -n "${aur_pkgorder[$i]}" && return 0 + if test -z "${aur_pkgorder[0]}" + then + error "Circular dependency found." + return 2 + fi ## Go up the reverse tree from bottom to top. -- cgit v1.2.3