2002-09-09 16:35:53 +04:00
#!/bin/sh -e
#
# brp-verify_elf - verify ELF objects.
#
2003-11-08 22:52:04 +03:00
# $Id$
2006-01-14 23:42:43 +03:00
# Copyright (C) 2002, 2003, 2006 Dmitry V. Levin <ldv@altlinux.org>
2002-09-09 16:35:53 +04:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
2003-11-09 19:30:18 +03:00
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
2002-09-09 16:35:53 +04:00
cd "$RPM_BUILD_ROOT"
2006-02-24 03:19:28 +03:00
export VERIFY_ELF_ARCH=normal
2006-01-15 01:49:01 +03:00
export VERIFY_ELF_FHS=relaxed
2003-11-08 19:39:27 +03:00
export VERIFY_ELF_RPATH=normal
export VERIFY_ELF_TEXTREL=normal
2006-03-07 19:14:23 +03:00
export VERIFY_ELF_UNRESOLVED=normal
2003-11-07 20:32:25 +03:00
for t in `printf %s "$RPM_VERIFY_ELF_METHOD" |tr , ' '`; do
case "$t" in
no|none|skip)
exit 0
;;
2006-02-24 03:19:28 +03:00
arch)
VERIFY_ELF_ARCH=normal
;;
arch=*)
VERIFY_ELF_ARCH="${t#arch=}"
;;
2006-01-14 23:42:43 +03:00
fhs)
VERIFY_ELF_FHS=normal
;;
fhs=*)
VERIFY_ELF_FHS="${t#fhs=}"
;;
2003-11-07 20:32:25 +03:00
rpath)
2003-11-08 19:39:27 +03:00
VERIFY_ELF_RPATH=normal
2003-11-07 20:32:25 +03:00
;;
rpath=*)
2003-11-08 19:39:27 +03:00
VERIFY_ELF_RPATH="${t#rpath=}"
2003-11-07 20:32:25 +03:00
;;
textrel)
2003-11-08 19:39:27 +03:00
VERIFY_ELF_TEXTREL=normal
2003-11-07 20:32:25 +03:00
;;
textrel=*)
2003-11-08 19:39:27 +03:00
VERIFY_ELF_TEXTREL="${t#textrel=}"
2003-11-07 20:32:25 +03:00
;;
2006-01-14 23:42:43 +03:00
unresolved)
VERIFY_ELF_UNRESOLVED=normal
;;
unresolved=*)
VERIFY_ELF_UNRESOLVED="${t#unresolved=}"
;;
2003-11-07 20:32:25 +03:00
normal)
2006-02-24 03:19:28 +03:00
VERIFY_ELF_ARCH=normal
2006-01-14 23:42:43 +03:00
VERIFY_ELF_FHS=normal
2003-11-08 19:39:27 +03:00
VERIFY_ELF_RPATH=normal
VERIFY_ELF_TEXTREL=normal
2006-01-14 23:42:43 +03:00
VERIFY_ELF_UNRESOLVED=normal
2003-11-07 20:32:25 +03:00
;;
strict)
2006-02-24 03:19:28 +03:00
VERIFY_ELF_ARCH=strict
2006-01-14 23:42:43 +03:00
VERIFY_ELF_FHS=strict
2003-11-08 19:39:27 +03:00
VERIFY_ELF_RPATH=strict
VERIFY_ELF_TEXTREL=strict
2006-01-14 23:42:43 +03:00
VERIFY_ELF_UNRESOLVED=strict
2003-11-07 20:32:25 +03:00
;;
relaxed)
2006-02-24 03:19:28 +03:00
VERIFY_ELF_ARCH=relaxed
2006-01-14 23:42:43 +03:00
VERIFY_ELF_FHS=relaxed
2003-11-08 19:39:27 +03:00
VERIFY_ELF_RPATH=relaxed
2003-11-24 00:08:49 +03:00
VERIFY_ELF_TEXTREL=relaxed
2006-01-14 23:42:43 +03:00
VERIFY_ELF_UNRESOLVED=relaxed
2003-11-07 20:32:25 +03:00
;;
*)
2003-11-09 19:30:18 +03:00
Fatal "Unrecognized verify_elf method: $t"
2003-11-07 20:32:25 +03:00
;;
esac
done
2006-02-24 03:19:28 +03:00
[ "$VERIFY_ELF_ARCH" != no ] || VERIFY_ELF_ARCH=
[ -z "$RPM_VERIFY_ELF_ARCH" ] || VERIFY_ELF_ARCH="$RPM_VERIFY_ELF_ARCH"
2006-01-14 23:42:43 +03:00
[ "$VERIFY_ELF_FHS" != no ] || VERIFY_ELF_FHS=
[ -z "$RPM_VERIFY_ELF_FHS" ] || VERIFY_ELF_FHS="$RPM_VERIFY_ELF_FHS"
2003-11-07 20:32:25 +03:00
[ "$VERIFY_ELF_RPATH" != no ] || VERIFY_ELF_RPATH=
2003-11-09 23:56:40 +03:00
[ -z "$RPM_VERIFY_ELF_RPATH" ] || VERIFY_ELF_RPATH="$RPM_VERIFY_ELF_RPATH"
2003-11-07 20:32:25 +03:00
[ "$VERIFY_ELF_TEXTREL" != no ] || VERIFY_ELF_TEXTREL=
2003-11-09 23:56:40 +03:00
[ -z "$RPM_VERIFY_ELF_TEXTREL" ] || VERIFY_ELF_TEXTREL="$RPM_VERIFY_ELF_TEXTREL"
2006-01-14 23:42:43 +03:00
[ "$VERIFY_ELF_UNRESOLVED" != no ] || VERIFY_ELF_UNRESOLVED=
[ -z "$RPM_VERIFY_ELF_UNRESOLVED" ] || VERIFY_ELF_UNRESOLVED="$RPM_VERIFY_ELF_UNRESOLVED"
2002-09-09 16:35:53 +04:00
2002-09-27 17:41:26 +04:00
: ${RPM_VERIFY_ELF_TOPDIR:=}
[ -d "$RPM_BUILD_ROOT$RPM_VERIFY_ELF_TOPDIR" ] || exit 0
2006-02-24 03:19:28 +03:00
echo "Verifying ELF objects in $RPM_BUILD_ROOT$RPM_VERIFY_ELF_TOPDIR (arch=$VERIFY_ELF_ARCH,fhs=$VERIFY_ELF_FHS,rpath=$VERIFY_ELF_RPATH,textrel=$VERIFY_ELF_TEXTREL,unresolved=$VERIFY_ELF_UNRESOLVED)"
2006-01-14 23:42:43 +03:00
dump_ld_config='@RPMCONFIGDIR@/dump_ld_config'
2006-01-15 02:33:29 +03:00
RPM_VERIFY_ELF_LDD_RPATH="$("$dump_ld_config" '' "$RPM_BUILD_ROOT")"
RPM_VERIFY_ELF_LDD_RPATH="$RPM_VERIFY_ELF_LDD_RPATH /$RPM_LIB $RPM_LIBDIR $("$dump_ld_config")"
2006-01-14 23:42:43 +03:00
export RPM_VERIFY_ELF_LDD_RPATH
2003-11-07 20:32:25 +03:00
2002-09-27 17:41:26 +04:00
find .$RPM_VERIFY_ELF_TOPDIR -type f -print0 |xargs -r0 @RPMCONFIGDIR@/verify-elf