summaryrefslogtreecommitdiff
path: root/extensions/strip-gplv3.configure
diff options
context:
space:
mode:
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)