如何解决如何故意保留一半配置?
我正在尝试测试与半配置包相关的 Wazuh 配置。因此,我正在尝试创建一个 .deb
程序包,该程序包在安装时将配置一半。
我开始遵循 these instructions 创建一个非常简单、无所作为的包。
我尝试将 debian/postinst.ex
的退出代码更改为 1,但还是成功安装了软件包。
我尝试将不存在的文件添加到 debian/conffiles
,但 debuild
失败。
我还到处搜索有关可能导致软件包配置一半的情况的信息,但没有任何运气。
谢谢!
解决方法
首先,我想提一下,失败的安装包有两种不同的状态:
- half-configured:包已解压,配置已开始,但由于某种原因尚未完成。
- half-installed:包的安装已经开始,但由于某种原因没有完成。
来源:https://www.man7.org/linux/man-pages/man1/dpkg.1.html
如果你想要一个半配置的包,那么这个包必须是解包的,配置步骤应该会失败。
现在,如果您按照与我们分享的指南进行操作,您可能已经错过了其中说 *.ex
文件是示例且未在包中引入的部分,因此如果您正在修改文件 { {1}},这些更改不会生效。
您可以删除所有 postinst.ex
文件并创建您自己的 *.ex
文件。例如我用过这个:
postinst
使用此文件(使用正确的名称),您的代码将在软件包安装后执行。你会得到这样的东西:
root@ubuntu:/tmp/build/greetings-0.1# cat debian/postinst
#!/bin/sh
# postinst script for greetings
#
# see: dh_installdeb(1)
set -e
case "$1" in
configure)
echo "configuring..."
sleep 1
echo "..."
sleep 2
echo "ERROR!"
exit 1
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
然后,您可以使用 dpkg 上的 root@ubuntu:/tmp/build# apt-get install ./greetings_0.1-1_all.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note,selecting 'greetings' instead of './greetings_0.1-1_all.deb'
The following NEW packages will be installed:
greetings
0 upgraded,1 newly installed,0 to remove and 1 not upgraded.
Need to get 0 B/2916 B of archives.
After this operation,14.3 kB of additional disk space will be used.
Get:1 /tmp/build/greetings_0.1-1_all.deb greetings all 0.1-1 [2916 B]
Selecting previously unselected package greetings.
(Reading database ... 76875 files and directories currently installed.)
Preparing to unpack .../build/greetings_0.1-1_all.deb ...
Unpacking greetings (0.1-1) ...
Setting up greetings (0.1-1) ...
configuring...
...
ERROR!
dpkg: error processing package greetings (--configure):
installed greetings package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
greetings
E: Sub-process /usr/bin/dpkg returned an error code (1)
标志来检查包状态:
-s
如您所见,由于软件包无法处理此类错误,因此软件包仍处于安装状态,其状态为root@ubuntu:/tmp/build# dpkg -s greetings
Package: greetings
Status: install ok half-configured
Priority: optional
Section: unknown
Installed-Size: 14
Maintainer: Person McTester <person@company.tld>
Architecture: all
Version: 0.1-1
Description: <insert up to 60 chars description>
<insert long description,indented with spaces>
Homepage: <insert the upstream URL,if relevant>
我希望这对你有帮助:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。