ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: devel@lists.altlinux.org
Subject: Re: [devel] cpp.req -- зависимости *.h файлов (телеграфом)
Date: Tue, 18 Mar 2008 00:21:12 +0300
Message-ID: <20080317212112.GE7777@solemn.turbinal> (raw)
In-Reply-To: <20080303152617.GB32305@solemn.turbinal>

[-- Attachment #1: Type: text/plain, Size: 10140 bytes --]

On Mon, Mar 03, 2008 at 06:26:17PM +0300, Alexey Tourbin wrote:
> Вывод препроцессора позволяет построить стек включаемых файлов и,
> следовательно, определить top-level includes.  Если первый флаг 1,
> то это push на стек, а если первый флаг 2 -- то это pop.  Push на
> начальной глубине даёт непосредственные зависимости исследуемого хедера.
> 
> $ cpp /usr/include/rpm/rpmlib.h |grep ^# |awk '$4==1{++I;if(I==1)print$3}$4==2{--I}'
> "/usr/include/rpm/rpmio.h"
> "/usr/include/rpm/rpmmessages.h"
> "/usr/include/rpm/rpmerr.h"
> "/usr/include/rpm/header.h"
> "/usr/include/popt.h"
> $ grep -w include /usr/include/rpm/rpmlib.h
> #include "rpmio.h"
> #include "rpmmessages.h"
> #include "rpmerr.h"
> #include "header.h"
> #include "popt.h"
> $ 

Предварительная релизация опубликована в моем репозитарии rpm.git.
Она ещё не совсем хорошо работает (на реальной сборке в хешере),
потому что по умолчанию используется "cpp -x c++", то есть пока
для работы требуется gcc4.1-c++.

Но можно уже смотреть, что получается.
Примеры:

а) Зависимости хедеров у пакета librpm-devel.

$ rpm -ql librpm-devel |file -NF$'\t' -f - |/usr/lib/rpm/cpp.req.files |/usr/lib/rpm/cpp.req -v |sort -u
cpp.req: /usr/include/rpm/header.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/header.h: /usr/include/rpm/rpmio.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/header.h: /usr/include/rpm/hdrinline.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/misc.h: /usr/include/string.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/rpmcli.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/stringbuf.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/misc.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/rpmspec.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmcli.h: /usr/include/rpm/rpmlib.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmcli.h: /usr/include/rpm/rpmurl.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmcli.h: /usr/include/rpm/rpmmacro.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmdb.h: /usr/include/rpm/rpmlib.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmerr.h: /usr/include/rpm/rpmlog.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/sys/types.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/sys/stat.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/dirent.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/glob.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/unistd.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/rpmio.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/rpmmessages.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/rpmerr.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/header.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/popt.h -> libpopt-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlog.h: /usr/lib/gcc/i586-alt-linux/4.1.2/include/stdarg.h -> gcc4.1 (via rpmdb)
cpp.req: /usr/include/rpm/rpmmessages.h: /usr/include/rpm/rpmlog.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmurl.h: /usr/include/assert.h -> glibc-devel (via rpmdb)
gcc4.1
glibc-devel
libpopt-devel
librpm-devel
$

Таким образом, у librpm-devel реальная зависимость это только
libpopt-devel.  Тогда как вручную у него прописано гораздо больше
(лишних) зависимостей:

$ rpm -qR librpm-devel |grep -e -devel
bzlib-devel  
libbeecrypt-devel  
libdb4.4-devel  
libpopt-devel  
zlib-devel  
$

б) Зависимости хедеров у пакета imlib-devel.

$ rpm -ql imlib-devel |file -NF$'\t' -f - |/usr/lib/rpm/cpp.req.files |/usr/lib/rpm/cpp.req -v |sort -u
cpp.req: /usr/include/Imlib.h: /usr/include/Imlib_types.h -> imlib-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/unistd.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/math.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/netinet/in.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/sys/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xlib.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xutil.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xatom.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xos.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/extensions/shape.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/cursorfont.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xlib.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xutil.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xatom.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xos.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/extensions/shape.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/math.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/netinet/in.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib.h: /usr/include/gdk_imlib_types.h -> imlib-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/unistd.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/math.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/netinet/in.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/sys/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xlib.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xutil.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xatom.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xos.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/extensions/shape.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/cursorfont.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/gtk-1.2/gdk/gdkprivate.h -> gtk+-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/gtk-1.2/gdk/gdkx.h -> gtk+-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_types.h: /usr/include/gtk-1.2/gdk/gdk.h -> gtk+-devel (via rpmdb)
glibc-devel
gtk+-devel
imlib-devel
libX11-devel
xorg-x11-proto-devel
$

Установим эти зависимости в чрут (кроме самого пакета imlib-devel).

$ hsh --init
$ hsh-install glibc-devel gtk+-devel libX11-devel xorg-x11-proto-devel
Preparing packages for installation...
libX11-locales-1.1.4-alt3
libXau-1.0.3-alt1
libXdmcp-1.0.2-alt1.0
libxcb-1.1-alt4
libxcb-devel-1.1-alt4
glib-1.2.10-alt13
glib-devel-1.2.10-alt13
libX11-1.1.4-alt3
libXext-1.0.4-alt1
libXi-1.1.3-alt2
gtk+-1.2.10-alt15
libICE-1.0.4-alt1
libSM-1.0.3-alt1
libXt-1.0.5-alt1
xorg-x11-proto-devel-7.3.0-alt12
libICE-devel-1.0.4-alt1
libSM-devel-1.0.3-alt1
libXdmcp-devel-1.0.2-alt1.0
libXau-devel-1.0.3-alt1
libX11-devel-1.1.4-alt3
libXt-devel-1.0.5-alt1
gtk+-devel-1.2.10-alt15
$

Теперь поставим в чрут сам пакет imlib-devel и посмотрим, какие лишние
лишние пакеты он вытягивает.

$ hsh-install imlib
Preparing packages for installation...
libjpeg-6b-alt8
libpng12-1.2.25-alt1
libtiff-3.8.2-alt1
libungif-4.1.4-alt1
imlib-1.9.15-alt1
$ hsh-install imlib-devel
Preparing packages for installation...
imlib-cfgeditor-1.9.15-alt1
libXext-devel-1.0.4-alt1
libjpeg-devel-6b-alt8
zlib-devel-1.2.3-alt4
libpng-devel-1.2.25-alt1
libtiff-devel-3.8.2-alt1
libungif-devel-4.1.4-alt1
imlib-devel-1.9.15-alt1
$ 

Шесть лишних *-devel пакетов.

В общем, вроде бы, идея жизнеспособна.

Встают следующие вопросы:

1) Как поточнее выбрать хедеры -- в Си+плюсе хедеры не обязаны иметь
конвенциональный суффикс *.h.
2) Как быть с "cpp -x c++" -- он запускает cc1plus, которого по
сборочным зависимостям может и не быть (и нежелательно его туда
вносить).
3) Как быть с зависимостями на glibc-devel и gcc4.1 (тж.
libstdc++4.1-devel).

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

      parent reply	other threads:[~2008-03-17 21:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-03 15:26 Alexey Tourbin
2008-03-03 16:22 ` Kirill A. Shutemov
2008-03-03 21:42   ` Alexey Tourbin
2008-03-17 21:21 ` 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=20080317212112.GE7777@solemn.turbinal \
    --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