RaspberryPi: Avoid interferring HTTP transparent proxies for APT

Tj

2017-09-23

Alternative methods for repairing package lists for RaspberryPi (armhf) devices using Raspbian where apt's fetching of packages is being broken by a transparent HTTP proxy operated by the ISP.

Assuming we have two RasPi's, respectively using the Jessie and Stretch Debian/Raspbian releases, and that both have corrupted/unusuable APT package lists.

I've provided two options here for attempting to restore them to working order:

  1. Install replacement packages files from TAR archives
  2. Install apt-transport-tor package and it's dependencies

In both cases I've downloaded all the required files and packaged them in a TAR archive compressed with bzip2.

Additionally this web-server is using HTTPS so any transparent HTTP proxy cannot interfere with transfers.

Install Replacement Package Files

In both cases this fetches the archive I built for the release and extracts the files to the RasPi's /var/lib/apt/lists/ directory.

Jessie

wget https://iam.tj/projects/raspi/jessie-var-lib-apt-lists.tar.bzip2
sudo tar -xvjf jessie-var-lib-apt-lists.tar.bzip2 -C /

Stretch

wget https://iam.tj/projects/raspi/stretch-var-lib-apt-lists.tar.bzip2
sudo tar -xvjf stretch-var-lib-apt-lists.tar.bzip2 -C /

After this:

sudo apt-get update

APT should not try to replace those files as they're current. If the archive files on the server are updated then apt will fetch replacements and that may well break APT once again.

Install apt-transport-tor

This may be preferable since it will permanently fix the transparent proxy issue and allow APT to fetch the package files unmolested. I've installed apt-transport-tor locally and observed the dependencies it also installed then put all those packages in a single TAR archive.

wget https://iam.tj/projects/raspi/apt-transport-tor-packages.tar.bzip2
tar -xvjf apt-transport-tor-packages.tar.bzip2
sudo dpkg -iR apt-transport-tor

This will fetch the archive, extract it to a local directory, and then tell dpkg to install all the .deb packages in that directory.

Once the packages are installed you need to ensure that the /etc/apt/sources.list uses the tor+http protocol method:

for list in /etc/apt/sources.list{,.d/*}; do sudo sed -i 's/ http:/ tor+http:/g' $list; done
sudo apt-get update

At this point the system should fetch and install valid package files over TOR without problems and continue to do so.

These apt-transport-tor packages I've included are from the Jessie release but should install on Stretch. Once working (on Stretch) you can upgrade them to the latest with

sudo apt-get dist-upgrade

I hope these options help you solve what is a complicated issue when you've not got an alternative link to the Internet.


This document created using:

pandoc --toc -s -t html5 -o README.html README.md