我有一个自制的Debian包,它可以安装两个脚本文件、两个systemd服务和一个tar文件。手工制作的保持器脚本有前置脚本、后期脚本、预脚本和postrm。
我目前遇到的问题是,当我运行dpkg --purge 时,进程会被某些东西所扼杀(我不确定是什么):
root@host:/data# dpkg --purge
(Reading database ... 32393 files and directories currently installed.)
Removing (第二次运行完全相同的命令时,它运行得很好。
root@host:/data# dpkg --purge
(Reading database ... 32393 files and directories currently installed.)
Removing () ...
dpkg: warning: while removing , unable to remove directory '/data': Device or resource busy - directory may be a mount point?
Purging configuration files for () ...
dpkg: warning: while removing web-chroot, unable to remove directory '/data': Device or resource busy - directory may be a mount point?
root@host:/data#注意: /data实际上是一个挂载点,它不属于任何其他Debian包,因此dpkg尝试(但失败)删除它。这被认为是Debian实现dpkg__的预期行为。
我的问题是,why是dpkg -清除过程在第一次运行时就会被杀死吗?什么会杀死它?
我试过检查各种日志,包括:
/var/log/dpkg.log/var/log/apt/history.log/var/log/apt/term.log/var/lib/dpkg/info/.* (.list,.prerm,.postrm,.preinst,.postinst)但是,没有什么能给我任何有用的指示,说明正在发生的事情。
注意: Debian包被安装到Debian 8 32位系统上。
The详细信息:Debian包在以下位置安装文件:
/~/start-fs.sh/~/stop-fs.sh/data/file-system_.tar.gz/etc/systemd/system/file-system.service/etc/systemd/system/file-system-helper.service维护人员脚本如下:
preinst
#!/bin/bash
# Stop services if they are running and disable them
systemctl is-active --quiet file-system && systemctl stop file-system > /dev/null 2>&1 || true
sleep 1
systemctl disable --quiet file-system.service || true
systemctl is-active --quiet file-system-helper && systemctl stop file-system-helper > /dev/null 2>&1 || true
# Remove any previous tars that could share the same name as the tar artifact
rm -f /data/file-system*.tar.gz
exit 0postinst
#!/bin/bash
error() {
echo "$1"
exit 1
}
# Untar the artifact in the /data directory
tar -xzf /data/file-system*.tar.gz --directory /data || error "Could not untar artifact"
# Remove tar artifact, as it has already been untarred
rm -f /data/file-system*.tar.gz
# Restart systemctl daemon to let it know about new service files
systemctl daemon-reload
# Enable service if it is not running and enable it
systemctl is-active --quiet file-system || systemctl start file-system
systemctl enable --quiet file-system.service
exit 0prerm
#!/bin/bash
# Stop services if they are running and disable them
systemctl is-active --quiet file-system && systemctl stop file-system.service > /dev/null 2>&1 || true
sleep 3
systemctl disable --quiet file-system.service || true
systemctl is-active --quiet file-system-helper && systemctl stop file-system-helper.service > /dev/null 2>&1 || true
exit 0postrm
#!/bin/bash
# Remove scripts
rm -f /root/start-fs.sh
rm -f /root/stop-fs.sh
# Remove fs in data dir
rm -rf /data/file-system/
# Remove any possible leftover artifacts (shouldn't be any)
rm -f /data/file-system*.tar.gz
# Remove systemd services
rm -f /etc/systemd/system/file-system-helper.service
rm -f /etc/systemd/system/file-system.service
exit 0当我第一次运行dpkg -s 时,它变成了half-configured,根据dpkg的意思是The package is unpacked and configuration has been started, but not yet completed for some reason.
root@host:/data# dpkg -s
[...]
Status: purge ok half-configured
[...]另外,如果我手动运行./prerm脚本,然后在使用dpkg -i 安装之后手动运行./postrm脚本,则包将成功卸载并正确删除文件。
发布于 2020-05-18 00:52:03
看起来,您正在尝试从维护脚本中重新实现dpkg应该做的事情,但是没有考虑到调用这些脚本的所有方式。
例如,在升级期间还会调用预录制和postrm!
我的建议是避免与tar跳奇怪的舞蹈,直接在.deb中提供这些文件,并停止手动删除.deb中提供的任何文件。只需在需要时让dpkg处理拆包和拆下。
然后,对于何时调用systemd的内容,您应该查看维护人员脚本流程图,无论是从Debian策略还是从各种deb- man页面(尽管这些都不太详细)。
https://unix.stackexchange.com/questions/558267
复制相似问题