RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Per Øyvind Karlsen Root: /v/rpm/cvs Email: pkarl...@rpm5.org Module: rpm Date: 28-Apr-2011 17:49:04 Branch: rpm-5_3 Handle: 2011042815490400 Modified files: (Branch: rpm-5_3) rpm/lib rpmds.c rpmfc.c Log: queued changes for fixing uClibc() dependencies and also devel() dependencies, sorry for big commit.. Summary: Revision Changes Path 2.167.2.15 +78 -11 rpm/lib/rpmds.c 1.73.2.10 +36 -1 rpm/lib/rpmfc.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/lib/rpmds.c ============================================================================ $ cvs diff -u -r2.167.2.14 -r2.167.2.15 rpmds.c --- rpm/lib/rpmds.c 16 Apr 2011 14:39:46 -0000 2.167.2.14 +++ rpm/lib/rpmds.c 28 Apr 2011 15:49:04 -0000 2.167.2.15 @@ -2906,7 +2906,7 @@ if (isElf64) { /* XXX: eehhk, would've been nice with consistency, mandriva legacy... :| */ if (!devel && s[strlen(s)-1] != ')') - (void) stpcpy( stpcpy(tmp, s), "()(64bit)"); + tmp = stpcpy( stpcpy(tmp, s), "()(64bit)"); else { tmp = stpcpy(tmp, s); if (devel) @@ -2985,8 +2985,11 @@ scn = gelf_offscn (elf, phdr->p_offset); shdr = gelf_getshdr(scn, &shdr_mem); data = elf_getdata (scn, data); - interp_name = strdup(data->d_buf); - goto end; + if (data && data->d_buf) { + interp_name = strdup(data->d_buf); + goto end; + } + /* no 'data' most likely implies that this is an elf interpreter itself */ } if (elf_getshdrstrndx (elf, &shstrndx) >= 0) @@ -3006,6 +3009,15 @@ for (cnt = 0; cnt <= dynsize; ++cnt) { dyn = gelf_getdyn (data, cnt, &dyn_mem); + /* if this an elf interpeter, the only thing we want is to find SONAME + * and return it + */ + if (phdr) { + if (dyn->d_tag != DT_SONAME) + continue; + interp_name = strdup(elf_strptr(elf, shdr->sh_link, dyn->d_un.d_val)); + goto end; + } if (rpath == NULL) { if (dyn->d_tag == DT_RPATH) rpath = elf_strptr (elf, shdr->sh_link, dyn->d_un.d_val); @@ -3015,7 +3027,7 @@ cnt = -1; continue; } - else if (rpath && DT_NEEDED == dyn->d_tag) { + else if (rpath && dyn->d_tag == DT_NEEDED) { char *tmp, *tmp2; char buf[1024]; char path[1024] = ""; @@ -3073,6 +3085,7 @@ strcpy(tmp, path_n); strcat(tmp, "/"); strcat(tmp, libpath); + if (stat(tmp, &statbuf) == 0 && statbuf.st_mode & S_IRUSR) { path[0] = '\0'; break; @@ -3504,6 +3517,7 @@ char buf[BUFSIZ]; const char * s; int is_executable; + int is_symlink; const char * soname = NULL; rpmds ds; int xx; @@ -3529,12 +3543,6 @@ if ((s = strrchr(fn, '.')) && strcmp(s, ".so")) return 0; - if ((lnklen = readlink(fn, path, MAXPATHLEN - 1)) == -1) { - warn("%s", fn); - return -1; - } - path[lnklen] = '\0'; - /*@-castfcnptr@*/ if (_rpmds_debug < 0) fprintf(stderr, "*** rpmdsELF(%s, %d, %p, %p)\n", fn, flags, (void *)add, context); @@ -3545,6 +3553,62 @@ if (lstat(fn, st) != 0) return -1; is_executable = (int)(st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)); + is_symlink = S_ISLNK(st->st_mode); + } + + if (is_symlink) { +#ifdef NOT_YET + if ((lnklen = readlink(fn, path, MAXPATHLEN - 1)) == -1) { + warn("%s", fn); + return -1; + } + /* XXX: unused, path should expand to absolute path... */ + path[lnklen] = '\0'; +#endif + } else { + FILE *fp = fopen(fn, "r"); + char buf[BUFSIZ]; + char *in; + stpcpy(path, fn); + fn = NULL; + if (fp == NULL || ferror(fp)) { + if (fp) (void) fclose(fp); + return -1; + } + /* try resolve ld scripts + * certainly *not* state of the art, but should in practice work + * everywhere where relevant... + */ + while ((in = fgets(buf, sizeof(buf) - 1, fp))) { + in[sizeof(buf)-1] = '\0'; + if ((in = strstr(in, "GROUP")) && + (in = strchr(in, '(')) && + (fn = strchr(in, '/')) && + (in = strchr(fn, ' '))) { + *in = '\0'; + break; + } + if (ferror(fp) || feof(fp)) + break; + } + fclose(fp); + if (!fn) + return -1; + else { + /* XXX: try determine relative root */ + struct stat sb, * st = &sb; + + while((in = strrchr(path, '/'))) { + stpcpy(in, fn); + if (stat(path, st) == 0) { + fn = path; + break; + } + *in = 0; + } + if (!fn) + return -1; + } } fdno = open(fn, O_RDONLY); @@ -3634,8 +3698,10 @@ /*@=uniondef @*/ exit: - if (gotSONAME && !skipR) + if (gotSONAME && !skipR) { for (i = 0, cnt = argvCount(deps); i < cnt; i++) { + if (deps[i][0] == 'l' && deps[i][1] == 'd') + continue; ds = rpmdsSingle(RPMTAG_REQUIRENAME, sonameDep(buf, deps[i], isElf64, 1, isuClibc), "", RPMSENSE_FIND_REQUIRES); @@ -3643,6 +3709,7 @@ (void)rpmdsFree(ds); ds = NULL; } + } deps = argvFree(deps); if (elf) (void) elf_end(elf); @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmfc.c ============================================================================ $ cvs diff -u -r1.73.2.9 -r1.73.2.10 rpmfc.c --- rpm/lib/rpmfc.c 16 Apr 2011 15:08:40 -0000 1.73.2.9 +++ rpm/lib/rpmfc.c 28 Apr 2011 15:49:04 -0000 1.73.2.10 @@ -515,7 +515,7 @@ #if defined(RPM_VENDOR_MANDRIVA) /* filter-overlapping-dependencies */ int overlap = 0; - if (*depsp) { + if (*depsp && rpmExpandNumeric("%{?_use_internal_dependency_generator}")) { int ix = rpmdsSearch(*depsp, ds); if (ix >= 0) { EVR_t lEVR = rpmEVRnew(RPMSENSE_ANY, 0), @@ -1026,6 +1026,11 @@ flags |= RPMELF_FLAG_SKIPPROVIDES; if (fc->skipReq) flags |= RPMELF_FLAG_SKIPREQUIRES; + /* XXX: Remove symlink classifier from linker scripts now that we've been + * able to feed it to the generator. + */ + if (fc->fcolor->vals[fc->ix] == (RPMFC_WHITE|RPMFC_INCLUDE|RPMFC_TEXT|RPMFC_SYMLINK)) + fc->fcolor->vals[fc->ix] &= ~RPMFC_SYMLINK; return rpmdsSymlink(fn, flags, rpmfcMergePR, fc); } @@ -1351,6 +1356,36 @@ /* Add (filtered) entry to sorted class dictionary. */ fcolor = rpmfcColoring(se); + + /* Quick&dirty hack for linker scripts replacing regular + * symlinks. Better *really* needs to be done ASAP. + */ +#if defined(RPM_VENDOR_MANDRIVA) + if (fcolor == (RPMFC_WHITE|RPMFC_INCLUDE|RPMFC_TEXT)) { + char * fn; + + if ((fn = strrchr(s, '.')) && !strcmp(fn, ".so")) { + FILE * fp = fopen(s, "r"); + char buf[BUFSIZ]; + char * in; + if (fp == NULL || ferror(fp)) { + if (fp) (void) fclose(fp); + } + while ((in = fgets(buf, sizeof(buf) - 1, fp))) { + in[sizeof(buf)-1] = '\0'; + if (ferror(fp) || feof(fp)) + break; + if ((fn = strstr(in, "GROUP")) && + (fn = strchr(fn, '(')) && (fn = strchr(in, '/'))) { + fcolor |= RPMFC_SYMLINK; + break; + } + } + if (fp) + fclose(fp); + } + } +#endif xx = argiAdd(&fc->fcolor, (int)fc->ix, fcolor); if (fcolor != RPMFC_WHITE && (fcolor & RPMFC_INCLUDE)) @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org