Commit Graph

50 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
530e79c7ee
Fix warnings detected by LTO. 2020-04-23 08:32:54 +02:00
Juan RP
e155ba6d20
lib/package_alternatives.c: revert back to orig order.
my mistake, I somehow confused it.
2020-04-20 10:32:14 +02:00
Juan RP
7b623783c8
lib/package_alternatives.c: fix CID 284970 (Resource leak).
Also fix calloc args order.
2020-04-19 11:38:09 +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
732a0e6bdf
alternatives: fixed replace_alternative_with_symlink test case.
Only 1 expected failure now!
2020-02-07 09:43:47 +01:00
Juan RP
94b56d7539
alternatives: do not remove symlinks if provider != target pkg.
This fixes the keep_provider_on_update test case, submitted
by @st3r4g via #219.

While checking for obsoletes make sure current provider
also matches the current target pkg.

Fixes #219
2020-02-07 09:16:57 +01:00
Juan RP
0e1482917a
Fix maybe-uninitialized warnings detected by LTO. 2019-12-27 10:53:10 +01:00
q66
85b8b3bbb7 lib/package_alternatives.c: prune obsolete alternatives groups
In the edge case when an updated package has different (or no)
alternatives groups, make sure to prune those that are in pkgdb
but not in the newly installed package.

A potentially common case of this is when a package that formerly
had alternatives gets removed and a transitional metapackage
takes its place (which has no alternatives).

When the new package has no dependencies, oldest next possible
alternatives group will be used. This is because that indicates
a removed package. When there are dependencies, the newest one
will be used; as this indicates a transitional package.
2019-11-17 13:22:15 +01:00
Juan RP
98e09e01e1
lib/package_alternatives.c: check if alternative is a symlink before removing it
Original commit by @duncaen ... but couldn't find this anywhere.
2019-10-27 08:44:37 +01:00
Juan RP
0677678387 Added LTO support and fix warnings (maybe-uninitialized). 2019-06-27 18:09:26 +02:00
Juan RP
829c5835f1
alternatives: respect (and love) current provider.
Added a new test case to verify.

Close #126
2019-06-18 20:47:55 +02:00
Juan RP
cf4f0f4aa0 xbps_alternatives_register: fix a memleak.
Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
bcd80f2936 xbps_alternatives_register: update pkgdb alternatives dictionary.
... otherwise the entry might not be added to our array and won't
hit pkgdb.

Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
1c85083a94 lib/package_alternatives.c: update copyright.
Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
f06edd8850 xbps_alternatives_register: no need to check for 'alloc'.
Found by @huglovefan. Thanks.

Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
639ff2d642 xbps_alternatives_register: get rid of an unnecessary change.
Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
d189921818 xbps_alternatives_register: fix test case "more_entries_update".
Even if the alternatives group is already registered, we need
to create the symlinks from current pkg dictionary (repo).

Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
f4f9bef6e5 xbps_alternatives_register: find and remove obsolete symlinks.
This fixes the new test case "less_entries_update" contributed
by @duncaen.

If "alternatives" dict from pkgdb differs from the one from repos,
find obsoletes and remove them.

Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
04f899c80f xbps_alternatives_unregister: fix removal of current provider.
Fix logic as found by @duncaen in #101.

Also set "first" when the entry is removed from the array.

Fixes #102

Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Juan RP
c29efcd13b xbps_alternatives_unregister: fix xbps_set_cb_state().
In the !current branch, "first" wasn't initialized so it displayed garbage:

Removing `pinentry-tty-1.1.0_5' ...
Removing 'pinentry' alternatives group symlink: pinentry
pinentry-tty-1.1.0_5: unregistered 'pinentry' alternatives group
Switched 'pinentry' alternatives group to 'p
o@�'
Creating 'pinentry' alternatives group symlink: pinentry -> /usr/bin/pinentry-tty
Removed file `/usr/bin/pinentry-tty'
Removed `pinentry-tty-1.1.0_5' successfully.

With my fix:

Removing `pinentry-tty-1.1.0_5' ...
Removing 'pinentry' alternatives group symlink: pinentry
pinentry-tty-1.1.0_5: unregistered 'pinentry' alternatives group
Switched 'pinentry' alternatives group to 'pinentry'
Creating 'pinentry' alternatives group symlink: pinentry -> /usr/bin/pinentry-tty
Removed file `/usr/bin/pinentry-tty'
Removed `pinentry-tty-1.1.0_5' successfully.

