Translation(s): English - Português (Brasil)

You MUST have a Debian unstable environment (physical/dual boot, virtual machine, container or a chroot with schroot) to create packages suitable for uploading to Debian. See instructions given below to setup Debian Sid. You can use lxc, docker or a virtual machine for development.

Note: The target audience is people just discovering Debian.

Readers note: This page lists 7 different approaches. It doesn't list 7 steps of one approach. You can choose any one approach at a time and follow the instructions under it. For example, if you want to use docker, there is no need to run the commands listed under Schroot/LXC/Virtual Machine.

If you want to use osx on x86_64 platform for packaging, refer to docker or virtual machines sections and for arm64 platform use UTM

Option 1: Systemd Nspawn and Debspawn

If your host system already has systemd as init system, this would be the best option for you.

Option 2: Schroot and Sbuild

If you already have a Debian stable or Debian-based distribution (Arch also has schroot package, though if you have a different distro, you need to check if it has schroot package), this option is best for you. If you are using a chroot for the first time, read this Wikipedia article to learn more

sudo apt install schroot debootstrap

Create root file system:

sudo mkdir -p /srv/chroot/debian-sid
sudo debootstrap sid /srv/chroot/debian-sid

If you have an unreliable internet connection, you may want to use apt-cacher-ng to store and reuses already downloaded debs when you retry the debootstrap command.

sudo apt install apt-cacher-ng auto-apt-proxy debian-archive-keyring

sudo auto-apt-proxy debootstrap sid /srv/chroot/debian-sid

Create a text file /etc/schroot/chroot.d/debian-sid with your favorite text editor (for example nano)

sudo nano /etc/schroot/chroot.d/debian-sid

and add the following lines in it:

# schroot chroot definitions.
# See schroot.conf(5) for complete documentation of the file format.
# Please take note that you should not add untrusted users to
# root-groups, because they will essentially have full root access
# to your system.  They will only have root access inside the chroot,
# but that's enough to cause malicious damage.
# The following lines are examples only.  Uncomment and alter them to
# customise schroot for your needs, or create a new entry from scratch.
description=Debian Sid for building packages suitable for uploading to Debian
users=<your username>

Where <your username> is an underprivileged user on your host system.

To get root shell use,

sudo schroot -c debian-sid

W: Failed to change to directory '/ ... is ok.

apt-get update && apt-get install <some-package>

To get normal user shell (run schroot as normal user),

schroot -c debian-sid

Error: pkg: unrecoverable fatal error, aborting: unknown system group 'apt-cacher-ng' in statoverride file

If you encountered this error, follow these steps ( this should be done inside chroot ) to remove it

1. Open "/var/lib/dpkg/statoverride"

nano /var/lib/dpkg/statoverride

2. Remove this line: "root apt-cacher-ng 640 /etc/apt-cacher-ng/security.conf" from the file and save it.

sbuild is a convenience wrapper script of schroot to build package under specified chroot such as unstable. See sbuild.

Note: You will need separate chroots for schroot (local development) and sbuild (clean build). Both schroot and sbuild should be setup on the host system (don't try to setup sbuild inside schroot).

Configuring locales

After you have set up the chroot, you also need to enable default locale of your host in the chroot as well.

To do this, go to the chroot

sudo schroot -c debian-sid

And run as root user in chroot:

# apt install locales
# dpkg-reconfigure locales

Now configure your locales according to the instructions on the screen.

Option 3: LXC

If you have trouble setting it up, skip this section and see docker section below.

If you already setup a sid development environment using one of the methods given above, you can skip this step.

Option 4: Docker

If you already setup a sid development environment using one of the methods given above, you can skip this step.

Option 5: Virtual Machine

If you already set up a sid development environment using one of the methods given above, you can skip this step.

Option 6: Direct/Bare metal install

You can also install Debian unstable in your machine under dual boot configuration or even replacing existing OS. See DebianUnstable

Option 7: Window Subsystem for Linux (WSL 2)

If you already set up a sid development environment using one of the methods given above, you can skip this step.

Debian unstable can also be installed in your local Windows OS machine using WSL2 (install info).

Note that this requires you be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11. See installing WSL2.

The installed WSL2 doesn't come with an "out of the box" setup for schroot. You will need to setup schroot (from Option 2) after installing a Debian distro on WSL2.