summaryrefslogtreecommitdiff
path: root/strip-gplv3.configure
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2013-05-28 16:36:28 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2013-05-29 11:50:25 +0100
commitcba63686deae6cf4d7de7ed101786f828d0c69b4 (patch)
tree9748c229e87d30564b7303caf68c49778413e447 /strip-gplv3.configure
parentae69c722332790788d8b1326a3b9781c7a1a344d (diff)
downloaddefinitions-cba63686deae6cf4d7de7ed101786f828d0c69b4.tar.gz
Add strip-gplv3 extension to genivi-baseline-systems
Diffstat (limited to 'strip-gplv3.configure')
-rwxr-xr-xstrip-gplv3.configure70
1 files changed, 70 insertions, 0 deletions
diff --git a/strip-gplv3.configure b/strip-gplv3.configure
new file mode 100755
index 00000000..26ad3e27
--- /dev/null
+++ b/strip-gplv3.configure
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+# Copyright (C) 2013 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+''' A Morph configuration extension for removing gplv3 chunks from a system
+
+Using a hard-coded list of chunks, it will read the system's /baserock metadata
+to find the files created by that chunk, then remove them.
+
+'''
+
+import cliapp
+import os
+import json
+
+class StripGPLv3ConfigureExtension(cliapp.Application):
+ gplv3_chunks = ['autoconf', 'bash', 'binutils', 'bison', 'ccache',
+ 'gawk', 'gdbm', 'gettext', 'gperf', 'groff', 'm4',
+ 'make', 'texinfo-tarball']
+
+ def process_args(self, args):
+ target_root = args[0]
+
+ for chunk in self.gplv3_chunks:
+ self.remove_chunk(target_root, chunk)
+
+ def remove_chunk(self, target_root, chunk):
+ chunk_meta_path = os.path.join(target_root, 'baserock',
+ chunk + '.meta')
+
+ with open(chunk_meta_path, 'r') as f:
+ 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)
+ for content_entry in reversed(chunk_meta_data['contents']):
+ self.remove_content_entry(target_root, content_entry)
+
+ os.remove(chunk_meta_path)
+
+ 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))
+ if os.path.exists(entry_path):
+ if os.path.islink(entry_path):
+ os.unlink(entry_path)
+ elif os.path.isfile(entry_path):
+ os.remove(entry_path)
+ elif os.path.isdir(entry_path):
+ 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()