Skip to content

Draft: DEMO: Initial Debian packaging of python-py-ecc (Closes: #1111786)

DEMO - DO NOT MERGE NOR CHERRY-PICK

Characteristics of a easy to review Merge Request for a new Debian package

This is an example of an ideal Merge Request for a new Debian package on Salsa. The target branch debian/latest has initially only the upstream contents as of the latest release (v8.0.0) and this MR proposes to merge a branch with the packaging in debian/ in a single commit that introduces it (there is no need to show intermediate commits on how the submitter ended up with the final version).

The reviewer can then easily read the whole commit and give feedback. Subsequent commits update the first one and are force pushed so that the state of the branch is always the final suggestion and ready to be merged. The reviewer can use GitLab's built-in features or their local git checkout to see what changed between the versions.

If the reviewer is the uploader, the reviewer will end review by uploading. If the submitter is the uploader, the reviewer will press Approve and submitter will proceed to upload.

How this was produced

# Clone upstream and call the origin `upstreamvcs`
git clone --origin upstreamvcs --branch main --single-branch https://github.com/ethereum/py_ecc.git python-py-ecc

# Create new branches from the upstream release tag, but don't add any contents yet
cd python-py-ecc
git tag # Latest is v8.0.0
git checkout -b upstream/latest v8.0.0
git checkout -b debian/latest

# Do the packaging on a development branch that is easy to rebase
git checkout -b next/debian/latest

# Create initial packaging with `dh_make --python` from Debian unstable inside a container
cd ..
podman run --interactive --tty --rm --shm-size=1G --cap-add SYS_PTRACE \
  --env='DEB*' --volume=$PWD:/tmp/test --workdir=/tmp/test debian:sid bash

apt update -q && apt install -q --yes git-buildpackage dpkg-dev dh-make 
cd python-py-ecc

dh_make --packagename python-py-ecc_8.0.0 --createorig --copyright expat --python
  Maintainer Name     : Otto Kekäläinen
  Email-Address       : otto@debian.org
  Date                : Tue, 16 Sep 2025 00:28:00 +0000
  Package Name        : python-py-ecc
  Version             : 8.0.0
  License             : expat
  Package Type        : python
  Are the details correct? [Y/n/q]
  y
  Done. Please edit the files in the debian/ subdirectory now.

exit

# In the host machine, do frequent commits from this point onwards
git add debian/
git commit -a -m "Initial Debian packaging"

# Ensure configs for upstream imports are correct
nano debian/gbp.conf debian/watch
git add debian/gbp.conf debian/watch
git commit -a -m "WIP: gbp.conf and watch file"

# Check that branches look correct
gitk --all &

Screenshot_from_2025-09-15_18-02-46

Note the upstream release tag v8.0.0 is the basis for the Debian packaging work, and branches upstream/latest and debian/latest have been created but they have no commits yet.

# Execute the import
gbp import-orig --uscan --upstream-version 8.0.0

# Check that branches look correct
gitk --all &

Screenshot_from_2025-09-15_18-06-18

Note the branch upstream/latest has now the import commit that overlayed the tarball contents on the git release tag. If they are exactly the same, the commit will be empty. The branch debian/latest is branching of the tag upstream/8.0.0 but still has no contents. The branch that was checked out when running gbp import-orig --uscan has no changes as git-buildpackage applied the import changes on other branches.

# If configs wrong, delete tags and reset branches, and try again. Otherwise 
# if everything was correct, rebase development branch on the import commit:
git rebase debian/latest

Screenshot_from_2025-09-15_18-06-27

Note the development branch next/debian/latest is now rebased on the debian/latest branch. This is the end goal and a Merge Request based on this git structure will be clean and easy to review (and later audit if there is malware that which's orgin needs to be traced).

# Continue iterating on package and builds until everything works
gbp buildpackage
git clean -fdx
nano debian/*
git commit -a -m "WIP"

# Once ready, rebase and squash into a single commit
git rebase -i debian/latest

Screenshot_from_2025-09-15_18-09-54

Note the demo commit on demo branch single-commit-new-debian-version-demo has just one single commit that adds the debian/ contents on the branch debian/latest, which will start the Debian package.

# Publish all branches
git remote add origin git@salsa.debian.org:python-team/packages/python-py-ecc.git
for BRANCH in debian/latest upstream/latest pristine-tar next/debian/latest
do
  git checkout $BRANCH
  git push --set-upstream origin $BRANCH
done

If you don't have permissions to push on the official Debian packaging repository, just push everything in a fork on in your own namespace. Your mentor can easily git pull or even gbp pull everything from your fork when needed.

After next/debian/latest has been pushed, open the Merge Request.

More information

For more information, see https://optimizedbyotto.com/post/debian-packaging-from-git/ and related articles in the blog about Debian packaging and git usage.

Edited by Otto Kekäläinen

Merge request reports

Loading