summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2012-05-02 03:08:07 +0200
committerAllan McRae <allan@archlinux.org>2012-12-14 04:45:12 +0100
commit097d5a478b32aece93013580fdb06cacbaf0e9a0 (patch)
tree678c0d254672c7b0c7e17bc6270d37910ea16638 /lib/libalpm
parent0445c68d9b7738553dd1a5088110b8b0a1e1f7f9 (diff)
downloadpacman-097d5a478b32aece93013580fdb06cacbaf0e9a0.tar.gz
pacman-097d5a478b32aece93013580fdb06cacbaf0e9a0.tar.xz
Add public functions for accessing mtree data
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.h21
-rw-r--r--lib/libalpm/be_local.c2
-rw-r--r--lib/libalpm/package.c25
3 files changed, 46 insertions, 2 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index f1c6efd3..c9dc247e 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -31,6 +31,10 @@ extern "C" {
#include <sys/types.h> /* off_t */
#include <stdarg.h> /* va_list */
+/* libarchive */
+#include <archive.h>
+#include <archive_entry.h>
+
#include <alpm_list.h>
/*
@@ -942,6 +946,23 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size,
int alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp);
+/** Open a package mtree file for reading.
+ * @param pkg the local package to read the changelog of
+ * @return a archive structure for the package mtree file
+ */
+struct archive *alpm_pkg_mtree_open(alpm_pkg_t *pkg);
+
+/** Read next entry from a package mtree file.
+ * @param pkg the package that the mtree file is being read from
+ * @param archive the archive structure reading from the mtree file
+ * @param entry an archive_entry to store the entry header information
+ * @return 0 if end of archive is reached, non-zero otherwise.
+ */
+int alpm_pkg_mtree_next(const alpm_pkg_t *pkg, struct archive *archive,
+ struct archive_entry **entry);
+
+int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive);
+
/** Returns whether the package has an install scriptlet.
* @return 0 if FALSE, TRUE otherwise
*/
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 57092455..6d47fa88 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -225,8 +225,6 @@ static struct archive *_cache_mtree_open(alpm_pkg_t *pkg)
int r;
struct archive *mtree;
- pkg->handle->pm_errno = 0;
-
alpm_db_t *db = alpm_pkg_get_db(pkg);
char *mtfile = _alpm_local_db_pkgpath(db, pkg, "mtree");
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 0909ba9b..d77471fd 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -403,6 +403,31 @@ int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
return pkg->ops->changelog_close(pkg, fp);
}
+/** Open a package mtree file for reading. */
+struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
+{
+ ASSERT(pkg != NULL, return NULL);
+ pkg->handle->pm_errno = 0;
+ return pkg->ops->mtree_open(pkg);
+}
+
+/** Read entry from an open mtree file. */
+int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archive,
+ struct archive_entry **entry)
+{
+ ASSERT(pkg != NULL, return -1);
+ pkg->handle->pm_errno = 0;
+ return pkg->ops->mtree_next(pkg, archive, entry);
+}
+
+/** Close a package mtree file for reading. */
+int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive)
+{
+ ASSERT(pkg != NULL, return -1);
+ pkg->handle->pm_errno = 0;
+ return pkg->ops->mtree_close(pkg, archive);
+}
+
int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);