--- rpm-5.4.10/lib/rpmds.c.uclibc_buildroot~ 2012-10-04 16:25:30.850199688 +0200 +++ rpm-5.4.10/lib/rpmds.c 2012-10-04 16:25:40.130349028 +0200 @@ -3063,8 +3063,10 @@ foo: } if (dyn->d_tag == DT_NEEDED) { char *tmp, *tmp2; - char buf[MAXPATHLEN]; - char path[MAXPATHLEN] = ""; + /* XXX: we multiply by 4 to make sure to have room for several paths */ + char buf[4*MAXPATHLEN] = ""; + char path[4*MAXPATHLEN]; + char *buildroot; libpath = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val); if (prev && *prev && libpath && !strcmp(basename(prev), libpath)) @@ -3084,10 +3086,9 @@ foo: if (stat(libpath, &statbuf) == 0) continue; - tmp2 = path; + tmp2 = buf; if (rpath && *rpath) { - tmp2 = stpcpy(tmp2, rpath); - tmp2 = stpcpy(tmp2, ":"); + tmp2 = stpcpy(buf, rpath); } tmp = getenv("LD_LIBRARY_PATH"); if (tmp) @@ -3096,6 +3097,28 @@ foo: tmp2 = stpcpy(tmp2, ":"); /* XXX: do better check to ensure libraries are all of the same class */ tmp2 = stpcpy(tmp2, (class == ELFCLASS64) ? "/lib64:/usr/lib64" : "/lib:/usr/lib"); + /* we need to search through library paths within buildroot as well */ + buildroot = rpmExpand("%{buildroot}", NULL); + if (stat(buildroot, &statbuf) == 0) { + char *tmp3; + for (tmp2 = buf, tmp = path; + tmp2 != NULL; + tmp2 = tmp3) { + tmp = stpcpy(tmp, buildroot); + tmp3 = strchr(tmp2, ':'); + if (tmp3) + *tmp3 = '\0'; + tmp = stpcpy(tmp, tmp2); + tmp = stpcpy(tmp, ":"); + if (tmp3) { + *tmp3 = ':'; + tmp3++; + } + } + } else + tmp = path; + _free(buildroot); + stpcpy(tmp, buf); tmp = buf; { int i, count = 1;