Clean up buildroot (remove suplicate slashes, trailing slashes)
authormarc <devnull@localhost>
Tue, 3 Mar 1998 17:07:39 +0000 (17:07 +0000)
committermarc <devnull@localhost>
Tue, 3 Mar 1998 17:07:39 +0000 (17:07 +0000)
CVS patchset: 2015
CVS date: 1998/03/03 17:07:39

CHANGES
build/files.c
build/misc.c
build/misc.h
build/parsePreamble.c

diff --git a/CHANGES b/CHANGES
index e3e5c7e..46465f8 100644 (file)
--- 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
index ed4050d..7ef3a54 100644 (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 */
index 7437f3d..72c7dde 100644 (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;
+}
index 1ac9415..4412fbf 100644 (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
index de26675..e88d530 100644 (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,