xbps-bin: add new action "repo-list".
--HG-- extra : convert_revision : e0d5fce9503c6544e8ceec56864560b170c0e8c8
This commit is contained in:
parent
045e10c94e
commit
db0484ae6e
3 changed files with 74 additions and 8 deletions
|
@ -230,3 +230,24 @@ xbps_list_pkgs_in_dict(prop_dictionary_t dict, const char *key)
|
||||||
|
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xbps_list_strings_in_array(prop_array_t array)
|
||||||
|
{
|
||||||
|
prop_object_iterator_t iter;
|
||||||
|
prop_object_t obj;
|
||||||
|
|
||||||
|
if (array == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
iter = prop_array_iterator(array);
|
||||||
|
if (iter == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
if (prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
|
printf("%s\n", prop_string_cstring_nocopy(obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
}
|
||||||
|
|
|
@ -87,6 +87,15 @@ xbps_find_string_in_array(prop_array_t, const char *);
|
||||||
void
|
void
|
||||||
xbps_list_pkgs_in_dict(prop_dictionary_t, const char *);
|
xbps_list_pkgs_in_dict(prop_dictionary_t, const char *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lists all string values in an array.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* - prop_array_t: array where to search on.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xbps_list_strings_in_array(prop_array_t);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Registers a repository specified by an URI into the pool.
|
* Registers a repository specified by an URI into the pool.
|
||||||
*
|
*
|
||||||
|
|
|
@ -45,12 +45,19 @@ static void usage(void);
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: xbps-bin [action] [pkg|url]\n\n"
|
printf("Usage: xbps-bin [action] [arguments]\n\n"
|
||||||
" Available actions: add-repo, show\n\n"
|
" Available actions:\n"
|
||||||
|
" repo-add, repo-list, show\n"
|
||||||
|
" Action arguments:\n"
|
||||||
|
" repo-add\t[<URI>]\n"
|
||||||
|
" repo-list\t[none]\n"
|
||||||
|
" show\t[<pkgname>]\n"
|
||||||
|
"\n"
|
||||||
" Examples:\n"
|
" Examples:\n"
|
||||||
" $ xbps-bin add-repo /path/to/directory\n"
|
" $ xbps-bin repo-list\n"
|
||||||
" $ xbps-bin add-repo http://www.location.org/xbps-repo\n"
|
" $ xbps-bin repo-add /path/to/directory\n"
|
||||||
" $ xbps-bin show klibc\n");
|
" $ xbps-bin repo-add http://www.location.org/xbps-repo\n"
|
||||||
|
" $ xbps-bin show klibc\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,14 +94,18 @@ int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
prop_dictionary_t dict;
|
prop_dictionary_t dict;
|
||||||
|
prop_array_t array;
|
||||||
repo_info_t *rinfo = NULL;
|
repo_info_t *rinfo = NULL;
|
||||||
char pkgindex[PATH_MAX], *tmp;
|
char pkgindex[PATH_MAX], *tmp;
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc < 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
/* Adds a new repository to the pool. */
|
if (strcmp(argv[1], "repo-add") == 0) {
|
||||||
if (strcmp(argv[1], "add-repo") == 0) {
|
/* Adds a new repository to the pool. */
|
||||||
|
if (argc != 3)
|
||||||
|
usage();
|
||||||
|
|
||||||
tmp = strncpy(pkgindex, argv[2], sizeof(pkgindex));
|
tmp = strncpy(pkgindex, argv[2], sizeof(pkgindex));
|
||||||
if (sizeof(*tmp) >= sizeof(pkgindex))
|
if (sizeof(*tmp) >= sizeof(pkgindex))
|
||||||
exit(ENAMETOOLONG);
|
exit(ENAMETOOLONG);
|
||||||
|
@ -133,6 +144,31 @@ main(int argc, char **argv)
|
||||||
rinfo->location_local, rinfo->index_version,
|
rinfo->location_local, rinfo->index_version,
|
||||||
rinfo->total_pkgs);
|
rinfo->total_pkgs);
|
||||||
free(rinfo);
|
free(rinfo);
|
||||||
|
|
||||||
|
} else if (strcmp(argv[1], "repo-list") == 0) {
|
||||||
|
/* Lists all repositories registered in pool. */
|
||||||
|
if (argc != 2)
|
||||||
|
usage();
|
||||||
|
|
||||||
|
dict =
|
||||||
|
prop_dictionary_internalize_from_file(XBPS_REPOLIST_PATH);
|
||||||
|
if (dict == NULL) {
|
||||||
|
printf("cannot find repository list file: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
exit(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
array = prop_dictionary_get(dict, "repository-list");
|
||||||
|
if (array)
|
||||||
|
xbps_list_strings_in_array(array);
|
||||||
|
|
||||||
|
} else if (strcmp(argv[1], "show") == 0) {
|
||||||
|
/* Shows info about a binary package. */
|
||||||
|
if (argc != 3)
|
||||||
|
usage();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue