From 0e5c0a0bbe1d5c7a2bce2cbdfe3f61f76bee91e8 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 10 Jan 2010 17:09:23 +0100 Subject: [PATCH] xbps-src: added code to verify required pkg rundeps. Every pkg containing shared libs must register them in common/mapping_shlib_binpkg.txt, this is where the code looks for transforming required libs to required binpkgs. The code will also report if a required rundep is missing from pkg run_depends array and will suggest to add some lines to the package template. --HG-- extra : convert_revision : 2d26d45b8e8f62218473abdbed7cc7aab7074e28 --- xbps-src/common/Makefile | 2 +- xbps-src/common/mapping_shlib_binpkg.txt | 184 +++++++++++++++++++++++ xbps-src/shutils/metadata.sh | 5 + xbps-src/shutils/tmpl_funcs.sh | 1 + xbps-src/shutils/verify_rundeps.sh | 169 +++++++++++++++++++++ 5 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 xbps-src/common/mapping_shlib_binpkg.txt create mode 100644 xbps-src/shutils/verify_rundeps.sh diff --git a/xbps-src/common/Makefile b/xbps-src/common/Makefile index 828a990f9c..435f28b49c 100644 --- a/xbps-src/common/Makefile +++ b/xbps-src/common/Makefile @@ -9,7 +9,7 @@ clean: .PHONY: install install: install -d $(DESTDIR)$(SHAREDIR)/common - install -m 644 *.sh $(DESTDIR)$(SHAREDIR)/common + install -m 644 *.sh *.txt $(DESTDIR)$(SHAREDIR)/common .PHONY: uninstall uninstall: diff --git a/xbps-src/common/mapping_shlib_binpkg.txt b/xbps-src/common/mapping_shlib_binpkg.txt new file mode 100644 index 0000000000..fc7604fa5e --- /dev/null +++ b/xbps-src/common/mapping_shlib_binpkg.txt @@ -0,0 +1,184 @@ +# --*-- shell --*-- +# +# This file represents a map between shared libraries and packages +# in XBPS. Every shared library installed by a package must be +# listed here and mapped to a binary package. +# +########################################################################## +# SHLIB BINPKG BINPKG-DEVEL +########################################################################## +libc.so glibc glibc-devel +libm.so glibc glibc-devel +libpthread.so glibc glibc-devel +librt.so glibc glibc-devel +libdl.so glibc glibc-devel +ld-linux-x86-64.so glibc glibc-devel +ld-linux.so glibc glibc-devel +libresolv.so glibc glibc-devel +libanl.so glibc glibc-devel +libthread_db.so glibc glibc-devel +libutil.so glibc glibc-devel +libnsl.so glibc glibc-devel +libcrypt.so glibc glibc-devel +libBrokenLocale.so glibc glibc-devel +libpcprofile.so glibc glibc-devel +libmemusage.so glibc glibc-devel +libSegFault.so glibc glibc-devel +libz.so zlib zlib-devel +libbz2.so bzip2 bzip2-devel +libarchive.so libarchive libarchive-devel +libgcc_s.so libgcc +libmp.so gmp gmp-devel +libgmp.so gmp gmp-devel +libgmpxx.so gmp gmp-devel +libmpfr.so mpfr mpfr-devel +libpwl.so ppl ppl-devel +libppl.so ppl ppl-devel +libppl_c.so ppl ppl-devel +libstdc++.so libstdc++ libstdc++-devel +libssp.so libssp libssp-devel +libncurses.so ncurses-libs ncurses-devel +libform.so ncurses-libs ncurses-devel +libpanel.so ncurses-libs ncurses-devel +libmenu.so ncurses-libs ncurses-devel +libncursesw.so ncursesw ncursesw-devel +libformw.so ncursesw ncursesw-devel +libpanelw.so ncursesw ncursesw-devel +libmenuw.so ncursesw ncursesw-devel +libobjc.so libobjc libobjc-devel +libmudflap.so libmudflap libmudflap-devel +libmudflapth.so libmudflap libmudflap-devel +libgomp.so libgomp libgomp +libmagic.so file file-devel +libcloog.so cloog-ppl cloog-ppl-devel +libbluetooth.so libbluetooth libbluetooth-devel +libwmf-0.2.so libwmf libwmf-devel +libwmflite-0.2.so libwmf libwmf-devel +libgthread-2.0.so glib glib-devel +libglib-2.0.so glib glib-devel +libgmodule-2.0.so glib glib-devel +libgio-2.0.so glib glib-devel +libgobject-2.0.so glib glib-devel +libatk-1.0.so atk atk-devel +libpangocairo-1.0.so pango pango-devel +libpangoft2-1.0.so pango pango-devel +libpangoxft-1.0.so pango pango-devel +libpangox-1.0.so pango pango-devel +libpango-1.0.so pango pango-devel +libcairo.so cairo cairo-devel +libgdk-x11-2.0.so gtk+ gtk+-devel +libgdk_pixbuf-2.0.so gtk+ gtk+-devel +libgtk-x11-2.0.so gtk+ gtk+-devel +libgdk_pixbuf_xlib-2.0.so gtk+ gtk+-devel +libgailutil.so gtk+ gtk+-devel +libfreetype.so freetype freetype-devel +libfontconfig.so fontconfig fontconfig-devel +libX11-xcb.so libX11 libX11-devel +libX11.so libX11 libX11-devel +libexpat.so expat expat-devel +libjpeg.so jpeg jpeg-devel +libpng12.so libpng libpng-devel +libdecoration.so compiz compiz-devel +libXrender.so libXrender libXrender-devel +libXrandr.so libXrandr libXrandr-devel +libGLU.so MesaLib MesaLib-devel +libEGL.so MesaLib MesaLib-devel +libGL.so MesaLib MesaLib-devel +libGLw.so MesaLib MesaLib-devel +librsvg-2.so librsvg librsvg-devel +libdbus-1.so dbus-libs dbus-devel +libdbus-glib-1.so dbus-glib dbus-glib-devel +libxml2.so libxml2 libxml2-devel +libfuse.so fuse fuse-devel +libXext.so libXext libXext-devel +libXcomposite.so libXcomposite libXcomposite-devel +libXdamage.so libXdamage libXdamage-devel +libXfixes.so libXfixes libXfixes-devel +libXinerama.so libXinerama libXinerama-devel +libSM.so libSM libSM-devel +libICE.so libICE libICE-devel +libXau.so libXau libXau-devel +libexslt.so libxslt libxslt-devel +libxslt.so libxslt libxslt-devel +libstartup-notification-1.so startup-notification startup-notification-devel +libwnck-1.so.22 libwnck libwnck-devel +libnl.so libnl libnl-devel +libssl.so openssl openssl-devel +libcrypto.so openssl openssl-devel +libreadline.so readline readline-devel +libxfcegui4.so libxfcegui4 libxfcegui4-devel +libxfce4menu-0.1.so libxfce4menu libxfce4menu-devel +libxfconf-0.so xfconf xfconf-devel +libthunar-vfs-1.so Thunar Thunar-devel +libexo-0.3.so exo exo-devel +libxfce4util.so libxfce4util libxfce4util-devel +libxfce4panel.so xfce4-panel xfce4-panel-devel +libgstreamer-0.10.so gstreamer gstreamer-devel +libgstbase-0.10.so gstreamer gstreamer-devel +libgstdataprotocol-0.10.so gstreamer gstreamer-devel +libgstcontroller-0.10.so gstreamer gstreamer-devel +libgstfft-0.10.so gst-plugins-base gst-plugins-base-devel +libgstaudio-0.10.so gst-plugins-base gst-plugins-base-devel +libgstapp-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstsdp-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgsttag-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstinterfaces-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstriff-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstcdda-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstnetbuffer-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstrtsp-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstvideo-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstpbutils-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libgstrtp-0.10.so.0 gst-plugins-base gst-plugins-base-devel +libbfd-2.20.so binutils binutils-devel +libopcodes-2.20.so binutils binutils-devel +libdb-4.8.so db db-devel +libdb_cxx-4.8.so db db-devel +libperl.so perl +libgdbm.so gdbm gdbm-devel +libgettextsrc-0.17.so gettext-libs gettext-devel +libgettextlib-0.17.so gettext-libs gettext-devel +libgettextpo.so gettext-libs gettext-devel +libattr.so attr attr-devel +libacl.so acl acl-devel +libpython2.6.so.1 python python-devel +libffi.so libffi libffi-devel +libcrack.so cracklib cracklib-devel +libpam.so pam pam-devel +libpam_misc.so pam pam-devel +libcap.so libcap libcap-devel +liblzma.so xz xz-devel +libuuid.so libuuid libuuid-devel +libblkid.so libblkid libblkid-devel +libeinfo.so OpenRC OpenRC-devel +librc.so OpenRC OpenRC-devel +libidn.so.11 libidn libidn-devel +libusb-1.0.so libusb libusb-devel +libusb-0.1.so libusb-compat libusb-compat-devel +libpci.so pciutils pciutils-devel +libpcre.so pcre pcre-devel +libpcreposix.so pcre pcre-devel +libpcrecpp.so pcre pcre-devel +libgirepository-everything-1.0.so gobject-introspection gobject-introspection-devel +libgirepository-1.0.so gobject-introspection gobject-introspection-devel +libudev.so udev udev-devel +libgudev.so libgudev libgudev-devel +libproc-3.2.8.so procps +libext2fs.so e2fsprogs-libs e2fsprogs-devel +libcom_err.so e2fsprogs-libs e2fsprogs-devel +libe2p.so e2fsprogs-libs e2fsprogs-devel +libss.so e2fsprogs-libs e2fsprogs-devel +libiw.so.29 wireless_tools wireless_tools-devel +libpopt.so popt popt-devel +libtasn1.so libtasn1 libtasn1-devel +libgpg-error.so libgpg-error libgpg-error-devel +liblzo2.so lzo lzo-devel +libgcrypt.so.11 libgcrypt libgcrypt-devel +libgnutls.so.26 gnutls gnutls-devel +libgnutlsxx.so.26 gnutls gnutls-devel +libgnutls-extra.so.26 gnutls gnutls-devel +libgnutls-openssl.so.26 gnutls gnutls-devel +libwrap.so tcp_wrappers-libs tcp_wrappers-devel +libdevmapper.so.1.02 device-mapper device-mapper-devel +libprop.so proplib proplib-devel +libxbps.so xbps diff --git a/xbps-src/shutils/metadata.sh b/xbps-src/shutils/metadata.sh index 112b2147d5..1d21170c05 100644 --- a/xbps-src/shutils/metadata.sh +++ b/xbps-src/shutils/metadata.sh @@ -59,6 +59,8 @@ xbps_write_metadata_pkg() . $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template pkgname=${subpkg} set_tmpl_common_vars + . ${XBPS_SHUTILSDIR}/verify_rundeps.sh + verify_rundeps ${DESTDIR} xbps_write_metadata_pkg_real done @@ -73,6 +75,9 @@ xbps_write_metadata_pkg() done fi setup_tmpl ${sourcepkg} + # Verify pkg deps. + . ${XBPS_SHUTILSDIR}/verify_rundeps.sh + verify_rundeps ${DESTDIR} xbps_write_metadata_pkg_real } diff --git a/xbps-src/shutils/tmpl_funcs.sh b/xbps-src/shutils/tmpl_funcs.sh index 84b55c4ecf..74c7cecbc5 100644 --- a/xbps-src/shutils/tmpl_funcs.sh +++ b/xbps-src/shutils/tmpl_funcs.sh @@ -76,6 +76,7 @@ reset_tmpl_vars() noarch subpackages sourcepkg gtk_iconcache_dirs \ abi_depends api_depends triggers openrc_services \ replaces system_accounts build_wrksrc create_wrksrc \ + ignore_vdeps_dir \ XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \ XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \ SRCPKGDESTDIR PATCHESDIR" diff --git a/xbps-src/shutils/verify_rundeps.sh b/xbps-src/shutils/verify_rundeps.sh new file mode 100644 index 0000000000..bb0b25a013 --- /dev/null +++ b/xbps-src/shutils/verify_rundeps.sh @@ -0,0 +1,169 @@ +#!/bin/sh +#- +# Copyright (c) 2010 Juan Romero Pardines. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#- +# +# Finds all required libraries for a package, by looking at its executables +# and shared libraries and skipping duplicated matches. +# +# Once the list is known it finds the binary package names mapped to those +# libraries and reports if any of them was not added. +# + +find_rundep() +{ + local dep="$1" i rpkgdep + + for i in ${run_depends}; do + rpkgdep="$($XBPS_PKGDB_CMD getpkgdepname $i)" + [ "${rpkgdep}" != "${dep}" ] && continue + return 1 + done +} + +verify_rundeps() +{ + local j i f nlib verify_deps maplib found_dup igndir + local missing missing_libs rdep builddep rdep_list builddep_list + + PKG_DESTDIR="$1" + maplib="$XBPS_COMMONVARSDIR/mapping_shlib_binpkg.txt" + + [ -n "$noarch" -o "$nostrip" ] && return 0 + msg_normal "Verifying required $pkgname run dependencies..." + + for f in $(find ${PKG_DESTDIR} -type f); do + # Don't check dirs specified in ignore_vdeps_dir. + for j in ${ignore_vdeps_dir}; do + if grep -q ${j} ${f}; then + igndir=1 + break + fi + done + [ -n "$igndir" ] && continue + unset igndir + + case "$(file -biz $f)" in + application/x-executable*|application/x-sharedlib*) + for nlib in $(objdump -p $f|grep NEEDED|awk '{print $2}'); do + # Strip major version + nlib="$(echo $nlib|sed -e 's|\.[0-9]$||')" + if [ -z "$verify_deps" ]; then + verify_deps="$nlib" + continue + fi + for i in ${verify_deps}; do + [ "$i" != "$nlib" ] && continue + found_dup=1 + break + done + if [ -z "$found_dup" ]; then + verify_deps="$verify_deps $nlib" + fi + unset found_dup + done + ;; + esac + done + + # Now verify that those required libs are added into package's + # template via Add_dependency. + for f in ${verify_deps}; do + # Bail out if maplib is not aware for this lib + rdep="$(grep "$f" $maplib|awk '{print $2}')" + if [ -z "$rdep" ]; then + msg_error_nochroot "unknown rundep for $f" + fi + # Ignore libs by current pkg + [ "$rdep" = "$pkgname" ] && continue + + # Warn if rundep is not in template. + if find_rundep "$rdep"; then + msg_warn_nochroot "required $f from $rdep (MISSING)" + missing=1 + if [ -z "$missing_libs" ]; then + missing_libs="$f" + continue + fi + for i in ${missing_libs}; do + [ "$i" != "$f" ] && continue + found_dup=1 + break + done + if [ -z "$found_dup" ]; then + missing_libs="$missing_libs $f" + fi + unset found_dup + continue + fi + echo "=> Requires $f from $rdep (OK)" + unset rdep + done + + [ -z "$missing" ] && return 0 + + # Print an informative message suggesting what needs to be added + # into the build template. + + msg_normal "The following code needs to be added into the build template:" + echo "============ CUT HERE ===============" + + for f in ${missing_libs}; do + rdep="$(grep "$f" $maplib|awk '{print $2}')" + builddep="$(grep "$f" $maplib|awk '{print $3}')" + + if [ -z "$rdep_list" ]; then + rdep_list="$rdep" + fi + if [ -z "$builddep_list" -a -n "$builddep" ]; then + builddep_list="$builddep" + fi + for i in ${rdep_list}; do + [ "$rdep" != "$i" ] && continue + found_dup=1 + break + done + if [ -z "$found_dup" ]; then + rdep_list="$rdep_list $rdep" + fi + unset found_dup + for i in ${builddep_list}; do + [ "$builddep" != "$i" ] && continue + found_dup=1 + break + done + if [ -z "$found_dup" ]; then + builddep_list="$builddep_list $builddep" + fi + unset found_dup + done + + for f in ${rdep_list}; do + echo "Add_dependency run $f" + done + for f in ${builddep_list}; do + echo "Add_dependency build $f" + done + echo "============ CUT HERE ===============" +}