Get list of conffiles in deb package in python

I want to get a list of conffiles related to the deb package using python. I am working on a project for which I need to know if any conffile installed by the package has changed, so I need to have a list of conffiles installed by the package so that I can use it to see which conffile has been changed.

I tried using the python-apt library , but could not find any method for this, please suggest me a way to do this, I know that I can extract the control information and read the raw conffiles file, but I think that in the library itself be a method.

+4
source share
2 answers

this is tested on python-apt under compression: I used the following package:

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 cut the last

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

you need to cut the first slash

+2
source

State flag

 dpkg --status bash 
0
source

Source: https://habr.com/ru/post/1379801/


All Articles