A library for querying installed (Debian) packages in C?

I need to check if certain Debian packages are installed on the system in my C program. I could use external shell scripts that do apt-cache grep magic with system (), but it seems a little inelegant and hacky as well the fact that it will not work if the user has set the language to another. Is there a C library I can connect with to request package installation?

+1
source share
1 answer

I don’t think that you will find a shipped library that matches your criteria, but the program dpkginternally does exactly what you describe and does not reference C ++ libs (or libstdC ++ in general):

tpost@tpost-desktop:~$ ldd -v /usr/bin/dpkg
        linux-gate.so.1 =>  (0x00f33000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0x00dfb000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x0077a000)
        /lib/ld-linux.so.2 (0x006a6000)

apt-get source dpkg, , , , lib/dpkg , database.c parse.c.

, , , . , GPL , , , .

dpkg dpkg -l | grep ii, , . , , , dpkg .

( dpkg), -, . , , , .

+2

Source: https://habr.com/ru/post/1787069/


All Articles