From: Alexey Tourbin <at@altlinux.ru>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] rpm-requires in headers
Date: Mon, 1 Sep 2008 21:30:46 +0400
Message-ID: <20080901173046.GI6477@altlinux.org> (raw)
In-Reply-To: <200809011621.38135.ledest@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 307 bytes --]
On Mon, Sep 01, 2008 at 04:21:38PM +0300, Led wrote:
> У нас зависимости в *.h файлах не ищутся? Может имеет смысл парсить хэдеры на
> предмет
> ^#[[:blank:]]*include[[:blank:]]+\<[^>]\>
> и проставлять зависимости на соответствующие *-devel?
Есть рабочий протоип, который использует препроцессор.
[-- Attachment #1.2: cpp.req --]
[-- Type: text/plain, Size: 2885 bytes --]
#!/bin/sh -efu
#
# Copyright (C) 2008 Alexey Tourbin <at@altlinux.org>
#
# 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.
. /usr/lib/rpm/functions
. /usr/lib/rpm/find-package
[ -n "${RPM_LIBDIR-}" ] || RPM_LIBDIR=`rpm --eval %_libdir`
PKG_CONFIG_PATH=$RPM_LIBDIR/pkgconfig:/usr/share/pkgconfig
[ -z "${RPM_BUILD_ROOT-}" ] ||
PKG_CONFIG_PATH=$RPM_BUILD_ROOT$RPM_LIBDIR/pkgconfig:$RPM_BUILD_ROOT/usr/share/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH
PkgconfigCflags()
{
local f="$1"; shift
local pc_files
if [ -n "${RPM_BUILD_ROOT-}" ]; then
pc_files=$(set +f; ls "$RPM_BUILD_ROOT$RPM_LIBDIR/pkgconfig"/*.pc 2>/dev/null ||:)
else
pc_files=$(rpmquery -f "$f" --list 2>/dev/null |
egrep "^$RPM_LIBDIR/pkgconfig/[^/]+[.]pc\$" || [ $? = 1 ])
fi
[ -n "$pc_files" ] || return 0
local pc
for pc in $pc_files; do
pkg-config --enable-recursion --cflags "$pc" ||
Fatal "$pc: pkg-config failed"
done
}
Cflags()
{
local f="$1"; shift
local cflags
cflags=$(PkgconfigCflags "$f")
set -- $cflags -I/usr/include -I${f%/*} -I${f%/*/*} -I${f%/*/*/*}
local cf
for cf; do
case $cf in
-D?*) echo $cf ;;
esac
done
for cf; do
[ -n "${RPM_BUILD_ROOT-}" ] || continue
case $cf in
-I/*) echo -I$RPM_BUILD_ROOT${cf#-I} ;;
esac
done
for cf; do
case $cf in
-I/*) echo $cf ;;
esac
done
}
cpp=
IncludedFiles()
{
local f="$1"; shift
if [ -z "$cpp" ]; then
cpp=/usr/bin/${RPM_ARCH:-noarch}-alt-linux-cpp
[ -x "$cpp" ] || cpp=/usr/bin/cpp
[ -z "${GCC_VERSION-}" ] || cpp=$cpp-$GCC_VERSION
Debug "cpp=$cpp"
fi
cflags=$(Cflags "$f")
Debug "$f: cflags:" $cflags
if ! out=$("$cpp" -w -x c++ $cflags "$f"); then
Warning "$f: cpp failed"
return 0
fi
echo "$out" |grep '^#' |awk -v prog="$PROG" -v hdr="$f" '
# info cpp "Preprocessor Output"
BEGIN {
SP = 0
Stack[SP] = hdr
}
function filename(f) {
if (!sub(/^"\//, "/", f) ||
!sub(/"$/, "", f))
printf "%s: %s: bad path %s\n",
prog, hdr, f >"/dev/stderr"
return f
}
function Push(f) {
f=filename(f)
Stack[++SP]=f
if (SP==1)
print f
}
function Pop(f) {
f=filename(f)
if (f != Stack[--SP])
printf "%s: %s: expected pop %s, got pop %s\n",
prog, hdr, Stack[SP], f >"/dev/stderr"
}
$4==1 { Push($3) }
$4==2 { Pop($3) }
END {
if (SP > 0)
printf "%s: %s: non-empty stack, top %s\n",
prog, hdr, Stack[SP] >"/dev/stderr"
}'
}
CppReq()
{
local f="$1"; shift
local files
files=$(IncludedFiles "$f")
[ -n "$files" ] || return 0
local RPM_FINDPACKAGE_HOST_PKG_NAMES=1
local inc
echo "$files" |while read -r inc; do
FindPackage "$f" "${inc#${RPM_BUILD_ROOT-}}"
done
}
ArgvFileAction CppReq "$@"
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
prev parent reply other threads:[~2008-09-01 17:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 13:21 Led
2008-09-01 14:25 ` Ivan A. Melnikov
2008-09-01 14:30 ` Mikhail Gusarov
2008-09-01 14:42 ` Anton Farygin
2008-09-01 15:00 ` Led
2008-09-01 17:30 ` Alexey Tourbin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080901173046.GI6477@altlinux.org \
--to=at@altlinux.ru \
--cc=devel@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git