Sometimes you just dont have any internet...

A tweet on twitter led me to this discussion on Github.

The short version of it is that how could you install the Mu editor onto a fleet of Raspeberry Pi in a school classroom environment where the network can not or will not allow them to connect to the wider internet.

One option could be to take the Pi's home to update but this would get out of hand quite quickly.

Another option would be to use one of the powers of APT. Using this power APT can generate a list of urls for the required packages which can then be downloaded elsewhere.

How?

  • Connect the Pi upto a network connection. This could be a phone hotspot...this is to update the package lists and shouldn't use a lot of data .
  • Open a terminal and switch to root.
  • Type apt-get update and let the the package lists update
  • Type apt-get --print-uris --yes upgrade | grep ^' | cut -d' -f2 >downloads.list and press enter. This will generate a list of urls for the required packages and dependencies which are wrote into the downloads.list file. This only needs to be done on the first Raspberry Pi.
  • Copy downloads.list onto a USB pendrive or similar.
  • Take pendrive to system that does have internet access.

* Connect pendrive and find the downloads.list * If your using a *nix based system then you can simply use:

wget --input-file <path to downloads.list>
in the terminal to download the relevant .deb files (Windows users will need to find and alternative to wget).

It's a good idea to run this in its own directory to contain the downloaded files.

  • Once they have downloaded, copy them back onto the pendrive.

  • Plug the pendrive back into the Pi and copy the downloaded .deb files into the APT archive: cp <path to downloaded deb files> /var/cache/apt/archives
  • Re-run apt-get upgrade and the Pi should start to update the packages
  • Once complete, move the pendrive to the next Pi and copy the files into /var/cache/apt/archives followed by running sudo apt-get update && sudo apt-get upgrade in the terminal.

If your after just a single package then swap:

apt-get --print-uris --yes upgrade | grep ^' | cut -d' -f2 >downloads.list

for

apt-get --print-uris --yes <name of package> | grep ^' | cut -d' -f2 >downloads.list

and follow the remaining steps.

Further Information

If your lucky enough to be in a situation where the Pi are permanently connected over a wired network then consider the use of PiNet which allows you to centralise user accounts, file storage and and administration of the Pi.

Extract from man apt-get:

--print-uris:
Instead of fetching the files to install their URIs are printed. Each URI will have the path, the destination file name, the size and the expected MD5 hash. Note that the file name to write to will not always match the file name on the remote site! This also works with the source and update commands. When used with the update command the MD5 and size are not included, and it is up to the user to decompress any compressed files. Configuration Item: APT::Get::Print-URIs.

Tux Radar article