#---------------------------------------------------------------
# Project         : PLF
# Module          : rpmlint
# File            : PlfCheckpy
# Version         : $Id$
# Author          : Michael Scherer
# Created On      : Mon May 19 11:25:37 2003
# Purpose         : Apply plf policy
#---------------------------------------------------------------

# how to use it.
# drop it in /usr/share/rpmlint, and add it to the Config.py


from Filter import *
import AbstractCheck
import rpm
import re
import Config

plf_package_regex=re.compile('plf$')
plf_description_regex=re.compile('plf',re.IGNORECASE)
# still use the old name since i am not sure that every computer of mandriva 
# have been migrated to the new name 
mdksoft_host_regex=re.compile('mandr(akesoft|iva).com$')

class PlfCheck(AbstractCheck.AbstractCheck):
	checks_=[]
    
	def __init__(self):
		AbstractCheck.AbstractCheck.__init__(self, "PlfCheck")
        
	def check(self, pkg):
		release=pkg[rpm.RPMTAG_RELEASE]
		if not plf_package_regex.search(release):
			return
	
		description=pkg[rpm.RPMTAG_DESCRIPTION]
		if not plf_description_regex.search(description):
			printError(pkg,'no-reason-for-plf')
		
		buildhost=pkg[rpm.RPMTAG_BUILDHOST]
		if mdksoft_host_regex.search(buildhost):
			printWarning(pkg, 'build-on-mdv-cluster', buildhost)

check=PlfCheck()

if Config.info:
	addDetails(
'no-reason-for-plf',
'''As all packages part of the PLF, this package description 
should include a note stating why it is part of the PLF repository.
Just say something like "This package is part of the PLF repository
because..."''',
'build-on-mdv-cluster',
'''Mandriva and PLF are not related. PLF cannot accept packages
build on Mandriva cluster :)'''

)
	

