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-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 * 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 exist in the repository, but other packages can provide it. A new array
in the package properties dictionary has been added to specify which 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. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,9 +34,9 @@
int xbps_install_new_pkg(const char *); int xbps_install_new_pkg(const char *);
int xbps_update_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_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_remove_installed_pkgs(int, char **, bool, bool, bool);
int xbps_check_pkg_integrity(const char *); int xbps_check_pkg_integrity(const char *);
int xbps_check_pkg_integrity_all(void); int xbps_check_pkg_integrity_all(void);

View File

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

View File

@ -153,11 +153,12 @@ main(int argc, char **argv)
struct sigaction sa; struct sigaction sa;
int i , c, flags, rv; int i , c, flags, rv;
bool yes, purge, with_debug, force_rm_with_deps; bool yes, purge, with_debug, force_rm_with_deps;
bool show_download_pkglist_url = false;
i = c = flags = rv = 0; i = c = flags = rv = 0;
yes = purge = force_rm_with_deps = with_debug = false; 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) { switch (c) {
case 'c': case 'c':
xbps_set_cachedir(optarg); xbps_set_cachedir(optarg);
@ -165,6 +166,9 @@ main(int argc, char **argv)
case 'd': case 'd':
with_debug = true; with_debug = true;
break; break;
case 'D':
show_download_pkglist_url = true;
break;
case 'F': case 'F':
force_rm_with_deps = true; force_rm_with_deps = true;
break; break;
@ -278,7 +282,7 @@ main(int argc, char **argv)
if ((rv = xbps_install_new_pkg(argv[i])) != 0) if ((rv = xbps_install_new_pkg(argv[i])) != 0)
goto out; goto out;
rv = xbps_exec_transaction(yes); rv = xbps_exec_transaction(yes, show_download_pkglist_url);
} else if (strcasecmp(argv[0], "update") == 0) { } else if (strcasecmp(argv[0], "update") == 0) {
/* Update an installed package. */ /* Update an installed package. */
@ -289,7 +293,7 @@ main(int argc, char **argv)
if ((rv = xbps_update_pkg(argv[i])) != 0) if ((rv = xbps_update_pkg(argv[i])) != 0)
goto out; goto out;
rv = xbps_exec_transaction(yes); rv = xbps_exec_transaction(yes, show_download_pkglist_url);
} else if (strcasecmp(argv[0], "remove") == 0) { } else if (strcasecmp(argv[0], "remove") == 0) {
/* Removes a binary package. */ /* Removes a binary package. */
@ -338,7 +342,7 @@ main(int argc, char **argv)
if (argc != 1) if (argc != 1)
usage(); usage();
rv = xbps_autoupdate_pkgs(yes); rv = xbps_autoupdate_pkgs(yes, show_download_pkglist_url);
} else if (strcasecmp(argv[0], "show-orphans") == 0) { } 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 .\" * set default formatting
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
@ -39,6 +39,15 @@ of
Enables extra debugging output to be shown to stderr. Enables extra debugging output to be shown to stderr.
.RE .RE
.PP .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 \fB\-F\fR
.RS 4 .RS 4
Used currently in the \fIremove\fR target. If set, package will be removed even if other packages 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 .RS 4
$ xbps\-bin find\-files "/usr/lib/libav\&*" $ xbps\-bin find\-files "/usr/lib/libav\&*"
.RE .RE
.PP
\fBRemove and purge the package \fBproplib-devel\fR:\fR
.RS 4
$ xbps\-bin -yp remove proplib\-devel
.PP
.SH "BUGS" .SH "BUGS"
.sp .sp
Probably, but I try to make this not happen\&. Use it under your own responsability and enjoy your life\&. Probably, but I try to make this not happen\&. Use it under your own responsability and enjoy your life\&.