xbps-checkvers: restore previous behaviour after 7a220b37db3.
The '%n' pkgname fmt option still needs to be the sourcepkg for xbps-src to work with no additional changes. This restores previous behaviour, and uses binpkg's pkgname while checking for pkgdb/repo.
This commit is contained in:
parent
90c040f37f
commit
64aeabf3f6
@ -46,22 +46,15 @@
|
|||||||
#define GOT_REVISION_VAR 0x4
|
#define GOT_REVISION_VAR 0x4
|
||||||
|
|
||||||
typedef struct _rcv_t {
|
typedef struct _rcv_t {
|
||||||
const char *prog, *fname;
|
const char *prog, *fname, *format;
|
||||||
char *xbps_conf, *rootdir, *distdir;
|
char *xbps_conf, *rootdir, *distdir, *buf, *ptr, *cachefile;
|
||||||
char *buf;
|
size_t bufsz, len;
|
||||||
size_t bufsz;
|
|
||||||
size_t len;
|
|
||||||
char *ptr;
|
|
||||||
uint8_t have_vars;
|
uint8_t have_vars;
|
||||||
|
bool show_all, manual, installed;
|
||||||
xbps_dictionary_t env;
|
xbps_dictionary_t env;
|
||||||
xbps_dictionary_t pkgd;
|
xbps_dictionary_t pkgd;
|
||||||
xbps_dictionary_t cache;
|
xbps_dictionary_t cache;
|
||||||
struct xbps_handle xhp;
|
struct xbps_handle xhp;
|
||||||
bool show_all;
|
|
||||||
bool manual;
|
|
||||||
bool installed;
|
|
||||||
const char *format;
|
|
||||||
char *cachefile;
|
|
||||||
} rcv_t;
|
} rcv_t;
|
||||||
|
|
||||||
typedef int (*rcv_check_func)(rcv_t *);
|
typedef int (*rcv_check_func)(rcv_t *);
|
||||||
@ -366,21 +359,6 @@ rcv_get_pkgver(rcv_t *rcv)
|
|||||||
else
|
else
|
||||||
val = strndup(v, vlen);
|
val = strndup(v, vlen);
|
||||||
|
|
||||||
/*
|
|
||||||
* Do not override binary package "pkgname"
|
|
||||||
* with the one from template, because the
|
|
||||||
* former might be a subpkg.
|
|
||||||
*/
|
|
||||||
if (strcmp(key, "pkgname") == 0) {
|
|
||||||
char *s;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
free(val);
|
|
||||||
s = strchr(rcv->fname, '/');
|
|
||||||
len = s ? strlen(rcv->fname) - strlen(s) : strlen(rcv->fname);
|
|
||||||
val = strndup(rcv->fname, len);
|
|
||||||
assert(val);
|
|
||||||
}
|
|
||||||
if (!xbps_dictionary_set(rcv->env, key,
|
if (!xbps_dictionary_set(rcv->env, key,
|
||||||
xbps_string_create_cstring(val))) {
|
xbps_string_create_cstring(val))) {
|
||||||
fprintf(stderr, "error: xbps_dictionary_set");
|
fprintf(stderr, "error: xbps_dictionary_set");
|
||||||
@ -550,9 +528,10 @@ static int
|
|||||||
rcv_check_version(rcv_t *rcv)
|
rcv_check_version(rcv_t *rcv)
|
||||||
{
|
{
|
||||||
const char *repover = NULL;
|
const char *repover = NULL;
|
||||||
char srcver[BUFSIZ] = { '\0' };
|
char srcver[BUFSIZ] = { '\0' }, *binpkgname = NULL, *s = NULL;
|
||||||
const char *pkgname, *version, *revision, *reverts, *repourl;
|
const char *pkgname, *version, *revision, *reverts, *repourl;
|
||||||
int sz;
|
int sz;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
assert(rcv);
|
assert(rcv);
|
||||||
|
|
||||||
@ -583,17 +562,24 @@ rcv_check_version(rcv_t *rcv)
|
|||||||
if (sz < 0 || (size_t)sz >= sizeof srcver)
|
if (sz < 0 || (size_t)sz >= sizeof srcver)
|
||||||
exit(EXIT_FAILURE);
|
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;
|
repourl = NULL;
|
||||||
if (rcv->installed) {
|
if (rcv->installed) {
|
||||||
rcv->pkgd = xbps_pkgdb_get_pkg(&rcv->xhp, pkgname);
|
rcv->pkgd = xbps_pkgdb_get_pkg(&rcv->xhp, binpkgname);
|
||||||
} else {
|
} 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, "repository", &repourl);
|
||||||
}
|
}
|
||||||
xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "pkgver", &repover);
|
xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "pkgver", &repover);
|
||||||
if (repover)
|
if (repover)
|
||||||
repover += strlen(pkgname)+1;
|
repover += strlen(binpkgname)+1;
|
||||||
|
|
||||||
|
free(binpkgname);
|
||||||
if (!repover && rcv->manual)
|
if (!repover && rcv->manual)
|
||||||
;
|
;
|
||||||
else if (rcv->show_all)
|
else if (rcv->show_all)
|
||||||
|
@ -468,7 +468,7 @@ subpkg_head() {
|
|||||||
atf_set "descr" "xbps-checkvers(1): test subpkgs"
|
atf_set "descr" "xbps-checkvers(1): test subpkgs"
|
||||||
}
|
}
|
||||||
subpkg_body() {
|
subpkg_body() {
|
||||||
mkdir -p some_repo pkg_A void-packages/srcpkgs/A
|
mkdir -p repo pkg_A void-packages/srcpkgs/A
|
||||||
touch pkg_A/file00
|
touch pkg_A/file00
|
||||||
cat > void-packages/srcpkgs/A/template <<EOF
|
cat > void-packages/srcpkgs/A/template <<EOF
|
||||||
pkgname=A
|
pkgname=A
|
||||||
@ -478,21 +478,21 @@ revision=1
|
|||||||
EOF
|
EOF
|
||||||
ln -s A void-packages/srcpkgs/A-subpkg
|
ln -s A void-packages/srcpkgs/A-subpkg
|
||||||
ln -s A void-packages/srcpkgs/B-subpkg
|
ln -s A void-packages/srcpkgs/B-subpkg
|
||||||
cd some_repo
|
cd repo
|
||||||
xbps-create -A noarch -n A-subpkg-1.1_1 -s "A-subpkg pkg" ../pkg_A
|
xbps-create -A noarch -n A-subpkg-1.1_1 -s "A-subpkg pkg" ../pkg_A
|
||||||
atf_check_equal $? 0
|
atf_check_equal $? 0
|
||||||
xbps-rindex -d -a $PWD/*.xbps
|
xbps-rindex -d -a $PWD/*.xbps
|
||||||
atf_check_equal $? 0
|
atf_check_equal $? 0
|
||||||
cd ..
|
cd ..
|
||||||
out=$(xbps-checkvers -i -R $PWD/some_repo -D $PWD/void-packages -sm A-subpkg)
|
out=$(xbps-checkvers -i -R $PWD/repo -D $PWD/void-packages -sm A-subpkg)
|
||||||
atf_check_equal $? 0
|
atf_check_equal $? 0
|
||||||
atf_check_equal "$out" "A-subpkg 1.1_1 1.0_1 A-subpkg $PWD/some_repo"
|
atf_check_equal "$out" "A 1.1_1 1.0_1 A-subpkg $PWD/repo"
|
||||||
|
|
||||||
out=$(xbps-checkvers -i -R $PWD/some_repo -D $PWD/void-packages -sm B-subpkg)
|
out=$(xbps-checkvers -i -R repo -D $PWD/void-packages -sm B-subpkg)
|
||||||
atf_check_equal $? 0
|
atf_check_equal $? 0
|
||||||
atf_check_equal "$out" "B-subpkg ? 1.0_1 B-subpkg ?"
|
atf_check_equal "$out" "A ? 1.0_1 B-subpkg ?"
|
||||||
|
|
||||||
out=$(xbps-checkvers -i -R $PWD/some_repo -D $PWD/void-packages -sm A)
|
out=$(xbps-checkvers -i -R repo -D $PWD/void-packages -sm A)
|
||||||
atf_check_equal $? 0
|
atf_check_equal $? 0
|
||||||
atf_check_equal "$out" "A ? 1.0_1 A ?"
|
atf_check_equal "$out" "A ? 1.0_1 A ?"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user