diff --git a/CHANGES b/CHANGES index e3e5c7ef0..46465f8f9 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ - allow spaces in group names - fix bug in memory allocation of special doc stuff - Jeff Johnson's mode/dev fixes + - clean up buildroot 2.4.101 -> 2.4.102: - fixed spelling of "instchangelog" in lib-rpmrc.in diff --git a/build/files.c b/build/files.c index ed4050d34..7ef3a5402 100644 --- a/build/files.c +++ b/build/files.c @@ -426,6 +426,7 @@ static int processPackageFiles(Spec spec, Package pkg, int installSpecialDoc) if (installSpecialDoc) { doScript(spec, RPMBUILD_STRINGBUF, "%doc", pkg->specialDoc, 0); } + /* fl.current now takes on "ownership" of the specialDocAttrRec */ /* allocated string data. */ fl.current = specialDocAttrRec; @@ -708,28 +709,13 @@ static int addFile(struct FileList *fl, char *name, struct stat *statp) { char fileName[BUFSIZ]; char diskName[BUFSIZ]; - char *copyTo, *copyFrom, copied; char *prefixTest, *prefixPtr; struct stat statbuf; int_16 fileMode; int fileUid, fileGid; char *fileUname, *fileGname; - /* Copy to fileName, eliminate duplicate "/" and trailing "/" */ - copyTo = fileName; - copied = '\0'; - copyFrom = name; - while (*copyFrom) { - if (*copyFrom != '/' || copied != '/') { - *copyTo++ = copied = *copyFrom; - } - copyFrom++; - } - *copyTo = '\0'; - copyTo--; - if ((copyTo != fileName) && (*copyTo == '/')) { - *copyTo = '\0'; - } + strcpy(fileName, cleanFileName(name)); if (fl->inFtw) { /* Any buildRoot is already prepended */ diff --git a/build/misc.c b/build/misc.c index 7437f3d2a..72c7ddeb1 100644 --- a/build/misc.c +++ b/build/misc.c @@ -200,3 +200,27 @@ StringBuf getOutputFrom(char *dir, char *argv[], return readBuff; } + +char *cleanFileName(char *name) +{ + static char res[BUFSIZ]; + char *copyTo, *copyFrom, copied; + + /* Copy to fileName, eliminate duplicate "/" and trailing "/" */ + copyTo = res; + copied = '\0'; + copyFrom = name; + while (*copyFrom) { + if (*copyFrom != '/' || copied != '/') { + *copyTo++ = copied = *copyFrom; + } + copyFrom++; + } + *copyTo = '\0'; + copyTo--; + if ((copyTo != res) && (*copyTo == '/')) { + *copyTo = '\0'; + } + + return res; +} diff --git a/build/misc.h b/build/misc.h index 1ac941509..4412fbf44 100644 --- a/build/misc.h +++ b/build/misc.h @@ -23,5 +23,6 @@ int parseNum(char *line, int *res); StringBuf getOutputFrom(char *dir, char *argv[], char *writePtr, int writeBytesLeft, int failNonZero); +char *cleanFileName(char *name); #endif diff --git a/build/parsePreamble.c b/build/parsePreamble.c index de2667569..e88d530f1 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -354,10 +354,11 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, char *macro, SINGLE_TOKEN_ONLY; if (! spec->buildRoot) { if (rpmGetVar(RPMVAR_BUILDROOT)) { - spec->buildRoot = strdup(rpmGetVar(RPMVAR_BUILDROOT)); + spec->buildRoot = rpmGetVar(RPMVAR_BUILDROOT); } else { - spec->buildRoot = strdup(field); + spec->buildRoot = field; } + spec->buildRoot = strdup(cleanFileName(spec->buildRoot)); } if (!strcmp(spec->buildRoot, "/")) { rpmError(RPMERR_BADSPEC,