|
Panu Matilainen |
9c33f4 |
diff -up rpm-4.4.2.2/build/rpmfc.c.develdeps rpm-4.4.2.2/build/rpmfc.c
|
|
Panu Matilainen |
9c33f4 |
--- rpm-4.4.2.2/build/rpmfc.c.develdeps 2007-09-11 09:28:12.000000000 +0300
|
|
Panu Matilainen |
9c33f4 |
+++ rpm-4.4.2.2/build/rpmfc.c 2007-12-21 14:22:55.000000000 +0200
|
|
Panu Matilainen |
9c33f4 |
@@ -497,7 +497,7 @@ static struct rpmfcTokens_s rpmfcTokens[
|
|
Panu Matilainen |
9c33f4 |
{ "ASCII text", RPMFC_WHITE|RPMFC_INCLUDE },
|
|
Panu Matilainen |
9c33f4 |
{ "ISO-8859 text", RPMFC_WHITE|RPMFC_INCLUDE },
|
|
Panu Matilainen |
9c33f4 |
|
|
Panu Matilainen |
9c33f4 |
- { "symbolic link to", RPMFC_SYMLINK },
|
|
Panu Matilainen |
9c33f4 |
+ { "symbolic link to", RPMFC_SYMLINK|RPMFC_INCLUDE },
|
|
Panu Matilainen |
9c33f4 |
{ "socket", RPMFC_DEVICE },
|
|
Panu Matilainen |
9c33f4 |
{ "special", RPMFC_DEVICE },
|
|
Panu Matilainen |
9c33f4 |
|
|
Panu Matilainen |
9c33f4 |
@@ -647,6 +647,109 @@ rpmfc rpmfcNew(void)
|
|
Panu Matilainen |
9c33f4 |
}
|
|
Panu Matilainen |
9c33f4 |
|
|
Panu Matilainen |
9c33f4 |
/**
|
|
Panu Matilainen |
9c33f4 |
+ * Ensure that symlinks for shared libs generate a dep on the shared lib
|
|
Panu Matilainen |
9c33f4 |
+ * @param fc file classifier
|
|
Panu Matilainen |
9c33f4 |
+ * @return 0 on success
|
|
Panu Matilainen |
9c33f4 |
+ */
|
|
Panu Matilainen |
9c33f4 |
+static int rpmfcSYMLINK(rpmfc fc)
|
|
Panu Matilainen |
9c33f4 |
+{
|
|
Panu Matilainen |
9c33f4 |
+ const char * fn = fc->fn[fc->ix];
|
|
Panu Matilainen |
9c33f4 |
+ struct stat sb;
|
|
Panu Matilainen |
9c33f4 |
+ int fdno;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ if (stat(fn, &sb) < 0)
|
|
Panu Matilainen |
9c33f4 |
+ return -1;
|
|
Panu Matilainen |
9c33f4 |
+ if (S_ISLNK(sb.st_mode))
|
|
Panu Matilainen |
9c33f4 |
+ return -1;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ fdno = open(fn, O_RDONLY);
|
|
Panu Matilainen |
9c33f4 |
+ if (fdno < 0) {
|
|
Panu Matilainen |
9c33f4 |
+ return fdno;
|
|
Panu Matilainen |
9c33f4 |
+ }
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+#if HAVE_GELF_H && HAVE_LIBELF
|
|
Panu Matilainen |
9c33f4 |
+ Elf * elf = NULL;
|
|
Panu Matilainen |
9c33f4 |
+ GElf_Ehdr ehdr_mem, * ehdr;
|
|
Panu Matilainen |
9c33f4 |
+ int isElf64;
|
|
Panu Matilainen |
9c33f4 |
+ int i, cnt;
|
|
Panu Matilainen |
9c33f4 |
+ char * soname = NULL;
|
|
Panu Matilainen |
9c33f4 |
+ char buf[BUFSIZ];
|
|
Panu Matilainen |
9c33f4 |
+ char * t;
|
|
Panu Matilainen |
9c33f4 |
+ rpmds ds;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ (void) elf_version(EV_CURRENT);
|
|
Panu Matilainen |
9c33f4 |
+ elf = NULL;
|
|
Panu Matilainen |
9c33f4 |
+ if ((elf = elf_begin (fdno, ELF_C_READ_MMAP, NULL)) == NULL
|
|
Panu Matilainen |
9c33f4 |
+ || elf_kind(elf) != ELF_K_ELF
|
|
Panu Matilainen |
9c33f4 |
+ || (ehdr = gelf_getehdr(elf, &ehdr_mem)) == NULL
|
|
Panu Matilainen |
9c33f4 |
+ || ehdr->e_type != ET_DYN)
|
|
Panu Matilainen |
9c33f4 |
+ goto exit;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ isElf64 = ehdr->e_ident[EI_CLASS] == ELFCLASS64;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ for (i = 0; i < ehdr->e_phnum; ++i) {
|
|
Panu Matilainen |
9c33f4 |
+ GElf_Phdr phdr_mem;
|
|
Panu Matilainen |
9c33f4 |
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
|
|
Panu Matilainen |
9c33f4 |
+ GElf_Shdr shdr_mem;
|
|
Panu Matilainen |
9c33f4 |
+ Elf_Data * data = NULL;
|
|
Panu Matilainen |
9c33f4 |
+ Elf_Scn * scn = NULL;
|
|
Panu Matilainen |
9c33f4 |
+ GElf_Shdr *shdr = NULL;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ if (phdr == NULL || phdr->p_type != PT_DYNAMIC)
|
|
Panu Matilainen |
9c33f4 |
+ continue;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
|
|
Panu Matilainen |
9c33f4 |
+ shdr = gelf_getshdr(scn, &shdr_mem);
|
|
Panu Matilainen |
9c33f4 |
+ if (shdr->sh_offset == phdr->p_offset)
|
|
Panu Matilainen |
9c33f4 |
+ break;
|
|
Panu Matilainen |
9c33f4 |
+ }
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ scn = gelf_offscn(elf, phdr->p_offset);
|
|
Panu Matilainen |
9c33f4 |
+ shdr = gelf_getshdr(scn, &shdr_mem);
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ if (scn != NULL && shdr != NULL && shdr->sh_type == SHT_DYNAMIC)
|
|
Panu Matilainen |
9c33f4 |
+ data = elf_getdata (scn, NULL);
|
|
Panu Matilainen |
9c33f4 |
+ if (data == NULL)
|
|
Panu Matilainen |
9c33f4 |
+ continue;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) {
|
|
Panu Matilainen |
9c33f4 |
+ GElf_Dyn dynmem;
|
|
Panu Matilainen |
9c33f4 |
+ GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dynmem);
|
|
Panu Matilainen |
9c33f4 |
+ if (dyn == NULL)
|
|
Panu Matilainen |
9c33f4 |
+ break;
|
|
Panu Matilainen |
9c33f4 |
+ if (dyn->d_tag != DT_SONAME)
|
|
Panu Matilainen |
9c33f4 |
+ continue;
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+ /* add the soname to package deps */
|
|
Panu Matilainen |
9c33f4 |
+ soname = elf_strptr(elf, shdr->sh_link, dyn->d_un.d_val);
|
|
Panu Matilainen |
9c33f4 |
+ if (soname == NULL)
|
|
Panu Matilainen |
9c33f4 |
+ break;
|
|
Panu Matilainen |
9c33f4 |
+ buf[0] = '\0';
|
|
Panu Matilainen |
9c33f4 |
+ t = buf;
|
|
Panu Matilainen |
9c33f4 |
+ t = stpcpy(t, soname);
|
|
Panu Matilainen |
9c33f4 |
+#if !defined(__alpha__)
|
|
Panu Matilainen |
9c33f4 |
+ if (isElf64)
|
|
Panu Matilainen |
9c33f4 |
+ t = stpcpy(t, "()(64bit)");
|
|
Panu Matilainen |
9c33f4 |
+#endif
|
|
Panu Matilainen |
9c33f4 |
+ t++;
|
|
Panu Matilainen |
9c33f4 |
+ /* Add to package dependencies. */
|
|
Panu Matilainen |
9c33f4 |
+ ds = rpmdsSingle(RPMTAG_REQUIRENAME,
|
|
Panu Matilainen |
9c33f4 |
+ buf, "", RPMSENSE_FIND_REQUIRES);
|
|
Panu Matilainen |
9c33f4 |
+ rpmdsMerge(&fc->requires, ds);
|
|
Panu Matilainen |
9c33f4 |
+ rpmfcSaveArg(&fc->ddict, rpmfcFileDep(t, fc->ix, ds));
|
|
Panu Matilainen |
9c33f4 |
+ ds = rpmdsFree(ds);
|
|
Panu Matilainen |
9c33f4 |
+ break;
|
|
Panu Matilainen |
9c33f4 |
+ }
|
|
Panu Matilainen |
9c33f4 |
+ }
|
|
Panu Matilainen |
9c33f4 |
+exit:
|
|
Panu Matilainen |
9c33f4 |
+ if (elf) (void) elf_end(elf);
|
|
Panu Matilainen |
9c33f4 |
+ close(fdno);
|
|
Panu Matilainen |
9c33f4 |
+ return 0;
|
|
Panu Matilainen |
9c33f4 |
+#endif
|
|
Panu Matilainen |
9c33f4 |
+ return -1;
|
|
Panu Matilainen |
9c33f4 |
+}
|
|
Panu Matilainen |
9c33f4 |
+
|
|
Panu Matilainen |
9c33f4 |
+/**
|
|
Panu Matilainen |
9c33f4 |
* Extract script dependencies.
|
|
Panu Matilainen |
9c33f4 |
* @param fc file classifier
|
|
Panu Matilainen |
9c33f4 |
* @return 0 on success
|
|
Panu Matilainen |
9c33f4 |
@@ -1094,6 +1197,7 @@ static struct rpmfcApplyTbl_s rpmfcApply
|
|
Panu Matilainen |
9c33f4 |
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PERL) },
|
|
Panu Matilainen |
9c33f4 |
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PYTHON) },
|
|
Panu Matilainen |
9c33f4 |
{ rpmfcSCRIPT, RPMFC_MONO },
|
|
Panu Matilainen |
9c33f4 |
+ { rpmfcSYMLINK, RPMFC_SYMLINK },
|
|
Panu Matilainen |
9c33f4 |
{ NULL, 0 }
|
|
Panu Matilainen |
9c33f4 |
};
|
|
Panu Matilainen |
9c33f4 |
|