add new action=fix to cfengine
Jo Rhett <[email protected]>
| Newsgroups | gmane.comp.sysutils.cfengine.bugs |
|---|---|
| Message-ID | <[email protected]> |
This patch adds a new action=fix to install or upgrade as appropriate a package. It updates and improves the package documentation as well. This patch includes the previous patch for FreeBSD. -- Jo Rhett Net Consonance : consonant endings by net philanthropy, open source and other randomness _______________________________________________ Bug-cfengine mailing list [email protected] https://cfengine.org/mailman/listinfo/bug-cfengine
cfengine-package-actionfix.patch
(application/octet-stream, 4.3 KB)
Index: src/cf.defs.h
===================================================================
--- src/cf.defs.h (revision 548)
+++ src/cf.defs.h (working copy)
@@ -1295,6 +1295,7 @@
pkgaction_install,
pkgaction_remove,
pkgaction_upgrade,
+ pkgaction_fix,
pkgaction_none
};
Index: src/do.c
===================================================================
--- src/do.c (revision 548)
+++ src/do.c (working copy)
@@ -2883,8 +2883,16 @@
if (ptr->action == pkgaction_remove)
{
PackageList(ptr,name,ptr->pkgmgr,ptr->ver,ptr->cmp,&pending_pkgs);
+
+ /* Some package managers operate best doing things one at a time. */
+ if ((ptr->pkgmgr == pkgmgr_freebsd) || (ptr->pkgmgr == pkgmgr_sun))
+ {
+ RemovePackage(ptr,ptr->pkgmgr,&pending_pkgs);
+ DeleteItemList(pending_pkgs);
+ pending_pkgs = NULL;
+ }
}
- else if (ptr->action == pkgaction_upgrade)
+ else if (ptr->action == pkgaction_upgrade) || (ptr->action == pkgaction_fix))
{
UpgradePackage(ptr,name,ptr->pkgmgr,ptr->ver,ptr->cmp);
}
@@ -2893,12 +2901,11 @@
{
AddMultipleClasses(ptr->elsedef);
- if (ptr->action == pkgaction_install)
+ if ((ptr->action == pkgaction_install) || (ptr->action == pkgaction_fix))
{
AppendItem(&pending_pkgs,name, NULL);
/* Some package managers operate best doing things one at a time. */
-
if ((ptr->pkgmgr == pkgmgr_freebsd) || (ptr->pkgmgr == pkgmgr_sun))
{
InstallPackage(ptr,ptr->pkgmgr,&pending_pkgs);
Index: src/globals.c
===================================================================
--- src/globals.c (revision 548)
+++ src/globals.c (working copy)
@@ -728,6 +728,7 @@
"install",
"remove",
"upgrade",
+ "fix",
NULL
};
Index: doc/cfengine-Reference.texinfo
===================================================================
--- doc/cfengine-Reference.texinfo (revision 548)
+++ doc/cfengine-Reference.texinfo (working copy)
@@ -10207,7 +10207,7 @@
version=@var{version-string}
define=@var{class-list}(,:.)
elsedefine=@var{class-list}(,:.)
- action=@b{none}/@var{install/remove/upgrade}
+ action=@b{none}/@var{install/remove/upgrade/fix}
ifelapsed=@var{mins}
expireafter=@var{mins}
@@ -10227,6 +10227,11 @@
version=1.2
cmp=le
+ # Make sure that version 1.2 is installed
+ compromised-1.2 action=fix
+ version=1.2
+ cmp=le
+
# remove any version of useless
useless action=remove
version=0.1
@@ -10236,6 +10241,28 @@
@end cartouche
@table @code
+@item action
+@vindex action=
+Determines the action taken if the comparison matches.
+
+@itemize @bullet
+@item
+@code{install}
+Install this package if the version comparison does not match.
+
+@item
+@code{upgrade}
+Upgrade this package if the version comparison does match.
+
+@item
+@code{fix}
+Install or Upgrade this package if the version comparison does match.
+
+@item
+@code{remove}
+Uninstall this package if the version comparison does match.
+@enditemize
+
@item cmp
@vindex cmp=
Determines how the version of the installed package will be compared to
@@ -10264,8 +10291,8 @@
The default value for this attribute is @code{eq}.
-Note that @code{cmp} is used differently for install versus upgrade and remove.
-The action is performed when false for install, but when true for upgrade or remove.
+Note that @code{cmp} is used differently for install versus upgrade, fix and remove.
+The action is performed when false for install, but when true for upgrade, fix or remove.
@item version
@vindex version=
@@ -10390,7 +10417,7 @@
@end smallexample
Note that specifying the version of the package that is part of the freebsd package filename is required if not using "-r" mode.
-However, it does not use this for comparison, just for the package filename to install.
+It does not use this version for comparison, just for the package filename to install.
You can also backgrade if you know that 1.2 is bad for instance.