[solved] How do I run buildroot offline/with cached packages?

Hello!

I've spent the entire day looking into this and can't seem to find the full story.
It's my understanding that OpenWRT buildroot downloads packages and tools only when requested to actually install them into an image. Given that I'm doing some work on multiple devices and will usually be plugged into them (internet won't work) when I'd like to rebuild images to make changes, it's causing me some inconvenience.

I'd like to also only need to download these packages/tools once to save both my and your bandwidth.

How do I obtain and set up a local mirror of all of these for ... whatever it is that buildroot downloads ahead of time? One that contains all the stuff I need and which won't get wiped on a make clean or similar?

I've found instructions for using rsync to make a mirror on the downloads page, but I'm not sure if this is the sort of mirror I need and I don't know how to add it to the buildroot.

On the other end, the FAQ mentions a local cache for speeding up the build (also a benefit admittedly), but also not how to get one.

If these both describe the same sort of cache, what part of the rsync'd download would be the part I list when creating the local cache?
I think the buildroot also downloads toolchains and probably other stuff too, how do I make sure to get those too before I go offline?

Well, if you are using the full toolchain (instead of the quick-and-dirty imagebuilder), the default is almost what you want.

https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem#cleaning_up

  • "make clean" does not delete toolchain or the downloaded source archives.
  • "make targetclean" deletes also toolchain
  • "make dirclean" deletes also built "build tools", but still keeps sources.
  • "make distclean" deletes also sources

In practice, once you build for a device, you have its downloaded sources and they are kept (unless you do "make distclean").

I build for multiple devices, and keep separate toolchains for them, but I have symlinked the "dl" directory of each buildroot to a common dl directory, so the source archives are shared.

The articles that you linked most talk about mirroring the openwrt Github source repositories, but you already have those: you local buildroot and feeds. At build time the underlying upstream source archives of needed packages are downloaded from the upstream sites, not from OpenWrt.

Once you have configured a device with make menuconfig or defconfig, you can do "make download" to download the needed upstream package source archives. You could that before going offline.

Note that if you later modify config or include new packages, you might need to download other packages, so the doing "make download" is meaningful only before changes.

Ps. If you look at the download.pl script (in your buildroot) that actually loads the source archives, you can also find out about https://sources.cdn.openwrt.org/
But that contains lots of ancient package versions, so it makes no sense to download all... And there are thousands of packages, most of which you will never use.

Pps.

You might look into the ccache build option (in menuconfig)

1 Like

I'd love to be able to pull all the source files ahead of time, but I guess that's the best I can do then.

I'm happy to know that subsequent builds won't re-download everything (yes, I am using the buildroot from source). OR, did you mean those just get re-downloaded from there rather than OpenWRT?

I did see that there was a FAQ on building all packages and if the sources are kept that might work, but I'll see if I can get by for now.

Thanks for the tip on symlinking the DL directory!

I meant that those upstream source archives (like collectd_5.12.0-1.tar.gz) are downloaded from upstream sites if not already found in your dl/

So, once you have downloaded & built a device, you have all those source archives locally in your dl/
You only download not-found-locally archives due to new package versions, due to new config additions etc.

1 Like

I actually ran into something of an exception - it seems packages from Feeds are also downloaded and stored in various subfolders there and were not available when I copied the dl folder to a parallel build.

Is there any good way to detect which feed package folders have content and back those up too? Just copy the lot?

The package sources of feeds packages are stored in the quite same dl/ as the sources for the main repo packages.

But some packages have build time dependencies (or the build process itself has), and make downloads sources in the middle of the build, if sources were not found. But those are rare exceptions.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.