From ace47d0fd2e2064478faefb9eae4a5da43a62221 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 14 Jun 2008 23:04:10 +0000 Subject: [PATCH 1/3] build/parseSpec.c (readLine): Fix chomp in preprocess mode --- build/parseSpec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/parseSpec.c b/build/parseSpec.c index b4c2e00..377bd1c 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -414,7 +414,7 @@ retry: if (spec->preprocess_mode) { size_t len = strlen(spec->line); - if (spec->line[len-1] == '\n') + if (len > 0 && spec->line[len-1] == '\n') len--; /* chomp */ fprintf(tmpfp, "%.*s\n", (int)len, spec->line); } From 96f8c331e6d72426cd28450d8c0e7db31b946fe1 Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Tue, 17 Jun 2008 04:54:46 +0400 Subject: [PATCH 2/3] Revert "fixed RPMTAG_SIZE calculation" This reverts commit 62c081a169d2ae2e9bab6ea4ae71e7b5fa9569e4. --- build/files.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build/files.c b/build/files.c index 0a1451f..aa58a6d 100644 --- a/build/files.c +++ b/build/files.c @@ -1333,6 +1333,8 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, &(flp->flags), 1); } + (void) headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, + &(fl->totalFileSize), 1); /* XXX This should be added always so that packages look alike. * XXX However, there is logic in files.c/depends.c that checks for @@ -1444,10 +1446,6 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, fi->actions[i] = FA_SKIP; continue; } - - if (S_ISREG(flp->fl_mode)) - fl->totalFileSize += flp->fl_size; - fi->actions[i] = FA_COPYOUT; fi->fuids[i] = getUidS(flp->uname); fi->fgids[i] = getGidS(flp->gname); @@ -1468,8 +1466,6 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, fi = _free(fi); /*@=branchstate@*/ } - (void) headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, - &(fl->totalFileSize), 1); } /** @@ -1815,6 +1811,9 @@ static int addFile(FileList fl, const char * diskURL, } } else i = fl->fileListRecsUsed; + + if (S_ISREG(flp->fl_mode) && i >= fl->fileListRecsUsed) + fl->totalFileSize += flp->fl_size; } fl->fileListRecsUsed++; From faeab68da23ec2e15c57b304ff185e4b4885f069 Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Tue, 17 Jun 2008 05:07:02 +0400 Subject: [PATCH 3/3] build/files.c: re-fixed RPMTAG_SIZE calculation (cf. #2634) --- build/files.c | 59 +++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/build/files.c b/build/files.c index aa58a6d..4ba0c62 100644 --- a/build/files.c +++ b/build/files.c @@ -1333,8 +1333,6 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, &(flp->flags), 1); } - (void) headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, - &(fl->totalFileSize), 1); /* XXX This should be added always so that packages look alike. * XXX However, there is logic in files.c/depends.c that checks for @@ -1458,7 +1456,41 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, if (flp->flags & RPMFILE_MULTILIB_MASK) fi->fmapflags[i] |= CPIO_MULTILIB; + if (S_ISREG(flp->fl_mode) && flp->fl_nlink == 1) + fl->totalFileSize += flp->fl_size; + else if (S_ISREG(flp->fl_mode) && flp->fl_nlink > 1) { + /* Hard links need be counted only once. */ + int j = i + 1; + FileListRec jlp = flp + 1; + int found = 0; + for (; j < fi->fc; j++, jlp++) { + while (((jlp - fl->fileList) < (fl->fileListRecsUsed - 1)) && + !strcmp(jlp->fileURL, jlp[1].fileURL)) + jlp++; + if (jlp->flags & RPMFILE_EXCLUDE) { + j--; + continue; + } + if (jlp->flags & RPMFILE_GHOST) + continue; + if (!S_ISREG(jlp->fl_mode)) + continue; + if (flp->fl_nlink != jlp->fl_nlink) + continue; + if (flp->fl_ino != jlp->fl_ino) + continue; + if (flp->fl_dev != jlp->fl_dev) + continue; + found = 1; + break; + } + if (!found) /* last entry in hardlink set */ + fl->totalFileSize += flp->fl_size; + } } + (void) headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, + &(fl->totalFileSize), 1); + /*@-branchstate@*/ if (cpioList) *cpioList = fi; @@ -1793,27 +1825,6 @@ static int addFile(FileList fl, const char * diskURL, && !parseForRegexMultiLib(fileURL)) flp->flags |= multiLib; - - /* Hard links need be counted only once. */ - if (S_ISREG(flp->fl_mode) && flp->fl_nlink > 1) { - FileListRec ilp; - for (i = 0; i < fl->fileListRecsUsed; i++) { - ilp = fl->fileList + i; - if (!S_ISREG(ilp->fl_mode)) - continue; - if (flp->fl_nlink != ilp->fl_nlink) - continue; - if (flp->fl_ino != ilp->fl_ino) - continue; - if (flp->fl_dev != ilp->fl_dev) - continue; - break; - } - } else - i = fl->fileListRecsUsed; - - if (S_ISREG(flp->fl_mode) && i >= fl->fileListRecsUsed) - fl->totalFileSize += flp->fl_size; } fl->fileListRecsUsed++; @@ -2348,8 +2359,6 @@ int processSourceFiles(Spec spec) flp->gname = getGname(flp->fl_gid); flp->langs = xstrdup(""); - fl.totalFileSize += flp->fl_size; - if (! (flp->uname && flp->gname)) { rpmError(RPMERR_BADSPEC, _("Bad owner/group: %s\n"), diskURL); fl.processingFailed = 1;