I have the following problem: I wrote a script, that extracts information about the installed packages of my system (Ubuntu 16.04 LTS). I am particularly interested in the source of the package. This means, that the data of APT-Sources from apt show <packagename> is crucial for me.
As of now, my script has to call apt show for every single installed package which creates an almost unacceptable workload in comparison to how small of a task this should be [the CPU load reaches almost 100%].
I was hoping, that there was some file on the system, that has all the information stored, that is output by apt show. Reading and parsing that file should be faster than calling apt show thousands of times. Is there such a file?
Please note, that I already tried to use dpkgand apt-cache, but both do not provide the APT-Sources information.
edit: Maybe some elaboration might be useful. My Python script calls apt list --installed to get the list of installed packages and parses this output into a list, containing only the package names as strings.
Then it calls apt show for every element in this list.
I would have liked, to only have a single file, read once, that contains information about the installed packages. I then would have my script parse this file, add the information to the list element and be done in one iteration. My hope was, that reading a large file once and parsing it, is faster than calling a CLI command many hundreds of times.
As such, I assume, that greping over multiple files multiple times would not really decrease the workload.