Note: Process in week 2 meant the process related to packaging best practices for multiple github repository and was meant for coordination. That process were replaced by the internal process of how to create debian packages.
Note: The process of creating debian packages are very flexible and upto each maintainer. Debian offers best practices and policies that must be followed, but there is no one way to do it. So for new maintainers is the biggest challange to overcome.
The bellow guide is based on following mainstream debian best practices, and were picked for simplicity and reproducibility in mind.
Setup docker container for creating/modifying deb package
# Use the official Debian image as the base image
FROM debian:bookworm
# Update the package lists and install build-essential and zsh
RUN apt-get update && \
apt-get install -y build-essential devscripts
# Debian maintainance tools
# Source: https://www.debian.org/doc/manuals/developers-reference/tools.html
RUN apt-get update && \
apt-get install -y dpkg-dev debconf fakeroot
RUN apt-get update && \
apt-get install -y lintian lintian-brush piuparts
RUN apt-get update && \
apt-get install -y diffoscope duck adequate i18nspector cme licensecheck blhc
RUN apt-get update && \
apt-get install -y debhelper dh-make
RUN apt-get update && \
apt-get install -y dupload dput
RUN apt-get update && \
apt-get install -y devscripts reportbug autotools-dev dpkg-repack alien dpkg-dev-el
RUN apt-get update && \
apt-get install -y dpkg-cross \
debian-policy doc-debian developers-reference maint-guide packaging-tutorial how-can-i-help docbook-xml debiandoc-sgml debian-keyring debian-el
RUN apt-get update && \
apt-get install -y autopkgtest
RUN apt-get update && \
apt-get install -y debootstrap sbuild
RUN apt-get update && \
apt-get install -y git-buildpackage
RUN apt-get update && \
apt-get install -y equivs
RUN apt-get update && \
apt-get install -y mc
RUN apt-get update && \
apt-get install -y vim nano
RUN apt-get update && \
apt-get install -y debmake
RUN apt-get update && \
apt-get install -y dgit
# Optionally, you can set the working directory inside the container
# This is where you can copy your package source code and work on it
# For example:
WORKDIR /package
# Set non-root user and group
ARG USERNAME=debian
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create a non-root user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
RUN adduser "$USERNAME" sbuild
# Set the non-root user as the default user for the container
USER $USERNAME
# Add the environment variables to the user's .zshrc file
RUN echo 'export DEBEMAIL="$EMAIL"' >> /home/$USERNAME/.bashrc
RUN echo 'export DEBFULLNAME="$FULLNAME"' >> /home/$USERNAME/.bashrc
RUN git config --global user.name "$EMAIL"
RUN git config --global user.email "$FULLNAME"
# Add the mc.sh initialization to zsh
RUN echo 'if [ -f /usr/lib/mc/mc.sh ]; then . /usr/lib/mc/mc.sh; fi' >> /home/$USERNAME/.bashrc
# Add the quilt alias and completions to zsh
RUN echo 'alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg"' >> /home/$USERNAME/.bashrc
RUN echo '. /usr/share/bash-completion/completions/quilt' >> /home/$USERNAME/.bashrc
RUN echo 'complete -F _quilt_completion $_quilt_complete_opt dquilt' >> /home/$USERNAME/.bashrc
# Add the content for ~/.quiltrc-dpkg
COPY .quiltrc-dpkg /home/$USERNAME/.quiltrc-dpkg
# Set up configurations in ~/.devscripts
RUN echo 'DEBUILD_DPKG_BUILDPACKAGE_OPTS="-i -I -us -uc"' >> /home/$USERNAME/.devscripts
RUN echo 'DEBUILD_LINTIAN_OPTS="-i -I --show-overrides"' >> /home/$USERNAME/.devscripts
# TODO
# RUN echo 'DEBSIGN_KEYID="Your_GPG_keyID"' >> /home/$USERNAME/.devscripts
# Create the ~/.sbuildrc configuration file
COPY .sbuildrc /home/$USERNAME/.sbuildrc
# Set an entry point or command if you want the container to execute something by default
# For example, to start an interactive shell:
CMD ["bash"]
docker build -t debian-build-essentials .
docker run -e EMAIL="your.email.address@example.org" -e FULLNAME="Your Name" -it --name debian_dev -v ~/debian/package:/package debian-build-essentials
docker exec -it debian_dev bash
High level overview
The oversimplified method for the Debian packaging workflow can be summarized in 10 steps as follows.
The above process is quite cumbersome if it requires creating the debian directory each time when releasing packages with new version or applying patches, and simply meant to used on each maintainer machine.
The current debian trends recommends using git for package maintainers.
Here is the process overview of how these can be done with git-buildpackage
gbp import-dsc /path/to/package_0.1-1.dsc
git clone <upstream-repo-url>
cd <upstream-repo-directory>
git checkout -b debian/latest
debmake
...modify files
git commit -a -m "Update package configuration"
gbp buildpackage /or debuild
Both ways will create upstream/latest and debian/latest branch, the main difference that the upstream branch in the second example the original code without the debian added directory.
For creating multiple packages this will be problematic, and both approach has pros and cons.
Upstream option
Pros:
Importing .tar.gz
Pros:
Multiarch packages can be accomplished by using cowbuilder.
Here is a detailed article how to use it.
Resources: