[Unstable][PATCH] UBUNTU: [Packaging] dkms-build: Support DEB822 sources

Noah Wager noah.wager at canonical.com
Thu Jun 6 19:54:09 UTC 2024


When going through pools to download the DKMS debs, support both
one-line (*.list) and DEB822 (*.sources) formats when parsing source
lists.

Signed-off-by: Noah Wager <noah.wager at canonical.com>
---
 debian/scripts/dkms-build | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build
index de97466d587a..8e9adc56f03d 100755
--- a/debian/scripts/dkms-build
+++ b/debian/scripts/dkms-build
@@ -60,8 +60,18 @@ do
 				break
 			fi
 
+			# Get pools from *.list files.
+			slist_files="/etc/apt/sources.list $( find /etc/apt/sources.list.d/ -type f -name "*.list" | xargs )"
+			slist_pools=$( grep -h '^deb ' $slist_files | awk '{print $2}' )
+
+			# Get pools from *.sources (deb822-style) files.
+			deb822_files=$( find /etc/apt/sources.list.d/ -type f -name "*.sources" | xargs )
+			# Split stanzas on empty lines and only select deb pools, then get the URIs.
+			# Since RS != \n, regex is not line-by-line so the newline matching is more explicit.
+			deb822_pools=$( awk -v RS= '/(^|\n)Types:[^\n]* deb($|\s)/' $deb822_files | sed -n 's/^URIs: //p' )
+
 			# Download from the available pools.
-			for pool in $( grep -h '^deb ' /etc/apt/sources.list /etc/apt/sources.list.d/*.list | awk '{print $2}' | sort -u )
+			for pool in $( echo $slist_pools $deb822_pools | xargs -n1 | sort -u )
 			do
 				if package_present "$lpackage"; then
 					break
-- 
2.43.0




More information about the kernel-team mailing list