From edf3ad468fbb2f5940f62e0155b4c5f80f0e43cb Mon Sep 17 00:00:00 2001 From: ewt Date: Wed, 7 Apr 1999 05:54:45 +0000 Subject: [PATCH] fix size estimates for source packages CVS patchset: 2961 CVS date: 1999/04/07 05:54:45 --- lib/fs.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/fs.c b/lib/fs.c index 27d6b32..24f412f 100644 --- a/lib/fs.c +++ b/lib/fs.c @@ -1,6 +1,7 @@ #include "system.h" #include "rpmlib.h" +#include "rpmmacro.h" struct fsinfo { char * mntPoint; @@ -197,7 +198,7 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles char * buf, * dirName; char * chptr; int maxLen; - char * lastDir; + char * lastDir, * sourceDir; int lastfs = 0; int lastDev = -1; /* I hope nobody uses -1 for a st_dev */ struct stat sb; @@ -219,15 +220,22 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles dirName = alloca(maxLen + 1); *lastDir = '\0'; + sourceDir = rpmGetPath("", "/%{_sourcedir}", NULL); + /* cut off last filename */ for (i = 0; i < numFiles; i++) { - strcpy(buf, fileList[i]); - chptr = buf + strlen(buf) - 1; - while (*chptr != '/') chptr--; - if (chptr == buf) - buf[1] = '\0'; - else - *chptr-- = '\0'; + if (*fileList[i] == '/') { + strcpy(buf, fileList[i]); + chptr = buf + strlen(buf) - 1; + while (*chptr != '/') chptr--; + if (chptr == buf) + buf[1] = '\0'; + else + *chptr-- = '\0'; + } else { + /* this should only happen for source packages (gulp) */ + buf = sourceDir; + } if (strcmp(lastDir, buf)) { strcpy(dirName, buf); @@ -269,6 +277,8 @@ int rpmGetFilesystemUsage(const char ** fileList, int_32 * fssizes, int numFiles usages[lastfs] += fssizes[i]; } + if (sourceDir) free(sourceDir); + *usagesPtr = usages; return 0; -- 2.7.4