| |
|
| |
pattern = argv[0];
|
| |
|
| - |
pkg_remote_repo_init();
|
| - |
pkg_remote_repo_load();
|
| - |
|
| - |
|
| |
/*
|
| |
* TODO: Implement a feature to search only
|
| - |
* in a given repository instead of all
|
| + |
* in a given repository specified in the argument list
|
| |
*/
|
| - |
while ((repo = pkg_remote_repo_next()) != NULL) {
|
| - |
snprintf(dbfile, MAXPATHLEN, "%s.sqlite", repo->name);
|
| - |
|
| - |
if ((retcode = pkgdb_open(&db, PKGDB_REMOTE, dbfile)) != EPKG_OK) {
|
| - |
warnx("cannot open repository database: %s/%s\n",
|
| - |
pkg_config("PKG_DBDIR"), dbfile);
|
| - |
warnx("skipping repository %s\n", repo->name);
|
| - |
pkgdb_close(db);
|
| - |
continue;
|
| - |
}
|
| |
|
| - |
if ((it = pkgdb_rquery(db, pattern, match, field)) == NULL) {
|
| - |
warnx("cannot query repository database: %s/%s\n",
|
| - |
pkg_config("PKG_DBDIR"), dbfile);
|
| - |
warnx("skipping repository %s\n", repo->name);
|
| - |
pkgdb_it_free(it);
|
| - |
pkgdb_close(db);
|
| - |
continue;
|
| - |
}
|
| + |
/*
|
| + |
* Honor PACKAGESITE if specified
|
| + |
*/
|
| + |
if (pkg_config("PACKAGESITE") != NULL) {
|
| + |
retcode = search_remote_repo(pattern, match, field, "repo");
|
| + |
} else {
|
| + |
pkg_remote_repo_init();
|
| + |
pkg_remote_repo_load();
|
| + |
|
| + |
while ((repo = pkg_remote_repo_next()) != NULL)
|
| + |
retcode = search_remote_repo(pattern, match, field, repo->name);
|
| + |
|
| + |
pkg_remote_repo_free();
|
| + |
}
|
| |
|
| - |
while ((retcode = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
|
| - |
printf("Name: %s\n", pkg_get(pkg, PKG_NAME));
|
| - |
printf("Version: %s\n", pkg_get(pkg, PKG_VERSION));
|
| - |
printf("Origin: %s\n", pkg_get(pkg, PKG_ORIGIN));
|
| - |
printf("Arch: %s\n", pkg_get(pkg, PKG_ARCH));
|
| - |
printf("Maintainer: %s\n", pkg_get(pkg, PKG_MAINTAINER));
|
| - |
printf("WWW: %s\n", pkg_get(pkg, PKG_WWW));
|
| - |
printf("Comment: %s\n", pkg_get(pkg, PKG_COMMENT));
|
| - |
printf("Repository: %s\n", repo->name);
|
| - |
humanize_number(size, sizeof(size), pkg_new_flatsize(pkg), "B", HN_AUTOSCALE, 0);
|
| - |
printf("Flat size: %s\n", size);
|
| - |
humanize_number(size, sizeof(size), pkg_new_pkgsize(pkg), "B", HN_AUTOSCALE, 0);
|
| - |
printf("Pkg size: %s\n", size);
|
| - |
printf("\n");
|
| - |
}
|
| + |
return (retcode);
|
| + |
}
|
| + |
|
| + |
static int
|
| + |
search_remote_repo(const char *pattern, match_t match, unsigned int field, const char *dbname)
|
| + |
{
|
| + |
char size[7];
|
| + |
char dbfile[MAXPATHLEN];
|
| + |
int retcode = EPKG_OK;
|
| + |
struct pkgdb *db = NULL;
|
| + |
struct pkgdb_it *it = NULL;
|
| + |
struct pkg *pkg = NULL;
|
| + |
|
| + |
snprintf(dbfile, MAXPATHLEN, "%s.sqlite", dbname);
|
| + |
|
| + |
if (pkgdb_open(&db, PKGDB_REMOTE, dbfile) != EPKG_OK) {
|
| + |
warnx("cannot open repository database: %s/%s\n",
|
| + |
pkg_config("PKG_DBDIR"), dbfile);
|
| + |
return(EPKG_FATAL);
|
| + |
}
|
| + |
|
| + |
if ((it = pkgdb_rquery(db, pattern, match, field)) == NULL) {
|
| + |
warnx("cannot query repository database: %s/%s\n",
|
| + |
pkg_config("PKG_DBDIR"), dbfile);
|
| + |
pkgdb_it_free(it);
|
| + |
pkgdb_close(db);
|
| + |
return(EPKG_FATAL);
|
| |
}
|
| |
|
| - |
pkg_remote_repo_free();
|
| + |
while ((retcode = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
|
| + |
printf("Name: %s\n", pkg_get(pkg, PKG_NAME));
|
| + |
printf("Version: %s\n", pkg_get(pkg, PKG_VERSION));
|
| + |
printf("Origin: %s\n", pkg_get(pkg, PKG_ORIGIN));
|
| + |
printf("Arch: %s\n", pkg_get(pkg, PKG_ARCH));
|
| + |
printf("Maintainer: %s\n", pkg_get(pkg, PKG_MAINTAINER));
|
| + |
printf("WWW: %s\n", pkg_get(pkg, PKG_WWW));
|
| + |
printf("Comment: %s\n", pkg_get(pkg, PKG_COMMENT));
|
| + |
printf("Repository: %s\n", dbname);
|
| + |
humanize_number(size, sizeof(size), pkg_new_flatsize(pkg), "B", HN_AUTOSCALE, 0);
|
| + |
printf("Flat size: %s\n", size);
|
| + |
humanize_number(size, sizeof(size), pkg_new_pkgsize(pkg), "B", HN_AUTOSCALE, 0);
|
| + |
printf("Pkg size: %s\n", size);
|
| + |
printf("\n");
|
| + |
}
|
| |
|
| - |
return (retcode);
|
| + |
return(retcode);
|
| |
}
|