summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-06-27 14:52:22 +0300
committerPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-15 12:21:44 +0300
commit2170996974a77bfabfbb8e2fe356196615796d74 (patch)
tree8b6fdf780a46224504d681a463fa9dab2e66dd31
parent91368408365a1e15cc7174ecc99c2834fef77d0a (diff)
downloadrpm-2170996974a77bfabfbb8e2fe356196615796d74.tar.gz
Pay attention to dir vs file when building (RhBug:505995)
- Preserve trailing slash if it exists, and also add one on explicit %dir entires. This lets rpmGlob() and friends to skip any matching files that might be present, fixing both test-cases in RhBug:505995. (cherry picked from commit 23167c3ea459405c98d8e759993efb6d9b1ea7f3)
-rw-r--r--build/files.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/build/files.c b/build/files.c
index 87f302a36..5ccd99c7a 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1402,8 +1402,11 @@ static rpmRC addFile(FileList fl, const char * diskPath,
statp->st_atime = now;
statp->st_mtime = now;
statp->st_ctime = now;
- } else {
- rpmlog(RPMLOG_ERR, _("File not found: %s\n"), diskPath);
+ } else {
+ const char *msg = fl->isDir ?
+ _("Directory not found: %s\n") :
+ _("File not found: %s\n");
+ rpmlog(RPMLOG_ERR, msg, diskPath);
fl->processingFailed = 1;
return RPMRC_FAIL;
}
@@ -1653,6 +1656,12 @@ static rpmRC processBinaryFile(Package pkg, FileList fl, const char * fileName)
int doGlob;
char *diskPath = NULL;
rpmRC rc = RPMRC_OK;
+ size_t fnlen = strlen(fileName);
+ int trailing_slash = (fnlen > 0 && fileName[fnlen-1] == '/');
+
+ /* XXX differentiate other directories from explicit %dir */
+ if (trailing_slash && !fl->isDir)
+ fl->isDir = -1;
doGlob = glob_pattern_p(fileName, quote);
@@ -1672,6 +1681,9 @@ static rpmRC processBinaryFile(Package pkg, FileList fl, const char * fileName)
* /.././../usr/../bin//./sh
*/
diskPath = rpmGenPath(fl->buildRoot, NULL, fileName);
+ /* Arrange trailing slash on directories */
+ if (fl->isDir)
+ diskPath = rstrcat(&diskPath, "/");
if (doGlob) {
ARGV_t argv = NULL;
@@ -1691,7 +1703,10 @@ static rpmRC processBinaryFile(Package pkg, FileList fl, const char * fileName)
}
argvFree(argv);
} else {
- rpmlog(RPMLOG_ERR, _("File not found by glob: %s\n"), diskPath);
+ const char *msg = (fl->isDir) ?
+ _("Directory not found by glob: %s\n") :
+ _("File not found by glob: %s\n");
+ rpmlog(RPMLOG_ERR, msg, diskPath);
rc = RPMRC_FAIL;
goto exit;
}