--- rpm-5.4.9/build/files.c.buildroot_dups~ 2012-04-15 17:04:14.000000000 +0200 +++ rpm-5.4.9/build/files.c 2012-05-15 02:11:03.734983519 +0200 @@ -2917,7 +2917,7 @@ exit: /* auxiliary function for checkDuplicateFiles() */ /* XXX need to pass Header because fi->h is NULL */ -static int fiIntersect(/*@null@*/ rpmfi fi1, /*@null@*/ rpmfi fi2) +static int fiIntersect(/*@null@*/ rpmfi fi1, /*@null@*/ rpmfi fi2, size_t buildrootL) /*@globals internalState @*/ /*@modifies fi1, fi2, internalState @*/ { @@ -2941,7 +2941,7 @@ static int fiIntersect(/*@null@*/ rpmfi if (!dups) dups = rpmiobNew(0); dups = rpmiobAppend(dups, "\t", 0); - dups = rpmiobAppend(dups, fn1, 1); + dups = rpmiobAppend(dups, fn1+buildrootL, 1); n++; } } @@ -2972,7 +2972,7 @@ static int fiIntersect(/*@null@*/ rpmfi * @param spec spec file control structure * @return number of duplicate files */ -static int checkDuplicateFiles(Spec spec) +static int checkDuplicateFiles(Spec spec, size_t buildrootL) /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ /*@modifies *spec->packages, rpmGlobalMacroContext, fileSystem, internalState @*/ @@ -2997,7 +2997,7 @@ static int checkDuplicateFiles(Spec spec #endif if (fi2 == NULL) continue; (void) rpmfiSetHeader(fi2, pkg2->header); - n += fiIntersect(fi1, fi2); + n += fiIntersect(fi1, fi2, buildrootL); (void) rpmfiSetHeader(fi2, NULL); fi2 = rpmfiFree(fi2); } @@ -3023,7 +3023,7 @@ static inline int packagedDir(Package pk * /A/B/C/D * Now directories "/A/B" and "/A/B/C" should also be packaged. */ -static int pkgUnpackagedSubdirs(Package pkg) +static int pkgUnpackagedSubdirs(Package pkg, size_t buildrootL) /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ /*@modifies pkg->header, rpmGlobalMacroContext, fileSystem, internalState @*/ @@ -3096,7 +3096,7 @@ static int pkgUnpackagedSubdirs(Package for (i = 0; i < n; i++) { list = rpmiobAppend(list, "\t", 0); - list = rpmiobAppend(list, unpackaged[i], 1); + list = rpmiobAppend(list, unpackaged[i]+buildrootL, 1); unpackaged[i] = _free(unpackaged[i]); } unpackaged = _free(unpackaged); @@ -3117,7 +3117,7 @@ static int pkgUnpackagedSubdirs(Package * @param spec spec file control structure * @return number of unpackaged subdirectories */ -static int checkUnpackagedSubdirs(Spec spec) +static int checkUnpackagedSubdirs(Spec spec, size_t buildrootL) /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ /*@modifies *spec->packages, rpmGlobalMacroContext, fileSystem, internalState @*/ @@ -3126,7 +3126,7 @@ static int checkUnpackagedSubdirs(Spec s Package pkg; for (pkg = spec->packages; pkg; pkg = pkg->next) - n += pkgUnpackagedSubdirs(pkg); + n += pkgUnpackagedSubdirs(pkg, buildrootL); return n; } @@ -3137,6 +3137,11 @@ rpmRC processBinaryFiles(Spec spec, int Package pkg; rpmRC res = RPMRC_OK; + char *buildroot = rpmExpand("%{?buildroot}", NULL); + size_t buildrootL = strlen(buildroot); + + buildroot = _free(buildroot); + for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { int rc; @@ -3178,8 +3183,8 @@ rpmRC processBinaryFiles(Spec spec, int if (res == RPMRC_OK) { if (checkUnpackagedFiles(spec) > 0) res = RPMRC_FAIL; - (void) checkDuplicateFiles(spec); - (void) checkUnpackagedSubdirs(spec); + (void) checkDuplicateFiles(spec, buildrootL); + (void) checkUnpackagedSubdirs(spec, buildrootL); } return res;