From 7a70b5bb80c69dafc345dfd4df577bfb1e983ee9 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Thu, 20 Sep 2007 16:09:20 -0400 Subject: first pass at packaging stuff version is 0.11-1 (this one goes to .11) "make rpms" should build a rpm from the setup.py and func.spec --- MANIFEST.in | 6 ++++ Makefile | 57 +++++++++++++++++++++++++++++++++ certs/slave-keys.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++ client/__init__.py | 0 func.spec | 61 +++++++++++++++++++++++++++++++++++ func/slave-keys.py | 80 ---------------------------------------------- init-scripts/funcd | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ settings | 1 + setup.py | 68 +++++++++++++++++++++++++++++++++++++++ version | 1 + 10 files changed, 365 insertions(+), 80 deletions(-) create mode 100644 MANIFEST.in create mode 100755 Makefile create mode 100644 certs/slave-keys.py create mode 100644 client/__init__.py create mode 100644 func.spec delete mode 100644 func/slave-keys.py create mode 100755 init-scripts/funcd create mode 100644 settings create mode 100644 setup.py create mode 100644 version diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..d5ed9be --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include settings +include version +recursive-include docs * +recursive-include init-scripts * +recursive-include po *.po +recursive-include po *.pot diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..b831591 --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +VERSION = $(shell echo `awk '{ print $$1 }' version`) +RELEASE = $(shell echo `awk '{ print $$2 }' version`) +NEWRELEASE = $(shell echo $$(($(RELEASE) + 1))) + +MESSAGESPOT=po/messages.pot + +all: rpms + +clean: + -rm -f MANIFEST + -rm -rf dist/ build/ + -rm -rf *~ + -rm -rf rpm-build/ + +#manpage: +# pod2man --center="cobbler" --release="" cobbler.pod | gzip -c > cobbler.1.gz +# pod2html cobbler.pod > cobbler.html + +#test: +# python tests/tests.py +# -rm -rf /tmp/_cobbler-* + +messages: server/*.py + xgettext -k_ -kN_ -o $(MESSAGESPOT) server/*.py + sed -i'~' -e 's/SOME DESCRIPTIVE TITLE/func/g' -e 's/YEAR THE PACKAGE'"'"'S COPYRIGHT HOLDER/2007 Red Hat, inc. /g' -e 's/FIRST AUTHOR , YEAR/Adrian Likins , 2007/g' -e 's/PACKAGE VERSION/func $(VERSION)-$(RELEASE)/g' -e 's/PACKAGE/func/g' $(MESSAGESPOT) + + +bumprelease: + -echo "$(VERSION) $(NEWRELEASE)" > version + +setversion: + -echo "$(VERSION) $(RELEASE)" > version + +build: clean + python setup.py build -f + +install: build + python setup.py install -f + +sdist: clean messages + python setup.py sdist + +new-rpms: bumprelease rpms + + +rpms: sdist + mkdir -p rpm-build + cp dist/*.gz rpm-build/ + cp version rpm-build/ + rpmbuild --define "_topdir %(pwd)/rpm-build" \ + --define "_builddir %{_topdir}" \ + --define "_rpmdir %{_topdir}" \ + --define "_srcrpmdir %{_topdir}" \ + --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \ + --define "_specdir %{_topdir}" \ + --define "_sourcedir %{_topdir}" \ + -ba func.spec diff --git a/certs/slave-keys.py b/certs/slave-keys.py new file mode 100644 index 0000000..dee0fd5 --- /dev/null +++ b/certs/slave-keys.py @@ -0,0 +1,80 @@ +#!/usr/bin/python -tt + +import sys +import os +import os.path +from OpenSSL import crypto +import socket + + +def_country = 'UN' +def_state = 'FC' +def_local = 'Func-ytown' +def_org = 'func' +def_ou = 'slave-key' + +cert_dir = '/home/skvidal/tmp/t' +key_file = '%s/slave.pem' % cert_dir +csr_file = '%s/slave.csr' % cert_dir + + +def make_cert(dest=None): + pkey = crypto.PKey() + pkey.generate_key(crypto.TYPE_RSA, 2048) + if dest: + destfo = open(dest, 'w') + destfo.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)) + destfo.close() + + return pkey + +def make_csr(pkey, dest=None, cn=None): + req = crypto.X509Req() + req.get_subject() + subj = req.get_subject() + subj.C = def_country + subj.ST = def_state + subj.L = def_local + subj.O = def_org + subj.OU = def_ou + if cn: + subj.CN = cn + else: + subj.CN = socket.getfqdn() + subj.emailAddress = 'root@%s' % subj.CN + + req.set_pubkey(pkey) + req.sign(pkey, 'md5') + if dest: + destfo = open(dest, 'w') + destfo.write(crypto.dump_certificate_request(crypto.FILETYPE_PEM, req)) + destfo.close() + + return req + +def retrieve_key_from_file(keyfile): + fo = open(keyfile, 'r') + buf = fo.read() + keypair = crypto.load_privatekey(crypto.FILETYPE_PEM, buf) + return keypair + +def main(): + keypair = None + try: + if not os.path.exists(cert_dir): + os.makedirs(cert_dir) + if not os.path.exists(key_file): + keypair = make_cert(dest=key_file) + if not os.path.exists(csr_file): + if not keypair: + keypair = retrieve_key_from_file(key_file) + csr = make_csr(keypair, dest=csr_file) + except: + return 1 + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) + \ No newline at end of file diff --git a/client/__init__.py b/client/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/func.spec b/func.spec new file mode 100644 index 0000000..2ad7d6f --- /dev/null +++ b/func.spec @@ -0,0 +1,61 @@ + +%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} + +Summary: func remote config, monitoring, and management api +Name: func +Source1: version +Version: %(echo `awk '{ print $1 }' %{SOURCE1}`) +Release: %(echo `awk '{ print $2 }' %{SOURCE1}`)%{?dist} +Source0: %{name}-%{version}.tar.gz +License: GPL +Group: Applications/System +Requires: python >= 2.3 +Requires: rhpl +Requires: yum-utils +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot +BuildArch: noarch +Url: https://hosted.fedoraproject.org/projects/func/ + +%description + +func is a remote api for mangement, configation, and monitoring of systems. +%prep +%setup -q +%build +%{__python} setup.py build + +%install +test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT +%{__python} setup.py install --root=$RPM_BUILD_ROOT + +%files +%{_bindir}/funcd +/etc/init.d/funcd +#%dir /var/lib/virt-factory +%config(noreplace) /etc/func/settings +%dir %{python_sitelib}/func +%dir %{python_sitelib}/func/server +%dir %{python_sitelib}/func/client +%{python_sitelib}/func/server/*.py* +%{python_sitelib}/func/client/*.py* + +%dir %{python_sitelib}/func/server/modules +%{python_sitelib}/func/server/modules/*.py* +%dir %{python_sitelib}/func/server/yaml +%{python_sitelib}/func/server/yaml/*.py* +%dir /var/log/func + +%post +/sbin/chkconfig --add funcd +exit 0 + +%preun +if [ "$1" = 0 ] ; then + /sbin/service funcd stop > /dev/null 2>&1 + /sbin/chkconfig --del funcd +fi + + +%changelog +* Thu Sep 20 2007 Adrian Likins - 0.0.11-1 +- initial release (this one goes to .11) diff --git a/func/slave-keys.py b/func/slave-keys.py deleted file mode 100644 index dee0fd5..0000000 --- a/func/slave-keys.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/python -tt - -import sys -import os -import os.path -from OpenSSL import crypto -import socket - - -def_country = 'UN' -def_state = 'FC' -def_local = 'Func-ytown' -def_org = 'func' -def_ou = 'slave-key' - -cert_dir = '/home/skvidal/tmp/t' -key_file = '%s/slave.pem' % cert_dir -csr_file = '%s/slave.csr' % cert_dir - - -def make_cert(dest=None): - pkey = crypto.PKey() - pkey.generate_key(crypto.TYPE_RSA, 2048) - if dest: - destfo = open(dest, 'w') - destfo.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)) - destfo.close() - - return pkey - -def make_csr(pkey, dest=None, cn=None): - req = crypto.X509Req() - req.get_subject() - subj = req.get_subject() - subj.C = def_country - subj.ST = def_state - subj.L = def_local - subj.O = def_org - subj.OU = def_ou - if cn: - subj.CN = cn - else: - subj.CN = socket.getfqdn() - subj.emailAddress = 'root@%s' % subj.CN - - req.set_pubkey(pkey) - req.sign(pkey, 'md5') - if dest: - destfo = open(dest, 'w') - destfo.write(crypto.dump_certificate_request(crypto.FILETYPE_PEM, req)) - destfo.close() - - return req - -def retrieve_key_from_file(keyfile): - fo = open(keyfile, 'r') - buf = fo.read() - keypair = crypto.load_privatekey(crypto.FILETYPE_PEM, buf) - return keypair - -def main(): - keypair = None - try: - if not os.path.exists(cert_dir): - os.makedirs(cert_dir) - if not os.path.exists(key_file): - keypair = make_cert(dest=key_file) - if not os.path.exists(csr_file): - if not keypair: - keypair = retrieve_key_from_file(key_file) - csr = make_csr(keypair, dest=csr_file) - except: - return 1 - - return 0 - - -if __name__ == "__main__": - sys.exit(main()) - \ No newline at end of file diff --git a/init-scripts/funcd b/init-scripts/funcd new file mode 100755 index 0000000..6066d99 --- /dev/null +++ b/init-scripts/funcd @@ -0,0 +1,91 @@ +#!/bin/sh +# +# funcd func api provider +# +# chkconfig: 345 99 99 +# description: Server to expose config, monitoring, and management apis to func +# See https://hosted.fedoraproject.org/projects/func/ +# +# processname: /usr/bin/funcd + +# Sanity checks. +[ -x /usr/bin/funcd ] || exit 0 + +# Source function library. +. /etc/rc.d/init.d/functions + +RETVAL=0 + +start() { + echo -n $"Starting the funcd : " + if test -f /var/lock/subsys/funcd ; then + echo_failure + echo + return 1 + fi + /usr/bin/funcd --daemon + RETVAL=$? + echo_success + echo + touch /var/lock/subsys/funcd + return $RETVAL +} + + +stop() { + echo -n $"Stopping funcd daemon: " + if ! test -f /var/lock/subsys/funcd ; then + echo_failure + echo + return 1 + fi + pkill funcd + RETVAL=$? + rm /var/lock/subsys/funcd + echo_success + echo + return $RETVAL +} + +mystatus() { + if test -f /var/lock/subsys/funcd ; then + echo "the funcd is alive..." + return 0 + fi + echo "we have lost the funcd" + echo + return 0 +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + mystatus + RETVAL=$? + ;; + restart) + stop + start + ;; + condrestart) + if [ -f /var/lock/subsys/vf_server ]; then + stop + start + fi + ;; + reload) + echo "can't reload configuration, you have to restart it" + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}" + ;; +esac +exit $RETVAL + diff --git a/settings b/settings new file mode 100644 index 0000000..9fe73d9 --- /dev/null +++ b/settings @@ -0,0 +1 @@ +this file is empty at the moment, but at some point it will be the config file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9584b05 --- /dev/null +++ b/setup.py @@ -0,0 +1,68 @@ +#!/usr/bin/python + +import sys +from distutils.core import setup, Extension +#from setuptools import setup,find_packages +import string +import glob + +NAME = "func" +VERSION = open("version", "r+").read().split()[0] +SHORT_DESC = "%s remote configuration and management api" % NAME +LONG_DESC = """ +A small pluggabe xml-rpc daemon used by %s to implement various web services hooks +""" % NAME + + +if __name__ == "__main__": + + manpath = "share/man/man1/" + etcpath = "/etc/%s" % NAME + etcpathdb = "/etc/%s/db" % NAME + wwwpath = "/var/www/%s" % NAME + initpath = "/etc/init.d/" + logpath = "/var/log/%s/" % NAME + logpathdb = "/var/log/%s/db/" % NAME + settingspath = "/var/lib/%s/" % NAME + migraterepopath = "/var/lib/%s/db/" % NAME + schemapath = "/usr/share/%s/db_schema/" % NAME + upgradepath = schemapath + "upgrade/" + puppetpath = "/usr/share/%s/puppet-config/" % NAME + manifestpath = "/etc/puppet/manifests/" + profiletemplatepath = "/usr/share/%s/profile-template/" % NAME + profilespath = "/var/lib/%s/profiles/" % NAME + queuedprofilespath = "/var/lib/%s/profiles/queued/" % NAME + setup( + name="%s" % NAME, + version = VERSION, + author = "Lots", + author_email = "et-mgmt-tools@redhat.com", + url = "https://hosted.fedoraproject.org/projects/func/", + license = "GPL", + scripts = ["scripts/funcd", + ], + # package_data = { '' : ['*.*'] }, + package_dir = {"%s" % NAME: "", + "%s/server" % NAME: "server", + "%s/server/modules" % NAME: "modules/", + "%s/client" % NAME: "client", + "%s/server/yaml" % NAME: "server/yaml/", + }, + packages = ["%s" % NAME, + "%s/server" % NAME, + "%s/client" % NAME, + "%s/server/modules" % NAME, + "%s/server/yaml" % NAME, + ], + data_files = [(initpath, ["init-scripts/funcd"]), + (etcpath, ["settings",]), + (etcpathdb, []), + (logpath, []), + (logpathdb, []), + (migraterepopath, []), + (profilespath, []), + (queuedprofilespath, [])], + description = SHORT_DESC, + long_description = LONG_DESC + ) + diff --git a/version b/version new file mode 100644 index 0000000..6f2b8fc --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.11 1 -- cgit