Being a good citizen: upstreaming your work

As part of the work in the Debcrafters team, we touch a huge number of packages to fix bugs, improve integration, adapt to Ubuntu-specific changes, keep them updated, etc. Over the years, some Ubuntu packages collected quite some delta to the Debian package. Every time a new version is uploaded to Debian, we need to merge this change into the Ubuntu package. It’s often easier and quicker to do a change just in Ubuntu, but the cost of maintaining it compounds over time.

On the other side of this coin, it means that valuable contributions do not get offered upstream (be that in Debian or upstream project itself), whereas they would probably be very beneficial to the projects. Reducing the delta gives us double the payoff: helping the broader open-source community and also reducing our own workload.

This cycle I spent quite some time trying to remove some of the Ubuntu delta by submitting these changes to the upstream project or to Debian (depending on which is the most upstream project). Let me show what that involves using lintian as an example.

Upstreaming lintian changes

Lintian is a native Debian package and actively maintained in Debian. For a native package, the delta was on the more manageable side. lintian 2.135.0ubuntu1 mentioned this delta:

  * Merge with Debian unstable. Remaining changes:
    - Fix building udebs, now that in Ubuntu noudebs is implied profile
      (LP #1918120)
    - Add zst as allowed compression for .deb & .udeb although we don't
      actually ship udeb packages that support zst (LP #1923845)
    - Add AC_INIT in
      macro-not-cross-compilation-safe/build-spec/orig/src/configure.ac
      (LP #1950989)
    - Add -fPIC ld flags to
      checks/binaries/prerequisites/numpy/binaries-missing-depends-on-numpy-abi
    - macro-not-cross-compilation-safe is expecting line one, we added AC_INIT
      so it should now match line three.
    - Ubuntu enables LTO by default, so without-fat-lto-objects is expected to
      fail.
    - d/control: Fix wrong dependency plzip to lzip
    - changelog-file-news-general, changelog-file-news-version: add custom rules
      to install NEWS.Debian manually. debhelper 13.31 trims NEWS entries older
      than the main changelog date
    - changelog-file-empty-entry: remove extraneous change data from the second
      entry so the trailer falls at the line number expected by hints
    - min-js-with-sources, cruft-minified-js: add skip files, terser output line
      length varies by version

In Ubuntu 26.10 we are down to two changes now (see below for details). I expect those two changes to be eliminated in the near future to get to zero delta.

Add zst as allowed compression for .deb

One difference between Debian and Ubuntu is that Ubuntu uses zstd to compress the .deb packages, but Debian uses xz. So the quick and easy solution is to patch lintian to just accept zstd as a compression format for .deb packages. But this cannot be submitted as-is to Debian, because that change just accepts ztsd as compression even when targeting Debian. To upstream this change to Debian, this patch had to be made configurable to only allow zstd when using the Ubuntu profile. I came up with a new lintian tag unsupported-zstd-deb-archive that would complain about zstd compressed .deb files and the Ubuntu profile would just disable that tag. The submitted merge request triggered quite some discussion. I had to add test cases and the solution wasn’t liked, because the lintian tag malformed-deb-archive would mention zstd as supported compression format (even on Debian where this is not the case). A discussion in the merge request came up with a different solution: Make the supported compression formats configurable via a data file. Example control-compression:

# List of supported file extensions for control.tar
gz
xz
@if-vendor-is ubuntu zst

I completely rewrote the patch, and that version landed in lintian 2.138.0. It took effort to get to this point, but it was worth it. This implementation is cleaner compared to what we had, and it works everywhere. So people on Debian can use Debian’s lintian to check a package they built for Ubuntu and vice versa.

Add AC_INIT in macro-not-cross-compilation-safe/build-spec/orig/src/configure.ac

We carried the Ubuntu delta to add AC_INIT to a test case plus “macro-not-cross-compilation-safe is expecting line one, we added AC_INIT so it should now match line three”. I tested lintian and it builds fine without this delta. While writing this blog post, I tried to collect the information about the history of this delta. Instead of presenting a nice explanation why we could drop this delta I am left confused. I dropped the delta with the explanation that it was fixed in commit 503fe6d12cb9b6a2f4a4e0a4a380ceee2b25254c but this commit was part of lintian 2.105.0. The Ubuntu delta was introduced afterwards in lintian 2.111.0ubuntu2.

Ubuntu enables LTO by default

Ubuntu enables LTO by default which caused one test to fail (because it assumed that LTO was not used). We carried a fix for that since lintian 2.116.1ubuntu3 in 2023, but nobody cared about forwarding it to Debian. I forwarded it to Debian and it was just merged. It can be so easy sometimes. Now lintian would not run into this test failure when they decide to enable LTO by default as well.

Fix wrong dependency plzip to lzip

The description to fix a wrong dependency on plzip is misleading. lintian in Debian uses plzip (a parallel lzip compressor), but we only have lzip in Ubuntu main. Since plzip is faster due to using concurrency, we should switch from lzip to plzip as well. I started an Ubuntu main inclusion process for it which is still in progress. Once we replaced lzip by plzip, this Ubuntu delta can be dropped.

Fix building udebs, now that in Ubuntu noudebs is implied profile

Debian uses udebs for their Debian installer. Ubuntu does not use udebs and we do not build udebs on Ubuntu. dpkg/debhelper in Ubuntu implies “DEB_BUILD_PROFILE=noudeb”. The lintian tests for udebs fail on Ubuntu due to this build profile. This behavior can be overridden by setting the build profile “!noudeb” to build udebs on Ubuntu (double negation). I forwarded the patch to set !noudeb for those tests to Debian. This submitted patch triggered a discussion with the lintian and dpkg maintainers. It revealed that “!noudeb” is not a valid profile name (exclamation marks are not allowed). dpkg 1.23.8 rejects such build profile names now. So the next dpkg merge will need to address this. I started a discussion on the debian-devel mailing list about how to set those build profile defaults.

Team uploads in Debian

I am part of several Debian teams and can upload packages to Debian directly. We have multiple changed packages where the changes were not tied to Ubuntu. Therefore I did team uploads in Debian to not carry a delta in Ubuntu any more. Examples:

Debian Python Team:

  • pyudev (run upstream tests and package modernization)
  • dnspython (demote some recommends to suggests when building the package on Ubuntu)

Debian Multimedia Maintainers:

  • libcaca (security fix, demote some recommends to suggests when building the package on Ubuntu, package modernization)
  • libva (demote some recommends to suggests when building the package on Ubuntu)

Debian team on Salsa:

  • lftp (cherry-pick upstream fix, rely on debhelper to set correct compiler flags, let dh_autoreconf rebuild all files)

Dropping delta

Sometimes we should reconsider if carrying a delta is still worth the cost. We provided a busybox-initramfs package in Ubuntu that was built explicitly for being used inside the initramfs. To reduce the delta to Debian, I opened Debian bug #1135987 asking to provide a busybox-initrd package. The benefit of such a package is that the busybox binary would be smaller:

# ls -alh /usr/bin/busybox /usr/lib/initramfs-tools/bin/busybox
-rwxr-xr-x 1 root root 827K Jan 14 15:50 /usr/bin/busybox
-rwxr-xr-x 1 root root 323K Jan 14 15:50 /usr/lib/initramfs-tools/bin/busybox

The maintainer was against this change arguing that this size difference is negligible. So we dropped busybox-initramfs since maintaining the delta for a slightly smaller install in the initrds isn’t worth the tradeoff in 2026.

Collecting delta again

In 2024, I worked on getting rid of all Ubuntu delta in sbuild. We released Ubuntu 24.04 with sbuild 0.85.7. But we started to collect delta again. We carry some ugly patches to make sbuild work with mmdebstrap for Ubuntu. It’s on my to-do list to improve the mmdebstrap Ubuntu support in a way that is upstreamable to Debian. Stay tuned for a future blog post about how to use sbuild with unshare (which uses mmdebstrap in the background).

The Verdict

Forwarding the Ubuntu changes to the upstream projects takes more time and sometimes multiple iterations of a patch, but it will lower the maintenance cost in the future and result in cleaner, more robust solutions. I hope that this blog post inspires you to follow my example to push for getting changes upstreamed.

9 Likes