xbps-rindex(8): fix #24 and added an ATF test case.
This commit is contained in:
parent
6861e1d623
commit
7c57918950
2
NEWS
2
NEWS
@ -1,5 +1,7 @@
|
|||||||
xbps-0.28 (2014-??-??):
|
xbps-0.28 (2014-??-??):
|
||||||
|
|
||||||
|
* Fixed issue #24: https://github.com/voidlinux/xbps/issues/24
|
||||||
|
|
||||||
xbps-0.27 (2013-11-29):
|
xbps-0.27 (2013-11-29):
|
||||||
|
|
||||||
* libxbps: make sure that base symlinks in the root directory are never removed,
|
* libxbps: make sure that base symlinks in the root directory are never removed,
|
||||||
|
@ -49,8 +49,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
|||||||
xbps_object_t obj, fileobj;
|
xbps_object_t obj, fileobj;
|
||||||
struct xbps_repo *repo;
|
struct xbps_repo *repo;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *oldpkgver, *arch, *oldarch;
|
const char *arch;
|
||||||
char *pkgver, *pkgname, *sha256, *repodir, *buf;
|
char *pkgver, *opkgver, *oarch, *pkgname, *sha256, *repodir;
|
||||||
char *tmprepodir;
|
char *tmprepodir;
|
||||||
int rv = 0, ret = 0;
|
int rv = 0, ret = 0;
|
||||||
bool flush = false, found = false;
|
bool flush = false, found = false;
|
||||||
@ -116,17 +116,17 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
|||||||
}
|
}
|
||||||
} else if (!force) {
|
} else if (!force) {
|
||||||
/* Only check version if !force */
|
/* Only check version if !force */
|
||||||
xbps_dictionary_get_cstring_nocopy(curpkgd,
|
xbps_dictionary_get_cstring(curpkgd, "pkgver", &opkgver);
|
||||||
"pkgver", &oldpkgver);
|
xbps_dictionary_get_cstring(curpkgd, "architecture", &oarch);
|
||||||
xbps_dictionary_get_cstring_nocopy(curpkgd,
|
ret = xbps_cmpver(pkgver, opkgver);
|
||||||
"architecture", &oldarch);
|
|
||||||
ret = xbps_cmpver(pkgver, oldpkgver);
|
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
/* Same version or index version greater */
|
/* Same version or index version greater */
|
||||||
fprintf(stderr, "index: skipping `%s' "
|
fprintf(stderr, "index: skipping `%s' "
|
||||||
"(%s), already registered.\n",
|
"(%s), already registered.\n",
|
||||||
pkgver, arch);
|
pkgver, arch);
|
||||||
xbps_object_release(newpkgd);
|
xbps_object_release(newpkgd);
|
||||||
|
free(opkgver);
|
||||||
|
free(oarch);
|
||||||
free(pkgver);
|
free(pkgver);
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
continue;
|
continue;
|
||||||
@ -135,11 +135,11 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
|||||||
* Current package version is greater than
|
* Current package version is greater than
|
||||||
* index version.
|
* index version.
|
||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf("`%s' (%s)", oldpkgver, oldarch);
|
|
||||||
xbps_dictionary_remove(idx, pkgname);
|
xbps_dictionary_remove(idx, pkgname);
|
||||||
xbps_dictionary_remove(idxfiles, oldpkgver);
|
xbps_dictionary_remove(idxfiles, opkgver);
|
||||||
printf("index: removed obsolete entry %s.\n", buf);
|
printf("index: removed obsolete entry `%s' (%s).\n", opkgver, oarch);
|
||||||
free(buf);
|
free(opkgver);
|
||||||
|
free(oarch);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* We have the dictionary now, add the required
|
* We have the dictionary now, add the required
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
syntax("kyuafile", 1)
|
syntax("kyuafile", 1)
|
||||||
|
|
||||||
test_suite("xbps-rindex")
|
test_suite("xbps-rindex")
|
||||||
|
atf_test_program{name="add_test"}
|
||||||
atf_test_program{name="clean_test"}
|
atf_test_program{name="clean_test"}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
TOPDIR = ../../..
|
TOPDIR = ../../..
|
||||||
-include $(TOPDIR)/config.mk
|
-include $(TOPDIR)/config.mk
|
||||||
|
|
||||||
TESTSHELL = clean_test
|
TESTSHELL = add_test clean_test
|
||||||
TESTSSUBDIR = xbps/xbps-rindex
|
TESTSSUBDIR = xbps/xbps-rindex
|
||||||
EXTRA_FILES = Kyuafile
|
EXTRA_FILES = Kyuafile
|
||||||
|
|
||||||
|
35
tests/xbps/xbps-rindex/add_test.sh
Normal file
35
tests/xbps/xbps-rindex/add_test.sh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#! /usr/bin/env atf-sh
|
||||||
|
# Test that xbps-rindex(8) -a (add mode) works as expected.
|
||||||
|
|
||||||
|
# 1st test: test that update mode work as expected.
|
||||||
|
atf_test_case update
|
||||||
|
|
||||||
|
update_head() {
|
||||||
|
atf_set "descr" "xbps-rindex(8) -a: update test"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_body() {
|
||||||
|
mkdir -p some_repo pkg_A
|
||||||
|
touch pkg_A/file00
|
||||||
|
cd some_repo
|
||||||
|
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-rindex -a *.xbps
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" ../pkg_A
|
||||||
|
atf_check_equal $? 0
|
||||||
|
xbps-rindex -a *.xbps
|
||||||
|
atf_check_equal $? 0
|
||||||
|
cd ..
|
||||||
|
result="$(xbps-query --repository=some_repo -o \*)"
|
||||||
|
expected="foo-1.1_1: /file00 (some_repo)"
|
||||||
|
rv=0
|
||||||
|
if [ "$result" != "$expected" ]; then
|
||||||
|
rv=1
|
||||||
|
fi
|
||||||
|
atf_check_equal $rv 0
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_init_test_cases() {
|
||||||
|
atf_add_test_case update
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user