summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorJudd Vinet <judd@archlinux.org>2006-09-28 20:51:33 +0000
committerJudd Vinet <judd@archlinux.org>2006-09-28 20:51:33 +0000
commitcf6da173f62ee96703714e66f8538069a46a63e3 (patch)
tree164ba65ccd916674929f2e058a40fe7f6abced52 /lib/libalpm/package.c
parent54008798efcc9646f622f6b052ecd83281d57cda (diff)
downloadpacman-cf6da173f62ee96703714e66f8538069a46a63e3.tar.xz
removed libtar support in favour of libarchive
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 277b3946..c8822240 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -26,8 +26,6 @@
#include <fcntl.h>
#include <string.h>
#include <libintl.h>
-#include <libtar.h>
-#include <zlib.h>
/* pacman */
#include "log.h"
#include "util.h"
@@ -247,14 +245,9 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
int config = 0;
int filelist = 0;
int scriptcheck = 0;
- TAR *tar = NULL;
+ register struct archive *archive;
+ struct archive_entry *entry;
pmpkg_t *info = NULL;
- tartype_t gztype = {
- (openfunc_t)_alpm_gzopen_frontend,
- (closefunc_t)gzclose,
- (readfunc_t)gzread,
- (writefunc_t)gzwrite
- };
if(pkgfile == NULL || strlen(pkgfile) == 0) {
RET_ERR(PM_ERR_WRONG_ARGS, NULL);
@@ -269,23 +262,30 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
goto error;
}
- if(tar_open(&tar, pkgfile, &gztype, O_RDONLY, 0, TAR_GNU) == -1) {
+ if((archive = archive_read_new()) == NULL) {
+ RET_ERR(PM_ERR_LIBARCHIVE_ERROR, NULL);
+ }
+
+ archive_read_support_compression_all(archive);
+ archive_read_support_format_all(archive);
+ if(archive_read_open_file(archive, pkgfile, 10240) != ARCHIVE_OK) {
pm_errno = PM_ERR_NOT_A_FILE;
goto error;
}
- for(i = 0; !th_read(tar); i++) {
+ for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
if(config && filelist && scriptcheck) {
/* we have everything we need */
break;
}
- if(!strcmp(th_get_pathname(tar), ".PKGINFO")) {
+ if(!strcmp(archive_entry_pathname(entry), ".PKGINFO")) {
char *descfile;
int fd;
/* extract this file into /tmp. it has info for us */
descfile = strdup("/tmp/alpm_XXXXXX");
fd = mkstemp(descfile);
- tar_extract_file(tar, descfile);
+ _alpm_archive_read_entry_data_into_fd(archive, fd);
+ close(fd);
/* parse the info file */
if(parse_descfile(descfile, info, 0) == -1) {
_alpm_log(PM_LOG_ERROR, _("could not parse the package description file"));
@@ -300,10 +300,10 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
FREE(descfile);
close(fd);
continue;
- } else if(!strcmp(th_get_pathname(tar), "._install") || !strcmp(th_get_pathname(tar), ".INSTALL")) {
+ } else if(!strcmp(archive_entry_pathname(entry), "._install") || !strcmp(archive_entry_pathname(entry), ".INSTALL")) {
info->scriptlet = 1;
scriptcheck = 1;
- } else if(!strcmp(th_get_pathname(tar), ".FILELIST")) {
+ } else if(!strcmp(archive_entry_pathname(entry), ".FILELIST")) {
/* Build info->files from the filelist */
FILE *fp;
char *fn;
@@ -316,7 +316,8 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
}
fn = strdup("/tmp/alpm_XXXXXX");
fd = mkstemp(fn);
- tar_extract_file(tar, fn);
+ _alpm_archive_read_entry_data_into_fd(archive, fd);
+ close(fd);
fp = fopen(fn, "r");
while(!feof(fp)) {
if(fgets(str, PATH_MAX, fp) == NULL) {
@@ -339,19 +340,18 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
if(!filelist) {
/* no .FILELIST present in this package.. build the filelist the */
/* old-fashioned way, one at a time */
- expath = strdup(th_get_pathname(tar));
+ expath = strdup(archive_entry_pathname(entry));
info->files = _alpm_list_add(info->files, expath);
}
}
- if(TH_ISREG(tar) && tar_skip_regfile(tar)) {
+ if(archive_read_data_skip(archive)) {
_alpm_log(PM_LOG_ERROR, _("bad package file in %s"), pkgfile);
goto error;
}
expath = NULL;
}
- tar_close(tar);
- tar = NULL;
+ archive_read_finish(archive);
if(!config) {
_alpm_log(PM_LOG_ERROR, _("missing package info file in %s"), pkgfile);
@@ -367,9 +367,7 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
error:
FREEPKG(info);
- if(tar) {
- tar_close(tar);
- }
+ archive_read_finish(archive);
return(NULL);
}