2012-01-15 13:14:40 -05:00
---
2021-03-13 13:06:18 -05:00
lang: en
2015-04-10 16:17:45 -04:00
layout: doc
2021-06-16 22:56:25 -04:00
permalink: /doc/qubes-builder/
2015-10-11 03:04:59 -04:00
redirect_from:
2015-10-28 18:14:40 -04:00
- /en/doc/qubes-builder/
2015-10-11 03:04:59 -04:00
- /doc/QubesBuilder/
- /wiki/QubesBuilder/
2021-03-13 13:06:18 -05:00
ref: 64
2021-07-08 21:06:41 -04:00
title: Qubes builder
2012-01-15 13:14:40 -05:00
---
2024-03-03 05:19:40 -05:00
< div class = "alert alert-warning" role = "alert" >
< i class = "fa fa-exclamation-circle" > < / i >
< b > Note:< / b > These instructions concern the older Qubes builder (v1). It supports
2024-06-12 05:19:49 -04:00
only building Qubes 4.2 or earlier.< br > The build process has been completely rewritten in < a href = "https://github.com/QubesOS/qubes-builderv2/" > qubes-builder v2< / a > . This can be used for building Qubes R4.2 and later, and all related components.
2024-03-03 05:19:40 -05:00
< / div >
2019-04-06 13:18:53 -04:00
**Note: See [ISO building instructions ](/doc/qubes-iso-building/ ) for a streamlined overview on how to use the build system.**
2017-04-27 13:03:43 -04:00
2012-01-15 13:14:40 -05:00
2015-04-21 08:41:23 -04:00
We have a fully automated build system for Qubes, that downloads, builds and
packages all the Qubes components, and finally should spit out a ready-to-use
2020-10-09 20:29:43 -04:00
installation ISO, all in a [secure ](/news/2016/05/30/build-security/ ) way.
2012-01-15 13:14:40 -05:00
2019-07-01 10:28:29 -04:00
In order to use it, you should use an rpm-based distro, like Fedora :), and should ensure the following packages are installed:
2012-01-15 13:14:40 -05:00
2021-03-13 12:03:23 -05:00
- sudo
- gnupg
- git
- createrepo
- rpm-build
2023-01-24 09:38:24 -05:00
- dnf-plugins-core
2021-03-13 12:03:23 -05:00
- make
- wget
- rpmdevtools
- python3-sh
- dialog
- rpm-sign
- dpkg-dev
- debootstrap
- python3-pyyaml
- devscripts
- perl-Digest-MD5
- perl-Digest-SHA
2012-01-15 13:14:40 -05:00
2019-07-01 10:28:29 -04:00
Usually you can install those packages by just issuing:
2012-01-15 13:14:40 -05:00
2021-03-13 12:03:23 -05:00
```shell
sudo dnf install gnupg git createrepo rpm-build make wget rpmdevtools python3-sh dialog rpm-sign dpkg-dev debootstrap python3-pyyaml devscripts perl-Digest-MD5 perl-Digest-SHA
```
2012-01-15 13:14:40 -05:00
2019-07-01 10:28:29 -04:00
The build system creates build environments in chroots and so no other packages are needed on the host.
All files created by the build system are contained within the qubes-builder directory.
The full build requires some 25GB of free space, so keep that in mind when deciding where to place this directory.
2012-01-15 13:14:40 -05:00
2019-07-01 10:28:29 -04:00
The build system is configured via builder.conf file.
You can use the setup.sh script to create and modify this file.
Alternatively, you can copy the provided default builder.conf, and modify it as needed, e.g.:
2012-02-06 05:22:41 -05:00
2021-03-13 12:03:23 -05:00
```shell
cp example-configs/qubes-os-master.conf builder.conf
# edit the builder.conf file and set the following variables:
NO_SIGN=1
```
2012-02-06 05:22:41 -05:00
2021-03-13 12:03:23 -05:00
One additional useful requirement is that 'sudo root' must work without any prompt, which is default on most distros (e.g. 'sudo bash' brings you the root shell without asking for any password).
2019-07-01 10:28:29 -04:00
This is important as the builder needs to switch to root and then back to user several times during the build process.
2012-01-15 13:14:40 -05:00
2021-06-26 17:34:47 -04:00
Additionally, if building with signing enabled (NO\_SIGN is not set), you must adjust `\~/.rpmmacros` file so that it points to the GPG key used for package signing, e.g.:
2012-02-06 05:22:41 -05:00
2021-03-13 12:03:23 -05:00
```bash
%_signature gpg
%_gpg_path /home/user/.gnupg
%_gpg_name AC1BF9B3 # < -- Key ID used for signing
```
2012-02-06 05:22:41 -05:00
2019-07-01 10:28:29 -04:00
It is also recommended that you use an empty passphrase for the private key used for signing.
Contrary to a popular belief, this doesn't affect your key or sources security -- if somebody compromised your system, then the game is over anyway, whether you have used an additional passphrase for the key or not.
2012-02-06 05:22:41 -05:00
2019-07-01 10:28:29 -04:00
So, to build Qubes you would do:
2012-01-15 13:14:40 -05:00
2021-03-13 12:03:23 -05:00
```shell
# Import the Qubes master key
gpg --recv-keys 0xDDFA1A3E36879494
# Verify its fingerprint, set as 'trusted'.
# This is described here:
# https://www.qubes-os.org/doc/VerifyingSignatures
wget https://keys.qubes-os.org/keys/qubes-developers-keys.asc
gpg --import qubes-developers-keys.asc
2022-03-16 08:38:12 -04:00
git clone https://github.com/QubesOS/qubes-builder.git qubes-builder
2021-03-13 12:03:23 -05:00
cd qubes-builder
# Verify its integrity:
git tag -v `git describe`
cp example-configs/qubes-os-master.conf builder.conf
# edit the builder.conf file and set the following variables:
# NO_SIGN="1"
# Download all components:
make get-sources
2021-04-17 04:31:11 -04:00
# And now to build all Qubes RPMs (this will take a few hours):
2021-03-13 12:03:23 -05:00
make qubes
# ... and then to build the ISO
make iso
```
2012-01-15 13:14:40 -05:00
And this should produce a shiny new ISO.
You can also build selected component separately. Eg. to compile only gui virtualization agent/daemon:
2021-03-13 12:03:23 -05:00
```shell
2021-03-28 14:58:39 -04:00
make gui-daemon
2021-03-13 12:03:23 -05:00
```
2012-01-15 13:14:40 -05:00
2021-03-13 12:03:23 -05:00
You can get a full list from make help.
2012-08-15 14:37:37 -04:00
2021-03-13 12:03:23 -05:00
## Making customized build
2012-08-15 14:37:37 -04:00
2012-08-21 13:09:15 -04:00
### Manual source modification
2012-08-15 14:37:37 -04:00
2019-07-01 10:28:29 -04:00
You can also modify sources somehow if you wish.
Here are some basic steps:
2012-08-15 14:37:37 -04:00
2021-03-13 12:03:23 -05:00
1. Download qubes-builder as described above (if you want to use marmarek's branches, you should also download qubes-builder from his repo - replace 'QubesOS' with 'marmarek' in above git clone command)
2. Edit builder.conf (still the same as above), some useful additions:
- You can also set GIT\_PREFIX="marmarek/qubes-" to use marmarek's repo instead of "mainstream" - it contains newer (but less tested) versions
3. Download unmodified sources
2012-08-15 14:37:37 -04:00
2021-03-13 12:03:23 -05:00
```shell
make get-sources
```
2012-08-15 14:37:37 -04:00
2021-03-13 12:03:23 -05:00
4. **Make your modifications here**
2012-08-15 14:37:37 -04:00
2021-03-13 12:03:23 -05:00
5. Build the Qubes
2019-07-01 10:28:29 -04:00
`make qubes` actually is just meta target which builds all required
components in correct order. The list of components is configured in
2015-04-21 08:41:23 -04:00
builder.conf. You can also check the current value at the end of `make
2021-03-13 12:03:23 -05:00
help`, or using `make build-info` .
2012-08-15 14:37:37 -04:00
2015-10-07 16:33:16 -04:00
6. `get-sources` is already done, so continue with the next one. You can skip `sign-all` if you've disabled signing
2021-03-13 12:03:23 -05:00
```shell
make vmm-xen core-admin linux-kernel gui-daemon template desktop-linux-kde installer-qubes-os manager linux-dom0-updates
```
2012-08-15 14:37:37 -04:00
2021-03-13 12:03:23 -05:00
7. build iso installation image
2012-08-15 14:37:37 -04:00
2021-03-13 12:03:23 -05:00
```shell
make iso
```
2012-08-22 06:31:11 -04:00
2019-02-12 00:36:39 -05:00
### Use pre-built Qubes packages
2019-02-10 16:48:07 -05:00
2019-07-01 10:28:29 -04:00
For building just a few selected packages, it's very useful to download pre-built qubes-specific dependencies from `{yum,deb}.qubes-os.org` .
2019-02-12 00:36:39 -05:00
This is especially true for `gcc` , which takes several hours to build.
2019-02-10 16:48:07 -05:00
2019-02-12 00:36:39 -05:00
Before creating the `chroot` , add this to your `builder.conf` :
2019-02-10 16:48:07 -05:00
2021-03-13 12:03:23 -05:00
```
USE_QUBES_REPO_VERSION = $(RELEASE)
```
2019-02-10 16:48:07 -05:00
2019-02-12 00:36:39 -05:00
It will add the 'current' Qubes repository to your `chroot` environment.
2019-04-06 19:32:28 -04:00
Next, specify which components (`gcc`, for example) you want to download instead of compiling:
2019-04-06 19:18:48 -04:00
2021-03-13 12:03:23 -05:00
```
COMPONENTS := $(filter-out gcc,$(COMPONENTS))
```
2019-04-06 19:18:48 -04:00
Alternatively, edit the actual COMPONENTS list which is defined in the included version-dependent config from example-configs (see series of include directives near the beginning of `builder.conf` ).
This way, you can build only the packages in which you are interested.
2019-02-12 00:36:39 -05:00
If you also want to use the 'current-testing' repository, add this to your configuration:
2019-02-10 16:48:07 -05:00
2021-03-13 12:03:23 -05:00
```
USE_QUBES_REPO_TESTING = 1
```
2019-02-10 16:48:07 -05:00
2019-07-01 10:28:29 -04:00
In the case of an existing `chroot` , for mock-enabled builds, this works immediately because `chroot` is constructed each time separately.
2019-02-12 00:36:39 -05:00
For legacy builds, it will not add the necessary configuration into the build environment unless a specific builder change or configuration would force rebuilding chroot.
2019-02-10 17:31:53 -05:00
2019-02-12 00:36:39 -05:00
Also, once enabled, disabling this setting will not disable repositories in relevant chroots.
2019-07-01 10:28:29 -04:00
And even if it did, there could be some leftover packages installed from those repos (which may or may not be desirable).
2021-03-13 12:03:23 -05:00
**Note**
2019-07-01 10:28:29 -04:00
If you are building Ubuntu templates, you cannot use this option.
This is because Qubes does not provide official packages for Ubuntu templates.
2019-02-10 16:48:07 -05:00
2021-03-13 12:03:23 -05:00
## Code verification keys management
2014-04-30 09:47:25 -04:00
2019-07-01 10:28:29 -04:00
[QubesBuilder ](/doc/qubes-builder/ ) by default verifies signed tags on every downloaded code.
Public keys used for that are stored in `keyrings/git` .
By default Qubes developers' keys are imported automatically, but if you need some additional keys (for example your own), you can add them using:
2014-04-30 09:47:25 -04:00
2021-03-13 12:03:23 -05:00
```shell
GNUPGHOME=$PWD/keyrings/git gpg --import /path/to/key.asc
GNUPGHOME=$PWD/keyrings/git gpg --edit-key ID_OF_JUST_IMPORTED_KEY
# here use "trust" command to set key fully or ultimately trusted - only those keys are accepted by QubesBuilder
```
2014-04-30 09:47:25 -04:00
2014-05-02 14:37:45 -04:00
All Qubes developers' keys are signed by the Qubes Master Signing Key (which is set as ultimately trusted key), so are trusted automatically.
2014-04-30 09:47:25 -04:00
2014-05-02 14:37:45 -04:00
If you are the owner of Master key and want to revoke such signature, use the `revsig` gpg key edit command and update the key in qubes-developers-keys.asc - now the key will be no longer trusted (unless manually set as such).
2020-01-16 12:53:12 -05:00
2021-03-13 12:03:23 -05:00
## Further information
2020-01-16 12:53:12 -05:00
For advanced [QubesBuilder ](/doc/qubes-builder/ ) use, and preparing sources, take a look at [QubesBuilderDetails ](/doc/qubes-builder-details/ ) page, or [QubesBuilder's doc directory ](https://github.com/marmarek/qubes-builder/tree/master/doc ).