xbps-repo(8): added 'show-files' target.

It will search for 'pkgname' and will print its list of files, by
searching it in repository pool. The first repo wins.

Bump XBPS_RELVER to 20091125.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091125021556-n8p6atfbkuvb4doi
This commit is contained in:
Juan RP 2009-11-25 02:15:56 +00:00
parent c11094d5dd
commit 3117c8b4ee
6 changed files with 85 additions and 56 deletions

View File

@ -62,12 +62,8 @@ int
show_pkg_files_from_metadir(const char *pkgname)
{
prop_dictionary_t pkgd;
prop_array_t array;
prop_object_iterator_t iter = NULL;
prop_object_t obj;
const char *file;
char *plist, *array_str = "files";
int i, rv = 0;
char *plist;
int rv = 0;
plist = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
@ -81,54 +77,7 @@ show_pkg_files_from_metadir(const char *pkgname)
}
free(plist);
/* Links. */
array = prop_dictionary_get(pkgd, "links");
if (array && prop_array_count(array) > 0) {
iter = xbps_get_array_iter_from_dict(pkgd, "links");
if (iter == NULL) {
rv = EINVAL;
goto out;
}
while ((obj = prop_object_iterator_next(iter))) {
if (!prop_dictionary_get_cstring_nocopy(obj,
"file", &file)) {
prop_object_iterator_release(iter);
rv = errno;
goto out;
}
printf("%s\n", file);
}
prop_object_iterator_release(iter);
}
/* Files and configuration files. */
for (i = 0; i < 2; i++) {
if (i == 0)
array_str = "conf_files";
else
array_str = "files";
array = prop_dictionary_get(pkgd, array_str);
if (array == NULL || prop_array_count(array) == 0)
continue;
iter = xbps_get_array_iter_from_dict(pkgd, array_str);
if (iter == NULL) {
rv = EINVAL;
goto out;
}
while ((obj = prop_object_iterator_next(iter))) {
if (!prop_dictionary_get_cstring_nocopy(obj,
"file", &file)) {
prop_object_iterator_release(iter);
rv = errno;
goto out;
}
printf("%s\n", file);
}
prop_object_iterator_release(iter);
}
out:
rv = show_pkg_files(pkgd);
prop_object_release(pkgd);
return rv;

View File

@ -29,6 +29,7 @@
/* From index.c */
int xbps_repo_genindex(const char *);
/* From util.c */
int show_pkg_files(prop_dictionary_t);
void show_pkg_info(prop_dictionary_t);
int show_pkg_namedesc(prop_object_t, void *, bool *);
int list_strings_in_array(prop_object_t, void *, bool *);

View File

@ -43,7 +43,8 @@ usage(void)
{
printf("Usage: xbps-repo [options] [action] [arguments]\n\n"
" Available actions:\n"
" add, genindex, list, remove, search, show, show-deps, sync\n"
" add, genindex, list, remove, search, show, show-deps,\n"
" show-files, sync\n"
" Actions with arguments:\n"
" add\t\t<URI>\n"
" genindex\t<path>\n"
@ -51,6 +52,7 @@ usage(void)
" search\t<string>\n"
" show\t<pkgname>\n"
" show-deps\t<pkgname>\n"
" show-files\t<pkgname>\n"
" Options shared by all actions:\n"
" -r\t\t<rootdir>\n"
" -V\t\tPrints xbps release version\n"
@ -346,6 +348,22 @@ main(int argc, char **argv)
goto out;
}
} else if (strcasecmp(argv[0], "show-files") == 0) {
/* Shows the package files in a binary package */
if (argc != 2)
usage();
pkgd = xbps_get_pkg_plist_dict_from_repo(argv[1],
"./files.plist");
if (pkgd == NULL) {
printf("E: couldn't read files.plist: %s.\n",
strerror(errno));
rv = errno;
goto out;
}
rv = show_pkg_files(pkgd);
prop_object_release(pkgd);
} else if (strcasecmp(argv[0], "genindex") == 0) {
/* Generates a package repository index plist file. */
if (argc != 2)

View File

@ -112,6 +112,63 @@ show_pkg_info(prop_dictionary_t dict)
printf(" %s\n", prop_string_cstring_nocopy(obj));
}
int
show_pkg_files(prop_dictionary_t filesd)
{
prop_array_t array;
prop_object_iterator_t iter = NULL;
prop_object_t obj;
const char *file;
char *array_str = "files";
int i = 0;
/* Links. */
array = prop_dictionary_get(filesd, "links");
if (array && prop_array_count(array) > 0) {
iter = xbps_get_array_iter_from_dict(filesd, "links");
if (iter == NULL)
return EINVAL;
while ((obj = prop_object_iterator_next(iter))) {
if (!prop_dictionary_get_cstring_nocopy(obj,
"file", &file)) {
prop_object_iterator_release(iter);
return errno;
}
printf("%s\n", file);
}
prop_object_iterator_release(iter);
}
/* Files and configuration files. */
for (i = 0; i < 2; i++) {
if (i == 0)
array_str = "conf_files";
else
array_str = "files";
array = prop_dictionary_get(filesd, array_str);
if (array == NULL || prop_array_count(array) == 0)
continue;
iter = xbps_get_array_iter_from_dict(filesd, array_str);
if (iter == NULL)
return EINVAL;
while ((obj = prop_object_iterator_next(iter))) {
if (!prop_dictionary_get_cstring_nocopy(obj,
"file", &file)) {
prop_object_iterator_release(iter);
return errno;
}
printf("%s\n", file);
}
prop_object_iterator_release(iter);
}
return 0;
}
int
show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
{

View File

@ -73,6 +73,10 @@ Please note that all targets are *case insensitive*.
Shows run time dependencies for binary package 'pkgname'. The first
repository in the pool wins.
*show-files 'pkgname'*::
Shows the file list for a binary package 'pkgname' by searching it
in repository pool. Local and remote repositories are supported.
*sync*::
Syncs the package index file for all registered remote repositories.
The new file will be fetched if local and remote size/mtime do not match.

View File

@ -38,7 +38,7 @@
#include <archive_entry.h>
/* Current release version */
#define XBPS_RELVER "20091124-1"
#define XBPS_RELVER "20091125"
/* Default root PATH for xbps to store metadata info. */
#define XBPS_META_PATH "/var/db/xbps"