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

Re: Checking for installed package-alternative in a wrapper-skript



> 
> --V0207lvV8h4k8FAm
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
> 
> On Sat, Jun 22, 2002 at 07:08:00PM +0200, Andreas Metzler wrote:
> > Hello,
> > Is there some canonical fast way to check in a script whether inn,
> > inn2 or cnews is installed on the system?
> 
> What dpkg does is parsing /var/lib/dpkg/status.
> I recommend using dpkg - its error prone to rely on an implicit data
> format of the status file.
> 
> If you look in the file, there is a paragraph for each package. What you
> want is searching the Packages: line, then search its Status: line and
> see if its last entry is "installed".
> You could use awk to do this (replace <package> with your package name).
> 
> 
> Greetings, Bastian
> 
> 
> test.sh
> if awk -f test.awk /var/lib/dpkg/status; then
>   echo "installed";
> else=20
>   echo "not installed";
> fi
> 
> test.awk
> /^Package: / { found =3D ($2=3D=3D"<package>"); }
> /^Status: / {
>   if (found) exit ($4!=3D"installed");
> }
> END { if (!found) exit 1; }
> 


Another option might be grep-status from grep-dctrl:

$ for p in inn inn2 cnews; do grep-status -s Status -PX $p; done
Status: purge ok not-installed
Status: purge ok not-installed
Status: purge ok not-installed
$

However beside the fact that grep-dctrl may not be installed I am not 
sure it is faster then dpkg.


> 
> --V0207lvV8h4k8FAm
> Content-Type: application/pgp-signature
> Content-Disposition: inline
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
> 
> iD8DBQE9FLrWeBwlBDLsbz4RAiijAJ9H/h8nid83sYWtkhsBCrvfJw0b2gCfc1X4
> jF3WBZ5lNwVRPrPMVR64Jsk=
> =1bUe
> -----END PGP SIGNATURE-----
> 
> --V0207lvV8h4k8FAm--
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-mentors-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 

-- 

    Shaul Karl, shaulka@bezeqint.n e t



-- 
To UNSUBSCRIBE, email to debian-mentors-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: