我需要将命令行选项传递给 apt 以便挂接 apt-get install/update 的执行。
我知道这可以通过更改配置文件来完成/etc/apt/apt.conf
,但我希望能够从命令行执行此操作,因为我只需要几次。
具体来说,我希望能够执行一个脚本,出于测试目的,我将其位于/home/jake/agio
。
不幸的是,apt-get 似乎不太容易打印错误或无法正常工作的原因。显然我已经测试了该脚本并且它可以正常工作。
我想我已经尝试了 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
你能帮助我吗?!
-o Debug::pkgProblemResolver=yes
工作中。
答案1
当我检查现有apt
配置时,我看到:
~ 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";
尝试各种变化后,看起来正确的形式应该是-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";
确实如此:
~ 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