This reverts commit be7d8cfaf1.
This commit missed some previous copyrights mentioned,
in general I think its better to have this per-file to
follow who wrote what and when.
This commit implements multiple performance improvements
to the transaction code:
- Don't process xbps_pkg_name() N times each time we access
its package dictionary (via pkgdb or rpool), just do it once
at xbps_pkgdb_init() time. At pkgdb init time, it just creates
a property in pkgdb, "pkgname". At rpool time, each time a
package is accessed, the "pkgname" string property is added.
- The package transaction dictionary contains the "transaction"
object to know what's the pkg type. This has been changed to an
uint8, this simplifies the logic and it's faster than checking
a string object. See xbps_trans_type_t and xbps_transaction_pkg_type().
- Fixed the issue that was marked with XXX in transaction shlibs
checking code. This has been fixed and improved and resources are
now just freed as expected.
- Simplified random code all over the place, avoiding unnecessary
allocations or operations.
- Rename some transaction files to have a better description.
This is my first rototill to the code in 2020.
The funcs xbps_pkg_name() and xbps_pkgpattern_name() were
using malloc(3) to return the result, until now.
They now have been changed to not allocate the result
via malloc, the caller is responsible to provide a buffer
at least of XBPS_NAME_SIZE (64).
If for whatever reason the pkgname can't be guessed,
returns false. This should avoid lots of small allocs
around libxbps.
New functions have the following prototype:
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
bool xbps_pkgpattern_name(char *dst, size_t len, const char *pkg)
as suggested by @duncaen.
xbps_find_virtualpkg_in_conf() needs to look at the vpkgs set up in
configuration files, not from those set by pkgdb.
As a result of this the two test cases that were failing yesterday are now
fixed.
Added a new test case to verify its correctness. Somehow virtual packages
declared via xbps.d(5) were not working correctly for dependencies.
This now works as expected with vpkgs declared with and without a version
component.
The list of required external deps is now confuse, libarchive and openssl.
libxbps now includes a wrapper for proplib prefixed with xbps_ rather than prop_.
These are the core interfaces in the new API:
rpool - Interface to interact with the repository pool.
rindex - Interface to interact with repository indexes.
pkgdb - Interface to interact with local packages.
transaction - Interface to interact with a transaction.
This also brings new repository index format, making the index file
per architecture and being incompatible with previous versions.
The transaction frequency flush option has been removed, and due to
the nature of package states it was causing more harm than good.
More changes coming soon, but the API shall remain stable from now on.
There's no need to prop_dictionary_copy the returned dictionary to
later have to free it again, just return directly the dictionary and
avoid the free(3)s.
1- We can cache the result of the first xbps_pkgdb_init() when it fails
and avoid the malloc/free/access from it.
2- We cache the uname(2) result into a private var in xbps_handle and
use it in xbps_pkg_arch_match().
This improves performance by ~5% approx and it's close as it was before
introducing the repository index format 1.5.
- xbps_repository_pool_find_pkg in best match case, now returns the
newest package version available in rpool.
- Added xbps_repository_pool_find_pkg_exact that returns a package
by exact matching a pkgver.
- Removed xbps_handle_alloc(), the user is free to use memory
allocated from heap or stack.
- Improved API documentation in preparation for 0.12.
Bumped XBPS_API_VERSION again.