We use a simple file lock that is created with O_CREAT|O_EXCL.
This should fix the concurrency issues with multiple processes
running xbps-rindex -a/-c on the same repository/arch combo.
If xbps_repo_open() was called with the lock arg set, xbps_repo_close()
will now unlock the repo file lock, without the need to set it.
This avoids the need to always unlock the file lock even if it wasn't
locked previously. This also introduceds an ABI/API break, but this
way it's cleaner.
- This mode prints to stdout the matching FILE stored in a binary package.
- ABI break: renamed xbps_get_pkg_plist_from_binpkg() xbps_binpkg_get_plist().
- Added xbps_binpkg_get_file() as a generic way to get pkg file contents.
- Removed useless comments from xbps_api_impl.h.
- if the user wants to add a package which is older than the
one in the index, xbps-rindex will check if the package
reverts the one on the index. If so the package will be added
regardless of its version
- if the user wants to add a package which is newer than the
one on the index, xbps-rindex will check if the package on the
index reverts the one the user wants to add. If so the package
will be skipped regardless of its version.
The repodata archive wasn't group writable, resulting in a new archive
created from scratch if the fd wasn't writable.
repodata archives are now created with 0664 mode, this way its main group
also can write to it.
This is magnituds faster than before; some results:
$ for f in 1 2 3; do time xbps-rindex -r /var/cache/xbps/ &>/dev/null; done
real 0m0.624s
user 0m2.163s
sys 0m0.032s
real 0m0.590s
user 0m2.159s
sys 0m0.023s
real 0m0.584s
user 0m2.144s
sys 0m0.039s
$ for f in 1 2 3; do time LD_PRELOAD=$PWD/lib/libxbps.so.2.0.0 ./bin/xbps-rindex/xbps-rindex -r /var/cache/xbps &>/dev/null; done
real 0m0.037s
user 0m0.030s
sys 0m0.010s
real 0m0.036s
user 0m0.032s
sys 0m0.007s
real 0m0.037s
user 0m0.035s
sys 0m0.006s
$
- xbps_repo_open() accepts a third argument (bool) to acquire a POSIX file
lock on the repository archive.
- xbps_repo_close() accepts a second argument (bool) to release a POSIX file
lock on the repository archive.
This avoids the issue of multiple xbps-rindex(8) processes being blocked
even for different repositories on the same architecture, resulting in
unnecessary contention.