diff mbox series

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

Message ID 20240606195513.75538-1-noah.wager@canonical.com
State New
Headers show
Series [Unstable] UBUNTU: [Packaging] dkms-build: Support DEB822 sources | expand

Commit Message

Noah Wager June 6, 2024, 7:54 p.m. UTC
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@canonical.com>
---
 debian/scripts/dkms-build | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Paolo Pisati June 7, 2024, 10:49 a.m. UTC | #1
On Thu, Jun 06, 2024 at 12:54:09PM -0700, Noah Wager wrote:
> 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@canonical.com>
diff mbox series

Patch

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