1

I'm upgrading some packages using Aptitude, and I want to get some program-readable status updates. I thought I could direct dpkg --status-fd to a file I open in advance (regular file for this experiment, but ultimately a named pipe), like this:

aptitude -o 'Dpkg::Options::=--status-fd=3' install 3>dpkg-status-log

But it seems that Aptitude closes my file descriptor before it runs dpkg:

dpkg: error: unable to read filedescriptor flags for <package status and progress file descriptor>: Bad file descriptor
E: Sub-process /usr/bin/dpkg returned an error code (2)

Is there an alternative way to get some progress feedback, short of trying to parse standard output?

Toby Speight
  • 8,678
  • What's the kind of progress information you're interested in? And what's the specific reason you need to use the rather interactive aptitude frontend for something where you need to know the progress programmatically? – Marcus Müller Feb 22 '23 at 14:54
  • @Marcus, I use Aptitude because it's usually better at resolving dependency problems (and because I know it well). I just want to update a "progress bar" to give user feedback that we're still working towards the goal (GUI application where users wouldn't want or understand the usual stdout). If I can use a different APT frontend, then I'm open to that suggestion. – Toby Speight Feb 22 '23 at 14:57
  • Ooh, the hint to look at plain apt-get reveals APT::Status-Fd config option. I think I can write my own answer based on what I found. Stand by! – Toby Speight Feb 22 '23 at 15:28
  • You can probably coax it with this procedure. It seems to work for me. https://askubuntu.com/questions/445245/how-do-i-enable-fancy-apt-colours-and-progress-bars#445246 – DDay Feb 22 '23 at 15:42
  • @DDay - that's something different - progress bar on a terminal, not to another program. – Toby Speight Feb 22 '23 at 15:46
  • Thanks @Marcus for a hint that actually led to my self-answer. – Toby Speight Feb 22 '23 at 15:47

1 Answers1

0

There's a pointer in APT's README.progress-reporting file:

If the apt options: "APT::Status-Fd" is set, apt will send status reports to that fd.

A simple experiment using aptitude -o 'APT::Status-Fd=3' install works where my attempt with Dpkg::Options:: did not, and I get a series of pmstatus lines that are ideal for my needs (in fact, it's more suitable than dpkg's own output, as I can just use column 3 from the pmstatus lines as "% complete").

Toby Speight
  • 8,678