Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH] catalyst: add a wrapper for executing directly out of git
Date: Tue, 10 Nov 2015 06:54:38
Message-Id: 20151109225345.5df4f6a5.dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH] catalyst: add a wrapper for executing directly out of git by Mike Frysinger
1 On Mon, 9 Nov 2015 16:05:45 -0500
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > This is a smaller wrapper to set up the environment (both python and
5 > some config options) so that all the code is used from the git repo.
6 > This way you don't have to install it in order to test things.
7 > ---
8 > bin/catalyst.git | 52
9 > ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed,
10 > 52 insertions(+) create mode 100755 bin/catalyst.git
11 >
12 > diff --git a/bin/catalyst.git b/bin/catalyst.git
13 > new file mode 100755
14 > index 0000000..eb6234b
15 > --- /dev/null
16 > +++ b/bin/catalyst.git
17 > @@ -0,0 +1,52 @@
18 > +#!/usr/bin/python
19 > +# -*- coding: utf-8 -*-
20 > +# Copyright 1999-2015 Gentoo Foundation
21 > +# Distributed under the terms of the GNU General Public License v2
22 > +
23 > +"""Run catalyst from git using local modules/scripts."""
24 > +
25 > +from __future__ import print_function
26 > +
27 > +import os
28 > +import sys
29 > +import tempfile
30 > +
31 > +from snakeoil import process
32 > +
33 > +
34 > +def main(argv):
35 > + """The main entry point"""
36 > + source_root =
37 > os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +
38 > + pympath = source_root
39 > + pythonpath = os.environ.get('PYTHONPATH')
40 > + if pythonpath is None:
41 > + pythonpath = pympath
42 > + else:
43 > + pythonpath = pympath + ':' + pythonpath
44 > + os.environ['PYTHONPATH'] = pythonpath
45 > +
46 > + with tempfile.NamedTemporaryFile(prefix='catalyst.conf.') as
47 > conf:
48 > + # Set up a config file with paths to the local tree.
49 > + conf.write(
50 > + ('sharedir=%(source_root)s\n'
51 > + 'shdir=%(source_root)s/targets\n'
52 > + 'envscript=%(source_root)s/etc/catalystrc\n'
53 > + % {'source_root':
54 > source_root}).encode('utf8')
55 > + )
56 > + conf.flush()
57 > + argv = [
58 > + '--config', os.path.join(source_root, 'etc',
59 > 'catalyst.conf'),
60 > + '--config', conf.name,
61 > + ] + argv
62 > +
63 > + cmd = [os.path.join(source_root, 'bin', 'catalyst')]
64 > + pid = os.fork()
65 > + if pid == 0:
66 > + os.execvp(cmd[0], cmd + argv)
67 > + (_pid, status) = os.waitpid(pid, 0)
68 > + process.exit_as_status(status)
69 > +
70 > +
71 > +if __name__ == '__main__':
72 > + main(sys.argv[1:])
73
74
75 huh, first time I looked at it, I missed seeing you were loading both
76 the main config and the temp config with the needed changes.
77
78 Looks good
79
80 --
81 Brian Dolbec <dolsen>