xbps-bin: make -C flag work when -r not set.
--HG-- extra : convert_revision : f4248255d94e9562483ef76630707eaefc3a9591
This commit is contained in:
parent
f28419db7d
commit
4edad150c0
|
@ -202,7 +202,7 @@ int
|
||||||
show_pkg_files_from_metadir(const char *pkgname, const char *destdir, bool hash)
|
show_pkg_files_from_metadir(const char *pkgname, const char *destdir, bool hash)
|
||||||
{
|
{
|
||||||
prop_dictionary_t pkgd;
|
prop_dictionary_t pkgd;
|
||||||
struct show_files_cb sf_cb;
|
struct show_files_cb sfc;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char *plist, *path;
|
char *plist, *path;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
@ -229,10 +229,10 @@ show_pkg_files_from_metadir(const char *pkgname, const char *destdir, bool hash)
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf_cb.destdir = destdir;
|
sfc.destdir = destdir;
|
||||||
sf_cb.check_hash = hash;
|
sfc.check_hash = hash;
|
||||||
rv = xbps_callback_array_iter_in_dict(pkgd, "filelist",
|
rv = xbps_callback_array_iter_in_dict(pkgd, "filelist",
|
||||||
show_pkg_files, (void *)&sf_cb);
|
show_pkg_files, (void *)&sfc);
|
||||||
prop_object_release(pkgd);
|
prop_object_release(pkgd);
|
||||||
free(plist);
|
free(plist);
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ show_pkg_files(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
{
|
{
|
||||||
struct show_files_cb *sfc = arg;
|
struct show_files_cb *sfc = arg;
|
||||||
const char *file = NULL, *sha256;
|
const char *file = NULL, *sha256;
|
||||||
char *path;
|
char *path = NULL;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
(void)loop_done;
|
(void)loop_done;
|
||||||
|
@ -256,22 +256,30 @@ show_pkg_files(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sfc->check_hash && file != NULL) {
|
if (sfc->check_hash && file != NULL) {
|
||||||
path = xbps_append_full_path(false, sfc->destdir, file);
|
|
||||||
if (path == NULL)
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
printf("%s", file);
|
printf("%s", file);
|
||||||
|
if (sfc->destdir) {
|
||||||
|
path = xbps_append_full_path(false, sfc->destdir, file);
|
||||||
|
if (path == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256);
|
prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256);
|
||||||
rv = xbps_check_file_hash(path, 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 (rv != 0 && rv != ERANGE) {
|
||||||
free(path);
|
if (sfc->destdir)
|
||||||
|
free(path);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
if (rv == ERANGE)
|
if (rv == ERANGE)
|
||||||
printf(" WARNING! SHA256 HASH MISMATCH!");
|
printf(" WARNING! SHA256 HASH MISMATCH!");
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
free(path);
|
if (sfc->destdir)
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue