XBPS major changes in June 2011.
- A configuration file "xbps-conf.plist" replaces the (un)register target in xbps-repo(8) and (un)set-prop in xbps-bin(8). For now, you can set the repositories and prefered virtual packages. - New package pattern matching code from NetBSD. Supports more ways of matching patterns in packages. - Multiple bugs fixed in virtual packages related matching code. --HG-- rename : LICENSE => COPYING
This commit is contained in:
@@ -33,8 +33,6 @@
|
||||
/* From index.c */
|
||||
int xbps_repo_genindex(const char *);
|
||||
/* From repository.c */
|
||||
int register_repository(const char *);
|
||||
int unregister_repository(const char *);
|
||||
int show_pkg_info_from_repolist(const char *);
|
||||
int show_pkg_deps_from_repolist(const char *);
|
||||
int repository_sync(void);
|
||||
|
||||
@@ -60,7 +60,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, prop_dictionary_keysym_t ke
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &filestr);
|
||||
if ((strcmp(filestr, pattern) == 0) ||
|
||||
(strstr(filestr, pattern)) ||
|
||||
(xbps_pkgpattern_match(filestr, __UNCONST(pattern)) == 1))
|
||||
(xbps_pkgpattern_match(filestr, pattern) == 1))
|
||||
printf(" %s: %s (%s)\n", pkgver, filestr, typestr);
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
|
||||
@@ -50,10 +50,16 @@ usage(void)
|
||||
static int
|
||||
repo_list_uri_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
{
|
||||
const char *pkgidx;
|
||||
uint64_t npkgs;
|
||||
|
||||
(void)arg;
|
||||
(void)done;
|
||||
|
||||
printf("%s\n", rpi->rpi_uri);
|
||||
prop_dictionary_get_cstring_nocopy(rpi->rpi_repod,
|
||||
"pkgindex-version", &pkgidx);
|
||||
prop_dictionary_get_uint64(rpi->rpi_repod, "total-pkgs", &npkgs);
|
||||
printf("%s (index %s, %zu packages)\n", rpi->rpi_uri, pkgidx, npkgs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -80,19 +86,22 @@ main(int argc, char **argv)
|
||||
struct xbps_handle xh;
|
||||
struct xbps_fetch_progress_data xfpd;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *rootdir, *cachedir;
|
||||
const char *rootdir = NULL, *cachedir = NULL, *conffile = NULL;
|
||||
int c, rv = 0;
|
||||
bool with_debug = false;
|
||||
bool debug = false;
|
||||
|
||||
rootdir = cachedir = NULL;
|
||||
|
||||
while ((c = getopt(argc, argv, "Vc:dr:")) != -1) {
|
||||
while ((c = getopt(argc, argv, "C:c:dr:V")) != -1) {
|
||||
switch (c) {
|
||||
case 'C':
|
||||
conffile = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
cachedir = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
with_debug = true;
|
||||
debug = true;
|
||||
break;
|
||||
case 'r':
|
||||
/* To specify the root directory */
|
||||
@@ -114,46 +123,29 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
/*
|
||||
* Initialize the function callbacks and debug in libxbps.
|
||||
* Initialize XBPS subsystems.
|
||||
*/
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.with_debug = with_debug;
|
||||
xh.with_debug = debug;
|
||||
xh.xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xh.xfpd = &xfpd;
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xbps_init(&xh);
|
||||
xh.conffile = conffile;
|
||||
|
||||
if ((rv = xbps_repository_pool_init()) != 0) {
|
||||
if (rv != ENOENT) {
|
||||
xbps_error_printf("xbps-repo: failed to initialize "
|
||||
"repository pool: %s\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[0], "add") == 0) {
|
||||
/* Adds a new repository to the pool. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
rv = register_repository(argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "list") == 0) {
|
||||
if (strcasecmp(argv[0], "list") == 0) {
|
||||
/* Lists all repositories registered in pool. */
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
xbps_repository_pool_foreach(repo_list_uri_cb, NULL);
|
||||
|
||||
} else if ((strcasecmp(argv[0], "rm") == 0) ||
|
||||
(strcasecmp(argv[0], "remove") == 0)) {
|
||||
/* Remove a repository from the pool. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
rv = unregister_repository(argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "search") == 0) {
|
||||
/*
|
||||
* Search for a package by looking at pkgname/short_desc
|
||||
|
||||
@@ -42,44 +42,6 @@ struct repoinfo {
|
||||
uint64_t totalpkgs;
|
||||
};
|
||||
|
||||
static const char *
|
||||
sanitize_url(const char *path)
|
||||
{
|
||||
static char buf[PATH_MAX];
|
||||
const char *res = NULL;
|
||||
char *dirnp, *basenp, *dir, *base;
|
||||
int r = 0;
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
|
||||
if ((dir = strdup(path)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((base = strdup(path)) == NULL) {
|
||||
free(dir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dirnp = dirname(dir);
|
||||
if (strcmp(dirnp, ".") == 0)
|
||||
goto out;
|
||||
|
||||
basenp = basename(base);
|
||||
if (strcmp(basenp, base) == 0)
|
||||
goto out;
|
||||
|
||||
r = snprintf(buf, sizeof(buf) - 1, "%s/%s", dirnp, basenp);
|
||||
if (r < 0 || r >= (int)sizeof(buf) - 1)
|
||||
goto out;
|
||||
|
||||
res = buf;
|
||||
out:
|
||||
free(dir);
|
||||
free(base);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static struct repoinfo *
|
||||
pkgindex_verify(const char *plist, const char *uri)
|
||||
{
|
||||
@@ -137,106 +99,6 @@ out:
|
||||
return rpi;
|
||||
}
|
||||
|
||||
int
|
||||
unregister_repository(const char *uri)
|
||||
{
|
||||
const char *idxstr = NULL;
|
||||
int rv = 0;
|
||||
|
||||
if ((idxstr = sanitize_url(uri)) == NULL)
|
||||
return errno;
|
||||
|
||||
if ((rv = xbps_repository_unregister(idxstr)) == 0)
|
||||
return 0;
|
||||
|
||||
if (rv == ENOENT) {
|
||||
xbps_error_printf("Repository '%s' not "
|
||||
"registered.\n", idxstr);
|
||||
} else {
|
||||
xbps_error_printf("xbps-repo: couldn't unregister "
|
||||
"repository: %s\n", strerror(rv));
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
register_repository(const char *uri)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
struct repoinfo *rpi = NULL;
|
||||
const char *idxstr = NULL;
|
||||
char *metadir, *plist;
|
||||
int rv = 0;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
if ((idxstr = sanitize_url(uri)) == NULL)
|
||||
return errno;
|
||||
|
||||
if (xbps_check_is_repository_uri_remote(idxstr)) {
|
||||
printf("Fetching remote package index at %s...\n", idxstr);
|
||||
rv = xbps_repository_sync_pkg_index(idxstr);
|
||||
if (rv == -1) {
|
||||
xbps_error_printf("xbps-repo: couldn't fetch pkg-index "
|
||||
"file: %s.\n", xbps_fetch_error_string());
|
||||
return rv;
|
||||
} else if (rv == 0) {
|
||||
printf("Package index file is already "
|
||||
"up to date.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
plist = xbps_pkg_index_plist(idxstr);
|
||||
} else {
|
||||
/*
|
||||
* Create metadir if necessary.
|
||||
*/
|
||||
metadir = xbps_xasprintf("%s/%s", xhp->rootdir,
|
||||
XBPS_META_PATH);
|
||||
if (metadir == NULL)
|
||||
return errno;
|
||||
|
||||
if (xbps_mkpath(metadir, 0755) == -1) {
|
||||
xbps_error_printf("xbps-repo: couldn't create metadata "
|
||||
"directory: %s.\n", strerror(errno));
|
||||
free(metadir);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
free(metadir);
|
||||
plist = xbps_pkg_index_plist(idxstr);
|
||||
}
|
||||
|
||||
if (plist == NULL)
|
||||
return errno;
|
||||
|
||||
if ((rpi = pkgindex_verify(plist, idxstr)) == NULL)
|
||||
goto out;
|
||||
|
||||
if ((rv = xbps_repository_register(idxstr)) != 0) {
|
||||
if (rv == EEXIST) {
|
||||
xbps_warn_printf("repository already registered.\n");
|
||||
} else {
|
||||
xbps_error_printf("xbps-repo: couldn't register "
|
||||
"repository: %s.\n", strerror(errno));
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("Added package index at %s (v%s) with %ju packages.\n",
|
||||
idxstr, rpi->pkgidxver, rpi->totalpkgs);
|
||||
|
||||
out:
|
||||
if (rpi != NULL) {
|
||||
if (rpi->pkgidxver != NULL)
|
||||
free(rpi->pkgidxver);
|
||||
free(rpi);
|
||||
}
|
||||
if (plist != NULL)
|
||||
free(plist);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_info_from_repolist(const char *pkgname)
|
||||
{
|
||||
@@ -286,7 +148,7 @@ repo_sync_pkg_index_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
if (!xbps_check_is_repository_uri_remote(rpi->rpi_uri))
|
||||
return 0;
|
||||
|
||||
printf("Syncing package index from: %s\n", rpi->rpi_uri);
|
||||
printf("Synchronizing package index for `%s' ...\n", rpi->rpi_uri);
|
||||
rv = xbps_repository_sync_pkg_index(rpi->rpi_uri);
|
||||
if (rv == -1) {
|
||||
xbps_error_printf("xbps-repo: failed to sync `%s': %s\n",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH "XBPS\-REPO" "8" "05/27/2011" "\ \&" "\ \&"
|
||||
.TH "XBPS\-REPO" "8" "06/04/2011" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
@@ -19,6 +19,11 @@ xbps-repo \- XBPS command for binary package repositories
|
||||
The xbps\-repo(8) command is used to handle local or remote binary package repositories in the \fBXBPS binary package system\fR\&. You can use it to create a package index for a local repository, add or remove local and remote repositories, search for packages and show information about a binary package in repository pool\&.
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\fB\-C\fR \fIconffile\fR
|
||||
.RS 4
|
||||
Full path to the \fIxbps-conf.plist\fR plist configuration file.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-c\fR \fIcachedir\fR
|
||||
.RS 4
|
||||
Sets the
|
||||
@@ -49,21 +54,12 @@ of
|
||||
.PP
|
||||
\fB\-V\fR
|
||||
.RS 4
|
||||
Shows the current XBPS release version (library and code)\&.
|
||||
Shows the current XBPS API and INDEX versions\&.
|
||||
.RE
|
||||
.SH "TARGETS"
|
||||
.sp
|
||||
Please note that all targets are \fBcase insensitive\fR\&.
|
||||
.PP
|
||||
\fBadd\fR \fIURI\fR
|
||||
.RS 4
|
||||
Adds a repository as specified in
|
||||
\fIURI\fR
|
||||
to the repository pool\&. Local (by specifying a
|
||||
\fBdirectory\fR) and remote (by specifiying an
|
||||
\fBHTTP/HTTPS/FTP URL\fR) repositories can be specified\&.
|
||||
.RE
|
||||
.PP
|
||||
\fBfind\-files\fR \fIpattern\fR
|
||||
.RS 4
|
||||
Prints the name for any package registered in the repository pool, that owns
|
||||
@@ -86,18 +82,7 @@ will be removed automatically\&.
|
||||
.PP
|
||||
\fBlist\fR
|
||||
.RS 4
|
||||
Lists all currently registered repositories in repository pool\&.
|
||||
.RE
|
||||
.PP
|
||||
\fBremove\fR \fIURI\fR
|
||||
.RS 4
|
||||
Removes a repository from repository pool as specified by the
|
||||
\fIURI\fR
|
||||
argument\&. You have to use the same
|
||||
\fIURI\fR
|
||||
that was used in the
|
||||
\fBadd\fR
|
||||
target\&.
|
||||
Lists all working repositories in repository pool\&.
|
||||
.RE
|
||||
.PP
|
||||
\fBsearch\fR \fIpattern\fR
|
||||
@@ -137,6 +122,11 @@ Syncs the package index file for all registered remote repositories\&. The new f
|
||||
.RE
|
||||
.SH "FILES"
|
||||
.PP
|
||||
\fB/etc/xbps-conf.plist\fR
|
||||
.RS 4
|
||||
Default XBPS configuration file\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB/var/db/xbps/repositories\&.plist\fR
|
||||
.RS 4
|
||||
Registered repository list\&.
|
||||
|
||||
Reference in New Issue
Block a user