Sunday 20 November 2016

LEDE project: prevent having to re-flash the latest nightly build every time you need a new package

I really admire the LEDE project and the reasons why they decided that it was necessary to fork openwrt and continue in a way that they saw fit. Unfortunately as they only recently started (somewhere about May 2016) there are no official releases yet and this means that there are only nightly builds.

This 'guide' will work for both openwrt and lede nightly builds. The reason is that every night the packages and dependencies get rebuilt and packages that rely on a specific kernel/kernel module version can not be installed at a later moment (when the new nightly build replaces the previous one online). To solve this we can make a copy of all packages for a given nightly build. In a nutshell:

  1. Download the firmware file from the LEDE/openwrt site
  2. Run the commands that download all packages from the LEDE/openwrt site
  3. Install/upgrade to recent build
  4. Run a local webserver
  5. Modify the package repository URL's to match your local webserver

So lets get started!

Download the firmware file

This is easy and probably something you've done before. If not: check out the architecture of your router and try to find whether openwrt/LEDE already supports your router. If they don't you're out of luck for now. For this guide I'll be using the TP-Link Archer C7 which is contained in the ar71xx builds of both LEDE and openwrt. 

Run these commands that download all packages from the LEDE/openwrt site

wget -m --no-parent -e robots=off https://downloads.lede-project.org/snapshots/targets/ar71xx/generic/packages/
wget -m --no-parent -e robots=off http://downloads.lede-project.org/snapshots/packages/mips_24kc/base
wget -m --no-parent -e robots=off http://downloads.lede-project.org/snapshots/packages/mips_24kc/luci
wget -m --no-parent -e robots=off http://downloads.lede-project.org/snapshots/packages/mips_24kc/packages
wget -m --no-parent -e robots=off http://downloads.lede-project.org/snapshots/packages/mips_24kc/routing
wget -m --no-parent -e robots=off http://downloads.lede-project.org/snapshots/packages/mips_24kc/telephony

The commands above should download all the packages that LEDE references within it's "software distribution feeds". For openwrt all references to lede-project.org should be replaced with openwrt.org. If you already have a version of openwrt/LEDE installed you can just make sure that you wget every of the URL's in the list instead of the URL's I provided above. Checkout 'System > Software' => Configuration tab for a list of feeds used by the current firmware.

After downloading the feeds you might want to move the contents of the downloads.lede-project.org/snapshots folder to a new folder. I'm using /Users/flix/Documens/lede-snapshots here as the /Users folder can be shared with Docker containers by default if you're using macOS. Not sure about how permissive Linux is in this regard.

Install/upgrade to the downloaded build

After downloading the packages you can install the firmware. To be sure that your 'offline' package feeds actually will work I suggest not (re)installing any of your packages just yet. Just the firmware.

Run a local webserver

Of course, the goal of downloading the packages is to serve them at a later moment in time. Let's get it started:

docker run --name nginx -v /Users/flix/Documents/lede-snapshots:/usr/share/nginx/html:ro -d -p 8080:80 nginx

The above command will pull an nginx container from docker hub and tell it to serve your local folder (containing the packages) on port 8080 from the machine you're running on. Of course you can copy the files to your home server, NAS, raspberry pi or any other device that can run a web server permanently, but for my use case (occasional desire to try out a package) I find spinning up a docker container the easiest.

Modify the package feed URLs

So now we can just swap the downloads.lede-project.org/snapshots part with the IP address of our webserver. This is it! You can now install packages from your local package mirror! Good luck!



No comments:

Post a Comment