import sys import re #print(sys.argv[1]) #print(sys.argv[2]) qian={} hou={}
f = open(sys.argv[1]) line = f.readline() while line: line=line.strip('\n') new_rpm = re.sub(r'-\d+\.', '.', line) new_rpm = new_rpm.split(".")[0] qian[new_rpm]=line line = f.readline() f.close()
f = open(sys.argv[2]) line = f.readline() while line: line=line.strip('\n') new_rpm = re.sub(r'-\d+\.', '.', line) new_rpm = new_rpm.split(".")[0] hou[new_rpm]=line line = f.readline() f.close()
print("===检查本地有远程没有的情况==需要本地卸载==") for key,val in qian.items(): if key in hou: if qian[key].strip(' ') == hou[key].strip(' '): pass else: print(qian[key]+" "+hou[key]) else: print("yum remove -y %s" %(key))
print("===检查远程有本地没有的情况=需要本地安装===")
for key,val in hou.items(): if key in qian: if hou[key].strip(' ') == qian[key].strip(' '): pass else: print(qian[key]+" "+hou[key]) else: print("rpm -ivh %s" %(key))