Bug #15382

APT hooks for ASP should be non-blocking

Added by intrigeri 2018-03-06 09:55:17 . Updated 2018-04-05 17:53:41 .

Status:
Resolved
Priority:
Normal
Assignee:
alant
Category:
Persistence
Target version:
Start date:
2018-03-06
Due date:
% Done:

100%

Feature Branch:
Type of work:
Code
Blueprint:

Starter:
Affected tool:
Additional Software Packages
Deliverable for:
299

Description

The APT package installation currently does not complete until the hook has returned. I suspect that’s not on purpose and one should add exec to the command line in DPkg::Pre-Install-Pkgs and DPkg::Post-Invoke.


Subtasks


History

#1 Updated by intrigeri 2018-03-06 16:33:46

Incidentally, I believe the current implementation breaks features/apt.feature (and any non-interactive usage of APT): no package installation can succeed without the user clicking on the desktop notification. Cc bertagaz so he does not waste time working around what is more likely an implementation mistake rather than behaviour we should adjust our test suite for.

#2 Updated by alant 2018-03-13 12:15:08

  • Status changed from Confirmed to In Progress

Applied in changeset commit:d3a5336e23306a09ac0724ef6f6bc9a0b70e1af4.

#3 Updated by alant 2018-03-13 14:47:10

  • % Done changed from 0 to 50
  • QA Check set to Ready for QA

#4 Updated by alant 2018-03-18 10:49:08

  • Status changed from In Progress to Resolved
  • QA Check changed from Ready for QA to Pass

#5 Updated by alant 2018-03-18 11:11:59

  • Status changed from Resolved to Confirmed
  • QA Check changed from Pass to Dev Needed

Adding exec doesn’t make the hook non-blocking. When using synaptic, adding & after the command makes the hook not being executed at all. To be investigated.

#6 Updated by alant 2018-03-18 11:23:36

  • Assignee changed from alant to intrigeri
  • QA Check changed from Dev Needed to Info Needed

> I suspect that’s not on purpose and one should add exec to the command line

That fails to make the hook non-blocking, and adding & prevent it from being called from synaptic (but works from the terminal). Do you have a magic idea or should I take time to investigate?

#7 Updated by intrigeri 2018-03-18 11:55:07

  • QA Check changed from Info Needed to Dev Needed

>> I suspect that’s not on purpose and one should add exec to the command line

> That fails to make the hook non-blocking,

That’s strange. My understanding of apt.conf(5) suggests it should work. On my system I see that /etc/apt/apt.conf.d/20adequate uses exec. I’ve not verified if it works but I would hope it does. I would suggest you try it out and see if that one works, which should help you figure out why yours does not.

If you want me to help further on the exec option, please push somewhere the exact code you’ve seen fail.

> and adding & prevent it from being called from synaptic (but works from the terminal).

Wow. I’ll ignore this for now: let’s first investigate the exec way, that has greater chances to work (& might not be enough to indicate to the calling apt process that the hook has completed).

> Do you have a magic idea or should I take time to investigate?

Reading apt.conf(5) I have a doubt wrt. how DPkg::Tools::Options plays with what we’re trying to do: it’s not clear to me how APT extracts cmd from the shell scripts we have in DPkg::Pre-Install-Pkgs and DPkg::Post-Invoke. That’s merely anecdotal evidence but on my system, every command for any hook that uses DPkg::Tools::Options starts with cmd, e.g.:

  • DPkg::Pre-Install-Pkgs { "/usr/bin/apt-listchanges […] matches DPkg::Tools::Options::/usr/bin/apt-listchanges::
  • DPkg::Pre-Install-Pkgs { "adequate […] matches DPkg::Tools::Options::adequate::

… so it may be that prefixing our command with exec makes it so DPkg::Tools::Options::/usr/local/sbin/tails-additional-software::Version "3" is unused, which I suspect can break some of our stuff. See how adequate handles this.

Worst case, you’ll need to handle the forking (the double-fork pattern might be needed actually) in the Python script itself.

#8 Updated by intrigeri 2018-03-18 12:02:30

  • Assignee changed from intrigeri to alant

#9 Updated by bertagaz 2018-03-19 10:00:33

intrigeri wrote:
> > and adding & prevent it from being called from synaptic (but works from the terminal).
>
> Wow. I’ll ignore this for now: let’s first investigate the exec way, that has greater chances to work (& might not be enough to indicate to the calling apt process that the hook has completed).

I confirm it works in the terminal, but not in shells that don’t have a TTY, as in the test suite for example. :)

#10 Updated by bertagaz 2018-03-19 11:32:16

  • Status changed from Confirmed to In Progress

Applied in changeset commit:abb33e204cf3f2819b77c699dadf0365471df737.

#11 Updated by alant 2018-03-25 20:59:14

  • % Done changed from 50 to 70
  • QA Check changed from Dev Needed to Ready for QA

This should be fixed by double-forking inside the python script. Tested with synaptic.

#12 Updated by bertagaz 2018-04-03 13:06:18

Indeed according to the test suite Synaptic now works great with ASP. I still had to leave a workaround for the apt install case, but I think that’s because of the remote shell in the test suite, that is not a real one (e.g it has no TTY). So for the test suite part of it this ticket can be considered as solved.

#13 Updated by alant 2018-04-05 17:53:41

  • Status changed from In Progress to Resolved
  • % Done changed from 70 to 100
  • QA Check changed from Ready for QA to Pass