From ba1105397c2e02b0fe15319b50ad883596b3d6c3 Mon Sep 17 00:00:00 2001
From: Tianon Gravi <tianon@debian.org>
Date: Mon, 3 Oct 2022 13:12:14 -0700
Subject: [PATCH] Apply "EXCLUDE_DEPENDENCY" during "resolve_deps"

Without this, we end up including (unnecessary) dependencies of our excluded dependencies.

In the case of current `usrmerge`, that's `libfile-find-rule-perl* libgdbm-compat4* libgdbm6* libnumber-compare-perl* libperl5.34* libtext-glob-perl* perl* perl-modules-5.34*` (altogether ~50MiB worth of packages).
---
 debootstrap | 3 +--
 functions   | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/debootstrap b/debootstrap
index c86c34c..cc17fac 100755
--- a/debootstrap
+++ b/debootstrap
@@ -724,10 +724,9 @@ if am_doing_phase finddebs; then
 
 		info RESOLVEREQ "Resolving dependencies of required packages..."
 		required=$(resolve_deps "$requiredX")
-		required=$(without "$required" "$EXCLUDE_DEPENDENCY")
 		info RESOLVEBASE "Resolving dependencies of base packages..."
 		base=$(resolve_deps "$baseX")
-		base=$(without "$base" "$required $EXCLUDE_DEPENDENCY")
+		base=$(without "$base" "$required")
 
 		if [ "$LOG_EXTRA_DEPS" = true ]; then
 			baseN=$(without "$baseX" "$requiredX")
diff --git a/functions b/functions
index 903c127..a8bb538 100644
--- a/functions
+++ b/functions
@@ -1587,6 +1587,9 @@ resolve_deps () {
 				NEWPKGS="$NEWPKGS $("$PKGDETAILS" GETDEPS "$pkgdest" $PKGS)"
 			done
 		done
+		if [ -n "${EXCLUDE_DEPENDENCY:-}" ]; then
+			NEWPKGS="$(without "$NEWPKGS" "$EXCLUDE_DEPENDENCY")"
+		fi
 		PKGS=$(echo "$PKGS $NEWPKGS" | tr ' ' '\n' | sort | uniq)
 		local REALPKGS=""
 		for s in $SUITE $EXTRA_SUITES; do
-- 
GitLab

