[pacman-dev] [PATCH 3/5] be_pacakge: Refactor handling of simple path checks

Florian Pritz bluewind at xinu.at
Mon Jan 27 18:02:35 EST 2014


This is used to deduplicate code when using the mtree as the file list
source.

Signed-off-by: Florian Pritz <bluewind at xinu.at>
---
 lib/libalpm/be_package.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 149f281..066c220 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -353,6 +353,23 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
 }
 
 /**
+ * Handle the existance of simple paths for _alpm_load_pkg_internal()
+ * @param pkg package to change
+ * @param path path to examine
+ * @return 0 if path doesn't match any rule, 1 if it has been handled
+ */
+static int handle_simple_path(alpm_pkg_t *pkg, const char *path)
+{
+	if(strcmp(path, ".INSTALL") == 0) {
+		pkg->scriptlet = 1;
+	} else {
+		return 0;
+	}
+
+	return 1;
+}
+
+/**
  * Load a package and create the corresponding alpm_pkg_t struct.
  * @param handle the context handle
  * @param pkgfile path to the package file
@@ -423,8 +440,8 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
 			}
 			config = 1;
 			continue;
-		} else if(strcmp(entry_name, ".INSTALL") == 0) {
-			newpkg->scriptlet = 1;
+		} else if(handle_simple_path(newpkg, entry_name)) {
+			continue;
 		} else if(*entry_name == '.') {
 			/* for now, ignore all files starting with '.' that haven't
 			 * already been handled (for future possibilities) */
-- 
1.8.5.3


More information about the pacman-dev mailing list