xbps: update to 0.58.

This commit is contained in:
Juan RP 2020-01-30 17:57:43 +01:00
parent 6def72415b
commit ef13c888bf
8 changed files with 3 additions and 737 deletions

View file

@ -1,33 +0,0 @@
commit 10075c28e5065e948cac707285681f6541759873
Author: Juan RP <xtraeme@gmail.com>
Date: Sat Jan 4 13:01:28 2020 +0100
libxbps: ignore indirect broken revdeps while updating xbps.
This fixes the long standing issue that has been a plague for
a long time.
See the test case for more information.
diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c
index 3d3fc36a..03725ee3 100644
--- lib/transaction_ops.c
+++ lib/transaction_ops.c
@@ -271,6 +271,17 @@ xbps_autoupdate(struct xbps_handle *xhp)
if (rv && rv != ENOENT && rv != EEXIST && rv != ENODEV)
return -1;
}
+ /*
+ * Set XBPS_FLAG_FORCE_REMOVE_REVDEPS to ignore broken
+ * reverse dependencies in xbps_transaction_prepare().
+ *
+ * This won't skip revdeps of the xbps pkg, rather other
+ * packages in rootdir that could be broken indirectly.
+ *
+ * A sysup transaction after updating xbps should fix them
+ * again.
+ */
+ xhp->flags |= XBPS_FLAG_FORCE_REMOVE_REVDEPS;
return 1;
} else if (rv == ENOENT || rv == EEXIST || rv == ENODEV) {
/* no update */

View file

@ -1,355 +0,0 @@
From 85b8b3bbb72ab6de6f4d72c9a2ca3f2be053eeb1 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Thu, 14 Nov 2019 17:40:54 +0100
Subject: [PATCH] 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.
---
lib/package_alternatives.c | 155 +++++++++++++++++-----
tests/xbps/xbps-alternatives/main_test.sh | 93 +++++++++++++
2 files changed, 218 insertions(+), 30 deletions(-)
diff --git a/lib/package_alternatives.c b/lib/package_alternatives.c
index 5e4f2b36..ecdc40ae 100644
--- lib/package_alternatives.c
+++ lib/package_alternatives.c
@@ -309,6 +309,22 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname,
return rv;
}
+static int
+switch_alt_group(struct xbps_handle *xhp, const char *grpn, const char *pkgn,
+ xbps_dictionary_t *pkg_alternatives)
+{
+ xbps_dictionary_t curpkgd, pkgalts;
+
+ curpkgd = xbps_pkgdb_get_pkg(xhp, pkgn);
+ assert(curpkgd);
+
+ xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_SWITCHED, 0, NULL,
+ "Switched '%s' alternatives group to '%s'", grpn, pkgn);
+ pkgalts = xbps_dictionary_get(curpkgd, "alternatives");
+ if (pkg_alternatives) *pkg_alternatives = pkgalts;
+ return create_symlinks(xhp, xbps_dictionary_get(pkgalts, grpn), grpn);
+}
+
int
xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
{
@@ -339,7 +355,6 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
xbps_array_t array;
xbps_object_t keysym;
- xbps_dictionary_t curpkgd = pkgd;
bool current = false;
const char *first = NULL, *keyname;
@@ -377,15 +392,7 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
continue;
/* get the new alternative group package */
- curpkgd = xbps_pkgdb_get_pkg(xhp, first);
- assert(curpkgd);
- xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_SWITCHED, 0, NULL,
- "Switched '%s' alternatives group to '%s'", keyname, first);
- pkg_alternatives = xbps_dictionary_get(curpkgd, "alternatives");
- rv = create_symlinks(xhp,
- xbps_dictionary_get(pkg_alternatives, keyname),
- keyname);
- if (rv != 0)
+ if (switch_alt_group(xhp, keyname, first, &pkg_alternatives) != 0)
break;
}
xbps_object_release(allkeys);
@@ -394,25 +401,119 @@ xbps_alternatives_unregister(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
return rv;
}
+/*
+ * Prune the alternatives group from the db. This will first unregister
+ * it for the package and if there's no other package left providing the
+ * same, also ditch the whole group. When this is called, it is guranteed
+ * that what is happening is an upgrade, because it's only invoked when
+ * the repo and installed alternatives sets differ for a specific package.
+ */
+static void
+prune_altgroup(struct xbps_handle *xhp, xbps_dictionary_t repod,
+ char *pkgname, const char *pkgver, const char *keyname) {
+ const char *newpkg, *curpkg;
+ xbps_array_t array;
+ xbps_dictionary_t alternatives;
+ xbps_string_t kstr;
+ unsigned int grp_count;
+ bool current = false;
+
+ xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_REMOVED, 0, NULL,
+ "%s: unregistered '%s' alternatives group", pkgver, keyname);
+
+ alternatives = xbps_dictionary_get(xhp->pkgdb, "_XBPS_ALTERNATIVES_");
+ assert(alternatives);
+ array = xbps_dictionary_get(alternatives, keyname);
+
+ /* if using alt group from another package, we won't switch anything */
+ xbps_array_get_cstring_nocopy(array, 0, &curpkg);
+ current = (strcmp(pkgname, curpkg) == 0);
+
+ /* actually prune the alt group for the current package */
+ xbps_remove_string_from_array(array, pkgname);
+ grp_count = xbps_array_count(array);
+ if (grp_count == 0) {
+ /* it was the last one, ditch the whole thing */
+ xbps_dictionary_remove(alternatives, keyname);
+ return;
+ }
+ if (!current) {
+ /* not the last one, and ours wasn't the one being used */
+ return;
+ }
+
+ if (xbps_array_count(xbps_dictionary_get(repod, "run_depends")) == 0 &&
+ xbps_array_count(xbps_dictionary_get(repod, "shlib-requires")) == 0) {
+ /*
+ * Empty dependencies indicate a removed package (pure meta),
+ * use the first available group after ours has been pruned
+ */
+ xbps_array_get_cstring_nocopy(array, 0, &newpkg);
+ switch_alt_group(xhp, keyname, newpkg, NULL);
+ return;
+ }
+
+ /*
+ * Use the last group, as this indicates that a transitional metapackage
+ * is replacing the original and therefore a new package has registered
+ * a replacement group, which should be last in the array (most recent).
+ */
+ xbps_array_get_cstring_nocopy(array, grp_count - 1, &newpkg);
+
+ /* put the new package as head */
+ kstr = xbps_string_create_cstring(newpkg);
+ xbps_remove_string_from_array(array, newpkg);
+ xbps_array_add_first(array, kstr);
+ xbps_array_get_cstring_nocopy(array, 0, &newpkg);
+ xbps_object_release(kstr);
+
+ switch_alt_group(xhp, keyname, newpkg, NULL);
+}
+
+
static void
-remove_obsoletes(struct xbps_handle *xhp, xbps_dictionary_t pkgd, xbps_dictionary_t repod)
+remove_obsoletes(struct xbps_handle *xhp, char *pkgname, const char *pkgver,
+ xbps_dictionary_t repod)
{
xbps_array_t allkeys;
+ xbps_dictionary_t pkgd, pkgd_alts, repod_alts;
- allkeys = xbps_dictionary_all_keys(pkgd);
+ pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
+ if (xbps_object_type(pkgd) != XBPS_TYPE_DICTIONARY) {
+ return;
+ }
+
+ pkgd_alts = xbps_dictionary_get(pkgd, "alternatives");
+ repod_alts = xbps_dictionary_get(repod, "alternatives");
+
+ if (xbps_object_type(pkgd_alts) != XBPS_TYPE_DICTIONARY) {
+ return;
+ }
+
+ allkeys = xbps_dictionary_all_keys(pkgd_alts);
for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
xbps_array_t array, array_repo;
xbps_object_t keysym;
const char *keyname;
keysym = xbps_array_get(allkeys, i);
- array = xbps_dictionary_get_keysym(pkgd, keysym);
+ array = xbps_dictionary_get_keysym(pkgd_alts, keysym);
keyname = xbps_dictionary_keysym_cstring_nocopy(keysym);
- array_repo = xbps_dictionary_get(repod, keyname);
+ array_repo = xbps_dictionary_get(repod_alts, keyname);
if (!xbps_array_equals(array, array_repo)) {
remove_symlinks(xhp, array, keyname);
}
+
+ /*
+ * There is nothing left in the alternatives group, which means
+ * the package is being upgraded and is removing it; if we don't
+ * prune it, the system will keep it set after removal of its
+ * parent package, but it will be empty and invalid...
+ */
+ if (xbps_array_count(array_repo) == 0) {
+ prune_altgroup(xhp, repod, pkgname, pkgver, keyname);
+ }
}
xbps_object_release(allkeys);
}
@@ -421,7 +522,7 @@ int
xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
{
xbps_array_t allkeys;
- xbps_dictionary_t alternatives, pkg_alternatives, pkgd, pkgd_alts;
+ xbps_dictionary_t alternatives, pkg_alternatives;
const char *pkgver;
char *pkgname;
int rv = 0;
@@ -431,10 +532,6 @@ xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
if (xhp->pkgdb == NULL)
return EINVAL;
- pkg_alternatives = xbps_dictionary_get(pkg_repod, "alternatives");
- if (!xbps_dictionary_count(pkg_alternatives))
- return 0;
-
alternatives = xbps_dictionary_get(xhp->pkgdb, "_XBPS_ALTERNATIVES_");
if (alternatives == NULL) {
alternatives = xbps_dictionary_create();
@@ -449,17 +546,15 @@ xbps_alternatives_register(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
if (pkgname == NULL)
return EINVAL;
- pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
- if (xbps_object_type(pkgd) == XBPS_TYPE_DICTIONARY) {
- /*
- * Compare alternatives from pkgdb and repo and
- * then remove obsolete symlinks.
- */
- pkgd_alts = xbps_dictionary_get(pkgd, "alternatives");
- if (xbps_object_type(pkgd_alts) == XBPS_TYPE_DICTIONARY) {
- remove_obsoletes(xhp, pkgd_alts, pkg_alternatives);
- }
- }
+ /*
+ * Compare alternatives from pkgdb and repo and then remove obsolete
+ * symlinks, also remove obsolete (empty) alternatives groups.
+ */
+ remove_obsoletes(xhp, pkgname, pkgver, pkg_repod);
+
+ pkg_alternatives = xbps_dictionary_get(pkg_repod, "alternatives");
+ if (!xbps_dictionary_count(pkg_alternatives))
+ return 0;
allkeys = xbps_dictionary_all_keys(pkg_alternatives);
for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
diff --git a/tests/xbps/xbps-alternatives/main_test.sh b/tests/xbps/xbps-alternatives/main_test.sh
index fd66bcbf..4eddc411 100644
--- tests/xbps/xbps-alternatives/main_test.sh
+++ tests/xbps/xbps-alternatives/main_test.sh
@@ -674,6 +674,98 @@ respect_current_provider_body() {
atf_check_equal $rv 0
}
+atf_test_case prune_leftover_groups
+
+prune_leftover_groups_head() {
+ atf_set "descr" "xbps-alternatives: prune leftover groups on upgrades"
+}
+prune_leftover_groups_body() {
+ mkdir -p repo pkg_A/usr/bin pkg_B/usr/bin
+ touch pkg_A/usr/bin/fileA pkg_B/usr/bin/fileB
+ cd repo
+ xbps-create -A noarch -n A-1.1_1 -s "A pkg" --alternatives "file:/usr/bin/file:/usr/bin/fileA" ../pkg_A
+ atf_check_equal $? 0
+ xbps-create -A noarch -n B-1.1_1 -s "B pkg" --alternatives "file:/usr/bin/file:/usr/bin/fileB" ../pkg_B
+ atf_check_equal $? 0
+ xbps-rindex -d -a $PWD/*.xbps
+ atf_check_equal $? 0
+ cd ..
+
+ # A is the current provider now
+ xbps-install -r root --repository=repo -ydv A
+ atf_check_equal $? 0
+
+ out=$(xbps-query -r root -p pkgver A)
+ atf_check_equal $out A-1.1_1
+
+ # C will replace it via a transitional package
+ mkdir -p pkg_C/usr/bin
+ touch pkg_C/usr/bin/fileC
+ rm pkg_A/usr/bin/fileA
+ cd repo
+ xbps-create -A noarch -n C-1.2_1 -s "C pkg" --alternatives "file:/usr/bin/file:/usr/bin/fileC" ../pkg_C
+ atf_check_equal $? 0
+ xbps-create -A noarch -n A-1.2_1 -s "A pkg" --dependencies "C>=1.2_1" ../pkg_A
+ atf_check_equal $? 0
+ xbps-rindex -d -a $PWD/*.xbps
+ atf_check_equal $? 0
+ cd ..
+
+ # C is now the current provider, via upgraded A
+ # also install B, to make sure it doesn't get that first
+ xbps-install -r root --repository=repo -ydv B A
+
+ out=$(xbps-query -r root -p pkgver A)
+ atf_check_equal $out A-1.2_1
+ out=$(xbps-query -r root -p pkgver B)
+ atf_check_equal $out B-1.1_1
+ out=$(xbps-query -r root -p pkgver C)
+ atf_check_equal $out C-1.2_1
+
+ lnk=$(readlink -f root/usr/bin/file)
+ rv=1
+ if [ "$lnk" = "$PWD/root/usr/bin/fileC" ]; then
+ rv=0
+ fi
+ echo "lnk: $lnk"
+ atf_check_equal $rv 0
+
+ # Create a new provider, D; then make C a removed package
+ mkdir -p pkg_D/usr/bin
+ touch pkg_D/usr/bin/fileD
+ rm pkg_C/usr/bin/fileC
+ cd repo
+ xbps-create -A noarch -n D-1.4_1 -s "D pkg" --alternatives "file:/usr/bin/file:/usr/bin/fileD" ../pkg_D
+ atf_check_equal $? 0
+ xbps-create -A noarch -n C-1.3_1 -s "C pkg" ../pkg_C
+ atf_check_equal $? 0
+ xbps-rindex -d -a $PWD/*.xbps
+ atf_check_equal $? 0
+ cd ..
+
+ # B is now the current provider, as it's the first group available after
+ # pruning C; the system special cases packages without dependencies as
+ # removed packages, so it will not assume a renamed replacement
+ xbps-install -r root --repository=repo -ydv C D
+
+ out=$(xbps-query -r root -p pkgver A)
+ atf_check_equal $out A-1.2_1
+ out=$(xbps-query -r root -p pkgver B)
+ atf_check_equal $out B-1.1_1
+ out=$(xbps-query -r root -p pkgver C)
+ atf_check_equal $out C-1.3_1
+ out=$(xbps-query -r root -p pkgver D)
+ atf_check_equal $out D-1.4_1
+
+ lnk=$(readlink -f root/usr/bin/file)
+ rv=1
+ if [ "$lnk" = "$PWD/root/usr/bin/fileB" ]; then
+ rv=0
+ fi
+ echo "lnk: $lnk"
+ atf_check_equal $rv 0
+}
+
atf_init_test_cases() {
atf_add_test_case register_one
atf_add_test_case register_one_dangling
@@ -692,4 +784,5 @@ atf_init_test_cases() {
atf_add_test_case useless_switch
atf_add_test_case remove_current_provider
atf_add_test_case respect_current_provider
+ atf_add_test_case prune_leftover_groups
}

View file

@ -1,14 +0,0 @@
diff --git lib/package_alternatives.c lib/package_alternatives.c
index ecdc40ae..2dbb6546 100644
--- lib/package_alternatives.c
+++ lib/package_alternatives.c
@@ -113,6 +113,9 @@ remove_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
unsigned int i, cnt;
struct stat st;
+ if (strcmp(grname, "cc") == 0)
+ return 0;
+
cnt = xbps_array_count(a);
for (i = 0; i < cnt; i++) {
xbps_string_t str;

View file

@ -1,36 +0,0 @@
commit cf20e53d34446bcf8d1dd6c8da9fedf4dd5447ab
Author: Duncan Overbruck <mail@duncano.de>
Date: Tue Jan 28 20:03:56 2020 +0100
lib/fetch: fix CVE-2020-7450
diff --git lib/fetch/fetch.c lib/fetch/fetch.c
index d0cce7b8..feaf768d 100644
--- lib/fetch/fetch.c
+++ lib/fetch/fetch.c
@@ -331,6 +331,8 @@ fetch_pctdecode(char *dst, const char *src, size_t dlen)
}
if (dlen-- > 0)
*dst++ = c;
+ else
+ return (NULL);
}
return (s);
}
@@ -481,10 +483,14 @@ find_user:
if (p != NULL && *p == '@') {
/* username */
q = fetch_pctdecode(u->user, URL, URL_USERLEN);
+ if (q == NULL)
+ goto ouch;
/* password */
- if (*q == ':')
+ if (*q == ':') {
q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN);
-
+ if (q == NULL)
+ goto ouch;
+ }
p++;
} else {
p = URL;

View file

@ -1,70 +0,0 @@
We only care if the `pkg-config` bin is there, don't override
it with the result from _which(). In the xbps-src world,
pkg-config is a wrapper, that makes it cross compile easily.
--xtraeme
--- configure.orig 2019-12-26 14:48:59.160477429 +0100
+++ configure 2019-12-26 14:50:45.476628591 +0100
@@ -683,14 +683,14 @@ fi
LIBARCHIVE_REQVER=3.3.3
printf "Checking for libarchive >= ${LIBARCHIVE_REQVER} via pkg-config ... "
-if ! $PKGCONFIG_BIN --atleast-version=${LIBARCHIVE_REQVER} libarchive; then
+if ! pkg-config --atleast-version=${LIBARCHIVE_REQVER} libarchive; then
echo "libarchive.pc file not found, exiting."
exit 1
else
- echo "found version $($PKGCONFIG_BIN --modversion libarchive)."
- echo "CFLAGS += $($PKGCONFIG_BIN --cflags libarchive)" >>$CONFIG_MK
- echo "LDFLAGS += $($PKGCONFIG_BIN --libs libarchive)" >>$CONFIG_MK
- echo "STATIC_LIBS += $($PKGCONFIG_BIN --libs --static libarchive)" \
+ echo "found version $(pkg-config --modversion libarchive)."
+ echo "CFLAGS += $(pkg-config --cflags libarchive)" >>$CONFIG_MK
+ echo "LDFLAGS += $(pkg-config --libs libarchive)" >>$CONFIG_MK
+ echo "STATIC_LIBS += $(pkg-config --libs --static libarchive)" \
>>$CONFIG_MK
fi
@@ -698,17 +698,17 @@ fi
# libssl with pkg-config support is required.
#
printf "Checking for libssl via pkg-config ... "
-if $PKGCONFIG_BIN --exists 'libssl < 1.2' && ! $PKGCONFIG_BIN --exists libtls ; then
- echo "found OpenSSL version $($PKGCONFIG_BIN --modversion libssl)."
-elif $PKGCONFIG_BIN --exists libssl libtls; then
- echo "found LibreSSL version $($PKGCONFIG_BIN --modversion libssl)."
+if pkg-config --exists 'libssl < 1.2' && ! pkg-config --exists libtls ; then
+ echo "found OpenSSL version $(pkg-config --modversion libssl)."
+elif pkg-config --exists libssl libtls; then
+ echo "found LibreSSL version $(pkg-config --modversion libssl)."
else
echo "libssl.pc file not found or incompatible version detected, exiting."
exit 1
fi
-echo "CFLAGS += $($PKGCONFIG_BIN --cflags libssl)" >>$CONFIG_MK
-echo "LDFLAGS += $($PKGCONFIG_BIN --libs libssl)" >>$CONFIG_MK
-echo "STATIC_LIBS += $($PKGCONFIG_BIN --libs --static libssl)" \
+echo "CFLAGS += $(pkg-config --cflags libssl)" >>$CONFIG_MK
+echo "LDFLAGS += $(pkg-config --libs libssl)" >>$CONFIG_MK
+echo "STATIC_LIBS += $(pkg-config --libs --static libssl)" \
>>$CONFIG_MK
#
@@ -726,13 +726,13 @@ fi
#
if [ "$BUILD_TESTS" = "yes" ]; then
printf "Checking for ATF via pkg-config ... "
- if ! $PKGCONFIG_BIN --atleast-version=0.15 atf-c; then
+ if ! pkg-config --atleast-version=0.15 atf-c; then
echo "ATF >= 0.15 not found in PKG_CONFIG_LIBDIR, exiting."
exit 1
fi
- echo "found version $($PKGCONFIG_BIN --modversion atf-c)."
- echo "TEST_CFLAGS += $($PKGCONFIG_BIN --cflags atf-c)" >>$CONFIG_MK
- echo "TEST_LDFLAGS += $($PKGCONFIG_BIN --libs atf-c)" >>$CONFIG_MK
+ echo "found version $(pkg-config --modversion atf-c)."
+ echo "TEST_CFLAGS += $(pkg-config --cflags atf-c)" >>$CONFIG_MK
+ echo "TEST_LDFLAGS += $(pkg-config --libs atf-c)" >>$CONFIG_MK
echo "BUILD_TESTS = yes" >>$CONFIG_MK
BUILD_TESTS_VALUE=yes
else

View file

@ -1,144 +0,0 @@
commit 87ff41f401cb8b159859b65a04b398ac58a55e2d
Author: Duncan Overbruck <mail@duncano.de>
Date: Tue Oct 29 13:13:21 2019 +0100
Revert "lib/util.c: verify revision in xbps_pkg_{version,revision,name}"
This reverts commit 699b2bdd3b98b086ac989af3cf034135a7a6f570.
diff --git lib/util.c lib/util.c
index 6228d8fc..ee690304 100644
--- lib/util.c
+++ lib/util.c
@@ -50,16 +50,6 @@
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
-static bool is_numeric(const char *str) {
- if (str == NULL || str[0] == '\0'){
- return false;
- }
- while (isdigit(str[0])) {
- ++str;
- }
- return str[0] == '\0';
-}
-
/**
* @file lib/util.c
* @brief Utility routines
@@ -127,22 +117,16 @@ xbps_pkg_is_ignored(struct xbps_handle *xhp, const char *pkg)
const char *
xbps_pkg_version(const char *pkg)
{
- const char *p, *r;
- size_t p_len;
+ const char *p;
if ((p = strrchr(pkg, '-')) == NULL)
return NULL;
- ++p; /* skip first '-' */
- p_len = strlen(p);
- for (unsigned int i = 0; i < p_len; i++) {
+ for (unsigned int i = 0; i < strlen(p); i++) {
if (p[i] == '_')
break;
- if (isdigit((unsigned char)p[i]) && (r = strchr(p + i + 1, '_'))) {
- if (!is_numeric(r + 1)) {
- break;
- }
- return p;
+ if (isdigit((unsigned char)p[i]) && strchr(p, '_')) {
+ return p + 1; /* skip first '-' */
}
}
return NULL;
@@ -224,47 +208,36 @@ xbps_binpkg_arch(const char *pkg)
const char *
xbps_pkg_revision(const char *pkg)
{
- const char *p, *r;
- size_t p_len;
+ const char *p;
- if ((p = strrchr(pkg, '-')) == NULL)
+ assert(pkg != NULL);
+
+ /* Get the required revision */
+ if ((p = strrchr(pkg, '_')) == NULL)
return NULL;
- ++p; /* skip first '-' */
- p_len = strlen(p);
- for (unsigned int i = 0; i < p_len; i++) {
- if (p[i] == '_')
- break;
- if (isdigit((unsigned char)p[i]) && (r = strchr(p + i + 1, '_'))) {
- ++r; /* skip first '_' */
- if (!is_numeric(r)) {
- break;
- }
- return r;
- }
- }
- return NULL;
+ if (!isdigit((unsigned char)p[1]))
+ return NULL;
+
+ return p + 1; /* skip first '_' */
}
char *
xbps_pkg_name(const char *pkg)
{
- const char *p, *r;
+ const char *p;
char *buf;
unsigned int len;
- size_t p_len;
bool valid = false;
if ((p = strrchr(pkg, '-')) == NULL)
return NULL;
- p_len = strlen(p);
- /* i = 1 skips first '-' */
- for (unsigned int i = 1; i < p_len; i++) {
+ for (unsigned int i = 0; i < strlen(p); i++) {
if (p[i] == '_')
break;
- if (isdigit((unsigned char)p[i]) && (r = strchr(p + i + 1, '_'))) {
- valid = is_numeric(r + 1);
+ if (isdigit((unsigned char)p[i]) && strchr(p, '_')) {
+ valid = true;
break;
}
}
diff --git tests/xbps/libxbps/util/main.c tests/xbps/libxbps/util/main.c
index 41aac6ee..9ae88f1c 100644
--- tests/xbps/libxbps/util/main.c
+++ tests/xbps/libxbps/util/main.c
@@ -43,19 +43,19 @@ ATF_TC_BODY(util_test, tc)
ATF_CHECK_EQ(xbps_pkg_name("python-e_dbus"), NULL);
ATF_CHECK_EQ(xbps_pkg_name("fs-utils-v1"), NULL);
ATF_CHECK_EQ(xbps_pkg_name("fs-utils-v_1"), NULL);
- ATF_CHECK_EQ(xbps_pkg_name("font-adobe-100dpi-1.8_blah"), NULL);
ATF_CHECK_EQ(xbps_pkg_version("font-adobe-100dpi"), NULL);
ATF_CHECK_EQ(xbps_pkg_version("font-adobe-100dpi-7.8"), NULL);
ATF_CHECK_EQ(xbps_pkg_version("python-e_dbus"), NULL);
ATF_CHECK_EQ(xbps_pkg_version("python-e_dbus-1"), NULL);
- ATF_CHECK_EQ(xbps_pkg_version("font-adobe-100dpi-1.8_blah"), NULL);
- ATF_CHECK_EQ(xbps_pkg_revision("systemd-43_1_0"), NULL);
ATF_REQUIRE_STREQ(xbps_pkg_name("font-adobe-100dpi-7.8_2"), "font-adobe-100dpi");
ATF_REQUIRE_STREQ(xbps_pkg_name("systemd-43_1"), "systemd");
+ ATF_REQUIRE_STREQ(xbps_pkg_name("font-adobe-100dpi-1.8_blah"), "font-adobe-100dpi");
ATF_REQUIRE_STREQ(xbps_pkg_name("python-e_dbus-1.0_1"), "python-e_dbus");
ATF_REQUIRE_STREQ(xbps_pkg_version("font-adobe-100dpi-7.8_2"), "7.8_2");
+ ATF_REQUIRE_STREQ(xbps_pkg_version("font-adobe-100dpi-1.8_blah"), "1.8_blah");
ATF_REQUIRE_STREQ(xbps_pkg_version("python-e_dbus-1_1"), "1_1");
ATF_REQUIRE_STREQ(xbps_pkg_version("fs-utils-v1_1"), "v1_1");
+ ATF_REQUIRE_STREQ(xbps_pkg_revision("systemd-43_1_0"), "0");
ATF_REQUIRE_STREQ(xbps_pkg_revision("systemd_21-43_0"), "0");
ATF_REQUIRE_STREQ(xbps_pkgpattern_name("systemd>=43"), "systemd");
ATF_REQUIRE_STREQ(xbps_pkgpattern_name("systemd>43"), "systemd");

View file

@ -1,82 +0,0 @@
Sync xbps-checkvers(1) with code from 0.58.
This fixes detection of subpkgs in xbps repos.
--xtraeme
--- bin/xbps-checkvers/main.c.orig 2019-10-27 09:50:11.000000000 +0100
+++ bin/xbps-checkvers/main.c 2020-01-04 11:24:38.109708818 +0100
@@ -46,22 +46,15 @@
#define GOT_REVISION_VAR 0x4
typedef struct _rcv_t {
- const char *prog, *fname;
- char *xbps_conf, *rootdir, *distdir;
- char *buf;
- size_t bufsz;
- size_t len;
- char *ptr;
+ const char *prog, *fname, *format;
+ char *xbps_conf, *rootdir, *distdir, *buf, *ptr, *cachefile;
+ size_t bufsz, len;
uint8_t have_vars;
+ bool show_all, manual, installed;
xbps_dictionary_t env;
xbps_dictionary_t pkgd;
xbps_dictionary_t cache;
struct xbps_handle xhp;
- bool show_all;
- bool manual;
- bool installed;
- const char *format;
- char *cachefile;
} rcv_t;
typedef int (*rcv_check_func)(rcv_t *);
@@ -535,9 +528,10 @@ static int
rcv_check_version(rcv_t *rcv)
{
const char *repover = NULL;
- char srcver[BUFSIZ] = { '\0' };
+ char srcver[BUFSIZ] = { '\0' }, *binpkgname = NULL, *s = NULL;
const char *pkgname, *version, *revision, *reverts, *repourl;
int sz;
+ size_t len;
assert(rcv);
@@ -568,17 +562,24 @@ rcv_check_version(rcv_t *rcv)
if (sz < 0 || (size_t)sz >= sizeof srcver)
exit(EXIT_FAILURE);
+ /* Check against binpkg's pkgname, not pkgname from template */
+ s = strchr(rcv->fname, '/');
+ len = s ? strlen(rcv->fname) - strlen(s) : strlen(rcv->fname);
+ binpkgname = strndup(rcv->fname, len);
+ assert(binpkgname);
+
repourl = NULL;
if (rcv->installed) {
- rcv->pkgd = xbps_pkgdb_get_pkg(&rcv->xhp, pkgname);
+ rcv->pkgd = xbps_pkgdb_get_pkg(&rcv->xhp, binpkgname);
} else {
- rcv->pkgd = xbps_rpool_get_pkg(&rcv->xhp, pkgname);
+ rcv->pkgd = xbps_rpool_get_pkg(&rcv->xhp, binpkgname);
xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "repository", &repourl);
}
xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "pkgver", &repover);
if (repover)
- repover += strlen(pkgname)+1;
+ repover += strlen(binpkgname)+1;
+ free(binpkgname);
if (!repover && rcv->manual)
;
else if (rcv->show_all)
@@ -717,7 +718,7 @@ main(int argc, char **argv)
free(tmp);
}
- rcv.cachefile = xbps_xasprintf("%s/.xbps-checkvers.plist", rcv.distdir);
+ rcv.cachefile = xbps_xasprintf("%s/.xbps-checkvers-0.58.plist", rcv.distdir);
argc -= optind;
argv += optind;

View file

@ -1,7 +1,7 @@
# Template file for 'xbps'
pkgname=xbps
version=0.57.1
revision=9
version=0.58
revision=1
bootstrap=yes
build_style=configure
short_desc="XBPS package system utilities"
@ -10,7 +10,7 @@ license="BSD-2-Clause"
homepage="https://github.com/void-linux/xbps"
changelog="https://github.com/void-linux/xbps/blob/master/NEWS"
distfiles="https://github.com/void-linux/xbps/archive/${version}.tar.gz"
checksum=bccad7c4187c467f322e6905fbe96839c00d2cbdda254c0c99b38eabeedb8678
checksum=c9cb0823d4aa72e57b1531bc01eb17dc66d64b461b8861bc4e081465a5dff144
hostmakedepends="pkgconf"
checkdepends="kyua"