From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id AB1711384B4 for ; Tue, 10 Nov 2015 06:54:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3509221C004; Tue, 10 Nov 2015 06:54:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B0CA221C004 for ; Tue, 10 Nov 2015 06:54:37 +0000 (UTC) Received: from professor-x (S010634bdfa9ecf80.vc.shawcable.net [96.49.31.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id F095433FAAE for ; Tue, 10 Nov 2015 06:54:36 +0000 (UTC) Date: Mon, 9 Nov 2015 22:53:45 -0800 From: Brian Dolbec To: gentoo-catalyst@lists.gentoo.org Subject: Re: [gentoo-catalyst] [PATCH] catalyst: add a wrapper for executing directly out of git Message-ID: <20151109225345.5df4f6a5.dolsen@gentoo.org> In-Reply-To: <1447103145-18905-1-git-send-email-vapier@gentoo.org> References: <1447103145-18905-1-git-send-email-vapier@gentoo.org> Organization: Gentoo Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archives-Salt: 05508be3-d8ba-4fa0-a4f1-a0e4a19d2830 X-Archives-Hash: df7244fa9b09611aa0ab960e16fb58e9 On Mon, 9 Nov 2015 16:05:45 -0500 Mike Frysinger wrote: > 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. > --- > bin/catalyst.git | 52 > ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, > 52 insertions(+) create mode 100755 bin/catalyst.git > > 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:]) huh, first time I looked at it, I missed seeing you were loading both the main config and the temp config with the needed changes. Looks good -- Brian Dolbec