Commit Graph

70 Commits

Author SHA1 Message Date
Duncan Overbruck
44cd938115
Revert "Use shared LICENSE file for all xbps code."
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.
2020-04-29 14:12:10 +02:00
Juan RP
be7d8cfaf1
Use shared LICENSE file for all xbps code. 2020-04-24 11:44:19 +02:00
Juan RP
06c9891ae3 xbps_transaction_*: multiple performance improvements (v2).
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.
2020-02-21 09:37:32 +01:00
Juan RP
6010a24de6 libxbps: ABI/API break due to xbps_pkg{,pattern}_name changes.
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.
2020-02-08 19:49:57 +01:00
Juan RP
0677678387 Added LTO support and fix warnings (maybe-uninitialized). 2019-06-27 18:09:26 +02:00
Juan RP
173c834fc8
lib/pkgdb.c: initialize pkgdb_fd.
otherwise xbps_pkgdb_unlock will always succeed.
2019-06-23 11:05:03 +02:00
Juan RP
97672bd79f
pkgdb: fix two issues in _update() and _release().
xbps_pkgdb_update: inverted condition that made it 'flush' when !flush.
xbps_pkgdb_release: xhp->pkgdb might be NULL, but unlock pkgdb anyway.
2019-06-22 18:47:13 +02:00
Juan RP
f6116fc2ac xbps_pkgdb_lock(): check if rootfs is writable.
As shown in https://github.com/void-linux/xbps/issues/110
/var might be rw, while / might be ro.

Check this via xbps_pkgdb_lock() for both things.

Close #110

Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-13 17:41:01 +02:00
Duncaen
cd4c07a467 libxbps: sane umask for pkgdb and files plists 2019-04-20 10:46:59 +02:00
Duncaen
44778867df lib/pkgdb.c: set a sane umask for pkgdb plist 2017-02-27 18:24:46 +01:00
Juan RP
35ad10ccbd Fix 29765271e correctly.
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.
2016-03-24 10:23:20 +01:00
Juan RP
3ae197f94a xbps_pkgdb_unlock: there's no need to call xbps_pkgdb_update().
Users should call xbps_end() instead; this will flush pkgdb automatically.
2015-10-30 13:17:21 +01:00
Juan RP
cb857dfc27 Alternatives framework for xbps (2/2).
See xbps-alternatives(1) for more information.

