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-10 14:13:27 +0000
commit370a33a33f503bba02125e13a1c8f300a656d441 (patch)
tree127fc749a6262d9ef12933913de0a057424d1ff2 /extensions/strip-gplv3.configure
parent840292841f4495a79a037f81a26d6b3f51e7cb8c (diff)
downloaddefinitions-baserock/adamcoldrick/remove-dependencies-v2.tar.gz
Remove dependencies on morphlib and cliapp from deployment extensionsbaserock/adamcoldrick/remove-dependencies-v2
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.configure31
1 files changed, 19 insertions, 12 deletions
diff --git a/extensions/strip-gplv3.configure b/extensions/strip-gplv3.configure
index c08061ad..0585fe5d 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(object):
gplv3_chunks = [
['autoconf', ''],
['automake', ''],
@@ -51,7 +53,7 @@ class StripGPLv3ConfigureExtension(cliapp.Application):
['texinfo-tarball', ''],
]
- def process_args(self, args):
+ def run(self, args):
target_root = args[0]
meta_dir = os.path.join(target_root, 'baserock')
@@ -72,8 +74,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 +87,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 +98,11 @@ 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)
+
+try:
+ StripGPLv3ConfigureExtension().run(sys.argv[1:])
+except writeexts.ExtensionError as e:
+ sys.stdout.write('ERROR: %s' % e)
+ sys.exit(1)