- run ldconfig in -libs subpackage %post, not main package

- add patch to generate shared lib deps by following symlinks so that
-devel packages sanely depend on main libs
This commit is contained in:
Jeremy Katz 2006-04-28 15:41:40 +00:00
parent 4fe8a5fe93
commit b914fc5b40
2 changed files with 134 additions and 3 deletions

View File

@ -0,0 +1,123 @@
--- rpm-4.4.2/build/rpmfc.c 2006-04-27 21:35:41.000000000 -0400
+++ rpm/build/rpmfc.c 2006-04-27 21:33:48.000000000 -0400
@@ -492,7 +492,7 @@
{ "ASCII text", RPMFC_WHITE|RPMFC_INCLUDE },
{ "ISO-8859 text", RPMFC_WHITE|RPMFC_INCLUDE },
- { "symbolic link to", RPMFC_SYMLINK },
+ { "symbolic link to", RPMFC_SYMLINK|RPMFC_INCLUDE },
{ "socket", RPMFC_DEVICE },
{ "special", RPMFC_DEVICE },
@@ -642,6 +642,103 @@
}
/**
+ * Ensure that symlinks for shared libs generate a dep on the shared lib
+ * @param fc file classifier
+ * @return 0 on success
+ */
+static int rpmfcSYMLINK(rpmfc fc)
+{
+ const char * fn = fc->fn[fc->ix];
+ struct stat sb;
+ int fdno;
+
+ if (stat(fn, &sb) < 0)
+ return -1;
+ if (S_ISLNK(sb.st_mode))
+ return -1;
+
+ fdno = open(fn, O_RDONLY);
+ if (fdno < 0) {
+ return fdno;
+ }
+
+#if HAVE_GELF_H && HAVE_LIBELF
+ Elf * elf = NULL;
+ GElf_Ehdr ehdr_mem, * ehdr;
+ int isElf64;
+ int i, cnt;
+ char * soname = NULL;
+ char buf[BUFSIZ];
+ char * t;
+ rpmds ds;
+
+ (void) elf_version(EV_CURRENT);
+ elf = NULL;
+ if ((elf = elf_begin (fdno, ELF_C_READ_MMAP, NULL)) == NULL
+ || elf_kind(elf) != ELF_K_ELF
+ || (ehdr = gelf_getehdr(elf, &ehdr_mem)) == NULL
+ || ehdr->e_type != ET_DYN)
+ goto exit;
+
+ isElf64 = ehdr->e_ident[EI_CLASS] == ELFCLASS64;
+
+ for (i = 0; i < ehdr->e_phnum; ++i) {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
+ GElf_Shdr shdr_mem;
+ Elf_Data * data = NULL;
+ Elf_Scn * scn;
+ GElf_Shdr *shdr;
+
+ if (phdr == NULL || phdr->p_type != PT_DYNAMIC)
+ continue;
+
+ scn = gelf_offscn(elf, phdr->p_offset);
+ shdr = gelf_getshdr(scn, &shdr_mem);
+
+ if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC)
+ data = elf_getdata (scn, NULL);
+ if (data == NULL)
+ continue;
+
+ for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) {
+ GElf_Dyn dynmem;
+ GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dynmem);
+ if (dyn == NULL)
+ break;
+ if (dyn->d_tag != DT_SONAME)
+ continue;
+
+ /* add the soname to package deps */
+ soname = elf_strptr(elf, shdr->sh_link, dyn->d_un.d_val);
+ if (soname == NULL)
+ break;
+ buf[0] = '\0';
+ t = buf;
+ t = stpcpy(t, soname);
+#if !defined(__alpha__)
+ if (isElf64)
+ t = stpcpy(t, "()(64bit)");
+#endif
+ t++;
+ /* Add to package dependencies. */
+ ds = rpmdsSingle(RPMTAG_REQUIRENAME,
+ buf, "", RPMSENSE_FIND_REQUIRES);
+ rpmdsMerge(&fc->requires, ds);
+ rpmfcSaveArg(&fc->ddict, rpmfcFileDep(t, fc->ix, ds));
+ ds = rpmdsFree(ds);
+ break;
+ }
+ }
+exit:
+ if (elf) (void) elf_end(elf);
+ close(fdno);
+ return 0;
+#endif
+ return -1;
+}
+
+/**
* Extract script dependencies.
* @param fc file classifier
* @return 0 on success
@@ -1069,6 +1166,7 @@
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PERL) },
{ rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PYTHON) },
{ rpmfcSCRIPT, RPMFC_MONO },
+ { rpmfcSYMLINK, RPMFC_SYMLINK },
{ NULL, 0 }
};

View File

@ -20,7 +20,7 @@ Name: rpm
%define version 4.4.2
Version: %{version}
%{expand: %%define rpm_version %{version}}
Release: 20
Release: 21
Group: System Environment/Base
Source: ftp://wraptastic.org/pub/rpm-4.4.x/rpm-%{rpm_version}.tar.gz
Source1: mono-find-provides
@ -50,6 +50,7 @@ Patch21: rpm-4.4.2-userlock.patch
Patch22: rpm-4.4.2-vercmp.patch
Patch23: rpm-4.4.2-doxy.patch
Patch24: rpm-4.4.2-trust.patch
Patch25: rpm-4.4.2-devel-autodep.patch
License: GPL
Conflicts: patch < 2.5
%ifos linux
@ -184,6 +185,7 @@ shell-like rules.
%patch22 -p1 -b .vercmp
%patch23 -p1 -b .doxy
%patch24 -p1 -b .trust
%patch25 -p1 -b .develdeps
%build
@ -307,7 +309,6 @@ exit 0
%post
%ifos linux
/sbin/ldconfig
# Establish correct rpmdb ownership.
/bin/chown rpm.rpm /var/lib/rpm/[A-Z]*
@ -325,7 +326,6 @@ exit 0
%ifos linux
%postun
/sbin/ldconfig
if [ $1 = 0 ]; then
/usr/sbin/userdel rpm
/usr/sbin/groupdel rpm
@ -335,6 +335,9 @@ exit 0
%post devel -p /sbin/ldconfig
%postun devel -p /sbin/ldconfig
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%post -n popt -p /sbin/ldconfig
%postun -n popt -p /sbin/ldconfig
%endif
@ -576,6 +579,11 @@ exit 0
%{__includedir}/popt.h
%changelog
* Fri Apr 28 2006 Jeremy Katz <katzj@redhat.com> - 4.4.2-21
- run ldconfig in -libs subpackage %%post, not main package
- add patch to generate shared lib deps by following symlinks so that
-devel packages sanely depend on main libs
* Thu Apr 27 2006 Paul Nasrat <pnasrat@redhat.com> - 4.4.2-20
- Update --trusted stubs for rpmk breakage