Clean up buildroot (remove suplicate slashes, trailing slashes)

CVS patchset: 2015
CVS date: 1998/03/03 17:07:39
This commit is contained in:
marc 1998-03-03 17:07:39 +00:00
parent 9fa832f9b6
commit 6accf2f426
5 changed files with 31 additions and 18 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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;
}

View File

@ -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

View File

@ -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,