2013-05-15 15 views
2

我希望能够查看本地.deb文件和远程存储库并推断依赖关系等,以便我可以构建自己的存储库和部分镜像(可能通过为reprepro创建配置文件)。如何查询和管理Python中的Debian软件包储存库?

我们面临的挑战是许多命令行工具(apt-rdepends等)都假设你在目标系统上运行并利用本地apt cache,而我经常会处理来自我目前正在运行的不同Ubuntu和Debian发行版的东西,所以我想多花一点时间来做这件事。

功能强大但很少记录的python-apt软件包让我检查本地文件系统上的.deb文件并提取相关性。我现在想知道是否有类似的工具来解析存储库中的Packages.gz文件? (这不是太棘手,但我不想重新发明轮子!)

总体目标是创建和维护两个存储库:一个使用我们自己的软件包,另一个使用Ubuntu发行版的部分镜像已知的必需软件包以及他们或我们自己的软件所依赖的任何软件包。

回答

0

一个非常有效的方法是为所有相关分布创建本地适配缓存。来自devscripts软件包的工具chdist可让您创建多个这些缓存,而无需使用root权限。然后,您可以使用您习惯的工具(例如apt-rdepends)通过将它们包装在chdist中来查询这些缓存。您甚至可以使用rootdir关键字参数指向apt.cache.Cache,将python-apt指向本地缓存,然后您可以在其中解析依赖关系。

0

你可能想看看repoman,至少可以借鉴一些想法。

E.g.要得到这样https://github.com/synack/repoman#get-detailed-information-about-a-package-1

[ 
{ 
    "SHA1": "cae8b9a4a821237a24b5757566efdc95391090d4", 
    "Maintainer": "Jeremy Grosser <[email protected]>", 
    "Description": "server-side, HTML-embedded scripting language (meta-package) This package is a meta-package that, when installed, guarantees that you have at least one of the four server-side versions of the PHP5 interpreter installed. Removing this package won't remove PHP5 from your system, however it may remove other packages that depend on this one. . PHP5 is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly. . Homepage: http://www.php.net/", 
    "Package": "php5", 
    "Section": "web", 
    "MD5sum": "0efa615337f0ba59d8369e4469884730", 
    "Installed-Size": "20", 
    "Filename": "pool/main/p/php5/php5_5.2.9-digg8_all.deb", 
    "Priority": "normal", 
    "Depends": "libapache2-mod-php5 (>= 5.2.9-digg8) | php5-cgi (>= 5.2.9-digg8), php5-common (>= 5.2.9-digg8)", 
    "Version": "5.2.9-digg8", 
    "Architecture": "all", 
    "SHA256": "26844b968f6b51c1a02fd59c21455bf6ba47e46e47e53c6676af0ee4c2dd799b", 
    "Size": "1024" 
} 

]

代码deb包信息https://github.com/synack/repoman/blob/master/repoman/repository.py#L187