Creating local mirror for Buildroot package sources

When you need to frequently and quickly rebuild Buildroot for a variety of reasons, there's a neat feature in Buildroot that allows you to use a local source mirror, so you can avoid wasting bandwidth and unnecessary waiting for downloads.

First make sure that the source is already configured for a specific board, for example:

make riotboard_defconfig

Now all sources required to build this configuration can be automatically downloaded by the build scripts into a directory called "dl":

make source

Now all these sources can be copied to some HTTP server in the LAN (so multiple machines can use it), or can be even hosted on your local machine. This completes the mirroring preparation.

Now on the client side (either a developer workstation or a CI/CD configuration), you need to set some buildroot variables to activate this mirroring behavior. Here's a list of these variables:

BR2_PRIMARY_SITE
BR2_PRIMARY_SITE_ONLY
BR2_BACKUP_SITE
BR2_KERNEL_MIRROR
BR2_GNU_MIRROR
BR2_LUAROCKS_MIRROR
BR2_CPAN_MIRROR

The variables usage should be pretty obvious, but as always don't hesitate to take a look at the Config.in, where the variables are documented (or use menuconfig and go to "Build options", "Mirrors and Download locations").

Basically you have 2 ways to change these variables - either edit them in Config.in file, or assign them in your boards's configuration file (configs/boardname_defconfig). The difference is that boardname_defconfig affects only your board, and Config.in affects all boards' builds.

Here's a very simple example of making a local mirror for all sources, just add this to your boardname_defconfig:

# Use local source mirror
BR2_PRIMARY_SITE="http://localhost/mirrors/buildroot"

Of course the best place to put your server is inside your LAN, which will guarantee sub-second downloads during the build process.

See Archives for a complete list of articles