summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Holland <tigger@gentoo.org>2003-12-17 15:07:10 +0000
committerRob Holland <tigger@gentoo.org>2003-12-17 15:07:10 +0000
commit4d2ff4ba2ee60e304d5b331e994bb1ad453e3633 (patch)
treea0ade8bca49cac96517ed8802eb313c3e3b388a2 /net-misc/cfengine
parentAdded a cfengine module to test for installed software using portage. Removed... (diff)
downloadgentoo-2-4d2ff4ba2ee60e304d5b331e994bb1ad453e3633.tar.gz
gentoo-2-4d2ff4ba2ee60e304d5b331e994bb1ad453e3633.tar.bz2
gentoo-2-4d2ff4ba2ee60e304d5b331e994bb1ad453e3633.zip
Added a cfengine module to test for installed software using portage. Removed silly mkdir which did nothing
Diffstat (limited to 'net-misc/cfengine')
-rw-r--r--net-misc/cfengine/ChangeLog9
-rw-r--r--net-misc/cfengine/Manifest6
-rw-r--r--net-misc/cfengine/cfengine-2.0.8_p1-r3.ebuild75
-rw-r--r--net-misc/cfengine/files/cfportage.README71
-rw-r--r--net-misc/cfengine/files/digest-cfengine-2.0.8_p1-r31
-rw-r--r--net-misc/cfengine/files/module:cfportage330
6 files changed, 488 insertions, 4 deletions
diff --git a/net-misc/cfengine/ChangeLog b/net-misc/cfengine/ChangeLog
index f7f151e3e920..f2cfda0974af 100644
--- a/net-misc/cfengine/ChangeLog
+++ b/net-misc/cfengine/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for net-misc/cfengine
# Copyright 2002-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/cfengine/ChangeLog,v 1.19 2003/11/05 19:52:48 klieber Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/cfengine/ChangeLog,v 1.20 2003/12/17 15:07:02 tigger Exp $
+
+*cfengine-2.0.8_p1-r3 (17 Dec 2003)
+
+ 17 Dec 2003; rob holland <tigger@gentoo.org> cfengine-2.0.8_p1-r3.ebuild,
+ files/cfportage.README, files/module:cfportage:
+ Added a cfengine module to test for installed software using portage.
+ Removed silly mkdir which did nothing
*cfengine-2.1.0_p1 (05 Nov 2003)
diff --git a/net-misc/cfengine/Manifest b/net-misc/cfengine/Manifest
index 8ca914c6fb2e..4c25f4f28a93 100644
--- a/net-misc/cfengine/Manifest
+++ b/net-misc/cfengine/Manifest
@@ -1,8 +1,8 @@
-MD5 a088b7b3590381dff3f27f902acc39eb cfengine-2.0.8_p1-r3.ebuild 1638
+MD5 b9833356ba8b5eaf8fe127b1eedeafb9 cfengine-2.0.8_p1-r3.ebuild 1944
MD5 a2be03b6731823dbd298d4f35758f9b6 cfengine-1.6.3.ebuild 723
MD5 e35c3445cb81576250f15893c893b290 cfengine-2.1.0_p1.ebuild 1570
MD5 e35c3445cb81576250f15893c893b290 cfengine-2.0.8_p1-r2.ebuild 1570
-MD5 4e9776e108f6d05e6e9c3f32a7771f9d ChangeLog 3523
+MD5 852334dc98fa39d5c6cbb5f32299626f ChangeLog 3798
MD5 62a95c94d7136aa0edd4c4e32fe14434 metadata.xml 846
MD5 a1c3e8d4352d939660ecc6de54436e45 files/cfengine-2.0.6-db4.diff 567
MD5 d306cf207af6fe2703ab614c50719cbf files/digest-cfengine-2.1.0_p1 69
@@ -10,4 +10,4 @@ MD5 f4fe82c710efac73c0895ad268c54196 files/cfportage.README 2294
MD5 c8ffce770e77f013fb284e2ea3ecbb68 files/digest-cfengine-2.0.8_p1-r2 69
MD5 c8ffce770e77f013fb284e2ea3ecbb68 files/digest-cfengine-2.0.8_p1-r3 69
MD5 6453e4309a80963dde2df05003dfaf8a files/digest-cfengine-1.6.3 66
-MD5 063cfced82e6e769051b44de30eab022 files/module:cfportage 10245
+MD5 6b82ac72e557796ee7c63f7cba273bf5 files/module:cfportage 10243
diff --git a/net-misc/cfengine/cfengine-2.0.8_p1-r3.ebuild b/net-misc/cfengine/cfengine-2.0.8_p1-r3.ebuild
new file mode 100644
index 000000000000..d0441e3aae89
--- /dev/null
+++ b/net-misc/cfengine/cfengine-2.0.8_p1-r3.ebuild
@@ -0,0 +1,75 @@
+# Copyright 1999-2003 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $
+
+PARCH=${P/_/}
+DESCRIPTION="An agent/software robot and a high level policy language for building expert systems to administrate and configure large computer networks"
+HOMEPAGE="http://www.iu.hio.no/cfengine/"
+SRC_URI="ftp://ftp.iu.hio.no/pub/cfengine/${PARCH}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~x86 ~ppc ~sparc"
+
+DEPEND="virtual/glibc
+ >=sys-libs/db-3.2
+ >=dev-libs/openssl-0.9.6k"
+
+S="${WORKDIR}/${PARCH}"
+
+src_compile() {
+
+ # Enforce /var/cfengine for historical compatibility
+ econf \
+ --with-workdir=/var/cfengine \
+ --with-berkeleydb=/usr || die
+
+ # Fix Makefile to skip doc & inputs install to wrong locations
+ sed -i -e 's/\(SUBDIRS.*\) inputs doc/\1/' Makefile
+
+ emake || die
+}
+
+src_install() {
+ make DESTDIR=${D} install || die
+ dodoc AUTHORS ChangeLog COPYING DOCUMENTATION README TODO
+
+ # Manually install doc and inputs
+ doinfo doc/*.info*
+ dohtml doc/*.html
+ dodoc inputs/*.example
+
+ fperms 700 /var/cfengine
+ keepdir /var/cfengine/bin
+ keepdir /var/cfengine/inputs
+ keepdir /var/cfengine/modules
+
+ # Copy the cfportage module
+ insinto /var/cfengine/modules
+ doins ${FILESDIR}/module:cfportage
+
+ dodoc ${FILESDIR}/cfportage.README
+}
+
+pkg_postinst() {
+ if [ ! -f "/var/cfengine/ppkeys/localhost.priv" ]
+ then
+ einfo "Generating keys for localhost."
+ /usr/sbin/cfkey
+ fi
+
+ # Copy cfagent into the cfengine tree otherwise cfexecd won't
+ # find it. Most hosts cache their copy of the cfengine
+ # binaries here. This is the default search location for the
+ # binaries.
+
+ cp /usr/sbin/cf{agent,servd,execd} /var/cfengine/bin/
+
+ # let people know about the cfportage module
+ einfo
+ einfo "gentoo's cfengine package now comes with a module"
+ einfo "for checking for installed software using portage."
+ einfo "please see the readme for details."
+ einfo "/usr/share/doc/${PF}/cfportage.README.gz"
+ einfo
+}
diff --git a/net-misc/cfengine/files/cfportage.README b/net-misc/cfengine/files/cfportage.README
new file mode 100644
index 000000000000..0439482961ec
--- /dev/null
+++ b/net-misc/cfengine/files/cfportage.README
@@ -0,0 +1,71 @@
+# module:cfportage readme file
+# author: rob holland <tigger@gentoo.org>
+
+This readme describes the cfportage module which allows you to define
+classes depending on the versions of installed software.
+
+The code is based on the etcat tool by Alastair Tse.
+
+To use the module you will need to define:
+
+moduledirectory = ( /var/cfengine/modules )
+
+in one of your cfinputs.
+
+You can then make use of the module by adding a line like this to an
+actionsequnce section in a cfengine input file:
+
+"module:cfportage.vim_missing -i vim_missing app-editors/vim"
+
+Where the syntax is:
+
+"module:cfportage.<class_to_use> <test_type> <class_to_use> <package>"
+
+It is important that <class_to_use> _is the same_ both times, that is,
+you must type the class you'd like to set twice on the same line.
+
+The first one is used by cfengine to keep track of which classes might
+be set, the second one tells the module which class needs to be set.
+This has to be done as, unfortunately, cfengine doesn't pass on the
+class names its expecting the module to trigger.
+
+If this doesn't make sense to anyone, or you think I could have worded it
+better, please file a bug at http://bugs.gentoo.org or email me directly. Its
+difficult to explain clearly.
+
+Examples (with random version numbers that I made up) are:
+
+Define the class old_vim if the installed version of vim is a version
+before 2.0. The class will _not_ be defined if the package isn't
+installed.
+
+"module:cfportage.old_vim -o old_vim app-editors/vim-2.0"
+
+Each test type has a long version as well as a short one, so you could
+write the same thing as:
+
+"module:cfportage.old_vim older old_vim app-editors/vim-2.0"
+
+Test that you have the lastest version of gnupg due to a security scare:
+
+"module:cfportage.latest_gnupg newerorequal latest_gnupg app-crypt/gnupg-0.5-r1"
+
+Where 0.5-r1 is the fixed version
+
+The tests are:
+
+-i/installed
+-o/older
+-O/olderorequal
+-n/newer
+-N/newerorequal
+
+-o/-O/-n/-N will _never_ trigger if the package isn't installed.
+
+If you use the -i test and give a version number with the package then
+it will test for that specific version only.
+
+If you don't give a version number when using -i it will just check that
+any version of the package is installed.
+
+Hope that all made sense. Bugs/comments to http://bugs.gentoo.org please.
diff --git a/net-misc/cfengine/files/digest-cfengine-2.0.8_p1-r3 b/net-misc/cfengine/files/digest-cfengine-2.0.8_p1-r3
new file mode 100644
index 000000000000..58b0b328abcd
--- /dev/null
+++ b/net-misc/cfengine/files/digest-cfengine-2.0.8_p1-r3
@@ -0,0 +1 @@
+MD5 17f9647edcc955e5c07489a6ac6126b1 cfengine-2.0.8p1.tar.gz 1240535
diff --git a/net-misc/cfengine/files/module:cfportage b/net-misc/cfengine/files/module:cfportage
new file mode 100644
index 000000000000..0697ef89d4f9
--- /dev/null
+++ b/net-misc/cfengine/files/module:cfportage
@@ -0,0 +1,330 @@
+#!/usr/bin/env python2
+#
+# -*- mode: python; -*-
+#
+# --| Version Information |------------------------------------------
+#
+# etcat v0.1.4 (27 Apr 2003)
+#
+# $Header: /var/cvsroot/gentoo-x86/net-misc/cfengine/files/module:cfportage,v 1.1 2003/12/17 15:07:02 tigger Exp $
+#
+# --| About |--------------------------------------------------------
+#
+# This is a module for cfengine which can be used to test the for installed
+# software on a gentoo linux box.
+#
+# Several major functions, the layout of this file and the general code
+# structure were borrowed from the etcat tool by Alastair Tse.
+#
+# --| License |------------------------------------------------------
+#
+# Distributed under the terms of the GNU General Public License v2
+# Copyright (c) 2003 Rob Holland.
+#
+# --| Usage |--------------------------------------------------------
+#
+# module:cfportage [options] || <test_type> <class> <category/package[-ver]>
+#
+# -i/installed) defines <class> if the package is installed
+# -n/newer) defines <class> if a later version of the package is installed
+# -N/newerorequal) defines <class> if a later or equal version of the package is installed
+# -o/older) defines <class> if an earlier version of the package is installed
+# -O/olderorequal) defines <class> if an earlier or equal version of the package is installed
+
+import os,sys,string
+import getopt
+import portage
+
+__author__ = "Rob Holland"
+__email__ = "tigger@gentoo.org"
+__version__ = "0.2.0"
+__productname__ = "module:cfportage"
+__description__ = "Packages module for cfengine"
+
+# "option": ("shortcommand","desc")
+options = {
+ "newer":("n","Defines class if there is a newer version of the package installed"),
+ "newerorequal":("N","Defines class if there is a later version of the package installed"),
+ "installed":("i","Defines class if there is an exactly matching version of the package installed"),
+ "older":("o","Defines class if there is an earlier version of the package installed"),
+ "olderorequal":("O","Defines class if there is an earlier or equal version of the package installed"),
+}
+
+# .-------------------------------------------------------.
+# | Smart Package Version Comparison |
+# +-------------------------------------------------------+
+# | Does more advanced package sorting hueristics |
+# `-------------------------------------------------------'
+
+LETTERS=map(lambda x: chr(x), range(ord('a'),ord('z')))
+# find roughly which is the newer version
+def vercmp(a, b):
+ a_ver = []
+ a_min = ""
+ a_pre = ""
+ a_rev = 0
+ b_ver = []
+ b_min = ""
+ b_pre = ""
+ b_rev = 0
+
+ # split into digestable components
+ # eg. 1.2.3b_pre4-r5
+ # 1. get the 1.2.3 bit
+ a_parts = a.split("-")[0].split("_")
+ a_ver = a_parts[0].split(".")
+ b_parts = b.split("-")[0].split("_")
+ b_ver = b_parts[0].split(".")
+
+ # 2. get a,b,c.. or whatever letter at the end
+ if a_ver[-1][-1] in LETTERS:
+ a_min = a_ver[-1][-1]
+ a_ver[-1] = a_ver[-1][:-1]
+ if b_ver[-1][-1] in LETTERS:
+ b_min = b_ver[-1][-1]
+ b_ver[-1] = b_ver[-1][:-1]
+
+ # 2. get the _pre4 bit and -r5
+ if len(a_parts) > 1:
+ a_pre = a_parts[1]
+ if len(a.split("-")) > 1:
+ a_rev = int(a.split("-")[1][1:])
+ if len(b_parts) > 1:
+ b_pre = b_parts[1]
+ if len(b.split("-")) > 1:
+ b_rev = int(b.split("-")[1][1:])
+
+ # 3. do the comparison
+ for x in range(len(a_ver)):
+ # 3a. convert to numbers
+ try:
+ a_num = int(a_ver[x])
+ except (ValueError, IndexError):
+ a_num = 0
+ try:
+ b_num = int(b_ver[x])
+ except (ValueError, IndexError):
+ b_num = 0
+ # 3b. the comparison
+ if a_num == b_num:
+ continue
+ elif a_num > b_num:
+ return 1
+ elif a_num < b_num:
+ return -1
+
+ # 3c. compare minor ver
+ if a_min and not b_min:
+ return -1
+ elif not a_min and b_min:
+ return 1
+ elif a_min and b_min and a_min > b_min:
+ return 1
+ elif a_min and b_min and a_min < b_min:
+ return -1
+
+ # 3d. compare pre ver
+ if a_pre and not b_pre:
+ return -1
+ elif not a_pre and b_pre:
+ return 1
+ elif a_pre and b_pre and a_pre > b_pre:
+ return 1
+ elif a_pre and b_pre and a_pre < b_pre:
+ return -1
+
+ # 3e. compare rev
+ if a_rev > b_rev:
+ return 1
+ elif a_rev < b_rev:
+ return -1
+ else:
+ return 0
+
+
+def pkgcmp(a,b):
+ # strips out package name and returns the result of vercmp
+ awords = a.split("-")
+ bwords = b.split("-")
+ apkg = [awords[0]]
+ bpkg = [bwords[0]]
+ DIGITS = ['0','1','2','3','4','5','6','7','8','9']
+
+ for w in awords[1:]:
+ if w[0] in DIGITS:
+ break
+ else:
+ apkg.append(w)
+ aver = awords[len(apkg):]
+ apkg_str = string.join(apkg, "-")
+ aver_str = string.join(aver, "-")
+
+ for w in bwords[1:]:
+ if w[0] in DIGITS:
+ break
+ else:
+ bpkg.append(w)
+ bver = bwords[len(bpkg):]
+ bpkg_str = string.join(bpkg, "-")
+ bver_str = string.join(bver, "-")
+
+ if apkg_str > bpkg_str:
+ return 1
+ elif bpkg_str > apkg_str:
+ return -1
+ else:
+ return vercmp(aver_str, bver_str)
+
+# .-------------------------------------------------------.
+# | Package Name Guesser |
+# +-------------------------------------------------------+
+# | A smart (eg. dodgy) version of portage.catpkgsplit() |
+# | that determines the category, package, version and |
+# | revision given a string. If it doesn't know, it'll |
+# | leave the field blank. |
+# | |
+# | Returns a list like : |
+# | [ "net-www", "mozilla", "1.1", "r1"] |
+# `-------------------------------------------------------'
+
+def smart_pkgsplit(query):
+ cat = ''
+ pkg = ''
+ ver = ''
+ rev = ''
+
+ if len(query.split('/')) == 2:
+ cat = query.split('/')[0]
+ query = query.split('/')[1]
+
+ components = query.split('-')
+ name_components = []
+ ver_components = []
+
+ # seperate pkg-ver-rev
+ for c in components:
+ if ver_components:
+ ver_components.append(c)
+ elif ord(c[0]) > 47 and ord(c[0]) < 58:
+ ver_components.append(c)
+ else:
+ name_components.append(c)
+ pkg = '-'.join(name_components)
+
+ # check if there is a revision number
+ if len(ver_components) > 0 and ver_components[-1][0] == 'r':
+ rev = ver_components[-1]
+ ver_components = ver_components[:-1]
+
+ # check for version number
+ if len(ver_components) > 0:
+ ver = '-'.join(ver_components)
+
+ return [cat, pkg, ver, rev]
+
+# .-------------------------------------------------------.
+# | Versions Function |
+# +-------------------------------------------------------+
+# | Prints out the available version, masked status and |
+# | installed status. |
+# `-------------------------------------------------------'
+
+def test_version(type, define_class, query):
+ tup = smart_pkgsplit(query)
+ if tup[0] and tup[1]:
+ package = tup[0] + "/" + tup[1]
+ else:
+ print "Couldn't split package name properly. Aborting"
+ sys.exit(1)
+
+ if (type != 'installed') and (not tup[2]):
+ print "You must specify a version number when using the greater or lesser tests"
+ sys.exit(1)
+
+ curver = portage.db["/"]["vartree"].dep_bestmatch(package)
+
+ # tests if its installed
+ if (type == 'installed') and not tup[2] and curver: print "+" + define_class
+ # test if a specific version is installed
+ elif (type == 'installed') and curver and (pkgcmp(query, curver) == 0): print "+" + define_class
+ # test if a newer version is installed
+ elif (type == 'newer') and (pkgcmp(query, curver) == -1): print "+" + define_class
+ # test if an older version is installed
+ elif (type == 'older') and (pkgcmp(query, curver) == 1): print "+" + define_class
+ # test if an equal or newer version is installed
+ elif (type == 'newerorequal') and ((pkgcmp(query, curver) == -1) or (pkgcmp(query, curver) == 0)): print "+" + define_class
+ # test if an equal or older version is installed
+ elif (type == 'olderorequal') and ((pkgcmp(query, curver) == 1) or (pkgcmp(query, curver) == 0)): print "+" + define_class
+
+ sys.exit(0)
+
+def ver():
+ print __productname__ + " (" + __version__ + ") - " + __description__ + " - By: " + __author__ + " <" + __email__ + ">"
+
+def help():
+
+ ver()
+ print
+ print "Usage: " + __productname__ + " [ options ] [ test ] class package"
+ print
+ print "Options/Tests:"
+ print
+ for name,tup in options.items():
+ print " " + name + " (-" + tup[0] + " short option) - " + tup[1]
+ print
+
+# .-------------------------------------------------------.
+# | Main Function |
+# `-------------------------------------------------------'
+def main():
+
+ test = ''
+ package = ''
+
+ if len(sys.argv) < 3:
+ help()
+ sys.exit(1)
+
+ # delegates the commandline stuff to functions
+ pointer = 2
+ # short/long opts mapping
+ shortopts = map(lambda x: "-" + x[0], options.values())
+ short2long = {}
+ for k,v in options.items():
+ short2long[v[0]] = k
+ longopts = options.keys()
+ # loop thru arguments
+ for arg in sys.argv[1:]:
+ if arg[0] == "-" and len(arg) == 2 and arg in shortopts:
+ test = short2long[arg[1]]
+ if (len(sys.argv) - pointer) == 2:
+ define_class = sys.argv[pointer]
+ query = sys.argv[pointer+1]
+ else:
+ help()
+ sys.exit(1)
+ break
+ elif arg in longopts:
+ test = arg
+ if (len(sys.argv) - pointer) == 2:
+ define_class = sys.argv[pointer]
+ query = sys.argv[pointer+1]
+ else:
+ help()
+ sys.exit(1)
+ break
+ else:
+ pointer += 1
+
+ # abort if we don't have an action or query string
+ if not test or not define_class or not query:
+ print "You must specify a class, a test type and a package"
+ sys.exit(1)
+ else:
+ test_version(test, define_class, query)
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ print "Operation Aborted!"