Skip to content

Commit

Permalink
lib: make xbps_alternatives_{un,}register private
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Jul 20, 2022
1 parent b35b151 commit f8d708f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 30 deletions.
20 changes: 0 additions & 20 deletions include/xbps.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1011,26 +1011,6 @@ int xbps_pkg_exec_script(struct xbps_handle *xhp,
*/
int xbps_alternatives_set(struct xbps_handle *xhp, const char *pkg, const char *group);

/**
* Registers all alternative groups provided by a package.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @param[in] pkgd Package dictionary as stored in the transaction dictionary.
*
* @return 0 on success, or an errno value otherwise.
*/
int xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkgd);

/**
* Unregisters all alternative groups provided by a package.
*
* @param[in] xhp The pointer to the xbps_handle struct.
* @param[in] pkgd Package dictionary as stored in the transaction dictionary.
*
* @return 0 on success, or an errno value otherwise.
*/
int xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd);

/**
* Parse the alternative link path into \a path and optionally the
* symlink target into \a target.
Expand Down
4 changes: 4 additions & 0 deletions include/xbps_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ xbps_dictionary_t HIDDEN xbps_find_pkg_in_array(xbps_array_t, const char *,
xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_array(struct xbps_handle *,
xbps_array_t, const char *, xbps_trans_type_t);

/* alternatives */
int HIDDEN xbps_alternatives_register(struct xbps_handle *, xbps_dictionary_t);
int HIDDEN xbps_alternatives_unregister(struct xbps_handle *, xbps_dictionary_t, bool);

/* transaction */
bool HIDDEN xbps_transaction_check_revdeps(struct xbps_handle *, xbps_array_t);
bool HIDDEN xbps_transaction_check_shlibs(struct xbps_handle *, xbps_array_t);
Expand Down
9 changes: 3 additions & 6 deletions lib/package_alternatives.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,12 @@ switch_alt_group(struct xbps_handle *xhp, const char *grpn, const char *pkgn,
return create_symlinks(xhp, xbps_dictionary_get(pkgalts, grpn), grpn);
}

int
xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
int HIDDEN
xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool update)
{
xbps_array_t allkeys;
xbps_dictionary_t alternatives, pkg_alternatives;
const char *pkgver, *pkgname;
bool update = false;
int rv = 0;

assert(xhp);
Expand All @@ -305,8 +304,6 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);

xbps_dictionary_get_bool(pkgd, "alternatives-update", &update);

allkeys = xbps_dictionary_all_keys(pkg_alternatives);
for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
xbps_array_t array;
Expand Down Expand Up @@ -490,7 +487,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *pkgname, const char *pkgve
xbps_object_release(allkeys);
}

int
int HIDDEN
xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
{
xbps_array_t allkeys;
Expand Down
5 changes: 1 addition & 4 deletions lib/package_remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ xbps_remove_pkg(struct xbps_handle *xhp, const char *pkgver, bool update)
goto out;

/* unregister alternatives */
if (update)
xbps_dictionary_set_bool(pkgd, "alternatives-update", true);

if ((rv = xbps_alternatives_unregister(xhp, pkgd)) != 0)
if ((rv = xbps_alternatives_unregister(xhp, pkgd, update)) != 0)
goto out;

/*
Expand Down

0 comments on commit f8d708f

Please sign in to comment.