Build Configuration

From Whonix
Jump to navigation Jump to search

Non-Qubes-Whonix Build Configuration. APT Repository, Onion Sources, APT Cache, VM Settings, Skip Steps, Source Code Changes

Introduction[edit]

Usually the build configuration does not need to be changed. Whonix built from source code comes with safe defaults. The Derivative APT Repository will not be used.

The most interesting build configurations are documented in the following chapters.

If build configurations were used earlier, it might be better to delete the build configuration folder. A few example filenames may have changed since the last build.

sudo rm -r /etc/buildconfig-dist.d

/etc/buildconfig-dist.d is a modular flexible .d style configuration folder.

Less popular build configurations are documented in the derivative-maker buildconfig.d folder and on the Dev/Source_Code_Intro#Build_Configuration page, but it is less user-friendly.

To avoid typos, it is best to copy and paste text when creating build configuration files. Take care that editors do not capitalize variable names which are supposed to be lower case during copy and paste procedures.

Note: All of the following build configuration steps are optional.

Platforms Choice[edit]

Advanced users can create 32-bit instead of 64-bit builds.

If you are interested, click on Expand on the right.

  • Whonix is 64-bit by default. [1] [2]

To build Whonix 32-bit, add the following build parameter.

--arch i386
  • kFreeBSD is entirely untested and most likely needs additional work (see footnotes). [3]
  • Whonix for arm64 development discussion (working and tested with QEMU on Mac M1):
--arch arm64
  • Generally speaking, 64-bit builds cannot be created if running a 32-bit host kernel. See footnotes. [4] [5]

Derivative APT Repository[edit]

Non-Qubes-Whonix:
Whonix APT Repository is disabled by default [6] for builds from source code for reasons of Trust. Users can decide to update Whonix Debian packages by building them from source code (greater security). Alternatively, Whonix APT repository can be enabled right after building or after booting the build for the first time (greater convenience) using Whonix repository tool. To use the latter method which sacrifices security for convenience, click on Expand on the right side.

Do you want to opt-in Whonix APT Repository?

The easy way to add Whonix stable repository the following command line option can be used.

--repo true

Other settings can be set using an environment variable or build configuration. Below are examples using an environment variable.

DERIVATIVE_APT_REPOSITORY_OPTS='--enable --repository stable' DERIVATIVE_APT_REPOSITORY_OPTS='--enable --repository testers' DERIVATIVE_APT_REPOSITORY_OPTS='--enable --repository developers' DERIVATIVE_APT_REPOSITORY_OPTS='--enable --codename bookworm'

Add an environment variable as one normally does on that specific Linux platform. For example, to enable the Whonix stable repository during build, you could set DERIVATIVE_APT_REPOSITORY_OPTS by interjecting it between sudo and the ./derivative-maker command. Below is an example. Do not use [...]. Replace it with other chosen build parameters (such as --build, --target etc.) after ./derivative-maker.

sudo DERIVATIVE_APT_REPOSITORY_OPTS='--enable --repository stable' ./derivative-maker [...]

APT Onion Build Sources[edit]

For better build security, you can also use onions apt sources for building Whonix.

If you are interested, click on Expand on the right.

This does not ensure all of Whonix's build process will be torified! See Build Anonymity.

--connection onion

Torified or Host APT Cache[edit]

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 root rights.

Non-Qubes-Whonix

This box uses sudoedit for better security.

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

Qubes-Whonix

NOTES:

  • When using Qubes-Whonix, this needs to be done inside the Template.

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

  • After applying this change, shutdown the Template.
  • All App Qubes based on the Template need to be restarted if they were already running.
  • This is a general procedure required for Qubes and unspecific to Qubes-Whonix.

Others and Alternatives

  • This is just an example. Other tools could achieve the same goal.
  • If this example does not work for you or if you are not using Whonix, please refer to this link.

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

4. Add. [7]

