freight-team / freight

A modern take on the Debian archive.
Other
107 stars 37 forks source link

`freight cache` does not fail if `dpkg-deb` fails #141

Open JC3 opened 6 months ago

JC3 commented 6 months ago

When executing freight cache, if a dpkg-deb call fails, freight cache still returns success.

For example, when attempting to use freight to add a .deb file that uses zstd compression on a system that does not support zstd compression:

freight cache ; echo $?

Fails and outputs:

dpkg-deb: error: archive '/var/lib/freight/apt/test/adsys_0.9.2~22.04.1_amd64.deb' uses unknown compression for member 'control.tar.zst', giving up
# [freight] skipping invalid Debian package adsys_0.9.2~22.04.1_amd64.deb
0

Note that it still returns 0.

Expected behavior: If freight cache fails for some reason, it should return non-zero to the OS. Actual behavior: freight cache exits with 0 even on failure.

JC3 commented 6 months ago

Thinking about this, I can understand why it's difficult to solve, as the add and cache operations are separate, the error is difficult to recover from since invalid packages will stick around in /var/lib/freight even for future runs on different packages.

As a workaround, if anybody is struggling with this, I'm having good success using dpkg-deb to validate the package first before doing a freight add + freight cache, e.g.:

dpkg-deb -W package.deb && freight add package.deb apt/test && freight cache