summaryrefslogtreecommitdiff
path: root/extensions/strip-gplv3.configure
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-04 15:17:44 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-11 08:55:05 +0000
commite4c6b8a69f0df2d0b3beac46865a66e0de527151 (patch)
treed837a9768fe2a15557d400301ed8b6588504eb55 /extensions/strip-gplv3.configure
parent840292841f4495a79a037f81a26d6b3f51e7cb8c (diff)
downloaddefinitions-e4c6b8a69f0df2d0b3beac46865a66e0de527151.tar.gz
Remove dependencies on morphlib and cliapp from deployment extensionsbaserock/adamcoldrick/remove-dependencies-v3
This is done by either copying some utility functions from morph into writeexts.py, and using the `subprocess` module rather than cliapp's runcmd and ssh_runcmd. Note that this means that these extensions will require "$definitions_checkout/extensions" in PYTHONPATH when they are run. This commit also updates VERSION to 5, since the PYTHONPATH requirement means that this change is incompatible with old versions of morph. Change-Id: Iec6fa7e3c7219619ce55e18493e5c37c36e97816
Diffstat (limited to 'extensions/strip-gplv3.configure')
-rwxr-xr-xextensions/strip-gplv3.configure28
1 files changed, 16 insertions, 12 deletions
diff --git a/extensions/strip-gplv3.configure b/extensions/strip-gplv3.configure
index c08061ad..0c5250e4 100755
--- a/extensions/strip-gplv3.configure
+++ b/extensions/strip-gplv3.configure
@@ -21,12 +21,14 @@ to find the files created by that chunk, then remove them.
'''
-import cliapp
-import re
-import os
import json
+import os
+import re
+import sys
+
+import writeexts
-class StripGPLv3ConfigureExtension(cliapp.Application):
+class StripGPLv3ConfigureExtension(writeexts.Extension):
gplv3_chunks = [
['autoconf', ''],
['automake', ''],
@@ -57,7 +59,8 @@ class StripGPLv3ConfigureExtension(cliapp.Application):
for chunk in self.gplv3_chunks:
regex = os.path.join(meta_dir, "%s-[^-]\+\.meta" % chunk[0])
- artifacts = self.runcmd(['find', meta_dir, '-regex', regex])
+ artifacts = subprocess.check_output(['find', meta_dir,
+ '-regex', regex])
for artifact in artifacts.split():
self.remove_chunk(target_root, artifact, chunk[1])
@@ -72,8 +75,8 @@ class StripGPLv3ConfigureExtension(cliapp.Application):
chunk_meta_data = json.load(f)
if not 'contents' in chunk_meta_data:
- raise cliapp.AppError('Chunk %s does not have a "contents" list'
- % chunk)
+ raise writeexts.ExtensionError(
+ 'Chunk %s does not have a "contents" list' % chunk)
updated_contents = []
for content_entry in reversed(chunk_meta_data['contents']):
pat = re.compile(pattern)
@@ -85,8 +88,8 @@ class StripGPLv3ConfigureExtension(cliapp.Application):
def remove_content_entry(self, target_root, content_entry):
entry_path = os.path.join(target_root, './' + content_entry)
if not entry_path.startswith(target_root):
- raise cliapp.AppException('%s is not in %s'
- % (entry_path, target_root))
+ raise writeexts.ExtensionError(
+ '%s is not in %s' % (entry_path, target_root))
if os.path.exists(entry_path):
if os.path.islink(entry_path):
os.unlink(entry_path)
@@ -96,6 +99,7 @@ class StripGPLv3ConfigureExtension(cliapp.Application):
if not os.listdir(entry_path):
os.rmdir(entry_path)
else:
- raise cliapp.AppException('%s is not a link, file or directory'
- % entry_path)
-StripGPLv3ConfigureExtension().run()
+ raise writeexts.ExtensionError(
+ '%s is not a link, file or directory' % entry_path)
+
+StripGPLv3ConfigureExtension().run(sys.argv[1:])