Strip trailing slash from paths at addFile()
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 2 Aug 2011 09:39:51 +0000 (12:39 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 2 Aug 2011 09:42:21 +0000 (12:42 +0300)
- Fixes regression from commit 23167c3ea459405c98d8e759993efb6d9b1ea7f3
  which causes all %dir entries to have a trailing slash, breaking
  at least dependencies on such directories and probably something
  else as well.

build/files.c

index aa3ee63..cd3e489 100644 (file)
@@ -1306,13 +1306,23 @@ static rpmRC recurseDir(FileList fl, const char * diskPath);
 static rpmRC addFile(FileList fl, const char * diskPath,
                struct stat * statp)
 {
-    const char *cpioPath = diskPath;
+    size_t plen = strlen(diskPath);
+    char buf[plen + 1];
+    const char *cpioPath;
     struct stat statbuf;
     mode_t fileMode;
     uid_t fileUid;
     gid_t fileGid;
     const char *fileUname;
     const char *fileGname;
+
+    /* Strip trailing slash. The special case of '/' path is handled below. */
+    if (plen > 0 && diskPath[plen - 1] == '/') {
+       diskPath = strcpy(buf, diskPath);
+       buf[plen - 1] = '\0';
+    }
+    cpioPath = diskPath;
+       
     
     /* Path may have prepended buildRoot, so locate the original filename. */
     /*