sbuild task: add pre-upload consistency checks on sbuild results

debusine.tasks.sbuild.Sbuild.upload_artifacts currently does little consistency checking on the build result, besides looking for files by extension.

In theory, the build may succeed or fail:

  • If it succeeded, we'll have a binary .changes file, and an assorted set of .deb and .udeb files. We could validate the build before upload by checking if the .changes file is present, and then check if all files mentioned in the .changes file are present and their sizes match what's in the .changes.
  • If the build failed, then I guess we could discard everything and only upload the .build file.

There may be more checks, like:

  • Are there files other than .deb and .udeb listed in the .changes?
  • Are files non-empty?
  • Does the .changes file contains at least one file to upload?

In general, I would treat sbuild as if it were a malicious blackbox with regards to what output it generates, because Debian is quite full of unexpected corner cases: almost every time I had some assumption about packaging that I found perfectly reasonable, a perfectly valid case came up for which that assumption would be broken in some cases that could't be fixed or reimplemented otherwise.

Being strict in checking output of external Debian tools cano be a way to detect corner cases early, and explicitly get a chance to understand them and design how to handle them.

Edited by Enrico Zini