Page MenuHomeVyOS Platform

Override all debian mirror server name in url
In progress, NormalPublic

Description

Override all debian mirror server name in url, because the buster list is not affected by cli/toml parameters.

Debian official sources are slow in China, and as I tried, deb.debian.org and debian mirrors in China accepts both '/debian/' and '/debian-security/'.

In VyOS 1.4 build system, debian mirrors can be set from:

  • --debian-mirror, --debian-security-mirror, --pbuilder-debian-mirror
  • defaults.toml and build flavors

But there is still a buster.list.chroot with hard coded deb.debian.org and security.debian.org.

My solution is :

  1. Accept --debian-mirror-server
  2. Replace debian mirror urls (deb|security).debian.org to --debian-mirror-server if set
  3. Overwrite buster.list.chroot if --debian-mirror-server is set

My patch:

--- a/scripts/build-vyos-image
+++ b/scripts/build-vyos-image
@@ -146,7 +146,8 @@ if __name__ == "__main__":
        'vyos-mirror': ('VyOS package mirror', lambda: build_defaults["vyos_mirror"], None),
        'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']),
        'version': ('Version number (release builds only)', None, None),
-       'build-comment': ('Optional build comment', lambda: '', None)
+       'build-comment': ('Optional build comment', lambda: '', None),
+       'debian-mirror-server': ('Replace (deb|security).debian.org to debian-mirror-server in all debian mirror settings (e.g. mirrors.bit.edu.cn)', None, None)
     }
 
     # Create the option parser
@@ -198,6 +199,22 @@ if __name__ == "__main__":
        (args['pbuilder_debian_mirror'] == build_defaults["debian_mirror"]):
         args['pbuilder_debian_mirror'] = args['debian_mirror']
 
+    # Replace (deb|security).debian.org to debian_mirror_server if it's set
+    if args['debian_mirror_server'] is not None:
+        args['debian_mirror'] = re.sub('(deb|security).debian.org', args['debian_mirror_server'], args['debian_mirror'])
+        args['debian_security_mirror'] = re.sub('(deb|security).debian.org', args['debian_mirror_server'], args['debian_security_mirror'])
+        args['pbuilder_debian_mirror'] = re.sub('(deb|security).debian.org', args['debian_mirror_server'], args['pbuilder_debian_mirror'])
+
+        # overwrite data/live-build-config/archives/buster.list.chroot
+        with open('data/live-build-config/archives/buster.list.chroot', 'w+') as fp:
+            print(fp.read())
+            buster_repo = """
+deb http://deb.debian.org/debian/ buster main non-free
+deb http://deb.debian.org/debian/ buster-updates main non-free
+deb http://security.debian.org/debian-security buster/updates main non-free
+"""
+            fp.write(re.sub('(deb|security).debian.org', args['debian_mirror_server'], buster_repo))
+
     # Version can only be set for release builds,
     # for dev builds it hardly makes any sense
     if args['build_type'] == 'development':

PR will be send on github later.

Details

Difficulty level
Unknown (require assessment)
Version
1.4-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Improvement (missing useful functionality)

Event Timeline

sskaje created this object in space S1 VyOS Public.
sskaje changed Issue type from Unspecified (please specify) to Improvement (missing useful functionality).Mar 29 2023, 7:56 AM

PR: https://github.com/vyos/vyos-build/pull/325

Code changed, to override all settings in build_config instead of args from cli only.

Viacheslav changed the task status from Open to In progress.Jan 20 2024, 12:15 PM
Viacheslav triaged this task as Normal priority.