2013-05-15 19 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