summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-01-27 23:40:49 +0100
committerAllan McRae <allan@archlinux.org>2014-03-03 11:25:54 +1000
commit11fb1d30f430b4e4b01e08c84d3cdf0cfa749cb3 (patch)
tree7a3f76f73392b29f94836defc2de6b8376735f40 /lib/libalpm
parent42f4a5081e06793be6c807d50cd7ec0a83bbcdf1 (diff)
downloadpacman-11fb1d30f430b4e4b01e08c84d3cdf0cfa749cb3.tar.xz
be_package: Refactor handling of simple path checks
This is used to deduplicate code when using the mtree as the file list source. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/be_package.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 2fbb1dbb..5980784c 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -353,6 +353,26 @@ 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;
+ return 1;
+ } else if(*path == '.') {
+ /* for now, ignore all files starting with '.' that haven't
+ * already been handled (for future possibilities) */
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
* Load a package and create the corresponding alpm_pkg_t struct.
* @param handle the context handle
* @param pkgfile path to the package file
@@ -423,11 +443,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(*entry_name == '.') {
- /* for now, ignore all files starting with '.' that haven't
- * already been handled (for future possibilities) */
+ } else if(handle_simple_path(newpkg, entry_name)) {
+ continue;
} else if(full) {
const size_t files_count = newpkg->files.count;
alpm_file_t *current_file;