Chris Lamb: How to write your first Lintian check
Lintian's humble description of "Debian package checker" belies its importance within the Debian GNU/Linux project. An extensive static analysis tool, it's not only used by the vast majority of developers, falling foul of some of its checks even cause uploads to be automatically rejected by the archive maintenance software.
As you may have read in my recent monthly report, I've recently been hacking on Lintian itself. In particular:
- #798983: Check for libjs-* binary package name outside of the web section
- #814326: Warn if filenames contain wildcard characters
- #829744: Add new-package-should-not-package-python2-module tag
- #831864: Warn about Python packages that ship Coverage.py information
- #832096 Check for common typos in debian/rules target names
- #832099: Check for unnecessary SOURCE_DATE_EPOCH assignments
- #832771: Warn about systemd .service files with a missing Install key
Getting started
First, let's obtain the Lintian sources and create a branch for our work:
The most interesting files are under checks/*:
Let's add our new tag before we go any further. After poking around, it looks like files. pm,desc would be most appropriate, so we'll add our new tag definition to files.desc:
$ git clone https://anonscm.debian.org/git/lintian/lintian.git [ ] $ cd lintian $ git checkout -b warn-about-dotcoverage-files Switched to a new branch 'warn-about-dotcoverage-files'
$ ls -l checks/ head -n 9 total 1356 -rw-r--r-- 1 lamby lamby 6393 Jul 29 14:19 apache2.desc -rw-r--r-- 1 lamby lamby 8619 Jul 29 14:19 apache2.pm -rw-r--r-- 1 lamby lamby 1956 Jul 29 14:19 application-not-library.desc -rw-r--r-- 1 lamby lamby 3285 Jul 29 14:19 application-not-library.pm -rw-r--r-- 1 lamby lamby 544 Jul 29 14:19 automake.desc -rw-r--r-- 1 lamby lamby 1354 Jul 29 14:19 automake.pm -rw-r--r-- 1 lamby lamby 19506 Jul 29 14:19 binaries.desc -rw-r--r-- 1 lamby lamby 25204 Jul 29 14:19 binaries.pm -rw-r--r-- 1 lamby lamby 15641 Aug 24 21:42 changelog-file.desc -rw-r--r-- 1 lamby lamby 19606 Jul 29 14:19 changelog-file.pmNote that the files are in pairs; a foo.desc file that contains description of the tags and a sibling foo.pm Perl module that actually performs the checks.
Tag: package-contains-python-coverage-file Severity: normal Certainty: certain Info: The package contains a file that looks like output from the Python coverage.py tool. These are generated by python ,3 -coverage during a test run, noting which parts of the code have been executed. They can then be subsequently analyzed to identify code that could have been executed but was not. . As they are are unlikely to be of utility to end-users, these files should be removed from the package.The Severity and Certainty fields are documented in the manual. Note the convention of using double spaces after full stops in the Info section.
Extending the testsuite
Lintian has many moving parts based on regular expressions and other subtle logic, so it's especially important to provide tests in order to handle edge cases and to catch any regressions in the future.
We create tests by combining a tiny Debian package that will deliberately violate our check, along with some metadata and the expected output of running Lintian against this package.
The tests themselves are stored under t/tests. There may be an existing test that it would be more appropriate to extend, but I've gone with creating a new directory called files-python-coverage:
Note that we do not need a debian/rules file as long as we do not deviate from a "skeleton" debhelper style. We then add the aforementioned metadata to t/tests/files-python-coverage/desc:
When we run the testsuite, it should fail because we don't emit the check yet:
$ mkdir -p t/tests/files-python-coverage $ cd t/tests/files-python-coverageFirst, we create a simple package, installing dummy file to trigger the check:
$ mkdir -p debian/debian $ touch debian/.coverage $ echo ".coverage /usr/share/files-python-coverage" > debian/debian/install
Testname: files-python-coverage Sequence: 6000 Version: 1.0 Description: Check for Python .coverage files Test-For: package-contains-python-coverage-fileand the expected warning to t/tests/files-python-coverage/tags:
$ echo "W: files-python-coverage: package-contains-python-coverage-file" \
"usr/share/files-python-coverage/.coverage" > tags
$ cd $(git rev-parse --show-toplevel)
$ debian/rules runtests onlyrun=tag:package-contains-python-coverage-file
[ ]
--- t/tests/files-python-coverage/tags
+++ debian/test-out/tests/files-python-coverage/tags.files-python-coverage
@@ -1 +0,0 @@
-W: files-python-coverage: package-contains-python-coverage-file usr/share/files-python-coverage/.coverage
fail tests::files-python-coverage: output differs!
Failed tests (1)
tests::files-python-coverage
debian/rules:48: recipe for target 'runtests' failed
make: *** [runtests] Error 1
$ echo $?
1
Specifying onlyrun= means we only run the tests that are designed to trigger this tag rather than the whole testsuite. This is controlled by the Test-For key in our desc file, not by scanning the tags files.
This recipe for creating a testcase could be used when submitting a regular bug against Lintian providing a failing testcase not only clarifies misunderstandings resulting from the use of natural language, it also makes it easier, quicker and safer to correct the offending code itself.
Emitting the tag
Now, let's actually implement the check:
Our testsuite now passes:
tag 'package-installs-python-egg', $file; + # ---------------- .coverage (coverage.py output) + if ($file->basename eq ".coverage") + tag 'package-contains-python-coverage-file', $file; + # ---------------- /usr/lib/site-python
$ debian/rules runtests onlyrun=tag:package-contains-python-coverage-file private/generate-profiles.pl .... running tests .... mkdir -p "debian/test-out" t/runtests -k -j 9 t "debian/test-out" tag:package-contains-python-coverage-file ENV[PATH]=[..] pass tests::files-python-coverage if [ "tag:package-contains-python-coverage-file" = "" ]; then touch runtests; fi $ echo $? 0
Submitting the patch
Lastly, we create a patch for submission to the bug tracking system:
and we finally attach it to the existing bug:
$ git commit -a -m "c/files: Warn about Python packages which ship" \ "coverage.py information. (Closes: #831864)" $ git format-patch HEAD~ 0001-c-files-Warn-about-Python-packages-which-ship-covera.patch
To: 831864@bugs.debian.org Cc: 831864-submitter@bugs.debian.org Bcc: control@bugs.debian.org tags 831864 + patch thanks Patch attached. /lamby
Summary
I hope this post will encourage at some extra contributions towards this important tool.
(Be aware that I'm not a Lintian maintainer, so not only should you not treat anything here as gospel and expect this post may be edited over time if clarifications arise.)
My monthly report covers a large part of what I have been doing in the free software world. I write it for
The seventh update in the 0.12.* series of 

Even though the Chess Olympiad takes some attention right now, development on
Nageru (my live video mixer) has continued steadily throughout since the 1.3.0 release. I wanted to
take a little time to talk about the upcoming 1.4.0 release, and why things
are as they are; writing down things often make them a bit clearer.
Every major release of Nageru has had a specific primary focus: 1.0.0 was about
just getting everything to work, 1.1.0 was about NVIDIA support for more
oomph, 1.2.0 was about stabilization and polish (and added support for
Blackmagic's PCI cards as a nice little bonus), and 1.3.0 was about x264
integration. For 1.4.0, I wanted to work on multitrack audio and mixing.
Audio has always been a clear focus for Nageru, and for good reason; video is
90% about audio, and it's sorely neglected in most amateur productions
(not to mention that processing tools are nearly non-existant in most free or
cheap software video mixers). Right from the get-go, it's had a chain with
proper leveling, compressors and most importantly visual monitoring, so that
you know when things are not as they should be. However, it was also written
with an assumption that there would be a single audio input source (one of
the cameras), and that's going to change.
Single-input is less of a showstopper than one'd think at first; you can work
around it by buying a mixer, plug everything into that and then feed that
signal into the computer. However, there are a few downsides: If you want
camera audio, you'll need to pull more cable from each camera (or have SDI
de-embedders). Your mixer is likely to require an extra power supply, and
that means yet more cable (any decent USB video card can power over USB, so
why shouldn't your audio?). You'll need to buy and transport yet another
device. And so on. (If you already have a PA mixer, of course you can use it,
but just reusing the PA mix as a stream mix rarely gives the best results,
and mixing on an aux bus gives very little flexibility.)
So for 1.4.0, I wanted something to get essentially the processing equivalent
of a mid-range mixer. But even though my education is in DSP, my experience
with mixers is rather limited, so I did the only reasonable thing and went
over to a friend who's also an (award-winning) audio engineer. (It turns out
that everything on a mixer is the way it is for a pretty good reason, tuned
through 50+ years of collective audio experience. If you just try to make up
something on your own without understanding what's going on, you have a
0.001% chance of stumbling upon some genius new way of doing things by
accident, and a significantly larger chance than that of messing things up.)
After some back and forth, we figured out a reasonable set of basic tools
that would be useful in the right hands, and not too confusing for a
beginner. So let's have a look at the new controls you get:
There's one set of these controls for each bus. (This is the expanded view; there's
also a compact view that has only the meters and the fader, which is what
you'll typically want to use during the run itself the expanded view is for
setup and tweaking.) A bus in Nageru is a pair of channels (left/right),
sourced from a video capture or ALSA card. The channel mapping is flexible;
my USB sound card has 18 channels, for instance, and you can use that to make
several buses. Each bus has a name (here I named it very creatively Main ,
but in a real setting you might want something like Blue microphone or
Speaker PC ), which is just for convenience; it doesn't mean much.
The most important parts of the mix are given the most screen estate,
so even though the way through the signal chain is left-to-right
top-to-bottom, I'll go over it in the opposite direction.
By far the most important part is the audio level, so the fader naturally is
very prominent. (Note that the scale is nonlinear; you want more resolution
in the most important area.) Changing a fader with the mouse or keyboard is
possible, and probably most people will be doing that, but Nageru will also
support USB faders. These usually speak MIDI, for historical reasons, and
there are some UI challenges when they're all so different, but you can get
really small ones if you want to get that tactile feel without blowing up
your budget or getting a bigger backpack.
Then there's the meter to the left of that. Nageru already has R128 level
meters in the mastering section (not shown here, but generally unchanged from
1.3.0), and those are kept as-is, but for each bus, you don't want to know loudness; you want to know
recording levels, so you want a peak meter, not a loudness meter. In particular, you don't want the bus to send clipped data
to the master (which would happen if you set it too high); Nageru can handle
this situation pretty well (unlike most digital mixers, it mixes in
full 32-bit floating-point so there's no internal clipping, and there's a limiter on the master by default),
but it's still not a good place to be in, so you can see that being marked
in red in this example. The meter doubles as an input peak check during
setup; if you turn off all the effects and set the fader to neutral, you can
see if the input hits peak or not, and then adjust it down. (Also, you can
see here that I only have audio in the left channel; I'd better check my
connections, or perhaps just use mono, by setting the right channel on the
bus mapping to the same input as the left one.)
The compressor (now moved from the mastering section to each bus) should be
well-known for those using 1.3.0, but in this view, it also has a reduction
meter, so that you can see whether it kicks in or not. Most casual users
would want to just leave the gain staging and compressor settings alone, but
a skilled audio engineer will know how to adjust these to each speaker's
antics (some speak at a pretty even volume and thus can get a bit of
headroom, while some are much more variable and need tighter settings).
Finally (or, well, first), there's the EQ section. The lo-cut is again
well-known from 1.3.0 (the cutoff frequency is the same across all buses),
but there's now also a simple three-band EQ per bus. Simply ask the speaker
to talk normally for a bit, and tweak the controls until it sounds good.
People have different voices and different ways of holding the microphone,
and if you have a reasonable ear, you can use the EQ to your advantage to
make them sound a little more even on the stream. Either that, or just
put it in neutral, and the entire EQ code will be bypassed.
The code is making pretty good progress; all the DSP stuff is done
(save for some optimizations I want to do in zita-resampler, now that
the discussion flow is started again),
and in theory, one could use it already as-is. However, there's a fair
amount of gnarly support code that still needs to be written: In particular,
I need to do some refactoring to support ALSA hotplug (you don't want
your entire stream to go down just because an USB soundcard dropped out
for a split second), and similarly some serialization of saving/loading
bus mappings. It's not exactly rocket science, but all the code still needs
to be written, and there are a number of corner cases to think of.
If you want to peek, the code is in the
Me and Ana travelled to Cambridge last weekend for the Debian UK BBQ. We
travelled by train and it was a rather scenic journey. In the past, on long
journeys, I ve used APRS-IS to beacon my location and plot my route but I have
recently obtained the GPS module for my Yaesu VX-8DE and I thought I d give
some real RF APRS a go this time.
While the APRS IGate coverage in the UK is a little disappointing, as is
evidenced by the map, a few cool things did happen. I recieved a simplex APRS
message from a radio amateur 2M0RRT with the text test test IO86ML (but
unfortunately didn t notice until we d long passed by, sorry for not
replying!) and quite a few of my packets, sent from a 5 watt handheld in
Cambridge, were heard by the station M0BPQ-1 in North London (digipeated by
MB7UM).
My APRS Position Reports for the Debian UK BBQ 2016

The
The documentation for the
Since I've created the
It has been a while that I have been contacted by a recruiter, and the last few ones were fairly decent conversations, where they made an effort to research me first, and even if they did not get everything right, they still listened, and we had a productive talk. But four days ago, I had another recruiter reach out to me, from a company I know oh so well: one I