diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-04-13 12:19:29 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-04-13 12:19:29 +0000 |
| commit | 5483ca175e5aa2b7de55cb0cea69546d2ccd2cd5 (patch) | |
| tree | 9db7e93472cf359167f2ff3d11fecb99159fb7db | |
| parent | 7c49549a00c2be19e476153255cb7115a79c2bf8 (diff) | |
| download | python-apt-5483ca175e5aa2b7de55cb0cea69546d2ccd2cd5.tar.gz | |
* build-depends added to PkgSrcRecords, example for build-depends added
| -rwxr-xr-x | doc/examples/build-deps.py | 46 | ||||
| -rw-r--r-- | python/apt_pkgmodule.h | 1 | ||||
| -rw-r--r-- | python/makefile | 2 | ||||
| -rw-r--r-- | python/pkgsrcrecords.cc | 16 |
4 files changed, 64 insertions, 1 deletions
diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py new file mode 100755 index 00000000..c00e60e6 --- /dev/null +++ b/doc/examples/build-deps.py @@ -0,0 +1,46 @@ +#!/usr/bin/python + +import apt_pkg +import sys + + +def get_source_pkg(pkg, records, depcache): + # FIXME: use candidate version here + version = depcache.GetCandidateVer(pkg) + file, index = version.FileList.pop(0) + records.Lookup((file, index)) + if records.SourcePkg != "": + srcpkg = records.SourcePkg + else: + srcpkg = pkg.Name + return srcpkg + +# main +apt_pkg.init() +cache = apt_pkg.GetCache() +depcache = apt_pkg.GetDepCache(cache) +depcache.Init() +records = apt_pkg.GetPkgRecords(cache) +srcrecords = apt_pkg.GetPkgSrcRecords() + +# base package that we use for build-depends calculation +if len(sys.argv) < 2: + print "need a pkgname as argument" +base = cache[sys.argv[1]] +all_build_depends = set() + +depends = base.CurrentVer.DependsList +for dep in depends["Depends"]: + pkg = dep[0].TargetPkg + srcpkg_name = get_source_pkg(pkg, records, depcache) + srcrec = srcrecords.Lookup(srcpkg_name) + if srcrec: + #print srcrecords.Package + #print srcrecords.Binaries + bd = srcrecords.BuildDepends + #print "%s: %s " % (srcpkg_name, bd) + for b in bd: + all_build_depends.add(b[0]) + + +print "\n".join(all_build_depends) diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index d0bfbeae..95ab3ee8 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -67,6 +67,7 @@ PyObject *GetDepCache(PyObject *Self,PyObject *Args); extern PyTypeObject PkgCdromType; PyObject *GetCdrom(PyObject *Self,PyObject *Args); + // PkgRecords Stuff extern PyTypeObject PkgRecordsType; PyObject *GetPkgRecords(PyObject *Self,PyObject *Args); diff --git a/python/makefile b/python/makefile index 29bbaca9..273096a7 100644 --- a/python/makefile +++ b/python/makefile @@ -11,7 +11,7 @@ SLIBS = -lapt-pkg LIB_MAKES = apt-pkg/makefile APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \ cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \ - depcache.cc progress.cc + depcache.cc progress.cc cdrom.cc SOURCE := $(APT_PKG_SRC) include $(PYTHON_H) progress.h diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index f9a420b9..fb66284a 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -80,6 +80,22 @@ static PyObject *PkgSrcRecordsAttr(PyObject *Self,char *Name) return List; // todo } else if (strcmp("Files",Name) == 0) return 0; // todo + else if (strcmp("BuildDepends",Name) == 0) { + PyObject *List = PyList_New(0); + + vector<pkgSrcRecords::Parser::BuildDepRec> bd; + if(!Struct.Last->BuildDepends(bd, false /* arch-only*/)) + return NULL; // error + + PyObject *v; + for(unsigned int i=0;i<bd.size();i++) { + v = Py_BuildValue("(ssii)", bd[i].Package.c_str(), + bd[i].Version.c_str(), bd[i].Op, bd[i].Type); + PyList_Append(List, v); + Py_DECREF(v); + } + return List; + } } return Py_FindMethod(PkgSrcRecordsMethods,Self,Name); |
