build_needed() function returns true/yes if a source is missing,
even when the target/package exists and is up-to-date. This
behaviour triggers unnecesarry rebuilds.
Because only the remote sources can be missing and
we don't want to rebuild a port just because we've deleted
some of its remote sources, this patch changes that condition
from:
( the source is missing OR is newer than the target/package )
to
( the source exists AND is newer than the target/package )
This patch aborts the package installation and remove the package
from the database on any extraction error. This fixes FS#620.
I don't know why the extraction errors were ignored (even documented).
The initial commit already had this behaviour. Another odd thing
is that the install status of the package was commited to the database
before it was installed while there are exceptions used in pkg_install():
- archive open error
- empty archive
- archive read error
Any of these errors will falsely mark the package as installed (maybe
not a big problem with upgrades).
To avoid breaking something (else), this fix kicks in
only with fresh installs (not upgrades).
Thanks Erich Eckner, for pointing out that the issue
is reproductible with a read-only destination. Otherwise,
I don't think I would have looked at this issue.
A test case is presented with the FS issue, just in case someone
who loves C++ enough to dig deeper or have more knowledge about
the history of this program would take a closer look.
this is an artifact from make_md5sum() and NOT needed for make_signature().
In fact, this check breaks make_signature() because now packages that don't
have a $source don't get any .signature at all, even though it can
(and should) create a sha256 for the footprint and Pkgfile.
Patch by Camille (onodera).