在进行测试之前,必须先检查开发的rpm包数据
包括安装目录,权限,文件结构,是否包含某些文件等信息
写了个脚本自动化
python的rpm包,在网上资料实在不多,时间仓促,也就简单看了下
首先,import
import rpm
获取hdr
def get_hdr(rpmPath):
ts = rpm.ts()
try:
fdno = os.open(rpmPath,os.O_RDONLY)
hdr = ts.hdrFromFdno(fdno)
os.close(fdno)
except:
print("ERROR: Init rpm error!")
sys.exit(1)
return hdr
可以使用help(rpm)查看已经定义好的变量,变量基本读下就大概知道什么意思
主要是RPMTAG_*
以下简单获取自己想要的几项
def get_rpm_info(file_path):
rpm_info = {}
hdr = get_hdr(file_path)
tag_files = [s for s in hdr[rpm.RPMTAG_FILENAMES] if ".svn" not in s]
rpm_info.u