Permalink
Browse files

The as.recipe.frozenpkg recipe is no longer here

Minor chages
  • Loading branch information...
1 parent 115c2ba commit 7aa10d7161db3df9b39cd78647733b0336d37b59 Alvaro Saurin committed Mar 18, 2013
View
@@ -13,3 +13,5 @@ install:
# command to run tests
# script: nosetests -v -w tests
+script: /bin/true
+
View
@@ -129,7 +129,7 @@ clean-dcache:
clean: clean-pyc
@echo ">>> Cleaning stuff..."
- rm -rf $(TOP)/bin $(TOP)/doc $(TOP)/dist
+ rm -rf $(TOP)/bin $(TOP)/doc $(TOP)/dist $(TOP)/var
rm -rf $(TOP)/conf/*.conf $(TOP)/conf/*/*.conf
rm -rf $(TOP)/*.spec $(TOP)/buildout/packaging/*.spec
rm -rf $(TOP)/develop-eggs $(TOP)/eggs $(TOP)/html
View
@@ -6,7 +6,7 @@
extends = buildout/presets.cfg
relative-paths = true
-develop = buildout/recipes/frozenpkg
+develop = sources
virtualenv = ${buildout:directory}
conf-directory = ${buildout:directory}/conf
@@ -1,2 +0,0 @@
-
-
@@ -1,16 +0,0 @@
-
-PYTHON=python2.6
-
-all: build
-
-build:
- $(PYTHON) ./setup.py bdist_egg sdist
-
-upload: build
- $(PYTHON) ./setup.py bdist_egg sdist upload
-
-clean:
- rm -rf dist build *.egg-info
-
-distclean: clean
- rm -rf bin develop-eggs eggs parts
@@ -1,90 +0,0 @@
-Introduction
-============
-
-This recipe enables you to freeze your buildout in a RPM, tgz's, etc.
-You can specify the package details, the installation prefix, and the eggs and
-scripts that must be copied to the package.
-
-Only RPM packing is currently implemented.
-
-This recipe is EXPERIMENTAL and quite unstable, so use at your own risk...
-
-.. contents::
-
-- PyPI page: http://pypi.python.org/pypi?:action=display&name=as.recipe.frozenpkg
-
-Options
-=======
-
- pkg-name
- Mandatory. The package name.
-
- pkg-version
- The package version.
-
- pkg-vendor
- The package vendor.
-
- pkg-packager
- The packager.
-
- pkg-url
- The package URL.
-
- pkg-license
- The license.
-
- pkg-deps
- Package dependencies. It must be a space-separated list of RPM packages.
-
- install-prefix
- The installation prefix. Default: /opt/pkg-name
-
- eggs
- The list of eggs that must be copied to the RPM package.
-
- scripts
- The scripts that will be copied to the package. Tese scripts will have their paths relocated to the installation prefix.
-
- extra-copies
- Any additional extra copies. They must be specified as "orig -> dest", where orig can be any valid glob expression, and dest must be a path relative to install-prefix.
-
- pkg-pre-install
- Shell commands to run before installing the RPM
-
- pkg-post-install
- Shell commands to run after installing the RPM
-
-
-Example
-=======
-
- [rpm]
- recipe = as.recipe.frozenpkg:rpm
- pkg-name = testapp
- pkg-version = 1.0
- pkg-vendor = The Vendor
- pkg-packager = My Company
- pkg-url = http://www.mycomp.com
- pkg-license = GPL
- pkg-deps = libevent
-
- install-prefix = /opt/testapp
-
- eggs = ${main:eggs}
-
- scripts =
- testapp
-
- extra-copies =
- /usr/local/lib/mylib.so -> lib/
- /usr/local/lib/myextras*.so -> lib/
-
- pkg-pre-install =
- echo "Installing at ${buildout:pkg-prefix}"
-
- pkg-post-install =
- echo "Installed at ${buildout:pkg-prefix}"
-
- debug = yes
-
@@ -1,7 +0,0 @@
-# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
-try:
- __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
- from pkgutil import extend_path
- __path__ = extend_path(__path__, __name__)
-
@@ -1,7 +0,0 @@
-# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
-try:
- __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
- from pkgutil import extend_path
- __path__ = extend_path(__path__, __name__)
-
@@ -1,7 +0,0 @@
-
-
-__all__ = ['frozen', 'frozenrpm', 'frozenpkg']
-
-from frozen import *
-from frozenrpm import *
-from frozentgz import *
@@ -1,212 +0,0 @@
-
-
-import os
-import sys
-import shutil
-import logging
-import glob
-
-import subprocess
-
-
-
-import logging
-logger = logging.getLogger(__name__)
-
-
-
-################################################################################
-
-class Frozen(object):
- """
- Frozen packages base class
- """
-
- def __init__ (self, buildout, name, options):
- self.name = name
- self.options = options
- self.buildout = buildout
- self.logger = logging.getLogger(self.name)
-
- # patch some options
- self.eggs = self.options["eggs"]
-
- debug = options.get('debug', '').lower()
- if debug in ('yes', 'true', 'on', '1', 'sure'):
- self.debug = True
- else:
- self.debug = False
-
- ############################################################################
-
-
- def _create_venv(self, root_dir):
- """
- Create a virtualenv in a directory
- """
-
- ## we cannot use the Virtualenv library: there is something broken that do not allows us
- ## to use it as a library...
-
- virtualenv = [
- 'virtualenv',
- '--distribute',
- '--no-site-packages',
- '--clear',
- root_dir,
- ]
-
- logger.debug('Launching "%s"' % (" ".join(virtualenv)))
- job = subprocess.Popen(virtualenv,
- stdout = subprocess.PIPE,
- stderr = subprocess.STDOUT)
- stdout, _ = job.communicate()
-
- if job.returncode != 0:
- logger.critical('could not run virtualenv')
- sys.exit(1)
-
-
- def _copy_eggs (self, root_dir):
- """
- Copy all the required eggs to the virtualenv
- """
- bin_dir = os.path.join(root_dir, 'bin')
-
- easy_install = os.path.join(bin_dir, 'easy_install')
- if not os.path.exists(easy_install):
- logger.critical('could not find easy_install at %s' % easy_install )
- sys.exit(1)
-
- logger.debug('Copying eggs')
- eggs_dir = os.path.join(self.buildout['buildout']['directory'], 'eggs')
- for egg in glob.glob(os.path.join(eggs_dir, '*.egg')):
- logger.debug('... copying "%s"' % egg)
- command = [easy_install, '--no-deps', egg]
- job = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
- stdout, _ = job.communicate()
-
- if job.returncode != 0:
- logger.critical('could run easy_install: %s' % stdout)
- raise Exception(stdout)
-
- def _copy_outputs(self, root_dir):
- """
- Copies the outputs from parts
- :param root_dir: the root directory where to copy things
- """
- buildout_dir = self.buildout['buildout']['directory']
- for part in self.buildout['buildout']['parts'].split():
- try:
- outputs = self.buildout[part]['output']
- for output in outputs.splitlines():
- rel_dir = os.path.relpath(output, buildout_dir)
- dest_dir = os.path.join(root_dir, os.path.dirname(rel_dir))
-
- logger.debug('Copying %s -> %s' % (rel_dir, dest_dir))
- if not os.path.exists(dest_dir):
- os.makedirs(dest_dir)
- shutil.copy2(output, dest_dir)
-
- except KeyError:
- pass
-
-
- def _copy_extra_files (self, root_dir, install_prefix):
- """
- Copy any extra files, from the 'extra' options in the buildout
- :param root_dir: the root directory where to copy things
- """
- assert (root_dir != None and len(root_dir) > 0)
- assert (install_prefix != None and len(install_prefix) > 0)
-
- pythonpath = []
-
- buildroot = os.path.normpath(os.path.join(root_dir, install_prefix))
- buildout_dir = self.buildout['buildout']['directory']
-
- extra_copies = [
- r.strip()
- for r in self.options.get('extra-copies', self.name).split('\n')
- if r.strip()]
-
- for copy_line in extra_copies:
- try:
- src, dest = [b.strip() for b in copy_line.split("->")]
- except Exception, e:
- print "ERROR: malformed copy specification", e
- return pythonpath
-
- if not os.path.isabs(src):
- src = os.path.join(buildout_dir, src)
-
- full_path_dest = os.path.normpath(os.path.join(buildroot, dest))
- for src_el in glob.glob(src):
- logger.debug('Copying %s' % src_el)
- try:
- if os.path.isdir(src_el):
- shutil.copytree(src_el, full_path_dest)
- else:
- # maybe the destination is a directory: then we have to
- # create it at the target too...
- if dest.endswith('/') and not os.path.exists(full_path_dest):
- logger.debug('... creating %s directory' % dest)
- os.makedirs(full_path_dest)
-
- shutil.copy(src_el, full_path_dest)
-
- except Exception, e:
- logger.debug('ERROR: when copying %s to %s' % (src_el, full_path_dest))
-
- return pythonpath
-
-
- def _prepare_venv(self, root_dir):
- """
- Finish the virtualenv by making it relocatable and removing some extra things we do not need...
- """
-
- virtualenv = [
- 'virtualenv',
- '--relocatable',
- root_dir,
- ]
-
- logger.debug('Launching "%s"' % (" ".join(virtualenv)))
- job = subprocess.Popen(virtualenv,
- stdout = subprocess.PIPE,
- stderr = subprocess.STDOUT)
- stdout, _ = job.communicate()
-
- if job.returncode != 0:
- logger.critical('could not run virtualenv')
- sys.exit(1)
-
- local_dir = os.path.join(root_dir, "local")
- logger.debug('Removing"%s"' % local_dir)
- shutil.rmtree(local_dir)
-
-
- def _create_tar (self, root_dir, filename, compress = False):
- """
- Create a tar file from the virtualenv
- """
- import tarfile
- with tarfile.open(filename, 'w' if not compress else 'w:gz', dereference = True) as t:
- for name in glob.glob(os.path.join(root_dir, '*')):
- rel_name = '/' + os.path.relpath(name, root_dir)
- t.add(name, arcname = rel_name)
-
- if compress:
- return os.path.join(filename + ".gz")
- else:
- return filename
-
-
-################################################################################
-
-if __name__ == '__main__':
- f = Frozen()
-
-
-
Oops, something went wrong.

0 comments on commit 7aa10d7

Please sign in to comment.