xbps-bin(8): added -D option to only show the URL to download binary packages.

This commit is contained in:
Juan RP 2011-01-27 14:36:33 +01:00
parent 1c21a98545
commit c952337fd4
5 changed files with 48 additions and 13 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.8.0 (???):
* xbps-bin(8): added -D option to only show the URLs to download the binary
packages required by the "install", "update" and "autoupdate" targets.
* Added support for virtual packages. A virtual package is one that doesn't
exist in the repository, but other packages can provide it. A new array
in the package properties dictionary has been added to specify which

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2009-2010 Juan Romero Pardines.
* Copyright (c) 2009-2011 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,9 +34,9 @@
int xbps_install_new_pkg(const char *);
int xbps_update_pkg(const char *);
int xbps_autoupdate_pkgs(bool);
int xbps_autoupdate_pkgs(bool, bool);
int xbps_autoremove_pkgs(bool, bool);
int xbps_exec_transaction(bool);
int xbps_exec_transaction(bool, bool);
int xbps_remove_installed_pkgs(int, char **, bool, bool, bool);
int xbps_check_pkg_integrity(const char *);
int xbps_check_pkg_integrity_all(void);

View File

@ -42,6 +42,7 @@ struct transaction {
prop_dictionary_t dict;
prop_object_iterator_t iter;
bool yes;
bool only_show;
size_t inst_pkgcnt;
size_t up_pkgcnt;
size_t cf_pkgcnt;
@ -92,7 +93,7 @@ check_binpkg_hash(const char *path, const char *filename,
}
static int
download_package_list(prop_object_iterator_t iter)
download_package_list(prop_object_iterator_t iter, bool only_show)
{
prop_object_t obj;
struct xbps_fetch_progress_data xfpd;
@ -121,6 +122,7 @@ again:
binfile = xbps_get_binpkg_repo_uri(obj, repoloc);
if (binfile == NULL)
return errno;
/*
* If downloaded package is in cachedir, check its hash
* and refetch the binpkg again if didn't match.
@ -136,6 +138,11 @@ again:
prop_dictionary_set_bool(obj, "checksum_ok", true);
continue;
}
if (only_show) {
printf("%s\n", binfile);
free(binfile);
continue;
}
if (xbps_mkpath(__UNCONST(cachedir), 0755) == -1) {
free(binfile);
return errno;
@ -257,7 +264,7 @@ show_transaction_sizes(struct transaction *trans)
}
int
xbps_autoupdate_pkgs(bool yes)
xbps_autoupdate_pkgs(bool yes, bool show_download_pkglist_url)
{
int rv = 0;
@ -280,7 +287,7 @@ xbps_autoupdate_pkgs(bool yes)
}
}
return xbps_exec_transaction(yes);
return xbps_exec_transaction(yes, show_download_pkglist_url);
}
int
@ -470,6 +477,12 @@ exec_transaction(struct transaction *trans)
assert(trans->dict != NULL);
assert(trans->iter != NULL);
/*
* Only show the URLs to download the binary packages.
*/
if (trans->only_show)
return download_package_list(trans->iter, true);
/*
* Show download/installed size for the transaction.
*/
@ -491,7 +504,7 @@ exec_transaction(struct transaction *trans)
* and check its SHA256 hash.
*/
printf("[1/3] Downloading/integrity check\n");
if ((rv = download_package_list(trans->iter)) != 0)
if ((rv = download_package_list(trans->iter, false)) != 0)
return rv;
/*
@ -625,7 +638,7 @@ exec_transaction(struct transaction *trans)
}
int
xbps_exec_transaction(bool yes)
xbps_exec_transaction(bool yes, bool show_download_pkglist_url)
{
struct transaction *trans;
prop_array_t array;
@ -661,6 +674,7 @@ xbps_exec_transaction(bool yes)
}
trans->yes = yes;
trans->only_show = show_download_pkglist_url;
rv = exec_transaction(trans);
out:
if (trans->iter)

View File

@ -153,11 +153,12 @@ main(int argc, char **argv)
struct sigaction sa;
int i , c, flags, rv;
bool yes, purge, with_debug, force_rm_with_deps;
bool show_download_pkglist_url = false;
i = c = flags = rv = 0;
yes = purge = force_rm_with_deps = with_debug = false;
while ((c = getopt(argc, argv, "VcdFfpr:vy")) != -1) {
while ((c = getopt(argc, argv, "VcdDFfpr:vy")) != -1) {
switch (c) {
case 'c':
xbps_set_cachedir(optarg);
@ -165,6 +166,9 @@ main(int argc, char **argv)
case 'd':
with_debug = true;
break;
case 'D':
show_download_pkglist_url = true;
break;
case 'F':
force_rm_with_deps = true;
break;
@ -278,7 +282,7 @@ main(int argc, char **argv)
if ((rv = xbps_install_new_pkg(argv[i])) != 0)
goto out;
rv = xbps_exec_transaction(yes);
rv = xbps_exec_transaction(yes, show_download_pkglist_url);
} else if (strcasecmp(argv[0], "update") == 0) {
/* Update an installed package. */
@ -289,7 +293,7 @@ main(int argc, char **argv)
if ((rv = xbps_update_pkg(argv[i])) != 0)
goto out;
rv = xbps_exec_transaction(yes);
rv = xbps_exec_transaction(yes, show_download_pkglist_url);
} else if (strcasecmp(argv[0], "remove") == 0) {
/* Removes a binary package. */
@ -338,7 +342,7 @@ main(int argc, char **argv)
if (argc != 1)
usage();
rv = xbps_autoupdate_pkgs(yes);
rv = xbps_autoupdate_pkgs(yes, show_download_pkglist_url);
} else if (strcasecmp(argv[0], "show-orphans") == 0) {
/*

View File

@ -1,4 +1,4 @@
.TH "XBPS\-BIN" "8" "03/12/2010" "\ \&" "\ \&"
.TH "XBPS\-BIN" "8" "27/01/2011" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
@ -39,6 +39,15 @@ of
Enables extra debugging output to be shown to stderr.
.RE
.PP
\fB\-D\fR
.RS 4
Only show the URLs to download the binary packages from repositories.
This is useful if you want to download them by other means, and later you
can move them to the \fIcachedir\fR to start the installation.
This option can be used for the \fIinstall\fR, \fIupdate\fR and \fIautoupdate\fR
targets.
.RE
.PP
\fB\-F\fR
.RS 4
Used currently in the \fIremove\fR target. If set, package will be removed even if other packages
@ -344,6 +353,11 @@ $ xbps\-bin find\-files /bin/mount
.RS 4
$ xbps\-bin find\-files "/usr/lib/libav\&*"
.RE
.PP
\fBRemove and purge the package \fBproplib-devel\fR:\fR
.RS 4
$ xbps\-bin -yp remove proplib\-devel
.PP
.SH "BUGS"
.sp
Probably, but I try to make this not happen\&. Use it under your own responsability and enjoy your life\&.