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