0

I need to pass a command line option to apt in order to hook the execution of of apt-get install/update.

I know this can be done changing the configuration files in /etc/apt/apt.conf, but I want to be able to do it from command line, because i need it only a few times.

Specifically, I want to be able to execute a script, which for testing purposes I locaed in /home/jake/agio.

Unfortunately, apt-get does not seems to be very prone to printing the errors or the reason why this is not working. And obviously I have tested the script and is working.

I think I have tried all the possible combinations of options for apt-get:

apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o APT::Update::Post-Invoke-Success="/home/jake/agio" update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o APT::Update::Post-Invoke-Success={"/home/jake/agio"} update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o APT::Update::Post-Invoke-Success={"/home/jake/agio"\;} update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o APT::Update::Post-Invoke-Success={"/home/jake/agio "} update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o APT::Update::Post-Invoke-Success=/home/jake/agio update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o APT::Update::Post-Invoke-Success=/home/jake/agio update


apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke="/home/jake/agio" install youtube-dl
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke={"/home/jake/agio"} install youtube-dl
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke={"/home/jake/agio"\;} install youtube-dl
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke={"/home/jake/agio "} install youtube-dl
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke=/home/jake/agio install youtube-dl
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke=/home/jake/agio install youtube-dl


apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke="/home/jake/agio" update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke={"/home/jake/agio"} update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke={"/home/jake/agio"\;} update
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke={"/home/jake/agio "} update 
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke=/home/jake/agio update  
apt-get -y remove youtube-dl &&  apt-get -o Debug::pkgProblemResolver=yes -o DPkg::Post-Invoke=/home/jake/agio update

Can you help me?!

-o Debug::pkgProblemResolver=yes is working.

2

When I inspect existing apt configuration, I see:

~ apt-config dump | grep -i dpkg::post
DPkg::Post-Invoke "";
DPkg::Post-Invoke:: "if [ -d /var/lib/update-notifier ]; then touch /var/lib/update-notifier/dpkg-run-stamp; fi; /usr/lib/update-notifier/update-motd-updates-available 2>/dev/null || true";

And so trying out variations, it looks like the correct form would be -o DPkg::Post-Invoke::=/home/jake/agio:

$ apt-config -o DPKG::Post-invoke::='foo bar' dump | grep -i DPkg::Post
DPkg::Post-Invoke "";
DPkg::Post-Invoke:: "if [ -d /var/lib/update-notifier ]; then touch /var/lib/update-notifier/dpkg-run-stamp; fi; /usr/lib/update-notifier/update-motd-updates-available 2>/dev/null || true";
DPkg::Post-Invoke:: "foo bar";

And indeed:

~ sudo apt-get -o DPkg::Post-Invoke::='foo bar' install snapd-          
Reading package lists... Done
[...]
Processing triggers for man-db (2.7.5-1) ...
sh: 1: foo: not found
E: Problem executing scripts DPkg::Post-Invoke 'foo bar'
E: Sub-process returned an error code
2
  • I came to the same conclusion - however I'm still confused why DPKG::Post-invoke='foo bar' doesn't work, since it appears to insert foo bar as the first item in the list (replacing the empty string). – steeldriver Apr 20 '18 at 14:12
  • @steeldriver the way the output looks, I think the list members all come in the :: subsection, so maybe the empty string is not the first item in the list or part of the list at all, but some other attribute of Post-Invoke that doesn't have any meaning. – muru Apr 20 '18 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.