|
Panu Matilainen |
c9e651 |
diff -up rpm-4.7.0.git9101/build/rpmfc.c.devel-autodep rpm-4.7.0.git9101/build/rpmfc.c
|
|
Panu Matilainen |
c9e651 |
--- rpm-4.7.0.git9101/build/rpmfc.c.devel-autodep 2009-04-03 09:26:59.000000000 +0300
|
|
Panu Matilainen |
c9e651 |
+++ rpm-4.7.0.git9101/build/rpmfc.c 2009-04-03 11:34:44.000000000 +0300
|
|
Panu Matilainen |
c9e651 |
@@ -505,7 +505,7 @@ static const struct rpmfcTokens_s const
|
|
Panu Matilainen |
b60210 |
{ "ASCII text", RPMFC_WHITE|RPMFC_INCLUDE },
|
|
Panu Matilainen |
b60210 |
{ "ISO-8859 text", RPMFC_WHITE|RPMFC_INCLUDE },
|
|
Panu Matilainen |
b60210 |
|
|
Panu Matilainen |
b60210 |
- { "symbolic link to", RPMFC_SYMLINK },
|
|
Panu Matilainen |
b60210 |
+ { "symbolic link to", RPMFC_SYMLINK|RPMFC_INCLUDE },
|
|
Panu Matilainen |
b60210 |
{ "socket", RPMFC_DEVICE },
|
|
Panu Matilainen |
b60210 |
{ "special", RPMFC_DEVICE },
|
|
Panu Matilainen |
c9e651 |
{ " text", RPMFC_TEXT },
|
|
Panu Matilainen |
b60210 |
@@ -667,6 +667,105 @@ rpmds rpmfcRequires(rpmfc fc)
|
|
Panu Matilainen |
b60210 |
|
|
Panu Matilainen |
b60210 |
|
|
Panu Matilainen |
b60210 |
/**
|
|
Panu Matilainen |
b60210 |
+ * Ensure that symlinks for shared libs generate a dep on the shared lib
|
|
Panu Matilainen |
b60210 |
+ * @param fc file classifier
|
|
Panu Matilainen |
b60210 |
+ * @return 0 on success
|
|
Panu Matilainen |
b60210 |
+ */
|
|
Panu Matilainen |
b60210 |
+static int rpmfcSYMLINK(rpmfc fc)
|
|
Panu Matilainen |
b60210 |
+{
|
|
Panu Matilainen |
b60210 |
+ const char * fn = fc->fn[fc->ix];
|
|
Panu Matilainen |
b60210 |
+ struct stat sb;
|
|
Panu Matilainen |
b60210 |
+ int fdno;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ if (fc->skipReq)
|
|
Panu Matilainen |
b60210 |
+ return 0;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ if (stat(fn, &sb) < 0)
|
|
Panu Matilainen |
b60210 |
+ return -1;
|
|
Panu Matilainen |
b60210 |
+ if (S_ISLNK(sb.st_mode))
|
|
Panu Matilainen |
b60210 |
+ return -1;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ fdno = open(fn, O_RDONLY);
|
|
Panu Matilainen |
b60210 |
+ if (fdno < 0) {
|
|
Panu Matilainen |
b60210 |
+ return fdno;
|
|
Panu Matilainen |
b60210 |
+ }
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+#if HAVE_GELF_H && HAVE_LIBELF
|
|
Panu Matilainen |
b60210 |
+ Elf * elf = NULL;
|
|
Panu Matilainen |
b60210 |
+ GElf_Ehdr ehdr_mem, * ehdr;
|
|
Panu Matilainen |
b60210 |
+ int isElf64 = 0;
|
|
Panu Matilainen |
b60210 |
+ int i, cnt;
|
|
Panu Matilainen |
b60210 |
+ char * soname = NULL;
|
|
Panu Matilainen |
b60210 |
+ rpmds ds;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ (void) elf_version(EV_CURRENT);
|
|
Panu Matilainen |
b60210 |
+ elf = NULL;
|
|
Panu Matilainen |
b60210 |
+ if ((elf = elf_begin (fdno, ELF_C_READ_MMAP, NULL)) == NULL
|
|
Panu Matilainen |
b60210 |
+ || elf_kind(elf) != ELF_K_ELF
|
|
Panu Matilainen |
b60210 |
+ || (ehdr = gelf_getehdr(elf, &ehdr_mem)) == NULL
|
|
Panu Matilainen |
b60210 |
+ || ehdr->e_type != ET_DYN)
|
|
Panu Matilainen |
b60210 |
+ goto exit;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+/* alpha uses /lib, not /lib64 so don't add (64bit) deps */
|
|
Panu Matilainen |
b60210 |
+#if !defined(__alpha__)
|
|
Panu Matilainen |
b60210 |
+ isElf64 = ehdr->e_ident[EI_CLASS] == ELFCLASS64;
|
|
Panu Matilainen |
b60210 |
+#endif
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ for (i = 0; i < ehdr->e_phnum; ++i) {
|
|
Panu Matilainen |
b60210 |
+ GElf_Phdr phdr_mem;
|
|
Panu Matilainen |
b60210 |
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
|
|
Panu Matilainen |
b60210 |
+ GElf_Shdr shdr_mem;
|
|
Panu Matilainen |
b60210 |
+ Elf_Data * data = NULL;
|
|
Panu Matilainen |
b60210 |
+ Elf_Scn * scn;
|
|
Panu Matilainen |
b60210 |
+ GElf_Shdr *shdr;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ if (phdr == NULL || phdr->p_type != PT_DYNAMIC)
|
|
Panu Matilainen |
b60210 |
+ continue;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ scn = gelf_offscn(elf, phdr->p_offset);
|
|
Panu Matilainen |
b60210 |
+ shdr = gelf_getshdr(scn, &shdr_mem);
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC)
|
|
Panu Matilainen |
b60210 |
+ data = elf_getdata (scn, NULL);
|
|
Panu Matilainen |
b60210 |
+ if (data == NULL)
|
|
Panu Matilainen |
b60210 |
+ continue;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) {
|
|
Panu Matilainen |
b60210 |
+ GElf_Dyn dynmem;
|
|
Panu Matilainen |
b60210 |
+ GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dynmem);
|
|
Panu Matilainen |
b60210 |
+ char *depname = NULL;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ if (dyn == NULL)
|
|
Panu Matilainen |
b60210 |
+ break;
|
|
Panu Matilainen |
b60210 |
+ if (dyn->d_tag != DT_SONAME)
|
|
Panu Matilainen |
b60210 |
+ continue;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ /* add the soname to package deps */
|
|
Panu Matilainen |
b60210 |
+ soname = elf_strptr(elf, shdr->sh_link, dyn->d_un.d_val);
|
|
Panu Matilainen |
b60210 |
+ if (soname == NULL)
|
|
Panu Matilainen |
b60210 |
+ break;
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ rasprintf(&depname, "%s%s", soname, isElf64 ? "()(64bit)" : "");
|
|
Panu Matilainen |
b60210 |
+ /* Add to package dependencies. */
|
|
Panu Matilainen |
b60210 |
+ ds = rpmdsSingle(RPMTAG_REQUIRENAME, depname, "",
|
|
Panu Matilainen |
b60210 |
+ RPMSENSE_FIND_REQUIRES);
|
|
Panu Matilainen |
b60210 |
+ free(depname);
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+ rpmdsMerge(&fc->requires, ds);
|
|
Panu Matilainen |
b60210 |
+ rpmfcAddFileDep(&fc->ddict, fc->ix, ds);
|
|
Panu Matilainen |
b60210 |
+ ds = rpmdsFree(ds);
|
|
Panu Matilainen |
b60210 |
+ break;
|
|
Panu Matilainen |
b60210 |
+ }
|
|
Panu Matilainen |
b60210 |
+ }
|
|
Panu Matilainen |
b60210 |
+exit:
|
|
Panu Matilainen |
b60210 |
+ if (elf) (void) elf_end(elf);
|
|
Panu Matilainen |
b60210 |
+ close(fdno);
|
|
Panu Matilainen |
b60210 |
+ return 0;
|
|
Panu Matilainen |
b60210 |
+#endif
|
|
Panu Matilainen |
b60210 |
+ return -1;
|
|
Panu Matilainen |
b60210 |
+}
|
|
Panu Matilainen |
b60210 |
+
|
|
Panu Matilainen |
b60210 |
+/**
|
|
Panu Matilainen |
b60210 |
* Extract script dependencies.
|
|
Panu Matilainen |
b60210 |
* @param fc file classifier
|
|
Panu Matilainen |
b60210 |
* @return 0 on success
|
|
Panu Matilainen |
b60210 |
@@ -1097,6 +1196,7 @@ static const struct rpmfcApplyTbl_s cons
|
|
Panu Matilainen |
b60210 |
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_BOURNE|
|
|
Panu Matilainen |
b60210 |
RPMFC_PERL|RPMFC_PYTHON|RPMFC_MONO|
|
|
Panu Matilainen |
b60210 |
RPMFC_PKGCONFIG|RPMFC_LIBTOOL) },
|
|
Panu Matilainen |
b60210 |
+ { rpmfcSYMLINK, RPMFC_SYMLINK },
|
|
Panu Matilainen |
b60210 |
{ NULL, 0 }
|
|
Panu Matilainen |
b60210 |
};
|
|
Panu Matilainen |
b60210 |
|
|
Panu Matilainen |
b60210 |
@@ -1117,6 +1217,7 @@ rpmRC rpmfcApply(rpmfc fc)
|
|
Panu Matilainen |
b60210 |
int ix;
|
|
Panu Matilainen |
b60210 |
int i;
|
|
Panu Matilainen |
b60210 |
int xx;
|
|
Panu Matilainen |
b60210 |
+ int skipping = 0;
|
|
Panu Matilainen |
b60210 |
|
|
Panu Matilainen |
b60210 |
/* Generate package and per-file dependencies. */
|
|
Panu Matilainen |
b60210 |
for (fc->ix = 0; fc->fn[fc->ix] != NULL; fc->ix++) {
|
|
Panu Matilainen |
b60210 |
@@ -1171,11 +1272,13 @@ rpmRC rpmfcApply(rpmfc fc)
|
|
Panu Matilainen |
b60210 |
default:
|
|
Panu Matilainen |
b60210 |
break;
|
|
Panu Matilainen |
b60210 |
case 'P':
|
|
Panu Matilainen |
b60210 |
+ skipping = fc->skipProv;
|
|
Panu Matilainen |
b60210 |
ds = rpmdsSingle(RPMTAG_PROVIDENAME, N, EVR, Flags);
|
|
Panu Matilainen |
b60210 |
dix = rpmdsFind(fc->provides, ds);
|
|
Panu Matilainen |
b60210 |
ds = rpmdsFree(ds);
|
|
Panu Matilainen |
b60210 |
break;
|
|
Panu Matilainen |
b60210 |
case 'R':
|
|
Panu Matilainen |
b60210 |
+ skipping = fc->skipReq;
|
|
Panu Matilainen |
b60210 |
ds = rpmdsSingle(RPMTAG_REQUIRENAME, N, EVR, Flags);
|
|
Panu Matilainen |
b60210 |
dix = rpmdsFind(fc->requires, ds);
|
|
Panu Matilainen |
b60210 |
ds = rpmdsFree(ds);
|
|
Panu Matilainen |
b60210 |
@@ -1197,7 +1300,7 @@ assert(dix >= 0);
|
|
Panu Matilainen |
b60210 |
previx = ix;
|
|
Panu Matilainen |
b60210 |
xx = argiAdd(&fc->fddictx, ix, argiCount(fc->ddictx)-1);
|
|
Panu Matilainen |
b60210 |
}
|
|
Panu Matilainen |
b60210 |
- if (fc->fddictn && fc->fddictn->vals)
|
|
Panu Matilainen |
b60210 |
+ if (fc->fddictn && fc->fddictn->vals && !skipping)
|
|
Panu Matilainen |
b60210 |
fc->fddictn->vals[ix]++;
|
|
Panu Matilainen |
b60210 |
}
|
|
Panu Matilainen |
b60210 |
|