Development environment¶
Pick your platform to set up a development environment:
Install dependencies:
Expand this section if you are on Ubuntu 22.04 (Jammy).
The conmon version that Podman uses and Ubuntu Jammy ships, has a bug that gets triggered by Dangerzone (more details in https://github.com/freedomofpress/dangerzone/issues/685). If you want to run Dangerzone from source, you are advised to install a patched conmon version. A simple way to do so is to enable our apt-tools-prod repo, just for the conmon package:
sudo cp ./dev_scripts/apt-tools-prod.sources /etc/apt/sources.list.d/
sudo cp ./dev_scripts/apt-tools-prod.pref /etc/apt/preferences.d/
The conmon package provided in the above repo was built with the following instructions. Alternatively, you can install a conmon version higher than v2.0.25 from any repo you prefer.
Install Poetry using pipx (recommended) and add it to your $PATH:
(See also a list of alternative installation methods)
After this, restart the terminal window so that the poetry command is in your $PATH.
Clone this repository:
Change to the dangerzone folder, and install the poetry dependencies:
Note: due to an issue with poetry, if it prompts for your keyring, disable the keyring with
keyring --disableand run the command again.
Dangerzone depends on some assets (think binaries and other resources) that should be downloaded in order to run. This can be done with the following command:
Run the following command to download the latest container image, or use a local one:
Run from source tree:
Create a .deb:
This builds both the dangerzone (slim) and dangerzone-full packages in a single run. The slim package does not contain the container.tar image (it will be downloaded on the first run), while dangerzone-full bundles the container image for offline or air-gapped installations.
Note:
container.tarmust be present inshare/before running this command, as it is required for thedangerzone-fullpackage. See the instructions above for how to download or build it.
Install dependencies:
sudo dnf install -y rpm-build podman python3 python3-devel python3-poetry-core \
pipx qt6-qtbase-gui
Install Poetry using pipx:
Clone this repository:
Change to the dangerzone folder, and install the poetry dependencies:
Note: due to an issue with poetry, if it prompts for your keyring, disable the keyring with
keyring --disableand run the command again.
Dangerzone depends on some assets (think binaries and other resources) that should be downloaded in order to run. This can be done with the following command:
Run the following command to download the latest container image, or use a local one:
Run from source tree:
Note
Prefer running the following command in a Fedora development environment, created by ./dev_script/env.py.
Create a .rpm:
This builds the dangerzone package, which doesn't contain the container.tar image (it will be downloaded on the first run).
To build the dangerzone-full package with the container bundled:
⚠️ Native Qubes support is in beta stage, so the instructions below require switching between qubes, and are subject to change.
If you want to build Dangerzone on Qubes and use containers instead of disposable qubes, please follow the instructions of Fedora / Debian instead.
Initial Setup¶
The following steps must be completed once. Make sure you run them in the specified qubes.
Overview of the qubes you'll create:
| qube | type | purpose |
|---|---|---|
| dz | app qube | Dangerzone development |
| dz-dvm | app qube | offline disposable template for performing conversions |
| fedora-43-dz | template | template for the other two qubes |
In dom0:¶
The following instructions require typing commands in a terminal in dom0.
-
Create a new Fedora template (
fedora-43-dz) for Dangerzone development:💡 Alternatively, you can use your base Fedora 43 template in the following instructions. In that case, skip this step and replace
fedora-43-dzwithfedora-43in the steps below. -
Create an offline disposable template (app qube) called
dz-dvm, based on thefedora-43-dztemplate. This will be the qube where the documents will be sanitized: -
Create an app qube (
dz) that will be used for Dangerzone development and initiating the sanitization process:qvm-create --class AppVM --label red --template fedora-43-dz dz qvm-volume resize dz:private $(numfmt --from=auto 20Gi)💡 Alternatively, you can use a different app qube for Dangerzone development. In that case, replace
dzwith the qube of your choice in the steps below.In the commands above, we also resize the private volume of the
dzqube to 20GiB, since you may need some extra storage space when developing on Dangerzone (e.g., for container images, Tesseract data, and Python virtualenvs). -
Add an RPC policy (
/etc/qubes/policy.d/50-dangerzone.policy) that will allow launching a disposable qube (dz-dvm) when Dangerzone converts a document, with the following contents:
In the dz app qube¶
In the following steps you'll setup the development environment and install a dangerzone build. This will make development faster, since the server code is loaded dynamically on each run, instead of having to build and install a server package every time you want to test it.
-
Follow the Fedora installation instructions up until
poetry run mazette install. -
Build the Dangerzone RPM packages for Qubes:
-
Copy the produced
.rpmfiles intofedora-43-dz:
In the fedora-43-dz template¶
-
Install the
.rpmpackages you just copied, in order to get the Dangerzone dependencies: -
Shutdown the
fedora-43-dztemplate.
Developing Dangerzone¶
From here on, developing Dangerzone is similar to Fedora. The only differences are that you need to set the environment variable QUBES_CONVERSION=1 when you wish to test the Qubes conversion. Run the following commands on the dz development qube:
export DANGERZONE_DEV=1 QUBES_CONVERSION=1
# run the CLI
poetry run dangerzone-cli --help
# run the GUI
poetry run dangerzone
And when creating a .rpm you'll need to enable the --qubes flag.
Note
Prefer running the following command in a Fedora development environment, created by ./dev_script/env.py.
Tip
For faster changes to the server side components, you can let Dangerzone know about the location of dangerzone-image repo:
From there on, you can make changes in the dangerzone-image repo, and they will be mirrored to the disposable qube through the dz.ConvertDev RPC call.
The only reason to build a new Qubes RPM and install it in the fedora-43-dz template for development is if:
- The project requires new server-side components.
- The code for
qubes/dz.ConvertDevneeds to be updated.
Install the latest version of Python 3.13 from python.org, and make sure /Library/Frameworks/Python.framework/Versions/3.13/bin is in your PATH.
Clone this repository:
Install Python dependencies:
Install Homebrew dependencies:
Dangerzone depends on some assets (think binaries and other resources) that should be downloaded in order to run. This can be done with the following command:
Make sure to set the DANGERZONE_DEV env variable for development:
Run the following command to download the latest container image, or use a local one:
Run from source tree:
To create an app bundle, use the build-app.py script:
If you want to build for distribution, you'll need a codesigning certificate, and then run:
The output is in the dist folder.
Install the latest version of Python 3.13 (64-bit) from python.org. Make sure to check the "Add Python 3.13 to PATH" checkbox on the first page of the installer.
Install Microsoft Visual C++ 14.0 or greater. Get it with "Microsoft C++ Build Tools" and make sure to select "Desktop development with C++" when installing.
Install git from here.
Install poetry.
Open Windows "Terminal" application and run all remaining commands there.
Clone this repository:
Change to the dangerzone folder, and install the poetry dependencies:
Dangerzone depends on some assets (think binaries and other resources) that should be downloaded in order to run. This can be done with the following command:
Run the following command to download the latest container image, or use a local one:
After that you can launch dangerzone during development with:
# run the CLI
$Env:DANGERZONE_DEV = 1; poetry run dangerzone-cli --help
# run the GUI
$Env:DANGERZONE_DEV = 1; poetry run dangerzone
If you want to build the Windows installer¶
Install .NET SDK version 6 or later. Then, open a terminal and install the latest version of WiX Toolset .NET tool v5 with:
Install the WiX UI extension. You may need to open a new terminal in order to use the newly installed wix .NET tool:
Important
To avoid compatibility issues, ensure the WiX UI extension version matches the version of the WiX Toolset.
Run wix --version to check the version of WiX Toolset you have installed and replace 5.x.y with the full version number without the Git revision.
If you want to sign binaries with Authenticode¶
You'll need a code signing certificate.
To make a .exe¶
Open a command prompt, cd into the dangerzone directory, and run:
In build\exe.win32-3.13\ you will find dangerzone.exe, dangerzone-cli.exe, and all supporting files.
To build the installer¶
Note that you must have a codesigning certificate installed in order to use the install\windows\build-app.bat script, because it codesigns dangerzone.exe, dangerzone-cli.exe and Dangerzone.msi.
When you're done you will have dist\Dangerzone.msi.
Using a local container image¶
It is possible to use a local image for testing, provided you store it under share/container.tar. If the local image is not signed, you can bypass signature checks with:
export DANGERZONE_BYPASS_SIG_CHECKS=1 # On Linux and macOS
set DANGERZONE_BYPASS_SIG_CHECKS=1 # On Windows
To switch back to the original behavior, remove the environment variable: