为什么 postrm 在清除时运行两次?

为什么 postrm 在清除时运行两次?

我创建了一个包含postrm删除用户的脚本的包。运行时sudo apt-get remove ...,该postrm脚本的行为符合预期:

vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get -y remove datim4u-auto-cert-updater
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  datim4u-auto-cert-updater
0 upgraded, 0 newly installed, 1 to remove and 32 not upgraded.
After this operation, 18.4 kB disk space will be freed.
(Reading database ... 70225 files and directories currently installed.)
Removing datim4u-auto-cert-updater (1.0.1~trusty) ...
Removing user datim4u_auto_cert_updater and its home directory...
Looking for files to backup/remove ...
Removing files ...
Removing user `datim4u_auto_cert_updater' ...
Warning: group `datim4u_auto_cert_updater' has no more members.
Done.

但是,在运行时sudo apt-get purge ...postrm脚本运行了两次,导致错误/usr/sbin/deluser: The user '...' does not exist.

vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get -y purge datim4u-auto-cert-updater
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  datim4u-auto-cert-updater*
0 upgraded, 0 newly installed, 1 to remove and 32 not upgraded.
After this operation, 18.4 kB disk space will be freed.
(Reading database ... 70225 files and directories currently installed.)
Removing datim4u-auto-cert-updater (1.0.1~trusty) ...
Removing user datim4u_auto_cert_updater and its home directory...
Looking for files to backup/remove ...
Removing files ...
Removing user `datim4u_auto_cert_updater' ...
Warning: group `datim4u_auto_cert_updater' has no more members.
Done.
Purging configuration files for datim4u-auto-cert-updater (1.0.1~trusty) ...
Removing user datim4u_auto_cert_updater and its home directory...
/usr/sbin/deluser: The user `datim4u_auto_cert_updater' does not exist.

答案1

这是意料之中的,也是正常的。维护者脚本可能在包配置期间被多次调用,并且它们被调用时带有一个参数,指示它们被调用的操作。你可以在Debian Wiki 页面中的维护者脚本,包括此流程图移除和清除(与首先删除然后在不同操作中清除的包相反):

<code>postrm remove</code>,然后 <code>postrm purge</code>

全部您的维护脚本({pre,post}{inst,rm})应该注意传递给它们的参数并采取相应的行动。

相关内容