Skip to content

Commit

Permalink
Merge pull request fabtools#73 from scalp42/rpm_support
Browse files Browse the repository at this point in the history
CentOS/RHEL/SL support
  • Loading branch information
ronnix committed Feb 11, 2013
2 parents d5016ef + ac6302f commit 8c145e8
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ Supported targets
* Ubuntu 10.04 (lucid)
* Ubuntu 12.04 (precise)

* SmartOS (Joyent)
* RHEL 5/6
* CentOS 5/6
* Scientific Linux 5/6

* SmartOS (Joyent)

Contributions to help support other Unix/Linux distributions are welcome!
1 change: 1 addition & 0 deletions fabtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import fabtools.pkg
import fabtools.python
import fabtools.python_distribute
import fabtools.rpm
import fabtools.service
import fabtools.shorewall
import fabtools.supervisor
Expand Down
1 change: 1 addition & 0 deletions fabtools/require/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import fabtools.require.pkg
import fabtools.require.python
import fabtools.require.redis
import fabtools.require.rpm
import fabtools.require.service
import fabtools.require.shorewall
import fabtools.require.supervisor
Expand Down
10 changes: 5 additions & 5 deletions fabtools/require/deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def ppa(name):
"""
Require a `PPA`_ package source.
::
Example::
from fabtools import require
Expand All @@ -65,7 +65,7 @@ def package(pkg_name, update=False):
"""
Require a deb package to be installed.
::
Example::
from fabtools import require
Expand All @@ -79,7 +79,7 @@ def packages(pkg_list, update=False):
"""
Require several deb packages to be installed.
::
Example::
from fabtools import require
Expand All @@ -98,7 +98,7 @@ def nopackage(pkg_name):
"""
Require a deb package to be uninstalled.
::
Example::
from fabtools import require
Expand All @@ -112,7 +112,7 @@ def nopackages(pkg_list):
"""
Require several deb packages to be uninstalled.
::
Example::
from fabtools import require
Expand Down
127 changes: 127 additions & 0 deletions fabtools/require/rpm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
"""
Rpm packages
===============
This module provides high-level tools for managing CentOS/RHEL/SL packages
and repositories.
"""
from __future__ import with_statement

from fabtools.system import get_arch
from fabtools.rpm import *


def package(pkg_name, repos=None, yes=None, options=None):
"""
Require a rpm package to be installed.
Example::
from fabtools import require
require.rpm.package('emacs')
"""
if not is_installed(pkg_name):
install(pkg_name, repos, yes, options)


def packages(pkg_list, repos=None, yes=None, options=None):
"""
Require several rpm packages to be installed.
Example::
from fabtools import require
require.rpm.packages([
'nano',
'unzip',
'vim',
])
"""
pkg_list = [pkg for pkg in pkg_list if not is_installed(pkg)]
if pkg_list:
install(pkg_list, repos, yes, options)


def nopackage(pkg_name, options=None):
"""
Require a rpm package to be uninstalled.
Example::
from fabtools import require
require.rpm.nopackage('emacs')
"""
if is_installed(pkg_name):
uninstall(pkg_name, options)


def nopackages(pkg_list, options=None):
"""
Require several rpm packages to be uninstalled.
Example::
from fabtools import require
require.rpm.nopackages([
'unzip',
'vim',
'emacs',
])
"""
pkg_list = [pkg for pkg in pkg_list if is_installed(pkg)]
if pkg_list:
uninstall(pkg_list, options)


def repository(name):
"""
Require a repository. Aimed for 3rd party repositories.
*Name* currently only supports EPEL and RPMforge.
Example::
from fabtools import require
# RPMforge packages for CentOS 6
require.rpm.repository('rpmforge')
"""
name = name.lower()
epel_url = 'http://download.fedoraproject.org/pub/epel'
rpmforge_url = 'http://packages.sw.be/rpmforge-release/rpmforge-release'
rpmforge_version = '0.5.2-2'
arch = get_arch()
try:
release = int(str(distrib_release()))
except ValueError:
release = int(float(str(distrib_release())))
if release == 6:
epel_version = '6-8'
elif release == 5:
epel_version = '5-4'
if name == 'rpmforge' and arch == 'i386':
arch = 'i686'
supported = {
'rpmforge': {'%(arch)s' % locals(): {
'6': '%(rpmforge_url)s-%(rpmforge_version)s.el6.rf.i686.rpm' % locals(),
'5': '%(rpmforge_url)s-%(rpmforge_version)s.el5.rf.x86_64.rpm' % locals()},
'epel': { '%(arch)s' % locals(): {
'6': '%(epel_url)s/6/%(arch)s/epel-release-%(epel_version)s.noarch.rpm' % locals(),
'5': '%(epel_url)s/5/%(arch)s/epel-release-%(epel_version)s.noarch.rpm' % locals()}}
}}
keys = {
'rpmforge': 'http://apt.sw.be/RPM-GPG-KEY.dag.txt',
'epel': '%(epel_url)s/RPM-GPG-KEY-EPEL-%(release)s' % locals()
}
repo = supported[name][str(arch)][str(release)]
key = keys[name]
with settings(hide('warnings'), warn_only=True):
sudo('rpm --import %(key)s' % locals())
sudo('rpm -Uh %(repo)s' % locals())
Loading

0 comments on commit 8c145e8

Please sign in to comment.