Get rid of libfetch and proplib external dependencies.

The list of required external deps is now confuse, libarchive and openssl.

libxbps now includes a wrapper for proplib prefixed with xbps_ rather than prop_.
This commit is contained in:
Juan RP
2013-06-20 10:26:12 +02:00
parent 31efece727
commit 42c0766c00
67 changed files with 3004 additions and 1487 deletions

View File

@@ -43,6 +43,6 @@ int remove_obsoletes(struct xbps_handle *, const char *);
/* From repoflush.c */
int repodata_flush(struct xbps_handle *, const char *,
prop_dictionary_t, prop_dictionary_t);
xbps_dictionary_t, xbps_dictionary_t);
#endif /* !_XBPS_RINDEX_DEFS_H_ */

View File

@@ -44,9 +44,9 @@
int
index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
{
prop_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles;
prop_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd;
prop_object_t obj, fileobj;
xbps_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles;
xbps_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd;
xbps_object_t obj, fileobj;
struct xbps_repo *repo;
struct stat st;
const char *oldpkgver, *arch, *oldarch;
@@ -72,9 +72,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
idxfiles = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES);
}
if (idx == NULL)
idx = prop_dictionary_create();
idx = xbps_dictionary_create();
if (idxfiles == NULL)
idxfiles = prop_dictionary_create();
idxfiles = xbps_dictionary_create();
if (repo != NULL)
xbps_repo_close(repo);
@@ -92,13 +92,13 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
" skipping!\n", XBPS_PKGPROPS, argv[i]);
continue;
}
prop_dictionary_get_cstring_nocopy(newpkgd, "architecture",
xbps_dictionary_get_cstring_nocopy(newpkgd, "architecture",
&arch);
prop_dictionary_get_cstring(newpkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring(newpkgd, "pkgver", &pkgver);
if (!xbps_pkg_arch_match(xhp, arch, NULL)) {
fprintf(stderr, "index: ignoring %s, unmatched "
"arch (%s)\n", pkgver, arch);
prop_object_release(newpkgd);
xbps_object_release(newpkgd);
continue;
}
pkgname = xbps_pkg_name(pkgver);
@@ -109,7 +109,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
* than current registered package, update the index; otherwise
* pass to the next one.
*/
curpkgd = prop_dictionary_get(idx, pkgname);
curpkgd = xbps_dictionary_get(idx, pkgname);
if (curpkgd == NULL) {
if (errno && errno != ENOENT) {
free(pkgver);
@@ -118,9 +118,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
}
} else if (!force) {
/* Only check version if !force */
prop_dictionary_get_cstring_nocopy(curpkgd,
xbps_dictionary_get_cstring_nocopy(curpkgd,
"pkgver", &oldpkgver);
prop_dictionary_get_cstring_nocopy(curpkgd,
xbps_dictionary_get_cstring_nocopy(curpkgd,
"architecture", &oldarch);
ret = xbps_cmpver(pkgver, oldpkgver);
if (ret <= 0) {
@@ -128,7 +128,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
fprintf(stderr, "index: skipping `%s' "
"(%s), already registered.\n",
pkgver, arch);
prop_object_release(newpkgd);
xbps_object_release(newpkgd);
free(pkgver);
free(pkgname);
continue;
@@ -138,7 +138,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
* index version.
*/
buf = xbps_xasprintf("`%s' (%s)", oldpkgver, oldarch);
prop_dictionary_remove(idx, pkgname);
xbps_dictionary_remove(idx, pkgname);
printf("index: removed obsolete entry %s.\n", buf);
free(buf);
}
@@ -151,7 +151,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
free(pkgname);
return errno;
}
if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256",
if (!xbps_dictionary_set_cstring(newpkgd, "filename-sha256",
sha256)) {
free(pkgver);
free(pkgname);
@@ -165,7 +165,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
return errno;
}
if (!prop_dictionary_set_uint64(newpkgd, "filename-size",
if (!xbps_dictionary_set_uint64(newpkgd, "filename-size",
(uint64_t)st.st_size)) {
free(pkgver);
free(pkgname);
@@ -174,23 +174,23 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
/*
* Remove obsolete package objects.
*/
prop_dictionary_remove(newpkgd, "archive-compression-type");
prop_dictionary_remove(newpkgd, "build-date");
prop_dictionary_remove(newpkgd, "build_date");
prop_dictionary_remove(newpkgd, "conf_files");
prop_dictionary_remove(newpkgd, "filename");
prop_dictionary_remove(newpkgd, "homepage");
prop_dictionary_remove(newpkgd, "license");
prop_dictionary_remove(newpkgd, "maintainer");
prop_dictionary_remove(newpkgd, "packaged-with");
prop_dictionary_remove(newpkgd, "source-revisions");
prop_dictionary_remove(newpkgd, "long_desc");
prop_dictionary_remove(newpkgd, "pkgname");
prop_dictionary_remove(newpkgd, "version");
xbps_dictionary_remove(newpkgd, "archive-compression-type");
xbps_dictionary_remove(newpkgd, "build-date");
xbps_dictionary_remove(newpkgd, "build_date");
xbps_dictionary_remove(newpkgd, "conf_files");
xbps_dictionary_remove(newpkgd, "filename");
xbps_dictionary_remove(newpkgd, "homepage");
xbps_dictionary_remove(newpkgd, "license");
xbps_dictionary_remove(newpkgd, "maintainer");
xbps_dictionary_remove(newpkgd, "packaged-with");
xbps_dictionary_remove(newpkgd, "source-revisions");
xbps_dictionary_remove(newpkgd, "long_desc");
xbps_dictionary_remove(newpkgd, "pkgname");
xbps_dictionary_remove(newpkgd, "version");
/*
* Add new pkg dictionary into the index.
*/
if (!prop_dictionary_set(idx, pkgname, newpkgd)) {
if (!xbps_dictionary_set(idx, pkgname, newpkgd)) {
free(pkgname);
return EINVAL;
}
@@ -209,68 +209,68 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
}
/* Find out if binary pkg stored in index contain any file */
pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files");
if (prop_array_count(pkg_cffiles))
pkg_cffiles = xbps_dictionary_get(newpkgfilesd, "conf_files");
if (xbps_array_count(pkg_cffiles))
found = true;
else
pkg_cffiles = NULL;
pkg_files = prop_dictionary_get(newpkgfilesd, "files");
if (prop_array_count(pkg_files))
pkg_files = xbps_dictionary_get(newpkgfilesd, "files");
if (xbps_array_count(pkg_files))
found = true;
else
pkg_files = NULL;
pkg_links = prop_dictionary_get(newpkgfilesd, "links");
if (prop_array_count(pkg_links))
pkg_links = xbps_dictionary_get(newpkgfilesd, "links");
if (xbps_array_count(pkg_links))
found = true;
else
pkg_links = NULL;
/* If pkg does not contain any file, ignore it */
if (!found) {
prop_object_release(newpkgfilesd);
prop_object_release(newpkgd);
xbps_object_release(newpkgfilesd);
xbps_object_release(newpkgd);
free(pkgver);
free(pkgname);
continue;
}
/* create pkg files array */
filespkgar = prop_array_create();
filespkgar = xbps_array_create();
assert(filespkgar);
/* add conf_files in pkg files array */
if (pkg_cffiles != NULL) {
for (x = 0; x < prop_array_count(pkg_cffiles); x++) {
obj = prop_array_get(pkg_cffiles, x);
fileobj = prop_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj);
for (x = 0; x < xbps_array_count(pkg_cffiles); x++) {
obj = xbps_array_get(pkg_cffiles, x);
fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj);
}
}
/* add files array in pkg array */
if (pkg_files != NULL) {
for (x = 0; x < prop_array_count(pkg_files); x++) {
obj = prop_array_get(pkg_files, x);
fileobj = prop_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj);
for (x = 0; x < xbps_array_count(pkg_files); x++) {
obj = xbps_array_get(pkg_files, x);
fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj);
}
}
/* add links array in pkgd */
if (pkg_links != NULL) {
for (x = 0; x < prop_array_count(pkg_links); x++) {
obj = prop_array_get(pkg_links, x);
fileobj = prop_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj);
for (x = 0; x < xbps_array_count(pkg_links); x++) {
obj = xbps_array_get(pkg_links, x);
fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj);
}
}
prop_object_release(newpkgfilesd);
xbps_object_release(newpkgfilesd);
/* add pkg files array into index-files */
prop_dictionary_set(idxfiles, pkgver, filespkgar);
prop_object_release(filespkgar);
xbps_dictionary_set(idxfiles, pkgver, filespkgar);
xbps_object_release(filespkgar);
printf("index-files: added `%s' (%s)\n", pkgver, arch);
prop_object_release(newpkgd);
xbps_object_release(newpkgd);
free(pkgver);
free(pkgname);
}
@@ -283,12 +283,12 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
return rv;
}
printf("index: %u packages registered.\n",
prop_dictionary_count(idx));
xbps_dictionary_count(idx));
printf("index-files: %u packages registered.\n",
prop_dictionary_count(idxfiles));
xbps_dictionary_count(idxfiles));
prop_object_release(idx);
prop_object_release(idxfiles);
xbps_object_release(idx);
xbps_object_release(idxfiles);
return 0;
}