Thanks to all who helped to design this and for fixing grammar in
the manual page.
2015-10-30 12:24:46 +01:00
Wolfgang Draxinger
bd8ea8133f fixed umask value 2015-08-19 15:42:48 +02:00
Wolfgang Draxinger
13f73ef41a Merge branch 'master' of github.com:voidlinux/xbps 2015-08-11 18:29:30 +02:00
Juan RP
a8d2b1d742 pkgdb: handle possible NULL pointer derefs (CID #98684). 2015-07-26 08:08:05 +02:00
Wolfgang Draxinger
47b5eea0f6 set umask for pkgdb creation/access so that pkgdb remains readable for world, even if xbps tools have been called with a very restrictive umask 2015-07-19 11:47:09 +02:00
Juan RP
769a997afb Introduce xbps_plist_{array,dictionary}_from_file().
Those are a wrapper around xbps_{array,dictionary}_internalize_from_zfile()
that prints a debugging msg when the plist file cannot be internalized.

Update xbps to use these wrappers.
2015-05-28 10:15:05 +02:00
Juan RP
5e97a1eb39 xbps_pkgdb_update: return EINVAL if pkgdb cannot be internalized. 2015-05-22 12:18:54 +02:00
Juan RP
ea364affc8 libxbps: open fds with O_CLOEXEC to avoid warnings of leaked fds. 2015-04-15 21:02:38 +02:00
Juan RP
a651f33832 xbps_pkgdb_release: don't bother releasing everything. 2015-01-14 17:34:00 +01:00
Juan RP
7dea05f507 xbps_pkgdb_update: added 3rd bool arg "update", not update in memory pkgdb.
If true, the in memory pkgdb dict will be updated with data from the on-disk pkgdb.
2015-01-10 19:42:09 +01:00
Juan RP
7c153a2b15 pkgdb: disable pkgdb conversion code; 0.38 was released long ago. 2015-01-10 19:26:37 +01:00
Juan RP
ee175a2a68 Improve xbps_end() and use it before exit(3)ing.
- Simplify xbps_repo_open::repo_get_dict().
- Use xbps_end() in the utils where necessary.
- Make xbps_end() call xbps_pkgdb_unlock() if necessary.
- Make xbps_end() release rpool resources.
- Make xbps_end() release resources from xbps_handle.
- Fixed 90% of reported leaks (still reachable at exit) from valgrind.

That was to silence valgrind's memcheck with --leak-check=full.
2015-01-10 19:11:31 +01:00
Juan RP
1f6a5c0e47 libxbps: detection of orphaned packages is now 66% faster. 2015-01-10 05:43:35 +01:00
Juan RP
eee895c6d8 Fixed a regression in vpkgs and improve xbps.d(5) virtualpkg declarations.
See the NEWS file for more information.
2014-12-31 08:51:45 +01:00
Juan RP
1bae26606e Introduce xbps_{pkgdb,rpool}_get_pkg_fulldeptree().
These routines return a xbps_array_t with a full sorted dependency graph
for the target pkg, by querying pkgdb or rpool.

Update xbps-query(8) to use the new libxbps API.
2014-11-20 09:23:51 +01:00
Juan RP
595136704e Get rid of system virtualpkg.d support (<prefix>/share/xbps/virtualpkg.d).
Binary packages do not need to provide those virtualpkg configuration files
anymore; all vpkg info is now collected from pkgdb.
2014-11-04 11:17:27 +01:00
Juan RP
654c77df25 Switch back to uncompressed plists.
There's no point in slowing down read performance just to save a few bytes.
2014-10-24 10:15:41 +02:00
Juan RP
83f5e35ec7 pkgdb: switch to zplists by default. 2014-10-17 10:11:56 +02:00
Juan RP
4be2a0ee84 lib/pkgdb.c: CID 62719 (NULL pointer dereference) 2014-10-07 07:57:38 +02:00
Juan RP
287665009b Drop unused headers. 2014-09-13 08:54:12 +02:00
Juan RP
01dbb968dd Welcome pkgdb-0.38. 2014-09-11 00:12:12 +02:00
Juan RP
ed4a33e4d0 xbps_pkgdb_init: initialize xhp->pkgdb_plist if it wasn't before. 2014-03-04 14:59:58 +01:00
Juan RP
0416b067d0 Use a POSIX lock for pkgdb and only issue pkgdb writes in exact points.
- Rather than using a POSIX named semaphore use a POSIX lock (lockf(3))
for pkgdb for writers. Writers that cannot acquire the pkgdb lock will
get EAGAIN rather then being blocked.

- Due to using a file lock we cannot write the pkgdb every time a package
is being unpacked, configured or removed. Instead pkgdb is only written
at the end of a specific point in the transaction (unpack, configure, remove)
or via xbps_pkgdb_unlock().
2014-03-04 14:37:10 +01:00
Juan RP
4d1cdcac0c Fix concurrency issues in pkgdb: only allow 1 write transaction at the same time.
This implementation relies on a POSIX named semaphore, which is also
required by xbps-rindex(8).
2014-02-23 08:23:14 +01:00
Juan RP
2c9ab6a1f2 xbps_pkgdb_get_pkg_metadata: avoid an extra function call. 2013-12-08 08:07:10 +01:00
Juan RP
192ffa2d58 Update API documentation and dot files. 2013-09-25 11:15:04 +02:00
Juan RP
023484ca0b Introduce xbps_{array,pkgdb}_foreach_cb_multi() and use it where appropiate.
In some tasks the single threaded implementation outperms the multithreaded
one. Use it where it really makes a difference. The _multi() routines do not
spawn any thread if _SC_NPROCESSORS_ONLN == 1.

Bump XBPS_API_VERSION.
2013-09-17 16:30:13 +02:00
Juan RP
4057e4961c Use C99 for loop initializers.
That means that a C99 compiler is now mandatory.
2013-09-15 10:06:49 +02:00
Juan RP
0c7701f2bc Introduce xbps_array_foreach_cb() and use it in random code.
This routine will spawn a thread per core to process N items stored
in the specified array, the last thread gets the remainder of items left.

Results have shown that xbps benefits if there is a considerable amount
of items and number of threads being spawned.

Use it in xbps_pkgdb_foreach_cb(), xbps-pkgdb(8), xbps-query(8)
and xbps-rindex(8).

On UP systems there's no overhead because pthread(3) is not used at all.

WIP! investigate if it can be used in libxbps (xbps_rpool_foreach()),
and finish conversion of xbps-rindex(8) -c.
2013-07-27 09:47:16 +02:00
Juan RP
432067de48 Remove three unused API functions. 2013-07-27 06:12:59 +02:00
Juan RP
42c0766c00 Get rid of libfetch and proplib external dependencies.
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_.
2013-06-20 10:26:12 +02:00
Juan RP
9d80524a34 Minor optimization: no need to check if obj is NULL, prop_object_type() does that already. 2013-06-14 12:22:29 +02:00
Juan RP
db1efb3aa6 Relax memory requirements on 64bit platforms; fix two memleaks. 2013-06-12 10:04:10 +02:00
Juan RP
8fce81cc9f pkgdb: do not add dups in revdeps generation; remove old code. 2013-03-10 08:58:37 +01:00
Juan RP
7c1a0ac3e8 New pkgdb (0.21) and repo index (1.7) format, see NEWS for info. 2013-03-05 04:08:42 +01:00
Juan RP
3139f822da lib/pkgdb.c: print to stderr a meaningful msg on error. 2013-01-15 13:14:30 +01:00
Juan RP
22adf99e40 Faster generation of dynamic reverse dependencies and do this exactly once. 2012-12-15 07:33:49 +01:00
Juan RP
0e40a2dbba xbps_pkgdb_get_pkg_revdeps: make sure to not have dup entries. 2012-12-01 08:10:47 +01:00