Hi all,
There seems to be a bug in the behaviour of the packages section when
using DPKG.
When I use(d) the following in my config:
------------------------------------------
control:
DefaultPkgManager = ( dpkg )
actionsequence = ( packages )
packages:
any::
ipython action=install
------------------------------------------
I would expect the behaviour from the documentation:
------------------------------------------
version
Specifies the package manager specific version string to match. If
this is not specified, then any version matches, and the value of the
cmp attribute is ignored. See the allowed values of pkgmgr below for an
explation of how each package manager will interpret this.
------------------------------------------
Meaning cfengine will check if a package is installed, if it's not:
install it.
However the "Comparison result" is always "eq" (equal) somehow for me.
I decided to dig through the code and found that this little statement:
------------------------------------------
/* start with assuming that the versions are equal */
result = cmpsense_eq;
------------------------------------------
This causes the comparison to always be equal if the package is found in
the dpkg status and there was no cmp or version specified, regardless if
it's installed or not.
It starts to compare version "" (installed) with version "" (none
specified) which let's it to believe in the end that it's equal. This in
turn causes cfengine to think the package is installed, while it is not.
I have created a little patch to fix the problem and it now works as
expected for me, see the attached diff.
(Note: patch was made against the latest tar snap I found on the website)
Let me know if you think this patch is okay.
Kind regards,
- Ramon.
--
ing. R. Bastiaans HPC - Systems Programmer
SARA - Computing and Networking Services
Kruislaan 415 PO Box 194613
1098 SJ Amsterdam 1090 GP Amsterdam
Tel. +31 (0) 20 592 3000 Fax. +31 (0) 20 668 3167
---
There are really only three types of people:
Those who make things happen, those who watch things happen
and those who say, "What happened?"
diff -ur ./snap_orig/GNU-cfengine/src/cf.defs.h
./snap_patched/GNU-cfengine/src/cf.defs.h
--- ./snap_orig/GNU-cfengine/src/cf.defs.h 2006-02-24 14:26:43.000000000
+0100
+++ ./snap_patched/GNU-cfengine/src/cf.defs.h 2006-03-24 15:52:47.391928772
+0100
@@ -1179,7 +1179,8 @@
cmpsense_lt,
cmpsense_ge,
cmpsense_le,
- cmpsense_ne
+ cmpsense_ne,
+ cmpsense_none
};
/*******************************************************************/
diff -ur ./snap_orig/GNU-cfengine/src/globals.c
./snap_patched/GNU-cfengine/src/globals.c
--- ./snap_orig/GNU-cfengine/src/globals.c 2006-03-18 11:40:42.000000000
+0100
+++ ./snap_patched/GNU-cfengine/src/globals.c 2006-03-24 15:53:32.990758241
+0100
@@ -644,6 +644,7 @@
"ge",
"le",
"ne",
+ "none",
NULL
};
diff -ur ./snap_orig/GNU-cfengine/src/package.c
./snap_patched/GNU-cfengine/src/package.c
--- ./snap_orig/GNU-cfengine/src/package.c 2006-03-02 13:35:59.000000000
+0100
+++ ./snap_patched/GNU-cfengine/src/package.c 2006-03-24 16:01:29.168620705
+0100
@@ -477,7 +477,25 @@
if (strncmp (evrstart, "(none)", strlen ("(none)")) == 0)
{
sprintf (evrstart, "\"\"");
+
+ /* RB 34.02.06:
+ * Set compare result to nothing when (not)installed version is none
+ * because else we might return True for package check
+ * if checking without version/cmp statement.
+ *
+ * Or else it will cause us to assume package is installed
+ * while it is actually not.
+ */
+
+ result = cmpsense_none;
}
+ else
+ {
+
+ /* start with assuming that the versions are equal */
+
+ result = cmpsense_eq;
+ }
if (strncmp (version, "(none)", strlen ("(none)")) == 0)
{
@@ -487,10 +505,6 @@
/* the evrstart shall be a version number which we will
compare to version using '/usr/bin/dpkg --compare-versions' */
-/* start with assuming that the versions are equal */
-
-result = cmpsense_eq;
-
/* check if installed version is gt version */
snprintf (VBUFF, CF_BUFSIZE, "/usr/bin/dpkg --compare-versions %s gt %s",
evrstart, version);
@@ -567,7 +581,10 @@
return 1;
}
-Verbose("\n");
+/* RB 24.03.06: Why do we need an extra blank line here?: ugly
+ *
+ * Verbose("\n");
+ */
/* if we manage to make it here, we did not find a match */
DeleteItemList (evrlist);
_______________________________________________
Bug-cfengine mailing list
[email protected]
http://cfengine.org/mailman/listinfo/bug-cfengine