xbps-repo: 'sync' and 'pkg-list' target now accept a repository URI argument.
If set, only the matching repository will be used for the task.
This commit is contained in:
parent
ba84f82e66
commit
981b13bd5a
10
NEWS
10
NEWS
@ -1,5 +1,15 @@
|
|||||||
xbps-0.16 (???):
|
xbps-0.16 (???):
|
||||||
|
|
||||||
|
* xbps-repo(8): 'sync' target now is able to sync just a single repository
|
||||||
|
by passing the repository URI as argument, i.e:
|
||||||
|
|
||||||
|
$ xbps-repo sync http://xbps.mirror.org/repo
|
||||||
|
|
||||||
|
* xbps-repo(8): 'pkg-list' target now expects the repository URI than
|
||||||
|
the index number, i.e:
|
||||||
|
|
||||||
|
$ xbps-repo pkg-list http://xbps.mirror.org/repo
|
||||||
|
|
||||||
* xbps-bin(8): -n flag (dry-run mode) now also prints the pkg architecture
|
* xbps-bin(8): -n flag (dry-run mode) now also prints the pkg architecture
|
||||||
as last component and if the transaction reason supports it.
|
as last component and if the transaction reason supports it.
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ main(int argc, char **argv)
|
|||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
usage(true);
|
usage(true);
|
||||||
|
|
||||||
if (sync && ((rv = xbps_rpool_sync()) != 0))
|
if (sync && ((rv = xbps_rpool_sync(NULL)) != 0))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
@ -282,7 +282,7 @@ main(int argc, char **argv)
|
|||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
usage(true);
|
usage(true);
|
||||||
|
|
||||||
if (sync && ((rv = xbps_rpool_sync()) != 0))
|
if (sync && ((rv = xbps_rpool_sync(NULL)) != 0))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
@ -351,7 +351,7 @@ main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
usage(true);
|
usage(true);
|
||||||
|
|
||||||
if (sync && ((rv = xbps_rpool_sync()) != 0))
|
if (sync && ((rv = xbps_rpool_sync(NULL)) != 0))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
rv = dist_upgrade(yes, dry_run, show_download_pkglist_url);
|
rv = dist_upgrade(yes, dry_run, show_download_pkglist_url);
|
||||||
|
@ -80,6 +80,11 @@ find_files_in_package(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
|||||||
|
|
||||||
if ((idxfiles = prop_array_internalize_from_zfile(plist)) == NULL) {
|
if ((idxfiles = prop_array_internalize_from_zfile(plist)) == NULL) {
|
||||||
free(plist);
|
free(plist);
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
fprintf(stderr, "%s: index-files missing! "
|
||||||
|
"ignoring...\n", rpi->uri);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
free(plist);
|
free(plist);
|
||||||
|
@ -38,15 +38,12 @@ int
|
|||||||
repo_pkg_list_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
repo_pkg_list_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||||
{
|
{
|
||||||
struct list_pkgver_cb lpc;
|
struct list_pkgver_cb lpc;
|
||||||
uint16_t idx;
|
const char *repo = arg;
|
||||||
char *cp;
|
|
||||||
|
|
||||||
(void)done;
|
(void)done;
|
||||||
if (arg != NULL) {
|
if (repo && strcmp(rpi->uri, repo))
|
||||||
idx = (uint16_t)strtoul(arg, &cp, 0);
|
return 0;
|
||||||
if (rpi->index != idx)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
lpc.check_state = false;
|
lpc.check_state = false;
|
||||||
lpc.state = 0;
|
lpc.state = 0;
|
||||||
lpc.pkgver_len = find_longest_pkgver(rpi->repo);
|
lpc.pkgver_len = find_longest_pkgver(rpi->repo);
|
||||||
@ -64,8 +61,8 @@ repo_list_uri_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
|||||||
(void)arg;
|
(void)arg;
|
||||||
(void)done;
|
(void)done;
|
||||||
|
|
||||||
printf("[%u] %s (%zu packages)\n",
|
printf("%s (%zu packages)\n", rpi->uri,
|
||||||
rpi->index, rpi->uri, (size_t)prop_array_count(rpi->repo));
|
(size_t)prop_array_count(rpi->repo));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ usage(bool fail)
|
|||||||
" Generate a local repository in `directory'.\n"
|
" Generate a local repository in `directory'.\n"
|
||||||
" list\n"
|
" list\n"
|
||||||
" List registered repositories.\n"
|
" List registered repositories.\n"
|
||||||
" pkg-list [index]\n"
|
" pkg-list [repo]\n"
|
||||||
" Print packages in repository matching `index' number.\n"
|
" Print packages in repository matching `repo' URI.\n"
|
||||||
" If `index' not specified, all registered repositories will be used.\n"
|
" If `repo' not specified, all registered repositories will be used.\n"
|
||||||
" search <pattern> [patterns]\n"
|
" search <pattern> [patterns]\n"
|
||||||
" Search for packages in repositories matching the patterns.\n"
|
" Search for packages in repositories matching the patterns.\n"
|
||||||
" show <pkgname|pkgpattern>\n"
|
" show <pkgname|pkgpattern>\n"
|
||||||
@ -72,8 +72,9 @@ usage(bool fail)
|
|||||||
" Print package's required dependencies for `pkgname' or `pkgpattern'.\n"
|
" Print package's required dependencies for `pkgname' or `pkgpattern'.\n"
|
||||||
" show-files <pkgname|pkgpattern>\n"
|
" show-files <pkgname|pkgpattern>\n"
|
||||||
" Print package's files list for `pkgname' or `pkgpattern'.\n"
|
" Print package's files list for `pkgname' or `pkgpattern'.\n"
|
||||||
" sync\n"
|
" sync [repo]\n"
|
||||||
" Synchronize package index files for all registered repositories.\n\n"
|
" Synchronize package index file for `repo'.\n"
|
||||||
|
" If `repo' not specified, all remote repositories will be used. \n\n"
|
||||||
"Refer to xbps-repo(8) for a more detailed description.\n");
|
"Refer to xbps-repo(8) for a more detailed description.\n");
|
||||||
|
|
||||||
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
@ -266,14 +267,14 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
rv = repo_genindex(argv[1]);
|
rv = repo_genindex(argv[1]);
|
||||||
if (rv == 0)
|
if (rv == 0)
|
||||||
rv = repo_genindex_files(argv[1]);
|
rv = repo_genindex_files(argv[1])
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "sync") == 0) {
|
} else if (strcasecmp(argv[0], "sync") == 0) {
|
||||||
/* Syncs the pkg index for all registered remote repos */
|
/* Syncs the pkg index for all registered remote repos */
|
||||||
if (argc != 1)
|
if (argc < 1 || argc > 2)
|
||||||
usage(true);
|
usage(true);
|
||||||
|
|
||||||
rv = xbps_rpool_sync();
|
rv = xbps_rpool_sync(argv[1]);
|
||||||
if (rv == ENOTSUP) {
|
if (rv == ENOTSUP) {
|
||||||
xbps_error_printf("xbps-repo: no repositories "
|
xbps_error_printf("xbps-repo: no repositories "
|
||||||
"currently registered!\n");
|
"currently registered!\n");
|
||||||
|
@ -73,12 +73,11 @@ available in the index. If a newer package is available, the old package file
|
|||||||
will be removed automatically.
|
will be removed automatically.
|
||||||
.It Sy list
|
.It Sy list
|
||||||
Lists all working repositories in repository pool.
|
Lists all working repositories in repository pool.
|
||||||
.It Sy pkg-list Op index
|
.It Sy pkg-list Op repository
|
||||||
Lists all currently registered packages in repository index as specified
|
Lists all currently registered packages from all repositories, or just from
|
||||||
in the
|
.Ar repository .
|
||||||
.Ar index
|
If argument is not specified, any package contained in all repositories
|
||||||
argument. If argument is not specified, any package contained in all repositories
|
will be shown. The argument expects the repository URI.
|
||||||
will be shown. The argument expects a decimal number starting from 0,
|
|
||||||
matching the output of the
|
matching the output of the
|
||||||
.Ar list
|
.Ar list
|
||||||
target.
|
target.
|
||||||
@ -124,8 +123,9 @@ if a remote repository is the winner and binary package is not available in
|
|||||||
it will fetch remotely and
|
it will fetch remotely and
|
||||||
.Em on the fly
|
.Em on the fly
|
||||||
the info from target repository.
|
the info from target repository.
|
||||||
.It Sy sync
|
.It Sy sync Op repository
|
||||||
Syncs the package index file for all registered remote repositories.
|
Syncs the package index file for all remote repositories or just for
|
||||||
|
.Ar repository .
|
||||||
The index file will be fetched if local and remote size/mtime do not match.
|
The index file will be fetched if local and remote size/mtime do not match.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width /var/db/xbps/<repodir>/index-files.plist -compact
|
.Bl -tag -width /var/db/xbps/<repodir>/index-files.plist -compact
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.5"
|
#define XBPS_PKGINDEX_VERSION "1.5"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20120601"
|
#define XBPS_API_VERSION "20120601-1"
|
||||||
#define XBPS_VERSION "0.16"
|
#define XBPS_VERSION "0.16"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1492,22 +1492,19 @@ struct xbps_rpool_index {
|
|||||||
* URI string associated with repository.
|
* URI string associated with repository.
|
||||||
*/
|
*/
|
||||||
const char *uri;
|
const char *uri;
|
||||||
/**
|
|
||||||
* @var rpi_index
|
|
||||||
*
|
|
||||||
* Repository index in pool.
|
|
||||||
*/
|
|
||||||
uint16_t index;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronizes the package index file for all remote repositories
|
* Synchronizes the package index file for all remote repositories
|
||||||
* as specified in the configuration file, repositories.plist.
|
* as specified in the configuration file or if \a uri argument is
|
||||||
|
* set, just sync the index file for that repository.
|
||||||
|
*
|
||||||
|
* @param[in] uri Repository URI to match for sync (optional).
|
||||||
*
|
*
|
||||||
* @return 0 on success, ENOTSUP if no repositories were found in
|
* @return 0 on success, ENOTSUP if no repositories were found in
|
||||||
* the configuration file.
|
* the configuration file.
|
||||||
*/
|
*/
|
||||||
int xbps_rpool_sync(void);
|
int xbps_rpool_sync(const char *uri);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over the repository pool and executes the \a fn function
|
* Iterates over the repository pool and executes the \a fn function
|
||||||
|
@ -144,41 +144,33 @@ xbps_rpool_release(struct xbps_handle *xhp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_rpool_sync(void)
|
xbps_rpool_sync(const char *uri)
|
||||||
{
|
{
|
||||||
const struct xbps_handle *xhp = xbps_handle_get();
|
const struct xbps_handle *xhp = xbps_handle_get();
|
||||||
const char *repouri;
|
const char *repouri;
|
||||||
size_t i;
|
size_t i;
|
||||||
int rv;
|
int rv = 0;
|
||||||
|
|
||||||
if (xhp->cfg == NULL)
|
if (xhp->cfg == NULL)
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
|
||||||
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
|
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
|
||||||
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
|
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
|
||||||
|
/* If argument was set just process that repository */
|
||||||
|
if (uri && strcmp(repouri, uri))
|
||||||
|
continue;
|
||||||
/*
|
/*
|
||||||
* Fetch repository plist index.
|
* Fetch repository plist index.
|
||||||
*/
|
*/
|
||||||
rv = xbps_repository_sync_pkg_index(repouri, XBPS_PKGINDEX);
|
if (xbps_repository_sync_pkg_index(repouri, XBPS_PKGINDEX) == -1) {
|
||||||
if (rv == -1) {
|
rv = fetchLastErrCode != 0 ? fetchLastErrCode : errno;
|
||||||
xbps_dbg_printf("[rpool] `%s' failed to fetch: %s\n",
|
xbps_dbg_printf("[rpool] `%s' failed to fetch: %s\n",
|
||||||
repouri, fetchLastErrCode == 0 ?
|
repouri, fetchLastErrCode == 0 ? strerror(errno) :
|
||||||
strerror(errno) : xbps_fetch_error_string());
|
xbps_fetch_error_string());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Fetch repository plist files index.
|
|
||||||
*/
|
|
||||||
rv = xbps_repository_sync_pkg_index(repouri,
|
|
||||||
XBPS_PKGINDEX_FILES);
|
|
||||||
if (rv == -1) {
|
|
||||||
xbps_dbg_printf("[rpool] `%s' failed to fetch: %s\n",
|
|
||||||
repouri, fetchLastErrCode == 0 ?
|
|
||||||
strerror(errno) : xbps_fetch_error_string());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -207,8 +199,6 @@ xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), void *a
|
|||||||
d = prop_array_get(xhp->repo_pool, i);
|
d = prop_array_get(xhp->repo_pool, i);
|
||||||
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi.uri);
|
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi.uri);
|
||||||
rpi.repo = prop_dictionary_get(d, "index");
|
rpi.repo = prop_dictionary_get(d, "index");
|
||||||
rpi.index = i;
|
|
||||||
|
|
||||||
rv = (*fn)(&rpi, arg, &done);
|
rv = (*fn)(&rpi, arg, &done);
|
||||||
if (rv != 0 || done)
|
if (rv != 0 || done)
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user