From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7DE128DB76 for ; Fri, 1 Aug 2025 19:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754077600; cv=none; b=f7khQheSRRubPbsI6ALy/QFS5AlTGBiNu3FyOSTBHMt4d536HPTm7y7eoy4mzoe4gln1pmrHHrmVTGiXKx0Y865FSbG5QHmIQbKozeWaUTb/BfxsoE9TNUhO64NCMbOMWranKaivcfBw7O5IZElNvosLfst8ZbeELeXh35o8xu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754077600; c=relaxed/simple; bh=PJ4FLMnmyUvNk4X0oksaNbbjEYrUX1ZSLm3AUIA8y4E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fM4PFW/P05xob7QNaNfkO1wWINbLYZUt9mX2r0XXlo/2kQjf3R5rGncsdzu8R2gLJV6nWiM8yTjnQFNLj+NER5ogvFVcCpFbYWTWVXZBy344hbfLhMsaKoMpOrchDK3vNEIJIu716UX40l+0a8YxN1z5+fgIXcWc4kd1fmlbZO8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Qmy6/rdg; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Qmy6/rdg" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=oqzeXZBCxJspgO8Kd2h668UYdFzQ1b4TrKlZGKqeq2E=; b=Qmy6/rdgTMgtU1nu8Sec+PNUxX 1RsrvA8Lo22UagOe4o4iTbpwhp+gknadHvLha2GrLG9y2tkLZMyL27CU+pj2mTbaACJmGjqIB5U73 md/O5sK/ZTBgT6U3IQ3jd8l0+mROLCs8L2ikaNYM+cP9lR0KYD6OCTBfVMgL5WU1UAX/KwAmr27v8 unzv0JnF2BYhUu/PIRCqfS5/NrJUeqOZy6GR7x7Ohby3TdJe50v9X/JfYbO2rrdeZPK5Nm1I/avHo lKpItPtNrtd/MD9NT/qeEtf2af2V4IlQt1J33hZzm68n3WKfZoAGyQRl8NzyDzM1U9YVh/wOr5jrK nMUjgM6A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1uhvi9-00000006hrh-19V0; Fri, 01 Aug 2025 19:46:37 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH v3 08/11] scripts: enhance hop count detection to support DEB822 format Date: Fri, 1 Aug 2025 12:46:32 -0700 Message-ID: <20250801194635.1598544-9-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250801194635.1598544-1-mcgrof@kernel.org> References: <20250801194635.1598544-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain 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 --- 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