View File

@@ -40,10 +40,10 @@
struct thread_data {
pthread_t thread;
prop_dictionary_t idx;
prop_dictionary_t idxfiles;
prop_array_t result;
prop_array_t result_files;
xbps_dictionary_t idx;
xbps_dictionary_t idxfiles;
xbps_array_t result;
xbps_array_t result_files;
struct xbps_handle *xhp;
unsigned int start;
unsigned int end;
@@ -53,22 +53,22 @@ struct thread_data {
static void *
cleaner_thread(void *arg)
{
prop_object_t obj;
prop_dictionary_t pkgd;
prop_array_t array;
xbps_object_t obj;
xbps_dictionary_t pkgd;
xbps_array_t array;
struct thread_data *thd = arg;
char *filen;
const char *pkgver, *arch, *sha256;
unsigned int i;
/* process pkgs from start until end */
array = prop_dictionary_all_keys(thd->idx);
array = xbps_dictionary_all_keys(thd->idx);
for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i);
pkgd = prop_dictionary_get_keysym(thd->idx, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
obj = xbps_array_get(array, i);
pkgd = xbps_dictionary_get_keysym(thd->idx, obj);
xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
filen = xbps_xasprintf("%s.%s.xbps", pkgver, arch);
xbps_dbg_printf(thd->xhp, "thread[%d] checking %s\n",
thd->thread_num, pkgver);
@@ -77,20 +77,20 @@ cleaner_thread(void *arg)
* File cannot be read, might be permissions,
* broken or simply unexistent; either way, remove it.
*/
prop_array_add_cstring_nocopy(thd->result, pkgver);
xbps_array_add_cstring_nocopy(thd->result, pkgver);
free(filen);
continue;
}
/*
* File can be read; check its hash.
*/
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"filename-sha256", &sha256);
if (xbps_file_hash_check(filen, sha256) != 0)
prop_array_add_cstring_nocopy(thd->result, pkgver);
xbps_array_add_cstring_nocopy(thd->result, pkgver);
free(filen);
}
prop_object_release(array);
xbps_object_release(array);
return NULL;
}
@@ -98,35 +98,35 @@ cleaner_thread(void *arg)
static void *
cleaner_files_thread(void *arg)
{
prop_object_t obj;
prop_array_t array;
prop_dictionary_t ipkgd;
xbps_object_t obj;
xbps_array_t array;
xbps_dictionary_t ipkgd;
struct thread_data *thd = arg;
const char *pkgver, *ipkgver;
char *pkgname;
unsigned int i;
/* process pkgs from start until end */
array = prop_dictionary_all_keys(thd->idxfiles);
array = xbps_dictionary_all_keys(thd->idxfiles);
for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i);
pkgver = prop_dictionary_keysym_cstring_nocopy(obj);
obj = xbps_array_get(array, i);
pkgver = xbps_dictionary_keysym_cstring_nocopy(obj);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
ipkgd = prop_dictionary_get(thd->idx, pkgname);
ipkgd = xbps_dictionary_get(thd->idx, pkgname);
/* If pkg is not registered in index, remove it */
if (ipkgd == NULL)
prop_array_add_cstring_nocopy(thd->result_files, pkgver);
xbps_array_add_cstring_nocopy(thd->result_files, pkgver);
/* if another version is registered in index, remove it */
else {
prop_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver);
xbps_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver);
if (strcmp(ipkgver, pkgver))
prop_array_add_cstring_nocopy(thd->result_files, pkgver);
xbps_array_add_cstring_nocopy(thd->result_files, pkgver);
}
free(pkgname);
}
prop_object_release(array);
xbps_object_release(array);
return NULL;
}
@@ -140,7 +140,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
{
struct xbps_repo *repo;
struct thread_data *thd;
prop_dictionary_t idx, idxfiles;
xbps_dictionary_t idx, idxfiles;
const char *keyname;
char *pkgname;
unsigned int x, pkgcount, slicecount;
@@ -171,18 +171,18 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
thd = calloc(maxthreads, sizeof(*thd));
slicecount = prop_dictionary_count(idx) / maxthreads;
slicecount = xbps_dictionary_count(idx) / maxthreads;
pkgcount = 0;
/* Setup threads to cleanup index and index-files */
for (i = 0; i < maxthreads; i++) {
thd[i].thread_num = i;
thd[i].idx = idx;
thd[i].result = prop_array_create();
thd[i].result = xbps_array_create();
thd[i].xhp = xhp;
thd[i].start = pkgcount;
if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(idx);
thd[i].end = xbps_dictionary_count(idx);
else
thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]);
@@ -193,18 +193,18 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pthread_join(thd[i].thread, NULL);
/* Setup threads to cleanup index-files */
slicecount = prop_dictionary_count(idxfiles) / maxthreads;
slicecount = xbps_dictionary_count(idxfiles) / maxthreads;
pkgcount = 0;
for (i = 0; i < maxthreads; i++) {
thd[i].thread_num = i;
thd[i].idx = idx;
thd[i].idxfiles = idxfiles;
thd[i].result_files = prop_array_create();
thd[i].result_files = xbps_array_create();
thd[i].xhp = xhp;
thd[i].start = pkgcount;
if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(idxfiles);
thd[i].end = xbps_dictionary_count(idxfiles);
else
thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_files_thread, &thd[i]);
@@ -215,21 +215,21 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pthread_join(thd[i].thread, NULL);
for (i = 0; i < maxthreads; i++) {
for (x = 0; x < prop_array_count(thd[i].result); x++) {
prop_array_get_cstring_nocopy(thd[i].result,
for (x = 0; x < xbps_array_count(thd[i].result); x++) {
xbps_array_get_cstring_nocopy(thd[i].result,
x, &keyname);
printf("index: removed entry %s\n", keyname);
pkgname = xbps_pkg_name(keyname);
prop_dictionary_remove(idx, pkgname);
prop_dictionary_remove(idxfiles, keyname);
xbps_dictionary_remove(idx, pkgname);
xbps_dictionary_remove(idxfiles, keyname);
free(pkgname);
flush = true;
}
for (x = 0; x < prop_array_count(thd[i].result_files); x++) {
prop_array_get_cstring_nocopy(thd[i].result_files,
for (x = 0; x < xbps_array_count(thd[i].result_files); x++) {
xbps_array_get_cstring_nocopy(thd[i].result_files,
x, &keyname);
printf("index-files: removed entry %s\n", keyname);
prop_dictionary_remove(idxfiles, keyname);
xbps_dictionary_remove(idxfiles, keyname);
flush = true;
}
}
@@ -239,11 +239,11 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
return rv;
}
printf("index: %u packages registered.\n",
prop_dictionary_count(idx));
xbps_dictionary_count(idx));
printf("index-files: %u packages registered.\n",
prop_dictionary_count(idxfiles));
prop_object_release(idx);
prop_object_release(idxfiles);
xbps_dictionary_count(idxfiles));
xbps_object_release(idx);
xbps_object_release(idxfiles);
return rv;
}

