From 95fe3c0620c0bb72bfe449181bd991862be411ec Mon Sep 17 00:00:00 2001 From: "Gedminas, Marius" Date: Thu, 28 May 2026 14:02:51 +0300 Subject: [PATCH 1/3] Link all Debian mirrors from the same mirror+file source together Rework the Debian repository determination algorithm to link mirrors together when they come from the same source. The dist_repos/nondist_repos logic was moved into a case statement based on $arch, and is now also applied to repos that use mirror+file. The title of a repo now bases the architecture on the repo itself, rather than hardcoding it to host_arch. The architecture is omitted entirely when it's 'all' or missing. Closes #834. --- client/patchman-client | 51 +++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/client/patchman-client b/client/patchman-client index cbec7268..63eeed2c 100755 --- a/client/patchman-client +++ b/client/patchman-client @@ -580,25 +580,44 @@ get_repos() { if ${verbose} ; then echo 'Finding apt repos...' fi + local osname shortversion repos osname=$(echo ${os} | cut -d " " -f 1) shortversion=${VERSION_ID} - repo_string="'deb\' \'${osname} ${shortversion} ${host_arch} repo at" repos=$(apt-cache policy | grep -v Translation | grep -E "^ *[0-9]{1,5}" | grep -E " mirror\+file|http(s)?:" | sed -e "s/^ *//g" -e "s/ *$//g" | cut -d " " -f 1,2,3,4) - non_mirror_repos=$(echo "${repos}" | grep -Ev "mirror\+file") - dist_repos=$(echo "${non_mirror_repos}" | grep -v -e "Packages$") - nondist_repos=$(echo "${non_mirror_repos}" | grep -e "Packages$") - mirror_repos=$(echo "${repos}" | grep -E "mirror\+file") - for mirror_repo in ${mirror_repos} ; do - mirror_file=$(echo "${mirror_repo}" | sed -e "s/.* mirror+file://g" | cut -d " " -f 1) - if [ -f "${mirror_file}" ] ; then - for url in $(cat ${mirror_file}) ; do - dist_repo=$(echo "${mirror_repo}" | sed -e "s#mirror+file:${mirror_file}#${url}#g") - dist_repos="${dist_repos}"$'\n'"${dist_repo}" - done - fi - done - echo "${dist_repos}" | sed -e "s/\([0-9]*\) \(http:.*\|https:.*\)[\/]\? \(.*\/.*\) \(.*\)/${repo_string} \2\/dists\/\3\/binary-\4' '\1' '\2\/dists\/\3\/binary-\4'/" >> "${tmpfile_rep}" - echo "${nondist_repos}" | sed -e "s/\([0-9]*\) \(http:.*\|https:.*\)[\/]\? \(.*\/\?.*\) Packages/${repo_string} \2\/\3' '\1' '\2\/\3'/" >> "${tmpfile_rep}" + local prio baseurl suite_component arch + echo "${repos}" | while IFS=$FULL_IFS read -r prio baseurl suite_component arch; do + local baseurls + case "$baseurl" in + mirror+file:*) + mapfile -t baseurls < "${baseurl#mirror+file:}" + ;; + *) + baseurls=("$baseurl") + ;; + esac + local suffix + case "$arch" in + Packages|"") + suffix="/${suite_component}" + ;; + *) + suffix="/dists/${suite_component}/binary-${arch}" + ;; + esac + local urls=("${baseurls[@]/%/${suffix}}") + local title="${osname} ${shortversion}" + case "$arch" in + all|Packages|"") + ;; + *) + title="${title} ${arch}" + ;; + esac + title="${title} repo at ${urls[0]}" + local repo + printf -v repo "'%s' " deb "${title}" "${prio}" "${urls[@]}" + echo "${repo% }" + done >> "${tmpfile_rep}" fi # SUSE From 314168e2796875c58ce9a88ea64fae56f4df9dd5 Mon Sep 17 00:00:00 2001 From: "Gedminas, Marius" Date: Mon, 1 Jun 2026 13:41:50 +0300 Subject: [PATCH 2/3] Avoid double slashes in Debian repository URLs This was a regression introduced in the previous commit, where a mirror+file containing http://archive.ubuntu.com/ubuntu/ (with a trailing slash) would result in mirror URLs looking like http://archive.ubuntu.com/ubuntu//dists/noble/main/binary-amd64 instead of http://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64 --- client/patchman-client | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/patchman-client b/client/patchman-client index 63eeed2c..9bc053c5 100755 --- a/client/patchman-client +++ b/client/patchman-client @@ -604,7 +604,8 @@ get_repos() { suffix="/dists/${suite_component}/binary-${arch}" ;; esac - local urls=("${baseurls[@]/%/${suffix}}") + local urls=("${baseurls[@]/%\//}") + local urls=("${urls[@]/%/${suffix}}") local title="${osname} ${shortversion}" case "$arch" in all|Packages|"") From b7c653daa677eadcaca1ef8bdbef19580d6578e7 Mon Sep 17 00:00:00 2001 From: "Gedminas, Marius" Date: Mon, 1 Jun 2026 13:53:47 +0300 Subject: [PATCH 3/3] Refactor the stripping of trailing slashes in $baseurls Two lines starting with `local urls=...` looked too much like a copy/paste error. --- client/patchman-client | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/patchman-client b/client/patchman-client index 9bc053c5..a1d07eba 100755 --- a/client/patchman-client +++ b/client/patchman-client @@ -595,6 +595,7 @@ get_repos() { baseurls=("$baseurl") ;; esac + baseurls=("${baseurls[@]/%\//}") local suffix case "$arch" in Packages|"") @@ -604,8 +605,7 @@ get_repos() { suffix="/dists/${suite_component}/binary-${arch}" ;; esac - local urls=("${baseurls[@]/%\//}") - local urls=("${urls[@]/%/${suffix}}") + local urls=("${baseurls[@]/%/${suffix}}") local title="${osname} ${shortversion}" case "$arch" in all|Packages|"")