Skip to content

Commit 03e1b5d

Browse files
committed
bin/xbps-query: move --list-repo to main.c, list.c is exclusively package lists now
1 parent c12f5aa commit 03e1b5d

3 files changed

Lines changed: 46 additions & 59 deletions

File tree

bin/xbps-query/defs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ int list_orphans(struct xbps_handle *, const char *);
5757
int list_pkgs_pkgdb(struct xbps_handle *);
5858
int list_pkgdb(struct xbps_handle *, int (*filter)(xbps_object_t), const char *format, int json);
5959

60-
int repo_list(struct xbps_handle *);
61-
6260
/* from search.c */
6361
int search(struct xbps_handle *, bool, const char *, const char *, bool);
6462

bin/xbps-query/list.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -242,59 +242,3 @@ list_orphans(struct xbps_handle *xhp, const char *format)
242242
xbps_fmt_free(fmt);
243243
return r;
244244
}
245-
246-
#ifndef __UNCONST
247-
#define __UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
248-
#endif
249-
250-
static void
251-
repo_list_uri(struct xbps_repo *repo)
252-
{
253-
const char *signedby = NULL;
254-
uint16_t pubkeysize = 0;
255-
256-
printf("%5zd %s",
257-
repo->idx ? (ssize_t)xbps_dictionary_count(repo->idx) : -1,
258-
repo->uri);
259-
printf(" (RSA %s)\n", repo->is_signed ? "signed" : "unsigned");
260-
if (repo->xhp->flags & XBPS_FLAG_VERBOSE) {
261-
xbps_data_t pubkey;
262-
char *hexfp = NULL;
263-
264-
xbps_dictionary_get_cstring_nocopy(repo->idxmeta, "signature-by", &signedby);
265-
xbps_dictionary_get_uint16(repo->idxmeta, "public-key-size", &pubkeysize);
266-
pubkey = xbps_dictionary_get(repo->idxmeta, "public-key");
267-
if (pubkey)
268-
hexfp = xbps_pubkey2fp(pubkey);
269-
if (signedby)
270-
printf(" Signed-by: %s\n", signedby);
271-
if (pubkeysize && hexfp)
272-
printf(" %u %s\n", pubkeysize, hexfp);
273-
if (hexfp)
274-
free(hexfp);
275-
}
276-
}
277-
278-
static void
279-
repo_list_uri_err(const char *repouri)
280-
{
281-
printf("%5zd %s (RSA maybe-signed)\n", (ssize_t) -1, repouri);
282-
}
283-
284-
int
285-
repo_list(struct xbps_handle *xhp)
286-
{
287-
for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) {
288-
const char *repouri = NULL;
289-
struct xbps_repo *repo;
290-
xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri);
291-
repo = xbps_repo_open(xhp, repouri);
292-
if (!repo) {
293-
repo_list_uri_err(repouri);
294-
continue;
295-
}
296-
repo_list_uri(repo);
297-
xbps_repo_release(repo);
298-
}
299-
return 0;
300-
}

bin/xbps-query/main.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,51 @@ usage(bool fail)
8080
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
8181
}
8282

83+
static void
84+
show_repo(struct xbps_repo *repo)
85+
{
86+
xbps_data_t pubkey;
87+
const char *signedby = NULL;
88+
char *hexfp = NULL;
89+
uint16_t pubkeysize = 0;
90+
91+
printf("%5zd %s",
92+
repo->idx ? (ssize_t)xbps_dictionary_count(repo->idx) : -1,
93+
repo->uri);
94+
printf(" (RSA %s)\n", repo->is_signed ? "signed" : "unsigned");
95+
if (!(repo->xhp->flags & XBPS_FLAG_VERBOSE))
96+
return;
97+
98+
xbps_dictionary_get_cstring_nocopy(repo->idxmeta, "signature-by", &signedby);
99+
xbps_dictionary_get_uint16(repo->idxmeta, "public-key-size", &pubkeysize);
100+
pubkey = xbps_dictionary_get(repo->idxmeta, "public-key");
101+
if (pubkey)
102+
hexfp = xbps_pubkey2fp(pubkey);
103+
if (signedby)
104+
printf(" Signed-by: %s\n", signedby);
105+
if (pubkeysize && hexfp)
106+
printf(" %u %s\n", pubkeysize, hexfp);
107+
free(hexfp);
108+
}
109+
110+
static int
111+
show_repos(struct xbps_handle *xhp)
112+
{
113+
for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) {
114+
const char *repouri = NULL;
115+
struct xbps_repo *repo;
116+
xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri);
117+
repo = xbps_repo_open(xhp, repouri);
118+
if (!repo) {
119+
printf("%5zd %s (RSA maybe-signed)\n", (ssize_t)-1, repouri);
120+
continue;
121+
}
122+
show_repo(repo);
123+
xbps_repo_release(repo);
124+
}
125+
return 0;
126+
}
127+
83128
static int
84129
filter_hold(xbps_object_t obj)
85130
{
@@ -309,7 +354,7 @@ main(int argc, char **argv)
309354
rv = list_pkgdb(&xh, filter_repolock, format ? format : "{pkgver}\n", json) < 0;
310355
break;
311356
case SHOW_REPOS:
312-
rv = repo_list(&xh);
357+
rv = show_repos(&xh);
313358
break;
314359
case SEARCH_FILE:
315360
rv = ownedby(&xh, pkg, repo_mode, regex);

0 commit comments

Comments
 (0)