View File

@@ -39,7 +39,7 @@
struct thread_data {
pthread_t thread;
prop_array_t array;
xbps_array_t array;
struct xbps_repo *repo;
unsigned int start;
unsigned int end;
@@ -84,7 +84,7 @@ remove_pkg(const char *repodir, const char *arch, const char *file)
static void *
cleaner_thread(void *arg)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
struct thread_data *thd = arg;
const char *binpkg, *pkgver, *arch;
unsigned int i;
@@ -92,21 +92,21 @@ cleaner_thread(void *arg)
/* process pkgs from start until end */
for (i = thd->start; i < thd->end; i++) {
prop_array_get_cstring_nocopy(thd->array, i, &binpkg);
xbps_array_get_cstring_nocopy(thd->array, i, &binpkg);
pkgd = xbps_get_pkg_plist_from_binpkg(binpkg, "./props.plist");
if (pkgd == NULL) {
rv = remove_pkg(thd->repo->uri, arch, binpkg);
if (rv != 0) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
continue;
}
printf("Removed broken package `%s'.\n", binpkg);
}
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
/* ignore pkgs from other archs */
if (!xbps_pkg_arch_match(thd->repo->xhp, arch, NULL)) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
continue;
}
xbps_dbg_printf(thd->repo->xhp, "thread[%d] checking %s (%s)\n",
@@ -117,12 +117,12 @@ cleaner_thread(void *arg)
if (!xbps_repo_get_pkg(thd->repo, pkgver)) {
rv = remove_pkg(thd->repo->uri, arch, binpkg);
if (rv != 0) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
continue;
}
printf("Removed obsolete package `%s'.\n", binpkg);
}
prop_object_release(pkgd);
xbps_object_release(pkgd);
}
return NULL;
@@ -131,7 +131,7 @@ cleaner_thread(void *arg)
int
remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
{
prop_array_t array = NULL;
xbps_array_t array = NULL;
struct xbps_repo *repo;
struct thread_data *thd;
DIR *dirp;
@@ -171,16 +171,16 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
if (strcmp(ext, ".xbps"))
continue;
if (array == NULL)
array = prop_array_create();
array = xbps_array_create();
prop_array_add_cstring(array, dp->d_name);
xbps_array_add_cstring(array, dp->d_name);
}
(void)closedir(dirp);
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
thd = calloc(maxthreads, sizeof(*thd));
slicecount = prop_array_count(array) / maxthreads;
slicecount = xbps_array_count(array) / maxthreads;
pkgcount = 0;
for (i = 0; i < maxthreads; i++) {
@@ -189,7 +189,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
thd[i].repo = repo;
thd[i].start = pkgcount;
if (i + 1 >= maxthreads)
thd[i].end = prop_array_count(array);
thd[i].end = xbps_array_count(array);
else
thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]);

View File

@@ -39,7 +39,7 @@
int
repodata_flush(struct xbps_handle *xhp, const char *repodir,
prop_dictionary_t idx, prop_dictionary_t idxfiles)
xbps_dictionary_t idx, xbps_dictionary_t idxfiles)
{
struct archive *ar;
mode_t myumask;
@@ -60,7 +60,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
archive_write_set_options(ar, "compression-level=9");
archive_write_open_fd(ar, repofd);
xml = prop_dictionary_externalize(idx);
xml = xbps_dictionary_externalize(idx);
assert(xml);
if (xbps_archive_append_buf(ar, xml, strlen(xml),
XBPS_PKGINDEX, 0644, "root", "root") != 0) {
@@ -69,7 +69,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
}
free(xml);
xml = prop_dictionary_externalize(idxfiles);
xml = xbps_dictionary_externalize(idxfiles);
assert(xml);
if (xbps_archive_append_buf(ar, xml, strlen(xml),
XBPS_PKGINDEX_FILES, 0644, "root", "root") != 0) {