diff --git a/bin/xbps-repo/util.c b/bin/xbps-repo/util.c index 5ba775f15a..fa337eca62 100644 --- a/bin/xbps-repo/util.c +++ b/bin/xbps-repo/util.c @@ -243,13 +243,17 @@ static int show_pkg_files(prop_object_t obj, void *arg, bool *loop_done) { struct show_files_cb *sfc = arg; - const char *file = NULL, *sha256; + const char *file = NULL, *sha256, *type; char *path = NULL; int rv = 0; (void)loop_done; prop_dictionary_get_cstring_nocopy(obj, "file", &file); + prop_dictionary_get_cstring_nocopy(obj, "type", &type); + if (strcmp(type, "file") != 0) + return 0; + if (sfc->check_hash == false && file != NULL) { printf("%s\n", file); return 0; diff --git a/lib/remove.c b/lib/remove.c index 344536e3a2..f132ee79ad 100644 --- a/lib/remove.c +++ b/lib/remove.c @@ -112,18 +112,22 @@ remove_pkg_files(prop_object_t obj, void *arg, bool *loop_done) { prop_bool_t bobj; struct rm_cbarg *rmcb = arg; - const char *file = NULL, *sha256; + const char *file = NULL, *sha256, *type; char *path = NULL; int rv = 0; (void)loop_done; prop_dictionary_get_cstring_nocopy(obj, "file", &file); - if (file != NULL) { - path = xbps_append_full_path(false, rmcb->destdir, file); - if (path == NULL) - return EINVAL; + if (file == NULL) + return EINVAL; + path = xbps_append_full_path(false, rmcb->destdir, file); + if (path == NULL) + return EINVAL; + + prop_dictionary_get_cstring_nocopy(obj, "type", &type); + if (strcmp(type, "file") == 0) { prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256); rv = xbps_check_file_hash(path, sha256); if (rv != 0 && rv != ERANGE) { @@ -149,7 +153,7 @@ remove_pkg_files(prop_object_t obj, void *arg, bool *loop_done) goto out; } - if ((rv = unlink(path)) == -1) { + if ((rv = remove(path)) == -1) { if (rmcb->flags & XBPS_UNPACK_VERBOSE) printf("WARNING: can't remove file %s (%s)\n", file, strerror(errno)); @@ -159,19 +163,12 @@ remove_pkg_files(prop_object_t obj, void *arg, bool *loop_done) printf("Removed file: %s\n", file); goto out; - } - - prop_dictionary_get_cstring_nocopy(obj, "dir", &file); - if (file != NULL) { + } else if (strcmp(type, "dir") == 0) { if ((bobj = prop_dictionary_get(obj, "keep")) != NULL) { /* Skip permanent directory. */ return 0; } - path = xbps_append_full_path(false, rmcb->destdir, file); - if (path == NULL) - return EINVAL; - if ((rv = rmdir(path)) == -1) { if (errno == ENOTEMPTY) goto out; @@ -185,7 +182,17 @@ remove_pkg_files(prop_object_t obj, void *arg, bool *loop_done) if (rmcb->flags & XBPS_UNPACK_VERBOSE) printf("Removed directory: %s\n", file); } + } else if (strcmp(type, "link") == 0) { + if ((rv = remove(path)) == -1) { + if (rmcb->flags & XBPS_UNPACK_VERBOSE) + printf("WARNING: can't remove link %s (%s)\n", + file, strerror(errno)); + goto out; + } + if (rmcb->flags & XBPS_UNPACK_VERBOSE) + printf("Removed link: %s\n", file); } + out: free(path); diff --git a/lib/unpack.c b/lib/unpack.c index 41edc4d24b..6f3de82eb7 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -137,7 +137,8 @@ unpack_archive_init(prop_dictionary_t pkg, const char *destdir, #define EXTRACT_FLAGS ARCHIVE_EXTRACT_SECURE_NODOTDOT | \ ARCHIVE_EXTRACT_SECURE_SYMLINKS | \ ARCHIVE_EXTRACT_NO_OVERWRITE | \ - ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER + ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER | \ + ARCHIVE_EXTRACT_SPARSE #define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | \ ARCHIVE_EXTRACT_TIME | EXTRACT_FLAGS @@ -181,7 +182,6 @@ unpack_archive_fini(struct archive *ar, const char *destdir, int flags, free(buf); return -1; } - while (archive_read_next_header(ar, &entry) == ARCHIVE_OK) { /* * Run the pre installation action target if there's a script @@ -232,7 +232,6 @@ unpack_archive_fini(struct archive *ar, const char *destdir, int flags, continue; } } - if (flags & XBPS_UNPACK_VERBOSE) { printf(" %s\n", archive_entry_pathname(entry)); (void)fflush(stdout);