Great idea.
From Wikipedia (http://en.wikipedia.org/wiki/Aptitude_(software)):
8<--
As of the Debian 4.0 ("Etch") release of 2007, aptitude is "the
preferred program for package management from console both for package
installations and package or system upgrades."[1]
8<--
Please find a patch attached that defines a "have_aptitude" class. Also
please find a patch to the stdlib to integrate this. Feel free to hack
these if necessary :)
I think we should do something similar for Ubuntu - although I'm not
sure where exactly. Ubuntu is detected as "Ubuntu" by Lsb_Version(). I
think all versions of Ubuntu should prefer aptitude, except maybe the
very first ones, which I really doubt anyone still uses.
Regards,
Jonathan
[1] Quotation from Debian GNU/Linux FAQ, Chapter 8: The Debian package
management tools (http://www.debian.org/doc/FAQ/ch-pkgtools.en.html)
On 25/01/2010 14:47, Mark Burgess wrote:
This is good feedback. If we know the point at which aptitude came into play,
then we can
place classes in the body to separate, or test for it, e.g.
body package_method debian
{
have_aptitude::
....
!have_aptitude::
....
}
Jonathan Clarke wrote:
Hi,
I've been testing the standard library, in particular the apt
package_method. I come with a bug and some suggestions.
First off, the bug. package_update_command is set to "apt-get
dist-upgrade", which cause *all* packages to be updated to the latest
version, not just the one(s) we're updating. This fixes that:
-package_update_command => "/usr/bin/apt-get --yes dist-upgrade";
+package_update_command => "/usr/bin/apt-get --yes install";
(around line 779 of cfengine_stdlib.cf)
Yes, the "install" command would also install a package. If you specify
package_policy => "update", and the package is not installed, cf3 checks
first if the package is installed and won't run the update command if
it's not. So no risk here.
Secondly, this body uses "apt-get" for all commands, while "aptitude" is
the preferred package manager on Debian systems. I would like to suggest
either:
1) Replacing apt-get by aptitude in the apt package_method. However,
this may not be optimal on very old Debian installations, and might
confuse some people (if any are already relying on the stdlib).
2) Add another package_method, named "aptitude", that uses "aptitude"
instead of "apt-get".
The patch is as follows (note the change in the option name):
-package_add_command => "/usr/bin/apt-get --yes install";
-package_delete_command => "/usr/bin/apt-get --yes remove";
-package_update_command => "/usr/bin/apt-get --yes dist-upgrade";
+package_add_command => "/usr/bin/aptitude --assume-yes install";
+package_delete_command => "/usr/bin/aptitude --assume-yes remove";
+package_update_command => "/usr/bin/aptitude --assume-yes install";
(around line 777 of cfengine_stdlib.cf)
Apart from this, it is really great to have a standard library to base
our configuration on! It is making all my promise files *a lot* simpler
:-) Thanks!
Regards,
Jonathan
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine
Index: src/sysinfo.c
===================================================================
--- src/sysinfo.c (révision 738)
+++ src/sysinfo.c (copie de travail)
@@ -1626,6 +1626,14 @@
CfOut(cf_verbose,"","This appears to be a Debian %u system.", major);
snprintf(classname, CF_MAXVARSIZE, "debian_%u", major);
NewClass(classname);
+
+ // As of the Debian 4.0 ("Etch") release of 2007, aptitude is "the preferred program for package management
+ if (major >= 4)
+ {
+ snprintf(classname, CF_MAXVARSIZE, "have_aptitude");
+ NewClass(classname);
+ }
+
break;
case 0:
CfOut(cf_verbose,"","No Debian version number found.\n");
Index: cfengine_stdlib.cf
===================================================================
--- cfengine_stdlib.cf (révision 2)
+++ cfengine_stdlib.cf (copie de travail)
@@ -777,9 +777,16 @@
package_list_version_regex => "ii\s+[^\s]+\s+([^\s]+).*";
package_installed_regex => ".*"; # all reported are installed
package_name_convention => "$(name)";
-package_add_command => "/usr/bin/apt-get --yes install";
-package_delete_command => "/usr/bin/apt-get --yes remove";
-package_update_command => "/usr/bin/apt-get --yes dist-upgrade";
+
+have_aptitude::
+ package_add_command => "/usr/bin/aptitude --assume-yes install";
+ package_delete_command => "/usr/bin/aptitude --assume-yes remove";
+ package_update_command => "/usr/bin/aptitude --assume-yes install";
+
+!have_aptitude::
+ package_add_command => "/usr/bin/apt-get --yes install";
+ package_delete_command => "/usr/bin/apt-get --yes remove";
+ package_update_command => "/usr/bin/apt-get --yes install";
}
##
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine