xbps-bin: make -C flag work when -r not set.

--HG--
extra : convert_revision : f4248255d94e9562483ef76630707eaefc3a9591
This commit is contained in:
Juan RP 2009-02-27 18:30:59 +01:00
parent f28419db7d
commit 4edad150c0
1 changed files with 20 additions and 12 deletions

View File

@ -202,7 +202,7 @@ int
show_pkg_files_from_metadir(const char *pkgname, const char *destdir, bool hash)
{
prop_dictionary_t pkgd;
struct show_files_cb sf_cb;
struct show_files_cb sfc;
size_t len = 0;
char *plist, *path;
int rv = 0;
@ -229,10 +229,10 @@ show_pkg_files_from_metadir(const char *pkgname, const char *destdir, bool hash)
return errno;
}
sf_cb.destdir = destdir;
sf_cb.check_hash = hash;
sfc.destdir = destdir;
sfc.check_hash = hash;
rv = xbps_callback_array_iter_in_dict(pkgd, "filelist",
show_pkg_files, (void *)&sf_cb);
show_pkg_files, (void *)&sfc);
prop_object_release(pkgd);
free(plist);
@ -244,7 +244,7 @@ show_pkg_files(prop_object_t obj, void *arg, bool *loop_done)
{
struct show_files_cb *sfc = arg;
const char *file = NULL, *sha256;
char *path;
char *path = NULL;
int rv = 0;
(void)loop_done;
@ -256,14 +256,21 @@ show_pkg_files(prop_object_t obj, void *arg, bool *loop_done)
}
if (sfc->check_hash && file != NULL) {
printf("%s", file);
if (sfc->destdir) {
path = xbps_append_full_path(false, sfc->destdir, file);
if (path == NULL)
return EINVAL;
}
printf("%s", file);
prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256);
if (sfc->destdir)
rv = xbps_check_file_hash(path, sha256);
else
rv = xbps_check_file_hash(file, sha256);
if (rv != 0 && rv != ERANGE) {
if (sfc->destdir)
free(path);
return rv;
}
@ -271,6 +278,7 @@ show_pkg_files(prop_object_t obj, void *arg, bool *loop_done)
printf(" WARNING! SHA256 HASH MISMATCH!");
printf("\n");
if (sfc->destdir)
free(path);
}