9718
Comment: Add sbuild and link to its wiki page
|
9951
|
Deletions are marked like this. | Additions are marked like this. |
Line 84: | Line 84: |
''Error: pkg: unrecoverable fatal error, aborting: unknown system group 'apt-cacher-ng' in statoverride file {{{ Open /var/lib/dpkg/statoverride and remove this line: root apt-cacher-ng 640 /etc/apt-cacher-ng/security.conf }}} |
Contents
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 4 different approaches. It doesn't list 4 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
Sbuild
This is a convenience wrapper script of schroot to build package under specified chroot such as unstable. See sbuild.
Schroot
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.
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. # [debian-sid] description=Debian Sid for building packages suitable for uploading to debian type=directory directory=/srv/chroot/debian-sid users=<your username> root-groups=root personality=linux preserve-environment=true
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> exit
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 have trouble setting it up, skip this section and see docker section below. If you already have a GNU/Linux system, lxc would be the easiest to setup. Install lxc using this command. If you have Ubuntu 14.04/trusty then install lxc from backports Arch/Manjaro users see https://wiki.archlinux.org/index.php/Linux_Containers Now install some necessary packages for networking support for the container. Check status of libvirt daemon (service) and start if not running Now start the networking service using Check LXC#Network_setup_in_buster for buster specific changes. Now create the container named debian-sid You might have to use lxc-attach instead of lxc-console to connect to the container. After attaching yourself you could set your root password using passwd. Before connecting to the container, you might want to start the container To connect to the container This is assuming that you have named your container 'debian-sid' as per the previous instructions. lxc-attach would not setup the tty session for other users and ask pass, what that means is, no sudo, if you switch using su - <username> (see next step). Use lxc-console if you want to use sudo. See http://blog.scottlowe.org/2013/11/25/a-brief-introduction-to-linux-containers-with-lxc/ for more info on using lxc. Create a new user with adduser and switch to that user with su - <username>. See https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-debian-8. Easiest way to create a user with permission to run sudo would be: It is worth noting that you need to install sudo as it does not come default. Also the -m tag creates a home folder for the user, this is not trivial and can be skipped.
If you already setup a container with lxc as instructed above, you can skip this step. Install docker either from your OS's package repositories or check out https://docs.docker.com/engine/installation/linux/. If you have a Debian-based host system, you could run apt-cacher-ng and sbuild on your host system, but otherwise you need to install them inside the container.
Pull the development docker image that FSCI provides Create a container with it and run bash on it If needed, update and upgrade to latest versions of packages Create a normal user for packaging. See https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-debian-8 Exit after your work is done. If you need to connect to it later, use the following commands which will take you to the bash prompt
If your host system is not Debian-based (for example arch), then you can follow the steps below (this will setup docker with systemd integration which allows you to run services like apt-cacher-ng easily), You can start the container and get an interactive shell Setup apt-cacher-ng (this will cache all the packages locally) and auto-apt-proxy (this will auto configure the installed proxy for apt). auto-apt-proxy command should display http://172.17.0.1:3142 upon successful setup. You will now get a root shell and it is better to create a normal user for packaging. Now run this inside the container,
Install Virtual box and run Debian Sid in it. For Manual installation, download Debian Testing ISO from Debian website and install it inside already installed VirtualBox. Once you have Debian Testing, you can upgrade it to Sid/unstable. Edit /etc/apt/sources.list and change testing to sid or unstable.
If you want to make your job easy just install vagrant Make sure that you are having only single Hypervisor running otherwise be ready to see some error. Also, vagrant installation might ask you to install some other additional packages, allow it to do so. Add your user to libvirt group to use vagrant without additional privillege prompts Create a new directory from where you want to start VM. vagrant will store some configuration file in that directory and then switch to that directory Now we need to tell vagrant where we need to fetch Vagrant box (VM image) You can find recent Debian Testing vagrant box on the following URL https://app.vagrantup.com/debian/boxes/testing64 Note: This can take some time depending on your internet connection speed. Then you can connect to the VM by Note: Current image is very old, so you will need to run apt update and apt dist-upgrade (to update debian-archive-keying) before you can upgrade to sid. You can update to Sid by replacing testing with sid in /etc/apt/sources.list and running Note: If you use nfs to share host directory with the vm, then you'll need rpc-statd service or you may get no locks available error message. Open /var/lib/dpkg/statoverride and remove this line: root apt-cacher-ng 640 /etc/apt-cacher-ng/security.conf
LXC
sudo apt-get install lxc
sudo apt-get -t trusty-backports install lxc
sudo apt-get install -qy libvirt-clients libvirt-daemon-system iptables ebtables dnsmasq-base # if libvirt-client is not available, try libvirt-bin
systemctl status libvirtd
systemctl start libvirtd
sudo virsh net-start default
sudo virsh net-autostart default
sudo lxc-create -n debian-sid -t download -- --dist debian --release sid
sudo lxc-start -n debian-sid
sudo lxc-attach -n debian-sid
useradd -m -g sudo <username>
Docker
sudo apt install docker.io
Docker with Debian-based host
docker pull registry.gitlab.com/fsci/resources:debian-dev
docker run --privileged --name "sid" -it registry.gitlab.com/fsci/resources:debian-dev bash
apt-get update && apt-get upgrade
docker start sid
docker attach sid
Docker with non-Debian-based host
docker pull jgoerzen/debian-base-standard:sid
docker run -td --stop-signal=SIGRTMIN+3 \
--tmpfs /run:size=100M --tmpfs /run/lock:size=100M \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
--name=debian-sid jgoerzen/debian-base-standard:sid
docker start debian-sid
docker exec -it debian-sid bash
apt install apt-cacher-ng auto-apt-proxy
adduser <username>
su - <username>
Virtual Machine
Virtual Box
sudo apt install virtualBox
apt update
apt dist-upgrade
Vagrant
sudo apt install vagrant-libvirt libvirt-daemon-system
sudo gpasswd -a <your user> libvirt
mkdir /path/to/directory/packaging
cd /path/to/directory/packaging
vagrant init debian/testing64
vagrant up
vagrant ssh
apt update
apt dist-upgrade
sudo systemctl enable rpc-statd # Enable statd on boot
sudo systemctl start rpc-statd # Start statd for the current session