--- ./build/files.c.orig 2011-07-21 10:59:03.000000000 +0000 +++ ./build/files.c 2011-07-21 10:59:33.000000000 +0000 @@ -1398,7 +1398,7 @@ static rpmRC addFile(FileList fl, const } } - if ((! fl->isDir) && S_ISDIR(statp->st_mode)) { + if ((fl->isDir <= 0) && S_ISDIR(statp->st_mode)) { /* FIX: fl->buildRoot may be NULL */ return recurseDir(fl, diskPath); } @@ -1678,9 +1678,6 @@ static rpmRC processBinaryFile(Package p * /.././../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; @@ -1694,8 +1691,18 @@ static rpmRC processBinaryFile(Package p goto exit; } + /* Arrange trailing slash on directories */ + if (fl->isDir) + diskPath = rstrcat(&diskPath, "/"); + if (rpmGlob(diskPath, &argc, &argv) == 0 && argc >= 1) { for (i = 0; i < argc; i++) { + if (fl->isDir) { + /* strip trailing slash again */ + int l = strlen(argv[i]); + if (l > 1 && argv[i][l - 1] == '/') + argv[i][l - 1] = 0; + } rc = addFile(fl, argv[i], NULL); } argvFree(argv);