def __init__(self, buildout, name, options): BaseRecipe.__init__(self, buildout, name, options) self.options.setdefault('varnish_version', DEFAULT_VERSION) self._version_check() self.options.setdefault( 'url', DEFAULT_DOWNLOAD_URLS[options.get('varnish_version')]) self.options.setdefault('jobs', '4') CMMIRecipe.__init__(self, buildout, name, self.options)
def __init__(self, buildout, name, options): BaseRecipe.__init__(self, buildout, name, options) self.options.setdefault('varnish_version', DEFAULT_VERSION) self._version_check() self.options.setdefault( 'url', DEFAULT_DOWNLOAD_URLS[options.get('varnish_version')] ) self.options.setdefault('jobs', '4') CMMIRecipe.__init__(self, buildout, name, self.options)
def build(self): # build varnish super(BuildRecipe, self).build() if zc.buildout.buildout.bool_option(self.options, 'compile-vmods', False): if 'PKG_CONFIG_PATH' not in self.environ: self.environ['PKG_CONFIG_PATH'] = os.path.join( self.options["location"], "lib", "pkgconfig") os.environ.update(self.environ) vmods_options = { k[6:]: v for k, v in self.options.items() if k.startswith('vmods_') } vmods_options.setdefault('url', VMODS_DOWNLOAD_URL) vmods_options.setdefault('source-directory-contains', 'bootstrap') vmods_options.setdefault('configure-command', './bootstrap; ./configure') vmods_recipe = CMMIRecipe(self.buildout, self.name, vmods_options) vmods_recipe.build()
def install(self): """installer""" # building extra options owner = self.options.get('owner', utils.get_sysuser()) group = self.options.get('group', utils.get_sysgroup()) ssl_dir = self.options.get('ssl_dir', None) t_rsa = self.options.get('t_rsa', None) extra_options = self.options.get('extra-options', '') extra = '' if '--with-owner' not in extra_options: extra += ' --with-owner=%s' % owner if '--with-group' not in extra_options: extra += ' --with-group=%s' % group if ssl_dir is not None: if os.path.isdir(ssl_dir): extra += ' --with-ssl=%s' % ssl_dir else: self.logger.error( "You need to specify an valid directory for ssl directory") raise zc.buildout.UserError("ssl directory is invalid") if t_rsa is not None: try: t_rsa = int(t_rsa) extra += ' --with-t_rsa=%d' % (t_rsa,) except ValueError: self.logger.error( "You need to specify an integer for timeout rsa") raise zc.buildout.UserError("Time out rsa is invalid") if extra_options is not None: extra += ' %s' % (extra_options,) self.logger.info('compilation option : %s' % (extra,)) self.extra_options = extra # uses cmmi installer installed = CMMIRecipe.install(self) # building the script that launches pound command = os.path.join(self.options['location'], 'sbin', 'pound') var_dir = os.path.join(self.options['location'], 'var') pid = os.path.join(var_dir, 'pound.pid') script = TEMPLATE % {'pound': command, 'cfg': self.getFileNameConfig(), 'pid': pid} bin_dir = self.buildout['buildout']['bin-directory'] script_name = os.path.join(bin_dir, self.name) f = open(script_name, 'wb') f.write(script) f.close() mode = os.stat(script_name).st_mode os.chmod(script_name, mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) return (installed, script_name)
def install(self): """Installer""" options = self.options parts = self.buildout['buildout']['parts-directory'] name = options['url'].split('/')[-1].replace('.tar.gz', '') node_dir = os.path.join(parts, self.name) if not os.path.isdir(node_dir): os.makedirs(node_dir) node_binary = options.get('binary', os.path.join(parts, name, 'bin', 'node')) node_bin = os.path.dirname(node_binary) if not os.path.isfile(node_binary): from zc.recipe.cmmi import Recipe as Cmmi options['environment'] = 'PYTHONPATH=tools:deps/v8/tools' node = Cmmi(self.buildout, name, options) node.install() options['on_install'] = 'true' options['on_update'] = 'true' if not os.path.isfile(os.path.join(node_bin, 'npm')): p = subprocess.Popen(( 'curl -sk https://npmjs.org/install.sh > install.sh&&' 'PATH=%s:$PATH ' 'clean=yes sh install.sh&&rm install.sh' ) % (node_bin,), shell=True) p.wait() scripts = [script.strip() for script in options['scripts'].split() \ if script.strip()] npms = options.get('npms', '') if npms: npms = ' '.join([npm.strip() for npm in npms.split() \ if npm.strip()]) p = subprocess.Popen(('export HOME=%(node_dir)s;' 'export PATH=%(node_bin)s:$PATH;' 'echo "prefix=$HOME" > $HOME/.npmrc;' '%(node_bin)s/npm install -g %(npms)s' ) % locals(), shell=True) p.wait() for script in scripts: if script in ['node']: continue filename = os.path.join(node_bin, script) if os.path.isfile(filename): fd = open(filename) data = fd.read() fd.close() fd = open(filename, 'w') fd.seek(0) data = data.split('\n') data[0] = '#!%s' % node_binary fd.write('\n'.join(data)) fd.close() if 'node' not in scripts: scripts.append('node') node_path = options.get('node-path', '').split() node_path.insert(0, os.path.join(node_dir, 'lib', 'node_modules')) node_path = ':'.join(node_path) options['initialization'] = \ 'import os;\nos.environ["NODE_PATH"] = %r' % node_path options['eggs'] = 'gp.recipe.node' options['arguments'] = '%r, (%r, %r), sys.argv[0]' % ( node_binary, os.path.join(node_dir, 'bin'), node_bin, ) options['entry-points'] = '\n'.join([ '%s=gp.recipe.node.script:main' % s for s in scripts ]) from zc.recipe.egg import Scripts rscripts = Scripts(self.buildout, self.name, options) return rscripts.install()
def __init__(self, buildout, name, options): CMMIRecipe.__init__(self, buildout, name, options) self.buildout = buildout self.logger=logging.getLogger(self.name)
def __init__(self, buildout, name, options): BaseRecipe.__init__(self, buildout, name, options) self.options.setdefault('url', DOWNLOAD_URL) self.options.setdefault('jobs', '4') CMMIRecipe.__init__(self, buildout, name, self.options)