From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
kdevops@lists.linux.dev
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH v3 08/11] scripts: enhance hop count detection to support DEB822 format
Date: Fri, 1 Aug 2025 12:46:32 -0700 [thread overview]
Message-ID: <20250801194635.1598544-9-mcgrof@kernel.org> (raw)
In-Reply-To: <20250801194635.1598544-1-mcgrof@kernel.org>
Update get-distro-has-hop-count-sources.sh to detect and handle both
legacy sources.list and modern DEB822 debian.sources formats.
The script now:
- Checks for /etc/apt/sources.list.d/debian.sources first (DEB822)
- Falls back to /etc/apt/sources.list if DEB822 not found
- Extracts mirror URLs appropriately for each format:
- DEB822: Parses URIs: field
- Legacy: Parses deb lines
This ensures hop count detection works correctly regardless of which
APT sources format is in use.
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
scripts/get-distro-has-hop-count-sources.sh | 29 ++++++++++++++++++---
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/scripts/get-distro-has-hop-count-sources.sh b/scripts/get-distro-has-hop-count-sources.sh
index 98e422b0cc85..2a1f5aa49981 100755
--- a/scripts/get-distro-has-hop-count-sources.sh
+++ b/scripts/get-distro-has-hop-count-sources.sh
@@ -15,10 +15,17 @@ if [[ ! -f $DEBIAN_VERSION_FILE ]]; then
fi
SOURCES_FILE="/etc/apt/sources.list"
+DEB822_SOURCES_FILE="/etc/apt/sources.list.d/debian.sources"
-if [[ ! -f $SOURCES_FILE ]]; then
+# Check for DEB822 format first
+if [[ -f $DEB822_SOURCES_FILE ]]; then
+ SOURCES_FILE=$DEB822_SOURCES_FILE
+ IS_DEB822=true
+elif [[ ! -f $SOURCES_FILE ]]; then
echo n
exit 0
+else
+ IS_DEB822=false
fi
which traceroute > /dev/null
@@ -27,9 +34,23 @@ if [[ $? -ne 0 ]]; then
exit 0
fi
-LINE=$(grep -v "^#" $SOURCES_FILE | head -1)
-HOST_URL_LINE=$(echo $LINE | awk '{print $2}')
-HOST=$(echo $HOST_URL_LINE | awk -F[/:] '{print $4}')
+# Extract host depending on format
+if [[ "$IS_DEB822" == "true" ]]; then
+ # DEB822 format: URIs: https://deb.debian.org/debian
+ HOST_URL_LINE=$(grep -E "^URIs:" $SOURCES_FILE | head -1 | awk '{print $2}')
+ HOST=$(echo $HOST_URL_LINE | sed -E 's|https?://||' | cut -d'/' -f1)
+else
+ # Legacy format: deb http://deb.debian.org/debian ...
+ LINE=$(grep -v "^#" $SOURCES_FILE | head -1)
+ HOST_URL_LINE=$(echo $LINE | awk '{print $2}')
+ HOST=$(echo $HOST_URL_LINE | awk -F[/:] '{print $4}')
+fi
+
+if [[ -z "$HOST" ]]; then
+ echo n
+ exit 0
+fi
+
HOP_COUNT=$(traceroute -n -w 1,1,1 $HOST | wc -l)
HOP_COUNT=$((HOP_COUNT -1))
--
2.47.2
next prev parent reply other threads:[~2025-08-01 19:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 19:46 [PATCH v3 00/11] kdevops: add support for A/B testing Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 01/11] roles/guestfs: add missing bootlinux_9p: False Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 02/11] Makefile: suppress Ansible warnings during configuration generation Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 03/11] playbooks: few space cleanups Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 04/11] style: add extensive code formatting checks to make style Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 05/11] Makefile: move styling to scripts/style.Makefile Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 06/11] CLAUDE.md: add instrucitons to verify commit Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 07/11] all: run black Luis Chamberlain
2025-08-01 19:46 ` Luis Chamberlain [this message]
2025-08-01 19:46 ` [PATCH v3 09/11] devconfig: add automatic APT mirror fallback with DEB822 modernization Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 10/11] devconfig: enhance hop1 detection to support traditional sources.list Luis Chamberlain
2025-08-01 19:46 ` [PATCH v3 11/11] bootlinux: add support for A/B kernel testing Luis Chamberlain
2025-08-02 17:15 ` [PATCH v3 00/11] kdevops: add support for A/B testing Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250801194635.1598544-9-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=cel@kernel.org \
--cc=da.gomez@kruces.com \
--cc=kdevops@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox