[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[debian-users:22566] Re: output of apt-cache showpkg
- From: Taketoshi Sano <kgh12351@xxxxxxxxxxx>
- Subject: [debian-users:22566] Re: output of apt-cache showpkg
- Date: Sat, 27 May 2000 06:58:08 +0900
- X-dispatcher: imput version 991025(IM133)
- X-fingerprint: DA 00 13 8C 49 BB 60 BE A4 54 3D AF 2E CE 28 DD
- X-ml-info: If you have a question, send a mail with the body "# help" (without quotes) to the address debian-users-ctl@debian.or.jp; help=<mailto:debian-users-ctl@debian.or.jp?body=help>
- X-ml-name: debian-users
- X-mlserver: fml [fml 2.2]; post only (only members can post)
- References: <87og5u8tom.fsf@xxxxxxxxxxx>
- Message-id: <y5aln0yf4tq.fsf@xxxxxxxxxxxxxxxxxxxx>
- X-mail-count: 22566
- User-agent: T-gnus/6.13.3 (based on Pterodactyl Gnus v0.98) EMIKO/1.13.9 (Euglena tripteris) FLIM/1.13.2 (Kasanui) APEL/10.2 Emacs/20.6 (i386-debian-linux-gnu) MULE/4.0 (HANANOEN)
佐野@浜松です。
In article <87og5u8tom.fsf@xxxxxxxxxxx>,
at "Fri, 26 May 2000 07:28:39 +0900',
with "output of apt-cache showpkg",
ryo sakuma <KHB10110@xxxxxxxxxxx> さん writes:
> % apt-cache showpkg PACKAGE の出力結果でたとえば,
> Dependencies:
> 2.1-19 - libc5 (2 5.4.0-0) libc6 (2 2.1.2) (途中改行)
> libncurses5 (0 (null)) base-files (2 2.1.12) ldso (2 1.9.0-1)
> などと出ますが,括弧内の (<整数> <バージョン?>)
> の部分はどう読むのでしょうか? (null) の意味もわかりません.
私も前から知りたかったのですが、man apt-cache すると
For the specific meaning of the remainder of the output
it is best to consult the apt source code.
などと書いてありますね。
しょうがないので apt 0.3.19 のソースを見てみました。
まずソースツリーを展開して
find . -name Makefile |xargs grep apt-cache
何も出ない。
find . -name rules |xargs grep apt-cache
やっぱり無い。
find . -name '*.h' -or -name '*.c'|xargs grep apt-cache
これも無い。(実は .c は無くて .cc なファイルだけなことに後で気づく)
で、find . -type f |xargs grep apt-cache|less すると
たくさん出てきて、 ./cmdline/apt-cache.cc というズバリその名前な
ファイルが見つかります。
この ./cmdline/apt-cache.cc の中身を less で見て、showpkg で検索すると
CommandLine::Dispatch CmdsB[] = {{"showpkg",&DumpPackage},
というのがあるので、今度は DumpPackage を探します。
これは前のほうにあって
cout << "Dependencies: " << endl;
for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++)
{
cout << Cur.VerStr() << " - ";
for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; Dep++)
cout << Dep.TargetPkg().Name() << " (" << (int)Dep->CompareOp << " " << Dep.Ta
rgetVer() << ") ";
cout << endl;
}
が問題の表示を実行しているところらしい。
cout << Cur.VerStr() << " - ";
が
> 2.1-19 - libc5 (2 5.4.0-0) libc6 (2 2.1.2) (途中改行)
の "2.1-19 - " な部分までを出力している部分ですね。
そうすると問題は
for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; Dep++)
cout << Dep.TargetPkg().Name() << " (" << (int)Dep->CompareOp << " " << Dep.Ta
rgetVer() << ") ";
な部分、ということになります。
Dep.TargetPkg().Name() が例えば libc5 や libc6 といったパッケージ名、
"(" に続いて (int)Dep->CompareOp が 2 とか 0、さらに " " に続いて
Dep.TargetVer が 2.1.2 とか null とか、ですね。
で、このへんの意味を知るには、pkgCache::DepIterator を見たほうが良さそう。
そこでもう一度ソースツリーを検索して
find . -type f |grep pkgcache
を実行します。すると
./apt-pkg/pkgcache.cc
./apt-pkg/pkgcache.h
./apt-pkg/pkgcachegen.cc
./apt-pkg/pkgcachegen.h
./debian/cvs-build/apt-0.3.19/apt-pkg/pkgcache.cc
./debian/cvs-build/apt-0.3.19/apt-pkg/pkgcache.h
./debian/cvs-build/apt-0.3.19/apt-pkg/pkgcachegen.cc
./debian/cvs-build/apt-0.3.19/apt-pkg/pkgcachegen.h
こんな感じに出てくるので、まずは ./apt-pkg/ にある
pkgcache.cc と pkgcache.h を見てみます。
先に pkgcache.h を眺めてみると
class pkgCache
{
public:
// Cache element predeclarations
(省略)
// Iterators
class PkgIterator;
(省略)
// These are all the constants used in the cache structures
struct Dep
{
enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
Conflicts=5,Replaces=6};
enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
Greater=0x4,Equals=0x5,NotEquals=0x6};
};
と書いてあります。
もうここで (int)Dep->CompareOp がどういう意味か、見当がつきそうですね。
enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
Greater=0x4,Equals=0x5,NotEquals=0x6};
つまり DepCompareOp の値によって
16(0x10) : "|" (Or)
0 : "" (NoOp)
1(0x1) : "<=" (LessEq)
2(0x2) : ">=" (GreaterEq)
3(0x3) : "<" (Less)
4(0x4) : ">" (Greater)
5(0x5) : "=" (Equals)
6(0x6) : "!=" (NotEquals)
という意味がある、と。
なお、Dependency は "Depends" に現われるものだけでなく
enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
Conflicts=5,Replaces=6};
ここにあるように
Depends (1), PreDepends (2), Suggests (3), Recommends (4),
Conflicts (5), Replaces (6)
の 6 種類の情報を含んでいます。
例えば apt-cache show libc5 で見ると
Pre-Depends: ldso (>=1.7.14-2)
だけで、Depends: はありませんが、 apt-cache showpkg libc5 では
Dependencies:
5.4.46-3 - ldso (2 1.7.14-2)
となり、 ldso (>=1.7.14-2) であることが示されています。
同様に apt-cache show libc5-altdev は Depends: libc5 (=5.4.46-3) であり
apt-cache showpkg libc5-altdev では Dependencies: に
5.4.46-3 - libc5 (5 5.4.46-3) として libc5 (=5.4.46-3) と依存関係のある
ことが示されています。
libc6 には Pre-Depends の ldso 以外に Recommends, Suggests, Conflicts,
Replaces などにいろいろなパッケージが指定されているので、それらがすべて
Dependencies に現われてきます。例えば locales は Recommends: locales
かつ Replaces: locales (<< 2.1.3-5) なので showpkg で locales (0 (null))
および locales (3 2.1.3-5) として 2 回表示されるわけですね。
なお既におわかりでしょうが、 (0 (null)) はバージョン無しで依存関係が
指定されている場合の表示です。
私は C++ をほとんど知らない (cin, cout くらいならわかる) ので、実際の
コードがどう動いているかはよくわかりませんが、知っている単語を探して
眺めるだけでもある程度は見当がつけられるものです。たまに勘違いをして
失敗することがあっても、それもまた楽しみのひとつでしょう。
たまには、コードを眺めてみるのも楽しいものですよ。 ^^)
では。
--
# (わたしのおうちは浜松市、「夜のお菓子」で有名さ。)
<kgh12351@xxxxxxxxxxx> : Taketoshi Sano (佐野 武俊)