General overview
I am currently developing a widget for Debian to show the number of the updates complete and the total number of packages to update.
The desired rendering could be something like:
Current update: 4/25
What I already tried
I first genuinely think that it would be sufficient to just test if the following files are existing to be sure an APT job is running:
/var/lib/dpkg/lock
/var/lib/apt/lists/lock
/var/cache/apt/archives/lock
But it doesn’t work, because they also exist even if no update (or any other APT job is running).
An idea (not yet tested) I had
I remember that I’ve seen this kind of widget before on Gnome, so I think it’s possible. But probably (I’m not sure) there is no apt tool to just get the update state.
So the plan is the following:
- The widget will continuously store in a dedicated file the list of update packages ;
- Each time a package from the one stored in this file is detected as updated, so the number of already updated packages will be incremented.
But this seems to be so much overkill for this kind of feature.
The question
- Is it possible to programmatically detect if an APT update is running?
- If yes, is it possible to get the current state (something like « 4/20 »)? And how?
- If 1 and 2 are not possible, should I plan to consider the idea above?