help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

package installation in debian


From: pablobarbachano
Subject: package installation in debian
Date: Thu, 28 Apr 2005 19:37:26 +0200
User-agent: Mutt/1.5.9i

Hi! I have just tried the 2.1.14 version in debian, and was a bit
dissapointed with the new action=install command.

It seems that the version=x.y.z is mandatory, so I cannot just say:

slapd action=install

...but...

slapd version=2.2.23 cmp=ge action=install

just a bit annoying...

I was looking the source code for the reason ... well I didnt find it,
but found this function in package.c: DPKGPackageCheck ... Im not
really sure, but maybe this way the function is better? I surely miss
some C syntax, though:

--- package-snip.c      2005-04-28 17:55:31.000000000 +0200
+++ package-snip-simplified.c   2005-04-28 17:55:44.000000000 +0200
@@ -78,12 +78,18 @@ int DPKGPackageCheck(char *package,char 
   /* 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;
+  switch (cmp) {
+  case cmpsense_gt: op="gt";
+  case cmpsense_ge: op="ge";
+  case cmpsense_lt: op="lt";
+  case cmpsense_le: op="le";
+  case cmpsense_eq: op="eq";
+  case cmpsense_ne: op="ne";
+  }
   
   /* check if installed version is gt version */
-  snprintf (VBUFF, CF_BUFSIZE, "/usr/bin/dpkg --compare-versions %s gt " \
-           "%s", evrstart, version);
+  snprintf (VBUFF, CF_BUFSIZE, "/usr/bin/dpkg --compare-versions %s %s " \
+           "%s", evrstart, op, version);
   
   if ((pp = cfpopen (VBUFF, "r")) == NULL) {
     Verbose ("Could not execute DPKG-command.\n");
@@ -96,58 +102,14 @@ int DPKGPackageCheck(char *package,char 
   /* if dpkg --compare-versions exits with zero result the condition
      was satisfied, else not satisfied */
   if (cfpclose (pp) == 0) {
-    result = cmpsense_gt;
-  }    
-  
-  /* check if installed version is lt version */
-  snprintf (VBUFF, CF_BUFSIZE, "/usr/bin/dpkg --compare-versions %s lt " \
-           "%s", evrstart, version);
-
-  if ((pp = cfpopen (VBUFF, "r")) == NULL) {
-    Verbose ("Could not execute DPKG-command.\n");
-    return 0;
-  }
-  while (!feof (pp)) {
-    *VBUFF = '\0';
-    ReadLine (VBUFF, CF_BUFSIZE, pp);
-  }
-  /* if dpkg --compare-versions exits with zero result the condition
-     was satisfied, else not satisfied */
-  if (cfpclose (pp) == 0) {
-    result = cmpsense_lt;
-  }    
-  
-  Verbose ("Comparison result: %s\n", CMPSENSETEXT[result]);
-  
-  switch (cmp) {
-    case cmpsense_gt:
-      match = (result == cmpsense_gt);
-      break;
-    case cmpsense_ge:
-      match = (result == cmpsense_gt || result == cmpsense_eq);
-      break;
-    case cmpsense_lt:
-      match = (result == cmpsense_lt);
-      break;
-    case cmpsense_le:
-      match = (result == cmpsense_lt || result == cmpsense_eq);
-      break;
-    case cmpsense_eq:
-      match = (result == cmpsense_eq);
-      break;
-    case cmpsense_ne:
-      match = (result != cmpsense_eq);
-      break;
-  }
-  
-  if (match) {
+    Verbose ("Comparison result: %s: \n", CMPSENSETEXT[cmp]);
     DeleteItemList (evrlist);
     return 1;
   }
-
+    
   Verbose("\n");
 
   /* if we manage to make it here, we did not find a match */
   DeleteItemList (evrlist);
   return 0;
-}
+}  


I will try to solve the no-version problem tomorrow, if people think
it is worth it. I think it is, but maybe it is a bad idea ... if
someone could prove me wrong... :)

                
______________________________________________ 
Renovamos el Correo Yahoo!: �250 MB GRATIS! 
Nuevos servicios, m�s seguridad 
http://correo.yahoo.es



______________________________________________ 

Renovamos el Correo Yahoo!: �250 MB GRATIS! 

Nuevos servicios, m�s seguridad 

http://correo.yahoo.es





reply via email to

[Prev in Thread] Current Thread [Next in Thread]