[pacman-dev] [PATCH 3/3] Do not warn about missing files in NoExtract

Allan McRae allan at archlinux.org
Mon Nov 17 13:33:14 UTC 2014


When checking a packages files, ignore any missing files in NoExtract

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 src/pacman/check.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/pacman/check.c b/src/pacman/check.c
index 7109c7a..1a49537 100644
--- a/src/pacman/check.c
+++ b/src/pacman/check.c
@@ -27,17 +27,23 @@
 #include "util.h"
 
 static int check_file_exists(const char *pkgname, char *filepath,
-		struct stat *st)
+		const char *root, struct stat *st)
 {
 	/* use lstat to prevent errors from symlinks */
 	if(llstat(filepath, st) != 0) {
-		if(config->quiet) {
-			printf("%s %s\n", pkgname, filepath);
+		if(fnmatch_patterns(alpm_option_get_noextracts(config->handle),
+					filepath, root) == 0) {
+			/* NoExtract */
+			return -1;
 		} else {
-			pm_printf(ALPM_LOG_WARNING, "%s: %s (%s)\n",
-					pkgname, filepath, strerror(errno));
+			if(config->quiet) {
+				printf("%s %s\n", pkgname, filepath);
+			} else {
+				pm_printf(ALPM_LOG_WARNING, "%s: %s (%s)\n",
+						pkgname, filepath, strerror(errno));
+			}
+			return 1;
 		}
-		return 1;
 	}
 
 	return 0;
@@ -209,6 +215,7 @@ int check_pkg_fast(alpm_pkg_t *pkg)
 	for(i = 0; i < filelist->count; i++) {
 		const alpm_file_t *file = filelist->files + i;
 		struct stat st;
+		int exists;
 		const char *path = file->name;
 		size_t plen = strlen(path);
 
@@ -218,7 +225,8 @@ int check_pkg_fast(alpm_pkg_t *pkg)
 		}
 		strcpy(filepath + rootlen, path);
 
-		if(check_file_exists(pkgname, filepath, &st) == 0) {
+		exists = check_file_exists(pkgname, filepath, root, &st);
+		if(exists == 0) {
 			int expect_dir = path[plen - 1] == '/' ? 1 : 0;
 			int is_dir = S_ISDIR(st.st_mode) ? 1 : 0;
 			if(expect_dir != is_dir) {
@@ -226,7 +234,7 @@ int check_pkg_fast(alpm_pkg_t *pkg)
 						pkgname, filepath);
 				++errors;
 			}
-		} else {
+		} else if(exists == 1) {
 			++errors;
 		}
 	}
@@ -278,6 +286,7 @@ int check_pkg_full(alpm_pkg_t *pkg)
 		mode_t type;
 		size_t file_errors = 0;
 		int backup = 0;
+		int exists;
 
 		/* strip leading "./" from path entries */
 		if(path[0] == '.' && path[1] == '/') {
@@ -310,9 +319,13 @@ int check_pkg_full(alpm_pkg_t *pkg)
 		}
 		strcpy(filepath + rootlen, path);
 
-		if(check_file_exists(pkgname, filepath, &st) == 1) {
+		exists = check_file_exists(pkgname, filepath, root, &st);
+		if(exists == 1) {
 			errors++;
 			continue;
+		} else if (exists == -1) {
+			/* NoExtract */
+			continue;
 		}
 
 		type = archive_entry_filetype(entry);
-- 
2.1.3


More information about the pacman-dev mailing list