Angel, I'm moving your query to the bug-cfengine list, which is where  
the package management code is currently being discussed.

What you are saying below is entirely possible, and I agree with your  
suggested fix.  But to fix this problem someone would need both  
platform familiarity and a test system.  It would be a great help if  
you were to take on updating the DPKG routines to work better.  If  
you are not already on the bug-cfengine list, please subscribe and  
submit your suggested patches there.

FYI: a lot has changed between 2.1.20 and 2.2.2, however not the DPKG  
code.  Can you download the latest trunk and give us patches against  
that?

> From: "Angel L. Mateo" <[EMAIL PROTECTED]>
> Date: October 23, 2007 3:48:41 AM PDT
> To: [EMAIL PROTECTED]
> Subject: Problem with dpkg package check
>
>
> Hello,
>
>       I am a user of cfengine2 that had a problem with it. I am using
> cfengine 2.1.20. The problem is that dpkg checks are dependent of the
> locale used in the system, specifically I am using LANG=es_ES.UTF-8.
>
>       The problem is that in file src/package.c (in DPKGPackageCheck
> function), to check if the package is installed or not, your code is:
>
> /* check what version is installed on the system (if any) */
> snprintf (VBUFF, CF_BUFSIZE, "/usr/bin/apt-cache policy %s", package);
>
> if ((pp = cfpopen (VBUFF, "r")) == NULL)
>    {
>    Verbose ("Could not execute APT-command (apt-cache policy).\n");
>    return 0;
>    }
>
> while (!feof (pp))
>    {
>    *VBUFF = '\0';
>    ReadLine (VBUFF, CF_BUFSIZE, pp);
>    if (*VBUFF != '\0')
>       {
>       if (sscanf (VBUFF, "  Installed: %s", tmpBUFF) > 0)
>          {
>          AppendItem (&evrlist, tmpBUFF, "");
>          }
>       }
>    }
>
>       that looks for a Installed line, like this:
>
> nyctalus:~# apt-cache policy php5
> php5:
>   Installed: 5.2.0-8+etch7   <===========
>   Candidate: 5.2.0-8+etch7
>   Version table:
> *** 5.2.0-8+etch7 0
>         500 http://security.debian.org etch/updates/main Packages
>         100 /var/lib/dpkg/status
>      5.2.0-8+etch5~pu1 0
>         500 ftp://ftp.um.es etch/main Packages
>
>       but in other languages (like my case), the output of the command is:
>
> nyctalus:~# apt-cache policy php5
> php5:
>   Instalados: 5.2.0-8+etch7
>   Candidato: 5.2.0-8+etch7
>   Tabla de versión:
> *** 5.2.0-8+etch7 0
>         500 http://security.debian.org etch/updates/main Packages
>         100 /var/lib/dpkg/status
>      5.2.0-8+etch5~pu1 0
>         500 ftp://ftp.um.es etch/main Packages
>
>       One solution to this problem would be to look for the
> internationalizated string, that is, not to look always for the
> Installed string, but for the translation in the current language (I
> don't know how to use i18n from C, so I can't tell you the concrete
> sentence).
>
>       Another solution could be to use another language independent  
> sentence.
> For example, instead of using apt-cache policy to check if the package
> is installed, you could use dpkg -l, which output is language
> independent and has the form:
>
> nyctalus:~# dpkg -l php5
> Desired=Unknown/Install/Remove/Purge/Hold
> | Estado=No/Instalado/Config-files/Unpacked/Failed-config/Half- 
> installed
> |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err:
> mayúsc.=malo)
> ||/ Nombre         Versión       Descripción
> +++-==============-==============- 
> ============================================
> ii  php5           5.2.0-8+etch7  server-side, HTML-embedded  
> scripting..
>
>       Although the headers are language dependant, the important thing  
> there
> are:
>
>       * ii: Means that the package is completely installed
>       * php5: Is the name of the package
>       * 5.2.0-8+etch7: Is the package version installed
>
>       I hope this could help you to solve the problem and if you need help
> with dpkg commands, I could give it to you.
>
>       Thank you for your attention.
>
> -- 
> Angel L. Mateo Martínez
> Sección de Telemática
> Área de Tecnologías de la Información       _o)
> y las Comunicaciones Aplicadas (ATICA)      / \\
> http://www.um.es/atica                    _(___V
> Tfo: 968367590
> Fax: 968398337
>
>
>

-- 
Jo Rhett
senior geek

Silicon Valley Colocation
Support Phone: 408-400-0550





_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to