Commits

Taras KulaPard committed 866df83

add example fabfile.py

Comments (0)

Files changed (2)

             static/
 """
 
-# TODO: use virtualenv-clone script to move virtualenv from /tmp to working directory after unpacking
+# TODO: use virtualenv-clone or virtualenv-tools script to move virtualenv from /tmp to working directory after unpacking
 
 import sys
 import os.path
     Using:
     >>> from alexis.rhel import Deployment
     >>> deploy = Deployment(prefix, app_name)
-    >>> deploy.prepare_app(repository, branch)
+    >>> deploy.prepare_app(hg_repository, branch)
     >>> deploy.build_rpm()
 
     As result - downloading rpm packages in local ./rhel directory
         self.static_path = os.path.join(self.app_path, 'static')
 
     @with_settings(user='buildbot')
-    def prepare_app(self, repository, branch, python_path='/usr/bin/python', static_dir='static'):
+    def prepare_app(self, hg_repository, branch, python_path='/usr/bin/python', static_dir='static'):
         """
         Create default directories, create a virtualenv, check out src.
 
-        `repository` - source code repository (URL or path)
-        `branch` - repository branch name
+        `hg_repository` - source code hg_repository (URL or path)
+        `branch` - hg_repository branch name
         `python_path` - path to python
-        `static_dir` - path to static in source code repository
+        `static_dir` - path to static in source code hg_repository
         """
         run('rm -rf {0.base_path}'.format(self))
-        self.hg_repository = repository
+        self.hg_repository = hg_repository
         self.hg_branch = branch
         self.hg_clone()
         with cd(self.src_path):
             os.path.join(self.src_path, 'conf', 'requirements.txt'))
         )
         # If app need to be installed into virtualenv lets do it
-#        with cd(self.src_path):
-#            if os.path.exists('setup.py'):
-#                run('{} setup.py install'.format(os.path.join(self.venv_path, 'bin/python')))
+
+    #        with cd(self.src_path):
+    #            if os.path.exists('setup.py'):
+    #                run('{} setup.py install'.format(os.path.join(self.venv_path, 'bin/python')))
 
     @with_settings(user='buildbot')
     def build_rpm(self):

examples/fabfile.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from fabric.api import env, local, run, sudo, roles, cd, with_settings, put, get
+from alexis.rhel import Deployment
+
+env.roledefs = {
+    'buildserver': ['builder.dev.server.com'],
+}
+
+PREFIX = 'blablacompany'
+APP_NAME = 'superapp'
+
+@with_settings(user='user')
+@roles('buildserver')
+def rpm(branch='release'):
+    """
+    Create RPM package
+    """
+    deploy = Deployment(
+        prefix=PREFIX,
+        app_name=APP_NAME,
+        version='1.0.0',
+        release='1',
+        build_deps=[
+            'python-devel',
+            'libpqxx',
+            'libpqxx-devel',
+            'postgresql91',
+            'libxml2',
+            'libxml2-devel',
+            'libxslt',
+            'libxslt-devel'
+        ],
+        run_deps=[
+            'postgresql91',
+            'libpqxx',
+            'libxml2',
+            'libxslt'
+        ],
+    )
+    deploy.prepare_app(
+        hg_repository='ssh://hg.server.org/app_name',
+        branch=branch,
+        static_dir='app1/static',
+        python_path='/usr/bin/python3.2'
+    )
+    deploy.build_rpm()