[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 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 ...

VM Settings[edit]

Various VM settings can optionally be changed.

tested: Virtual RAM, virtual video RAM, hard drive size

untested: filesystem, hostname, password This is only relevant for VM builds.

Several examples are below. Values can be changed to suit user preferences.

VirtualBox's --vmsize option (virtual RAM).

--vmram 128

VirtualBox's --vram option (virtual video RAM).

--vram 128

grml-debootstrap's --vmsize option.

--vmsize 200G

grml-debootstrap'sarchive.org --filesystem option.

--filesystem ext4

grml-debootstrap's --hostname option. [8]

--hostname host

grml-debootstrap's --password option.

--os-password changeme

grml-debootstrap's --debopt option.

--debopt "--verbose"

Build Variables Changes[edit]

It is possible to add build configuration files snippets which can change build variables.

Build Configuration Folders:

You can drop configuration file either in:

  1. buildconfig.d or in
  2. /etc/buildconfig-dist.d
  3. ../buildconfig.d folder.

Files should have the file extension .conf.

Method 2. is recommended for users.

  1. Contains examples. It is more difficult to use. [9] Rather use the following.
  2. sudo mkdir --parents /etc/buildconfig-dist.d
  3. When /home/user/Whonix is your Whonix source folder, you could use /home/user/buildconfig.d as your Whonix build configuration folder. It is easier to use, since you don't have to git commit your build config files.

[10]

Below is an example how to use method 2.

sudo mkdir /etc/buildconfig-dist.d

Open file /etc/buildconfig-dist.d/50_user.conf in an editor with root rights.

Non-Qubes-Whonix

This box uses sudoedit for better security.

sudoedit /etc/buildconfig-dist.d/50_user.conf

Qubes-Whonix

NOTES:

  • When using Qubes-Whonix, this needs to be done inside the Template.

sudoedit /etc/buildconfig-dist.d/50_user.conf

  • After applying this change, shutdown the Template.
  • All App Qubes based on the Template need to be restarted if they were already running.
  • This is a general procedure required for Qubes and unspecific to Qubes-Whonix.

Others and Alternatives

  • This is just an example. Other tools could achieve the same goal.
  • If this example does not work for you or if you are not using Whonix, please refer to this link.

sudoedit /etc/buildconfig-dist.d/50_user.conf

Add. (Replace it with whatever build configuration variable you wish to set.)

Example 1.

export DERIVATIVE_APT_REPOSITORY_OPTS='--enable --repository stable'

Example 2.

export tbb_version=13.0.1

Save.

Done.

Build Variables[edit]

build results binary folder (derivative-binary) | binary_build_folder_dist | default: $HOMEVAR/derivative-binary

See #Build Variables Changes on how to set build variables.

Skip Steps[edit]

Advanced users can opt-in to skip certain build steps and/or Debian maintenance scripts (postinst, preinst, ...).

Skip Sanity Tests

Useful to speed up the build.

--sanity-tests false

Skipping Build Steps

export SKIP_SCRIPTS+=" 1300_create-raw-image "

Skipping Chroot and/or Postinst Scripts

export SKIP_SCRIPTS+=" dist-base-files.postinst "

Look at the file names and add them. export SKIP_SCRIPTS+=" another_file_name ". Do not forget empty spaces before and after ". [11]

Source Code Changes[edit]

If changes were made to the derivative-maker source code folder, it is the easiest to use the following build parameter.

Notes:

  • This is only required if changes were made to the derivative-maker source folder.
  • This is not required if only a customized build configuration was added to the /etc/buildconfig-dist.d folder.
--allow-uncommitted true

Or if not building from a git tag, it is the easiest to use the following build parameter.

--allow-untagged true

Otherwise, changes must be committed to git first, before creating a git tag.


Footnotes[edit]

  1. State of official 64-bit buildsarchive.org.
  2. Don't get confused by the term amd64. It runs on both, Intel and AMD. amd64 is only how Debian names the kernel. It works equally well on Intel and AMD.
  3. kFreeBSD (32-bit).
    --arch kfreebsd-i386 --kernel kfreebsd-image --headers kfreebsd-headers
    

    kFreeBSD (64-bit).

    --arch kfreebsd-amd64 --kernel kfreebsd-image --headers kfreebsd-headers
    
  4. https://github.com/grml/grml-debootstrap/pull/13archive.org
  5. In this case, try installing the packages linux-image-amd64 and linux-headers-amd64 on your host, then boot the amd64 kernel by choosing it in the boot menu. The whole system does not require re-installation; just be sure to boot with an amd64 kernel. Alternatively, consider to re-install your host using amd64.
  6. Since Whonix 7.3.3
    • 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.
  7. The anon-base-filesarchive.org package will change this later on.
  8. Since you would have to either:
    • A) git commit your build config files, OR,
    • B) See chapter source code changes below.
  9. This is because .. means "one level below this folder".
  10. We are expanding a bash array.

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 12 year success story and maybe DONATE!