# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2011 Red Hat, Inc # written by Seth Vidal from yum.plugins import TYPE_CORE from yum.constants import * requires_api_version = '2.4' plugin_type = (TYPE_CORE,) checksum_command = '/bin/true' import subprocess def call_checksum_cmd(filename): csum_proc = subprocess.Popen([checksum_command, filename], stdout=subprocess.PIPE, stderr=open('/dev/null', 'w')) csum_out = csum_proc.communicate()[0] result = None for line in csum_out.split('\n'): line.strip() if not line: continue try: csum_type, csum = line.split(':') except (IndexError, ValueError, KeyError): continue else: return (csum_type, csum) return result def verify_package_hook(conduit): for i in conduit.verify_package: results = call_checksum_cmd(i.filename) if not results: continue i.digest = results # you can set other values like file mode, size, date, etc here def config_hook(conduit): ''' Yum Plugin Config Hook: Add the 'verify' and 'verify-no-multilib' commands. ''' global checksum_command checksum_command = conduit.confString('main', 'checksum_command', default='/bin/true')