Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from mbacchi/pkg_config
Browse files Browse the repository at this point in the history
ship config.yml to /usr/share and copy to user home ~/.calyptos
  • Loading branch information
viglesiasce committed Jun 9, 2015
2 parents 3e32d88 + c878e0e commit 6cdc3d5
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include MANIFEST.in
include README.md
include euca-deploy.spec
include calyptos.spec
include etc/config.yml
include examples/*
44 changes: 43 additions & 1 deletion bin/calyptos
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,50 @@ import argparse
from fabric.colors import yellow
from stevedore import driver, extension
from calyptos.rolebuilder import RoleBuilder
import os
import shutil

dot_dir = os.path.expanduser('~/.calyptos')
# by default we look in users home dir first
default_cfgfile = os.path.join(dot_dir, "config.yml")
cfglist = []
cfglist.append(default_cfgfile)
cfglist.append('/usr/share/calyptos/config.yml')

def locate_cfgfile():
# if we find that the config file is in /usr/share
# but the rpm is not installed, we copy it to ~/.calyptos
# because that means calyptos was installed by setup.py
for item in cfglist:
if os.path.isfile(item):
if item != default_cfgfile:
import rpm # I think this is required by other parts of python so I'm safe using it
ts = rpm.TransactionSet()
mi = ts.dbMatch("name","calyptos")
if (len(mi) == 0):
if not os.path.isfile(default_cfgfile):
if not os.path.exists(dot_dir):
try:
os.makedirs(dot_dir)
except OSError as e:
print('Error: cannot create directory ~/.calyptos: %s' % e)
try:
# if this copy works, return default_cfgfile
# because it will be used going forward
shutil.copy('/usr/share/calyptos/config.yml', default_cfgfile)
return default_cfgfile
except shutil.Error as e:
print('Error: %s' % e)
except IOError as e:
print('Error: %s' % e.strerror)
# this is not in an else: block because its a
# last resort for the case where import rpm
# doesn't succeed above, because we still need
# to return a valid config file name
return item

if __name__ == '__main__':
cfgfile = locate_cfgfile()
parser = argparse.ArgumentParser()
default_repo = 'https://github.com/eucalyptus/eucalyptus-cookbook'
parser.add_argument('operation', choices=['validate',
Expand All @@ -13,7 +55,7 @@ if __name__ == '__main__':
'provision',
'debug',
'uninstall'])
parser.add_argument('-c', '--config', default='etc/config.yml')
parser.add_argument('-c', '--config', default=cfgfile)
parser.add_argument('-e', '--environment', default='etc/environment.yml')
parser.add_argument('-p', '--password', default='foobar')
parser.add_argument('-b', '--branch', default='euca-4.2')
Expand Down
10 changes: 4 additions & 6 deletions calyptos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ Provisions the rest of the system or update the configuration of an existing sys
### Debug
#### Not yet implemented!!!
This step will grab all necessary information from a system in order to provide artifacts for use in debugging a problem.






%prep
Expand All @@ -81,15 +79,15 @@ This step will grab all necessary information from a system in order to provide
%{__python2} setup.py build

%install
%{__python2} setup.py install --skip-build --root=$RPM_BUILD_ROOT
%{__python2} setup.py install --skip-build --root=$RPM_BUILD_ROOT --single-version-externally-managed

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/usr/bin/calyptos
%{python_sitelib}/eucadeploy/*
%{python_sitelib}/calyptos/*
%{python_sitelib}/*.egg-info
%config /etc/calyptos/config.yml
/usr/share/calyptos/config.yml
/usr/share/calyptos/examples/*
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ def make_release_tree(self, base_dir, files):
'build_py': build_py_with_git_version,
'sdist': sdist_with_git_version
},
#data_files=[('/etc/calyptos/', ['etc/config.yml']),
# ('/usr/share/calyptos/examples/', example_items)],
data_files=[('/usr/share/calyptos', ['etc/config.yml']),
('/usr/share/calyptos/examples/', example_items)],
)

0 comments on commit 6cdc3d5

Please sign in to comment.