diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-11-17 13:39:22 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-11-17 13:39:22 +0200 |
commit | 899dfb58927ec6e91014773430824462f4d0002e (patch) | |
tree | 48cf3e480b305fd9e8af7b71e4dc5af932195f3f /build | |
parent | 74ed5372f681a31987ba931d72ed5d8ae96f52d0 (diff) | |
download | rpm-899dfb58927ec6e91014773430824462f4d0002e.tar.gz rpm-899dfb58927ec6e91014773430824462f4d0002e.tar.bz2 rpm-899dfb58927ec6e91014773430824462f4d0002e.zip |
Calculate total file size correctly in build (mdvbz#45820, rhbz#247374)
- delay total size calculation until the real file list is known, ie
in genCpioListAndHeaders() where duplicates and excludes have been
weeded out
Diffstat (limited to 'build')
-rw-r--r-- | build/files.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/build/files.c b/build/files.c index d5888d068..51d6392de 100644 --- a/build/files.c +++ b/build/files.c @@ -94,7 +94,6 @@ typedef struct FileList_s { char * prefix; int fileCount; - rpm_loff_t totalFileSize; int processingFailed; int passedSpecialDoc; @@ -1042,6 +1041,7 @@ static void genCpioListAndHeader(FileList fl, char buf[BUFSIZ]; int i; pgpHashAlgo defaultalgo = PGPHASHALGO_MD5, digestalgo; + rpm_loff_t totalFileSize = 0; /* * See if non-md5 file checksum algorithm is requested. If not @@ -1155,6 +1155,9 @@ static void genCpioListAndHeader(FileList fl, rpm_off_t rsize32 = (rpm_off_t)flp->fl_size; headerPutUint32(h, RPMTAG_FILESIZES, &rsize32, 1); } + /* Excludes and dupes have been filtered out by now */ + if (S_ISREG(flp->fl_mode)) + totalFileSize += flp->fl_size; /* * For items whose size varies between systems, always explicitly @@ -1223,12 +1226,12 @@ static void genCpioListAndHeader(FileList fl, headerPutUint32(h, RPMTAG_FILEFLAGS, &(flp->flags) ,1); } - if (fl->totalFileSize < UINT32_MAX) { - rpm_off_t totalfilesize = fl->totalFileSize; - headerPutUint32(h, RPMTAG_SIZE, &totalfilesize, 1); + if (totalFileSize < UINT32_MAX) { + rpm_off_t totalsize = totalFileSize; + headerPutUint32(h, RPMTAG_SIZE, &totalsize, 1); } else { - rpm_loff_t totalfilesize = fl->totalFileSize; - headerPutUint64(h, RPMTAG_LONGSIZE, &totalfilesize, 1); + rpm_loff_t totalsize = totalFileSize; + headerPutUint64(h, RPMTAG_LONGSIZE, &totalsize, 1); } if (digestalgo != defaultalgo) { @@ -1503,8 +1506,6 @@ static rpmRC addFile(FileList fl, const char * diskPath, flp->diskPath); return RPMRC_FAIL; } - - fl->totalFileSize += flp->fl_size; } } @@ -1776,7 +1777,6 @@ static rpmRC processPackageFiles(rpmSpec spec, Package pkg, } fl.fileCount = 0; - fl.totalFileSize = 0; fl.processingFailed = 0; fl.passedSpecialDoc = 0; @@ -2085,7 +2085,6 @@ int processSourceFiles(rpmSpec spec) fl.fileList = xcalloc((spec->numSources + 1), sizeof(*fl.fileList)); fl.processingFailed = 0; fl.fileListRecsUsed = 0; - fl.totalFileSize = 0; fl.prefix = NULL; fl.buildRoot = NULL; @@ -2141,8 +2140,6 @@ int processSourceFiles(rpmSpec spec) } flp->langs = xstrdup(""); - fl.totalFileSize += flp->fl_size; - if (! (flp->uname && flp->gname)) { rpmlog(RPMLOG_ERR, _("Bad owner/group: %s\n"), diskPath); fl.processingFailed = 1; |