Change to the newly created directory by running `cd /srv/chroots`
3. Use sbuild-createchroot to create a new chroot environment with Kali packages and GitLab components, as well as any necessary dependencies:
# Change to the newly created directory by running `cd /srv/chroots`
cd /srv/chroots
# Use sbuild-createchroot to create a new chroot environment with Kali packages and GitLab components, as well as any necessary dependencies
sudo sbuild-createchroot \
--merged-usr \ # Merge the /usr directory with the root directory to save space
--keyring=/usr/share/keyrings/kali-archive-keyring.gpg \ # Specify the keyring file for Kali packages
--arch=amd64 \ # Specify the architecture as amd64
--components=main,contrib,non-free,non-free-firmware \ # Specify the components to include in the chroot environment
--include=kali-archive-keyring,kali-dev,kali-dev-amd64-sbuild \ # Specify the packages to include in the chroot environment
http://http.kali.org/kali # Specify the repository to use for downloading packages
This command will create a new chroot environment with the specified components and dependencies, as well as merge the usr directory to save space.
4. Edit /etc/schroot/chroot.d/kali-dev-amd64-sbuild* (note that ” *” is used here because sbuild-createchroot generates a unique filename) by adding the following lines:
#!/bin/bash
# This script creates a new chroot environment for building Debian packages, specifically for the kali-dev/amd64 distribution. It also merges the usr directory to save space.
# Create a new chroot environment with the specified components and dependencies
sbuild-createchroot kali-dev-amd64-sbuild /srv/chroots/kali-dev-amd64-sbuild http://http.kali.org/kali
# Edit the configuration file for the chroot environment
nano /etc/schroot/chroot.d/kali-dev-amd64-sbuild*
# Add the following lines to the configuration file
[kali-dev-amd64-sbuild]
description=Debian kali-dev/amd64 autobuilder
groups=root,sbuild
root-groups=root,sbuild
profile=sbuild
type=directory
directory=/srv/chroots/kali-dev-amd64-sbuild
union-type=overlay
source-root-groups=root,sbuild
# The above lines specify the name, description, groups, profile, type, directory, and union type for the chroot environment. These settings are necessary for the environment to function properly.
5. Add your user to the sbuild group using `sbuild-adduser $USER`
6. Create a new file called ~/.sbuildrc with the following contents:
# This script sets up the necessary configurations for sbuild, a tool used for building Debian packages.
# Set the variable $build_arch_all to 1, indicating that all architectures will be built.
build_arch_all=1;
# Set the variable $build_source to 1, indicating that source packages will also be built.
build_source=1;
# Set the variable $run_lintian to 1, indicating that lintian, a tool for checking Debian packages, will be run.
run_lintian=1;
# Set the variable $lintian_opts to ['-I'], indicating that lintian will only show informational messages.
lintian_opts=['-I'];
7. Reboot your system to ensure that the changes take effect.
8. To speed up package downloads, install apt-cacher-ng using `sudo apt install -y apt-cacher-ng` and configure it by adding the following lines to /etc/apt-cacher-ng/kali_mirrors:
#!/bin/bash
# This is a bash script used to configure apt-cacher-ng for faster package downloads on Kali Linux.
# Add the kali mirrors to the apt-cacher-ng configuration file.
echo "http://http.kali.org/kali/" >> /etc/apt-cacher-ng/kali_mirrors
# Update the apt-cacher-ng configuration.
service apt-cacher-ng restart
# Install apt-cacher-ng using sudo and automatically answer yes to any prompts.
sudo apt install -y apt-cacher-ng
# Add the kali mirrors to the apt-cacher-ng configuration file.
echo "http://http.kali.org/kali/" >> /etc/apt-cacher-ng/kali_mirrors
# Update the apt-cacher-ng configuration.
service apt-cacher-ng restart
# Reboot the system to ensure changes take effect.
reboot
# The following lines are added to the apt-cacher-ng configuration file to speed up package downloads.
# The first line adds the kali mirrors to the configuration file.
# The second line updates the configuration.
# The third line installs apt-cacher-ng using sudo and automatically answers yes to any prompts.
# The fourth line adds the kali mirrors to the configuration file again.
# The fifth line updates the configuration again.
# The sixth line reboots the system to ensure changes take effect.
Add your preferred mirror for Kali packages in backends_kali using `sudo tee /etc/apt-cacher-ng/backends_kali` and configure the proxy by adding a line to /etc/apt/apt.conf.d/01proxy:
# This line sets the HTTP proxy to be used for acquiring packages from the local host, using port 3142.
# It is necessary to configure the proxy in order to use apt-cacher-ng for caching packages.
# The following line adds the preferred mirror for Kali packages to the backends_kali file in the apt-cacher-ng directory.
# This allows for faster and more efficient package downloads from the specified mirror.
sudo tee /etc/apt-cacher-ng/backends_kali << EOF
# This command uses sudo to run the tee command, which allows for writing to a file with root privileges.
# The file being written to is the backends_kali file in the apt-cacher-ng directory.
http://http.kali.org/kali
# This is the preferred mirror for Kali packages, which is being added to the backends_kali file.
EOF
# This marks the end of the input for the tee command.
# The following line adds a configuration to the apt.conf.d directory, specifically the 01proxy file.
# This configuration sets the proxy to be used for all apt operations.
echo "Acquire::HTTP::Proxy \"http://localhost:3142\";" | sudo tee /etc/apt/apt.conf.d/01proxy
# This command uses echo to print the specified configuration to the 01proxy file.
# The output of echo is then piped to the tee command, which writes it to the 01proxy file with root privileges.
9. Enable apt-cacher-ng using `sudo systemctl enable apt-cacher-ng –now` and check that it is working by running tail -f /var/log/apt-cacher-ng/apt-cacher.log while building a package with sbuild.