summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-06-27 14:52:22 +0300
committerPanu Matilainen <pmatilai@redhat.com>2011-06-27 15:03:18 +0300
commit23167c3ea459405c98d8e759993efb6d9b1ea7f3 (patch)
tree11bc1d76bd2e139f5acf4a62311c0f671250bfbf
parent65e88045ba80b175418b865fe4c4a88d48c00189 (diff)
downloadlibrpm-tizen-23167c3ea459405c98d8e759993efb6d9b1ea7f3.tar.gz
librpm-tizen-23167c3ea459405c98d8e759993efb6d9b1ea7f3.tar.bz2
librpm-tizen-23167c3ea459405c98d8e759993efb6d9b1ea7f3.zip
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.
-rw-r--r--build/files.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/build/files.c b/build/files.c
index f679b93d7..b1ce4a4b8 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1382,8 +1382,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;
}
@@ -1614,6 +1617,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);
@@ -1633,6 +1642,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;
@@ -1651,7 +1663,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;
}