Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pre-uninstall scripts #309

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HaikuPorter/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ def _generatePackageInfo(self, packageInfoPath, requiresToUse, quiet,
self._writePackageInfoListQuotePaths(infoFile,
self.recipeKeys['POST_INSTALL_SCRIPTS'],
'post-install-scripts')
self._writePackageInfoListQuotePaths(infoFile,
self.recipeKeys['PRE_UNINSTALL_SCRIPTS'],
'pre-uninstall-scripts')

# Generate SourceURL lines for all ports, regardless of license.
# Re-use the download URLs, as specified in the recipe.
Expand Down
21 changes: 11 additions & 10 deletions HaikuPorter/Policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def checkPackage(self, package, packageFile):
self._checkMisplacedDevelopLibraries()
self._checkGlobalWritableFiles()
self._checkUserSettingsFiles()
self._checkPostInstallScripts()
self._checkPostInstallAndPreUninstallScripts('POST_INSTALL_SCRIPTS', 'post-install')
self._checkPostInstallAndPreUninstallScripts('PRE_UNINSTALL_SCRIPTS', 'pre-uninstall')

if self.strict and self.violationEncountered:
sysExit("packaging policy violation(s) in strict mode")
Expand Down Expand Up @@ -465,10 +466,10 @@ def _checkUserSettingsFiles(self):
'"%s" for user settings file "%s" as included'
% (components[2], components[0]))

def _checkPostInstallScripts(self):
def _checkPostInstallAndPreUninstallScripts(self, recipeKey, scriptType):
# check whether declared scripts exist
declaredFiles = set()
for script in self.package.recipeKeys['POST_INSTALL_SCRIPTS']:
for script in self.package.recipeKeys[recipeKey]:
if script.lstrip().startswith('#'):
continue

Expand All @@ -480,18 +481,18 @@ def _checkPostInstallScripts(self):

absScript = os.path.join(self.package.packagingDir, script)
if not os.path.exists(absScript):
self._violation('Package declares non-existent post-install '
'script "%s"' % script)
self._violation('Package declares non-existent %s '
'script "%s"' % (scriptType, script))

# check whether existing scripts are declared
postInstallDir = 'boot/post-install'
dir = os.path.join(self.package.packagingDir, postInstallDir)
relativeDir = 'boot/' + scriptType
dir = os.path.join(self.package.packagingDir, relativeDir)
if os.path.exists(dir):
for script in os.listdir(dir):
path = postInstallDir + '/' + script
path = relativeDir + '/' + script
if path not in declaredFiles:
self._violation('script "%s" not declared as post-install '
'script' % path)
self._violation('script "%s" not declared as %s '
'script' % (path, scriptType))

def _violation(self, message):
self.violationEncountered = True
Expand Down
1 change: 1 addition & 0 deletions HaikuPorter/Port.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@ def _updateShellVariables(self, forParsing):
'documentationDir': 'documentation',
'fontsDir': 'data/fonts',
'postInstallDir': 'boot/post-install',
'preUninstallDir': 'boot/pre-uninstall',
'preferencesDir': 'preferences',
'settingsDir': 'settings',
}
Expand Down
17 changes: 12 additions & 5 deletions HaikuPorter/RecipeAttributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,27 @@ def getRecipeFormatVersion():
'extendable': Extendable.DEFAULT,
'indexable': False,
},
'PROVIDES': {
'type': ProvidesList,
'required': True,
'default': None,
'POST_INSTALL_SCRIPTS': {
'type': list,
'required': False,
'default': [],
'extendable': Extendable.DEFAULT,
'indexable': False,
},
'POST_INSTALL_SCRIPTS': {
'PRE_UNINSTALL_SCRIPTS': {
'type': list,
'required': False,
'default': [],
'extendable': Extendable.DEFAULT,
'indexable': False,
},
'PROVIDES': {
'type': ProvidesList,
'required': True,
'default': None,
'extendable': Extendable.DEFAULT,
'indexable': False,
},
'REPLACES': {
'type': list,
'required': False,
Expand Down
Loading