Commit Graph

44 Commits

Author SHA1 Message Date
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