@@ -82,7 +82,8 @@ def checkPackage(self, package, packageFile):
82
82
self ._checkMisplacedDevelopLibraries ()
83
83
self ._checkGlobalWritableFiles ()
84
84
self ._checkUserSettingsFiles ()
85
- self ._checkPostInstallScripts ()
85
+ self ._checkPostInstallAndPreUninstallScripts ('POST_INSTALL_SCRIPTS' , 'post-install' )
86
+ self ._checkPostInstallAndPreUninstallScripts ('PRE_UNINSTALL_SCRIPTS' , 'pre-uninstall' )
86
87
87
88
if self .strict and self .violationEncountered :
88
89
sysExit ("packaging policy violation(s) in strict mode" )
@@ -465,10 +466,10 @@ def _checkUserSettingsFiles(self):
465
466
'"%s" for user settings file "%s" as included'
466
467
% (components [2 ], components [0 ]))
467
468
468
- def _checkPostInstallScripts (self ):
469
+ def _checkPostInstallAndPreUninstallScripts (self , recipeKey , scriptType ):
469
470
# check whether declared scripts exist
470
471
declaredFiles = set ()
471
- for script in self .package .recipeKeys ['POST_INSTALL_SCRIPTS' ]:
472
+ for script in self .package .recipeKeys [recipeKey ]:
472
473
if script .lstrip ().startswith ('#' ):
473
474
continue
474
475
@@ -480,18 +481,18 @@ def _checkPostInstallScripts(self):
480
481
481
482
absScript = os .path .join (self .package .packagingDir , script )
482
483
if not os .path .exists (absScript ):
483
- self ._violation ('Package declares non-existent post-install '
484
- 'script "%s"' % script )
484
+ self ._violation ('Package declares non-existent %s '
485
+ 'script "%s"' % ( scriptType , script ) )
485
486
486
487
# check whether existing scripts are declared
487
- postInstallDir = 'boot/post-install'
488
- dir = os .path .join (self .package .packagingDir , postInstallDir )
488
+ relativeDir = 'boot/' + scriptType
489
+ dir = os .path .join (self .package .packagingDir , relativeDir )
489
490
if os .path .exists (dir ):
490
491
for script in os .listdir (dir ):
491
- path = postInstallDir + '/' + script
492
+ path = relativeDir + '/' + script
492
493
if path not in declaredFiles :
493
- self ._violation ('script "%s" not declared as post-install '
494
- 'script' % path )
494
+ self ._violation ('script "%s" not declared as %s '
495
+ 'script' % ( path , scriptType ) )
495
496
496
497
def _violation (self , message ):
497
498
self .violationEncountered = True
0 commit comments