Page MenuHomeVyOS Platform

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


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, 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 and

My solution is :

  1. Accept --debian-mirror-server
  2. Replace debian mirror urls (deb|security) 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) to debian-mirror-server in all debian mirror settings (e.g.', 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) to debian_mirror_server if it's set
+    if args['debian_mirror_server'] is not None:
+        args['debian_mirror'] = re.sub('(deb|security)', args['debian_mirror_server'], args['debian_mirror'])
+        args['debian_security_mirror'] = re.sub('(deb|security)', args['debian_mirror_server'], args['debian_security_mirror'])
+        args['pbuilder_debian_mirror'] = re.sub('(deb|security)', 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(
+            buster_repo = """
+deb buster main non-free
+deb buster-updates main non-free
+deb buster/updates main non-free
+            fp.write(re.sub('(deb|security)', 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.


Difficulty level
Unknown (require assessment)
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


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.