aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-10-28 20:29:52 -0400
committerMike Frysinger <vapier@gentoo.org>2015-11-18 22:40:51 -0500
commit16f3af32eb645f3485e9e54b2bb9d128503fa9ce (patch)
tree75d8ff1e02b960076b4313b865cfb4c5d43e1c7c
parentcatalyst: switch to common python entry (diff)
downloadcatalyst-16f3af32eb645f3485e9e54b2bb9d128503fa9ce.tar.gz
catalyst-16f3af32eb645f3485e9e54b2bb9d128503fa9ce.tar.bz2
catalyst-16f3af32eb645f3485e9e54b2bb9d128503fa9ce.zip
catalyst: add a wrapper for executing directly out of git
This is a smaller wrapper to set up the environment (both python and some config options) so that all the code is used from the git repo. This way you don't have to install it in order to test things.
-rwxr-xr-xbin/catalyst.git52
1 files changed, 52 insertions, 0 deletions
diff --git a/bin/catalyst.git b/bin/catalyst.git
new file mode 100755
index 0000000..eb6234b
--- /dev/null
+++ b/bin/catalyst.git
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Run catalyst from git using local modules/scripts."""
+
+from __future__ import print_function
+
+import os
+import sys
+import tempfile
+
+from snakeoil import process
+
+
+def main(argv):
+ """The main entry point"""
+ source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+
+ pympath = source_root
+ pythonpath = os.environ.get('PYTHONPATH')
+ if pythonpath is None:
+ pythonpath = pympath
+ else:
+ pythonpath = pympath + ':' + pythonpath
+ os.environ['PYTHONPATH'] = pythonpath
+
+ with tempfile.NamedTemporaryFile(prefix='catalyst.conf.') as conf:
+ # Set up a config file with paths to the local tree.
+ conf.write(
+ ('sharedir=%(source_root)s\n'
+ 'shdir=%(source_root)s/targets\n'
+ 'envscript=%(source_root)s/etc/catalystrc\n'
+ % {'source_root': source_root}).encode('utf8')
+ )
+ conf.flush()
+ argv = [
+ '--config', os.path.join(source_root, 'etc', 'catalyst.conf'),
+ '--config', conf.name,
+ ] + argv
+
+ cmd = [os.path.join(source_root, 'bin', 'catalyst')]
+ pid = os.fork()
+ if pid == 0:
+ os.execvp(cmd[0], cmd + argv)
+ (_pid, status) = os.waitpid(pid, 0)
+ process.exit_as_status(status)
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])