[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

python-apt problem



I'm trying to get pyhon-apt to read an alternative configuration.

I've written an alternative config file and I can use with apt-get and apt-cache

apt-cache -c /tmp/myapt.conf search .

yields six packages relating to python. That's the way it's supposed
to be. I only have one small repository in the sources.list


Now here's a python script that tries to list the same packages 

#!/usr/bin/python
import apt_pkg,os,sys,time

Cnf = apt_pkg.newConfiguration()
apt_pkg.ReadConfigFile(Cnf,"/tmp/myapt.conf")

apt_pkg.init()
cache = apt_pkg.GetCache()
cache.PackageCount
print "[%s]" % ( cache.FileList,)

for package in cache.Packages:
    print package

But the script lists all the packages on my system rather than those
referenced by /tmp/myapt.conf.

Here are the first lines of output:
You can see that the pkgCache.PackageFile object points to
"/var/lib/dpkg/status" but it should point to
"/tmp/ma/var/lib/dpkg/status".

Here's some output

Reading Package Lists... Done
Building Dependency Tree... Done
[[<pkgCache::PackageFile object: File:'/var/lib/dpkg/status'
a=now,c=(null),v=(null),o=(null),l=(null) Arch='(null)' Site=''
IndexType='Debian ]
<pkgCache::Package object: Name:'snort-rules-default' Section: 'net'
ID:17558 Flags:0x0>
<pkgCache::Package object: Name:'python-tclink' Section: 'python'
ID:16478 Flags:0x0>
<pkgCache::Package object: Name:'pipenightdreams' Section: 'games'
ID:15831 Flags:0x0>
<pkgCache::Package object: Name:'osgcal-doc' Section: 'devel' ID:15427
Flags:0x0>
<pkgCache::Package object: Name:'xmms-stats' Section: 'utils' ID:19189
Flags:0x0>
<pkgCache::Package object: Name:'trophy-data' Section: 'games'
ID:18172 Flags:0x0>
<pkgCache::Package object: Name:'t38modem' Section: 'comm' ID:17846 Flags:0x0>
<pkgCache::Package object: Name:'openoffice.org-l10n-lt' Section:
'editors' ID:15301 Flags:0x0>
<pkgCache::Package object: Name:'lsb-cxx-ia32' Section: '(null)'
ID:13967 Flags:0x0>
<pkgCache::Package object: Name:'libgtkglext1-ruby' Section: 'libs'
ID:11204 Flags:0x0>
<pkgCache::Package object: Name:'libapache-dbilogconfig-perl' Section:
'perl' ID:9269 Flags:0x0>
<pkgCache::Package object: Name:'isdnutils-xtools' Section: 'x11'
ID:7682 Flags:0x0>
<pkgCache::Package object: Name:'drgenius' Section: '(null)' ID:3953 Flags:0x0>


And the apt config file myapt.conf:
Dir "/tmp/ma";
Dir::Cache "/tmp/ma/var/cache/";
Dir::Cache::Archives "/tmp/ma/var/cache/archives";
Dir::State::pkgcache "/tmp/ma/apt/pkgcache.bin";
Dir::State::status "/tmp/ma/var/lib/dpkg/status";
Dir::State "/tmp/ma/var/lib/dpkg/";

Dir::Etc "etc/";
Dir::Etc::SourceList "apt/sources.list";


Could anyone tell me what I'm doing wrong?

alex


-- 
Alex Polite
http://polite.se



Reply to: