简体   繁体   English

在python中获取deb包中的配置文件列表

[英]Get a List of conffiles in a deb package in python

I want to get the list of conffiles associated with a deb package using python. 我想使用python获取与deb软件包关联的conffile列表。 I am working on a project for which I need to know if any conffile installed by a package is modified so I need to have a list of conffiles installed by a package so that I can use it to see which of the conffile has been modified. 我正在研究一个项目,我需要知道该软件包安装的任何conffile是否被修改,因此我需要一个软件包安装的conffile列表,以便可以使用它查看已修改哪个conffile。

I tried to use python-apt library documentation , but could not find any method for doing that , Please suggest me a way of doing that. 我尝试使用python-apt库文档 ,但是找不到用于执行此操作的任何方法,请建议我这样做。 I know I can extract the control information and read the raw conffiles file but I think there might be a method in the library itself. 我知道我可以提取控制信息并读取原始的conffiles文件,但是我认为库本身中可能有一个方法。

this is tested on python-apt on squeeze: the package I used is: 这是在python-apt上进行了测试:

http://ftp.debian.org/debian/pool/main/o/openssh/openssh-server_5.5p1-6+squeeze1_amd64.deb http://ftp.debian.org/debian/pool/main/o/openssh/openssh-server_5.5p1-6+squeeze1_amd64.deb

from apt.debfile import DebPackage
ssh = DebPackage('openssh-server_5.5p1-6+squeeze1_amd64.deb')
print ssh.control_content('conffiles').split('\n')

[u'/etc/init.d/ssh', u'/etc/default/ssh', u'/etc/network/if-up.d/openssh-server', u'/etc/ufw/applications.d/openssh-server', u'/etc/pam.d/sshd', u'']

you need to strip out the last one 您需要删除最后一个

print ssh.data_content('etc/init.d/ssh')
u'#! /bin/sh\n\n### BEGIN INIT INFO\n#......'

you need to strip out the first slash 您需要删除第一个斜杠

状态标志

dpkg --status bash

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM