Template:Build Documentation apt-cache

From Whonix
Jump to navigation Jump to search

Using an apt cache will greatly improve build speed when building several times in a row (e.g. when debugging, during development). Whonix build script sets up an apt cache by default.

If you are interested in a torified apt-cacher-ng or host apt-cacher-ng, click on Expand on the right.

torified apt-cacher-ng

Notes:

  • The following torified apt-cacher-ng setup only has to be applied, if you are building using onion apt sources using --connection onion.
  • When building inside Whonix-Workstation, this is not required.

Note, this neither torifies all of the build script's connections nor hides Tor from your ISP! See Build Anonymity.

The goal of this is to torify apt-cacher-ng using torsocks so it will be able to connect to onions.

Note: This is currently broken. No fix available. Undocumented.

1. Install apt-cacher-ng, torsocks and tor.

sudo apt install apt-cacher-ng torsocks tor

2. Create folder apt-cacher-ng systemd drop-in folder /lib/systemd/system/apt-cacher-ng.service.d.

sudo mkdir -p /lib/systemd/system/apt-cacher-ng.service.d

3. Open file /lib/systemd/system/apt-cacher-ng.service.d/50_user.conf in an editor with administrative ("root") rights.

1 Select your platform.

Non-Qubes-Whonix

2 Notes.

  • Sudoedit guidance: See Kicksecure logo Open File with Root RightsOnion network Logo for details on why using sudoedit improves security and how to use it.
  • Editor requirement: Close Featherpad (or the chosen text editor) before running the sudoedit command.

3 Open the file with root rights.

sudoedit /lib/systemd/system/apt-cacher-ng.service.d/50_user.conf

Qubes-Whonix

2 Notes.

  • Sudoedit guidance: See Kicksecure logo Open File with Root RightsOnion network Logo for details on why using sudoedit improves security and how to use it.
  • Editor requirement: Close Featherpad (or the chosen text editor) before running the sudoedit command.
  • Template requirement: When using Qubes-Whonix, this must be done inside the Template.

3 Open the file with root rights.

sudoedit /lib/systemd/system/apt-cacher-ng.service.d/50_user.conf

4 Notes.

  • Shut down Template: After applying this change, shut down the Template.
  • Restart App Qubes: All App Qubes based on the Template need to be restarted if they were already running.
  • Qubes persistence: See also Kicksecure logo Qubes PersistenceOnion network Logo
  • General procedure: This is a general procedure required for Qubes and is unspecific to Qubes-Whonix.

Others and Alternatives

2 Notes.

  • Example only: This is just an example. Other tools could achieve the same goal.
  • Troubleshooting and alternatives: If this example does not work for you, or if you are not using Whonix, please refer to Open File with Root Rights.

3 Open the file with root rights.

sudoedit /lib/systemd/system/apt-cacher-ng.service.d/50_user.conf

4. Add. [1]

[Service] ExecStart= ExecStart=torsocks /usr/sbin/apt-cacher-ng SocketPath=/run/apt-cacher-ng/socket -c /etc/apt-cacher-ng ForeGround=1

5. Save.

6. Reload systemd.

sudo systemctl daemon-reload

7. Restart apt-cacher-ng.

sudo systemctl restart apt-cacher-ng

8. Done.

The process of torification of apt-cacher-ng has been completed.

9. Broken!

/etc/tor/torsocks.conf add:

AllowInbound 1 AllowOutboundLocalhost 1

But this is also insufficient.

sudo journalctl -f -u apt-cacher-ng

shows errors:

WARNING torsocks[17645]: Config file not found: /etc/tor/torsocks.conf. Using default for Tor (in config_file_read() at config-file.c:583)
Couldn't listen on socket: Operation not permitted
Error creating socket: Function not implemented

No fix available. Help welcome.

host apt-cacher-ng

This is probably only useful for developers. Most users will not need the complexity of an apt-cacher-ng running outside of the VM which runs derivative-maker or on another computer.

Be sure to have a firewall, so the whole internet cannot use the apt-cacher-ng service.

When building inside a non-Whonix VM, an apt cache can be used on the host. In that case, adjust the IP accordingly and manually test that it is reachable. When building inside a (Whonix) VM, just install the apt cache inside the VM and point to a localhost apt cache.

Prepend REPO_PROXY=http://127.0.0.1:3142archive.org iconarchive.today icon before the build command.

Replace the IP 127.0.0.1 with the IP address of your host. For security reasons, this should only be done over LAN and not over the internet.

sudo REPO_PROXY=http://127.0.0.1:3142 ./derivative-maker ...

Footnotes

[edit]
    • The first ExecStart= is to disable the default ExecStart in /lib/systemd/system/apt-cacher-ng.service.
    • This is based on /lib/systemd/system/apt-cacher-ng.service .
    • Only torsocks is prepended in front of /usr/sbin/apt-cacher-ng
    • No other changes.
Notification image

We believe security software like Whonix needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 14 year success story and maybe DONATE!