@ -70,16 +70,14 @@ class SourcePPAPolicy(BasePolicy):
return ' '
return ' '
def initialise ( self , britney ) :
def initialise ( self , britney ) :
""" Load and discover all source ppa data"""
""" Load cached source ppa data"""
super ( ) . initialise ( britney )
super ( ) . initialise ( britney )
self . britney = britney
self . britney = britney
try :
if os . path . exists ( self . filename ) :
with open ( self . filename , encoding = ' utf-8 ' ) as data :
with open ( self . filename , encoding = ' utf-8 ' ) as data :
self . cache = json . load ( data )
self . cache = json . load ( data )
self . log ( " Loaded cached source ppa data from %s " % self . filename )
self . log ( " Loaded cached source ppa data from %s " % self . filename )
except FileNotFoundError :
pass
def apply_policy_impl ( self , sourceppa_info , suite , source_name , source_data_tdist , source_data_srcdist , excuse ) :
def apply_policy_impl ( self , sourceppa_info , suite , source_name , source_data_tdist , source_data_srcdist , excuse ) :
""" Reject package if any other package copied from same PPA is invalid """
""" Reject package if any other package copied from same PPA is invalid """
@ -87,22 +85,30 @@ class SourcePPAPolicy(BasePolicy):
britney_excuses = self . britney . excuses
britney_excuses = self . britney . excuses
version = source_data_srcdist . version
version = source_data_srcdist . version
sourceppa = self . lp_get_source_ppa ( source_name , version )
sourceppa = self . lp_get_source_ppa ( source_name , version )
if not sourceppa :
return PolicyVerdict . PASS
shortppa = sourceppa . replace ( LAUNCHPAD_URL , ' ' )
self . source_ppas_by_pkg [ source_name ] [ version ] = sourceppa
self . source_ppas_by_pkg [ source_name ] [ version ] = sourceppa
if sourceppa :
sourceppa_info [ source_name ] = shortppa
# Check for other packages that might invalidate this one
# Check for other packages that might invalidate this one
for friend in self . pkgs_by_source_ppa [ sourceppa ] :
for friend in self . pkgs_by_source_ppa [ sourceppa ] :
if not britney_excuses [ friend ] . is_valid :
sourceppa_info [ friend ] = shortppa
accept = False
if not britney_excuses [ friend ] . is_valid :
self . pkgs_by_source_ppa [ sourceppa ] . add ( source_name )
accept = False
self . pkgs_by_source_ppa [ sourceppa ] . add ( source_name )
if not accept :
if not accept :
# Invalidate all packages in this source ppa
# Invalidate all packages in this source ppa
shortppa = sourceppa . replace ( LAUNCHPAD_URL , ' ' )
for friend in self . pkgs_by_source_ppa [ sourceppa ] :
for friend in self . pkgs_by_source_ppa [ sourceppa ] :
friend_exc = britney_excuses . get ( friend , excuse )
friend_exc = britney_excuses . get ( friend , excuse )
friend_exc . is_valid = False
if friend_exc . is_valid :
friend_exc . addreason ( ' source-ppa ' )
friend_exc . is_valid = False
self . log ( " Blocking %s because %s from %s " % ( friend , source_name , shortppa ) )
friend_exc . addreason ( ' source-ppa ' )
sourceppa_info [ friend ] = shortppa
friend_exc . policy_info [ ' source-ppa ' ] = sourceppa_info
self . log ( " Blocking %s because %s from %s " % ( friend , source_name , shortppa ) )
friend_exc . addhtml ( " Blocking because %s from the same PPA %s is invalid " %
( friend , shortppa ) )
return PolicyVerdict . REJECTED_PERMANENTLY
return PolicyVerdict . REJECTED_PERMANENTLY
return PolicyVerdict . PASS
return PolicyVerdict . PASS