summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-16 22:21:06 +0100
committerAurelien Foret <aurelien@archlinux.org>2005-03-16 22:21:06 +0100
commitab7ca5dc72d4bd1eb08d210ff911352d23bd1072 (patch)
tree035c22bcfebbf3e00f88368ae02ac0263b058f91 /src/pacman/util.c
parent2ce1105900fcbb1fa2ad176dae74e5f5290af4a4 (diff)
downloadpacman-ab7ca5dc72d4bd1eb08d210ff911352d23bd1072.tar.gz
pacman-ab7ca5dc72d4bd1eb08d210ff911352d23bd1072.tar.xz
- reworked sync_synctree() to make use of alpm_db_update()
- dropped unpack()
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c75
1 files changed, 1 insertions, 74 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 56c3349b..5ae26149 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -28,84 +28,11 @@
#include <fcntl.h>
#include <ctype.h>
#include <dirent.h>
-#include <zlib.h>
-#include <libtar.h>
+#include <unistd.h>
/* pacman */
#include "util.h"
-/* borrowed and modified from Per Liden's pkgutils (http://crux.nu) */
-long gzopen_frontend(char *pathname, int oflags, int mode)
-{
- char *gzoflags;
- int fd;
- gzFile gzf;
-
- switch (oflags & O_ACCMODE) {
- case O_WRONLY:
- gzoflags = "w";
- break;
- case O_RDONLY:
- gzoflags = "r";
- break;
- case O_RDWR:
- default:
- errno = EINVAL;
- return -1;
- }
-
- if((fd = open(pathname, oflags, mode)) == -1) {
- return -1;
- }
- if((oflags & O_CREAT) && fchmod(fd, mode)) {
- return -1;
- }
- if(!(gzf = gzdopen(fd, gzoflags))) {
- errno = ENOMEM;
- return -1;
- }
-
- return (long)gzf;
-}
-
-int unpack(char *archive, const char *prefix, const char *fn)
-{
- TAR *tar = NULL;
- char expath[PATH_MAX];
- tartype_t gztype = {
- (openfunc_t) gzopen_frontend,
- (closefunc_t)gzclose,
- (readfunc_t) gzread,
- (writefunc_t)gzwrite
- };
-
- /* open the .tar.gz package */
- if(tar_open(&tar, archive, &gztype, O_RDONLY, 0, TAR_GNU) == -1) {
- perror(archive);
- return(1);
- }
- while(!th_read(tar)) {
- if(fn && strcmp(fn, th_get_pathname(tar))) {
- if(TH_ISREG(tar) && tar_skip_regfile(tar)) {
- char errorstr[255];
- snprintf(errorstr, 255, "bad tar archive: %s", archive);
- perror(errorstr);
- tar_close(tar);
- return(1);
- }
- continue;
- }
- snprintf(expath, PATH_MAX, "%s/%s", prefix, th_get_pathname(tar));
- if(tar_extract_file(tar, expath)) {
- fprintf(stderr, "could not extract %s: %s\n", th_get_pathname(tar), strerror(errno));
- }
- if(fn) break;
- }
- tar_close(tar);
-
- return(0);
-}
-
/* does the same thing as 'mkdir -p' */
int makepath(char *path)
{