python-apt: update mirror parser and add note

This commit is contained in:
Luis Guzmán 2025-03-17 22:42:00 +00:00
parent de1bcc6d6b
commit e0f999388d
2 changed files with 18 additions and 1 deletions

View file

@ -31,6 +31,10 @@ parser.add_argument(
"-c", "-c",
help="Filter by country (e.g., AU, BR, CA)", help="Filter by country (e.g., AU, BR, CA)",
default=None) default=None)
parser.add_argument(
"--mirmon",
action="store_true",
help="List mirrors suitable for mirmon output")
args = parser.parse_args() args = parser.parse_args()
with open(args.file, 'r') as file: with open(args.file, 'r') as file:
@ -67,13 +71,25 @@ for block in blocks:
mirrors[country] = {} mirrors[country] = {}
mirrors[country][site] = {"https": https_urls, "http": http_urls} mirrors[country][site] = {"https": https_urls, "http": http_urls}
# Print mirmon output if selected
if args.mirmon:
for country, sites in sorted(mirrors.items()):
if args.country and country != args.country:
continue
for site, urls in sites.items():
if urls["https"]:
print(f"{country.lower()} {urls['https'][0]}")
elif urls["http"]:
print(f"{country.lower()} {urls['http'][0]}")
exit(0)
# Print output # Print output
for country, sites in sorted(mirrors.items()): for country, sites in sorted(mirrors.items()):
if args.country and country != args.country: if args.country and country != args.country:
continue continue
valid_sites = { valid_sites = {
site: urls for site, urls in sites.items() site: urls for site, urls in sites.items()
if urls["https"] or urls["http"] if urls["https"] or urls["http"]
} }
if not valid_sites: if not valid_sites:

View file

@ -22,6 +22,7 @@
# 'choose-mirror' package as a dependency for debian-installer, so when # 'choose-mirror' package as a dependency for debian-installer, so when
# a new release of the 'debian-installer' also ships the latest mirror # a new release of the 'debian-installer' also ships the latest mirror
# list available on the resulting netinstall (mini.iso) image. # list available on the resulting netinstall (mini.iso) image.
# The same way as 'ubiquity' is for for the next Live Desktop ISOs.
VERSION=10 VERSION=10
COMPONENT=main COMPONENT=main