Signed-off-by: Juan RP <xtraeme@gmail.com>
2019-06-11 19:53:19 +02:00
Duncaen
456f775e4d alternatives: don't switch unchanged alternative groups on removal
Closes: #82 [via git-merge-pr]
2019-04-22 14:51:32 +02:00
human
b502dc708a fix setting alternatives for packages with more than one group 2019-04-20 11:10:34 +02:00
Duncaen
3b04602cc6 lib/package_alternatives.c: cleanup create_symlinks 2016-09-05 16:03:41 +02:00
Duncaen
dd7a0d073b lib/package_alternatives.c: remove previous symlinks 2016-09-05 02:03:30 +02:00
Michael Gehring
3bfc7b5e6d alternatives: fix dirname() buffer reuse 2016-02-08 15:10:07 +01:00
Juan RP
93b50bc4dc alternatives: preserve order while updating pkgs (thanks chris2/duncaen). 2015-11-17 16:32:12 +01:00
Juan RP
15ab86c90d alternatives: fix a double free in error path. 2015-11-15 09:23:51 +01:00
Juan RP
9ef83cfa69 alternatives: handle dirname() returning ".". 2015-11-15 09:17:05 +01:00
Juan RP
b3c7d27c6b alternatives: fix creation of symlinks with unexistent dirs.
If an alternative needs to create /usr/bin/foo, and /usr/bin
does not exist, this directory must be created prior to create
the symlink.
2015-11-14 07:26:27 +01:00
Juan RP
da5ad3d052 lib/package_alternatives.c: fix builds on travis. 2015-11-10 12:05:20 +01:00
Enno Boland
ae44f32be2 lib/package_alternatives.c: fix memleak 2015-11-10 11:58:07 +01:00
Juan RP
0fced28044 lib/package_alternatives.c: error out if xbps_mkpath() fails.
... and ignore EEXIST for existing dirs.
2015-11-09 16:31:22 +01:00
Enno Boland
2927e58df2 lib/package_alternatives.c: fix style 2015-11-09 08:52:49 +01:00
Enno Boland
78e3bde269 lib/package_alternatives.c: Handle // cases. 2015-11-08 10:47:25 +01:00
Enno Boland
19a65158d9 lib/package_alternatives.c: get rid of goto in normpath. 2015-11-08 10:38:31 +01:00
Enno Boland
8bd2808108 lib/package_alternatives.c: fix wrong /. handling for normalizing paths. 2015-11-08 10:37:26 +01:00
Enno Boland
635db51c27 lib/package_alternatives.c: always use relative symlinks in alternatives
This commit adds relative link support to lib/package_alternatives.c.
Instead of creating absolute links, xbps will create relative links
to the target. This allows to follow links on systems even if the
aren't mounted on /.
2015-11-07 08:40:57 +01:00
Juan RP
9b0cde3267 xbps-alternatives: dangling symlinks are now supported. 2015-11-02 21:02:37 +01:00
Juan RP
f896b17ba7 alternatives: fix an assertion! 2015-10-31 14:19:50 +01:00
Juan RP
33a1bea633 alternatives: fix a warning. 2015-10-31 14:07:12 +01:00
Juan RP
512122da4c alternatives: really make relative symlinks this time. 2015-10-31 14:01:20 +01:00
Joey Gouly
b06ce15136 Allow relative symlinks in xbps-alternatives. 2015-10-31 11:54:01 +00:00
Juan RP
59a8d3d20e alternatives: skip dup alternative groups. 2015-10-31 11:47:58 +01:00
Juan RP
35718e676c Document alternatives in the API. 2015-10-30 13:18:32 +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
Juan RP
4e446968c5 alternatives: do not ignore symlink(2) return value.
This fixes the travisci warning seen with gcc.
2015-10-19 17:11:34 +02:00
Juan RP
faeff38ca2 Alternatives framework (1/2) (WIP). 2015-10-18 10:38:35 +02:00