Fli*_*int 3 ubuntu debian dpkg apt hook
根据man dpkg
I can use DPKG_HOOK_ACTION
to get the current dpkg action is running in my dpkg hook script
--pre-invoke=command\n--post-invoke=command\n Set an invoke hook command to be run via \xe2\x80\x9csh -c\xe2\x80\x9d before or after the dpkg run for the unpack, configure, install, triggers-only, remove and purge dpkg actions. This\n option can be specified multiple times. The order the options are specified is preserved, with the ones from the configuration files taking precedence. The environment\n variable DPKG_HOOK_ACTION is set for the hooks to the current dpkg action. Note: front-ends might call dpkg several times per invocation, which might run the hooks more\n times than expected.\n
Run Code Online (Sandbox Code Playgroud)\n\n但它似乎在这个钩子命令中不起作用。知道这里出了什么问题吗?
\n\n$ cat /etc/apt/apt.conf.d/99testhook\nDPkg::Pre-Invoke {"echo This is testhook. Current action is $DPKG_HOOK_ACTION; exit 0";};\n\n$ sudo apt-get install screen\n...\nFetched 628 kB in 0s (4,366 kB/s)\nThis is testhook. Current action is\nSelecting previously unselected package screen.\n
Run Code Online (Sandbox Code Playgroud)\n
这仅适用于--pre-invoke
和--post-invoke
选项指定的命令,不适用于在配置中设置命令的情况。
这可以通过将 echo 命令放入脚本中来演示:
# cat > /tmp/pre-invoke.sh <<'EOF'
#!/bin/sh
echo This is testhook. Current action is $DPKG_HOOK_ACTION; exit 0
EOF
# chmod +x /tmp/pre-invoke.sh
# dpkg --pre-invoke=/tmp/pre-invoke.sh -i /var/cache/apt/archives/rsync_3.1.1-2+b1_amd64.deb
This is testhook. Current action is install
(Reading database ... 113857 files and directories currently installed.)
Preparing to unpack .../rsync_3.1.1-2+b1_amd64.deb ...
Unpacking rsync (3.1.1-2+b1) over (3.1.1-2+b1) ...
Setting up rsync (3.1.1-2+b1) ...
Restarting rsync daemon: rsync.
Processing triggers for man-db (2.6.7.1-1) ...
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1356 次 |
最近记录: |