diff options
author | ewt <devnull@localhost> | 1997-05-06 15:27:46 +0000 |
---|---|---|
committer | ewt <devnull@localhost> | 1997-05-06 15:27:46 +0000 |
commit | 0a02b64c726bce0763e71ba393ad2740c2ecdd9f (patch) | |
tree | b8c61743bb8f4ea5ca43cc10b7c215fa326fa9ec /lib/install.c | |
parent | 260850e9b840b6b745121a8c7c9fe8d70b116d7e (diff) | |
download | librpm-tizen-0a02b64c726bce0763e71ba393ad2740c2ecdd9f.tar.gz librpm-tizen-0a02b64c726bce0763e71ba393ad2740c2ecdd9f.tar.bz2 librpm-tizen-0a02b64c726bce0763e71ba393ad2740c2ecdd9f.zip |
Added callbacks to cpio to allow -h to work.
CVS patchset: 1596
CVS date: 1997/05/06 15:27:46
Diffstat (limited to 'lib/install.c')
-rw-r--r-- | lib/install.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/install.c b/lib/install.c index a87cd8193..f4616d15d 100644 --- a/lib/install.c +++ b/lib/install.c @@ -30,6 +30,11 @@ enum instActions { UNKNOWN, CREATE, BACKUP, KEEP, SAVE, SKIP }; enum fileTypes { XDIR, BDEV, CDEV, SOCK, PIPE, REG, LINK } ; +struct callbackInfo { + unsigned long archiveSize; + rpmNotifyFunction notify; +}; + struct fileMemory { char ** md5s; char ** links; @@ -573,7 +578,11 @@ int rpmInstallPackage(char * rootdir, rpmdb db, int fd, char * location, return 0; } -#define BLOCKSIZE 1024 +static void callback(struct cpioCallbackInfo * cpioInfo, void * data) { + struct callbackInfo * ourInfo = data; + + ourInfo->notify(cpioInfo->bytesProcessed, ourInfo->archiveSize); +} /* NULL files means install all files */ static int installArchive(char * prefix, int fd, struct fileInfo * files, @@ -583,6 +592,7 @@ static int installArchive(char * prefix, int fd, struct fileInfo * files, int rc, i; struct cpioFileMapping * map; char * failedFile; + struct callbackInfo info; if (!files) { /* install all files */ @@ -592,6 +602,9 @@ static int installArchive(char * prefix, int fd, struct fileInfo * files, return 0; } + info.archiveSize = archiveSize; + info.notify = notify; + if (specFile) *specFile = NULL; map = alloca(sizeof(*map) * fileCount); @@ -611,18 +624,23 @@ static int installArchive(char * prefix, int fd, struct fileInfo * files, qsort(map, fileCount, sizeof(*map), cpioFileMapCmp); stream = gzdopen(fd, "r"); - rc = cpioInstallArchive(stream, map, fileCount, NULL, &failedFile); + rc = cpioInstallArchive(stream, map, fileCount, + (notify && archiveSize) ? callback : NULL, + &info, &failedFile); if (rc) { /* this would probably be a good place to check if disk space was used up - if so, we should return a different error */ - rpmError(RPMERR_CPIO, "unpacking of archive failed on file %s: %d", - failedFile, rc); + rpmError(RPMERR_CPIO, "unpacking of archive failed on file %s: %d: %s", + failedFile, rc, strerror(errno)); return 1; } - if (notify) + if (notify && archiveSize) notify(archiveSize, archiveSize); + else if (notify) { + notify(100, 100); + } return 0; } |