Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions bin/xbps-pkgdb/check_pkg_unneeded.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@

#include <sys/param.h>

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>

Expand All @@ -43,11 +40,9 @@
* and remove them if that was true.
*/
int
check_pkg_unneeded(struct xbps_handle *xhp UNUSED, const char *pkgname, xbps_dictionary_t pkgd)
check_pkg_unneeded(struct xbps_handle *xhp UNUSED, const char *pkgname UNUSED, xbps_dictionary_t pkgd)
{
xbps_array_t replaces;
const char *repo = NULL;
char *buf;

xbps_dictionary_remove(pkgd, "download");
xbps_dictionary_remove(pkgd, "remove-and-update");
Expand All @@ -58,16 +53,6 @@ check_pkg_unneeded(struct xbps_handle *xhp UNUSED, const char *pkgname, xbps_dic
xbps_dictionary_set_cstring(pkgd, "repository", repo);
xbps_dictionary_remove(pkgd, "repository-origin");
}
/*
* Remove self replacement when applicable.
*/
if ((replaces = xbps_dictionary_get(pkgd, "replaces"))) {
buf = xbps_xasprintf("%s>=0", pkgname);
xbps_remove_string_from_array(replaces, buf);
free(buf);
if (!xbps_array_count(replaces))
xbps_dictionary_remove(pkgd, "replaces");
}

return 0;
}
12 changes: 0 additions & 12 deletions lib/package_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
Expand All @@ -34,7 +33,6 @@
int HIDDEN
xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
{
xbps_array_t replaces;
xbps_dictionary_t pkgd;
time_t t;
struct tm tm, *tmp;
Expand Down Expand Up @@ -90,16 +88,6 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256);
}
free(buf);
/*
* Remove self replacement when applicable.
*/
if ((replaces = xbps_dictionary_get(pkgd, "replaces"))) {
buf = xbps_xasprintf("%s>=0", pkgname);
xbps_remove_string_from_array(replaces, buf);
free(buf);
if (!xbps_array_count(replaces))
xbps_dictionary_remove(pkgd, "replaces");
}
/*
* Remove unneeded objs from pkg dictionary.
*/
Expand Down
18 changes: 0 additions & 18 deletions lib/transaction_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include "xbps_api_impl.h"

Expand All @@ -35,9 +32,7 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs,
xbps_dictionary_t pkgrd, bool autoinst)
{
xbps_dictionary_t d, pkgd;
xbps_array_t replaces;
const char *pkgver, *pkgname, *curpkgver, *repo;
char *self_replaced;
int rv;

assert(xhp);
Expand Down Expand Up @@ -81,19 +76,6 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs,
if (autoinst && !xbps_dictionary_set_bool(pkgd, "automatic-install", true))
goto err;

/*
* Set a replaces to itself, so that virtual packages are always replaced.
*/
if ((replaces = xbps_dictionary_get(pkgd, "replaces")) == NULL)
replaces = xbps_array_create();

self_replaced = xbps_xasprintf("%s>=0", pkgname);
xbps_array_add_cstring(replaces, self_replaced);
free(self_replaced);

if (!xbps_dictionary_set(pkgd, "replaces", replaces))
goto err;

/*
* Add the dictionary into the unsorted queue.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/xbps/libxbps/shell/replace_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ self_replace_body() {
echo "A-1.0_1" > pkg_A/usr/bin/foo
echo "B-1.0_1" > pkg_B/usr/bin/foo
cd some_repo
atf_check -o ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check -o ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" --replaces "A>=0" ../pkg_A
atf_check -o ignore -- xbps-create -A noarch -n B-1.0_1 -s "B pkg" --replaces "A>=0" --provides="A-1.0_1" ../pkg_B
atf_check -o ignore -- xbps-rindex -a $PWD/*.xbps
cd ..
Expand Down
Loading