postinst中的db_input不起作用 [英] db_input in postinst doesn't work

查看:453
本文介绍了postinst中的db_input不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个postinst脚本的问题,我必须要求root密码MySQL为我的应用程序创建一些用户。我知道,在postinst中使用db_input是不好的做法,但我真的需要它。
为什么当我安装我的应用程序表单存储库时,这个postinst不起作用,当我将其安装为.deb包时可以正常工作?



postinst:

 #!/ bin / bash -e 

。 / usr / share / debconf / confmodule

db_input high my_app / mysql_root_password || true
db_go

错误:

  dpkg:错误处理我的应用程序(--configure):
子程序安装安装后脚本返回错误退出状态30
配置为不写apport报告
处理时遇到错误:
my-app
E:子进程/ usr / bin / dpkg返回错误代码(1)
/ pre>

解决方案

差异可能与您的postinst运行时如何设置终端有关;可能适用于与您自己运行dpkg时发生的不同。也许apt-wrapped postinst调用甚至没有分配TTY;我不太清楚,但是我并不认为在postinst中放置 db_input 甚至是支持,所以可能很难解决它。如果真的,真的需要从postinst脚本本身提出问题,您可以通过在debhelper命令运行的环境中将 $ DEBCONF_DEBUG 设置为开发人员进行调试



但是,我认为一个更有用的解决方案是这样的:你真的应该使用一个 debian / config 脚本对于 db_input ,建议。什么是阻止你?


I have a problem with postinst script, I have to ask root password for MySQL to create some user for my application. I know, it's bad practice to use db_input in postinst however I really need it. Why this postinst doesn't work when I install my app form repository but works properly when I install it as .deb package?

postinst:

#!/bin/bash -e

. /usr/share/debconf/confmodule

db_input high my_app/mysql_root_password || true
db_go

error:

dpkg: error processing my-app (--configure):
 subprocess installed post-installation script returned error exit status 30
configured to not write apport reports
                                      Errors were encountered while processing:
 my-app
E: Sub-process /usr/bin/dpkg returned an error code (1)

解决方案

The difference probably has something to do with how the terminal is set up when your postinst is run; probably apt does something differently from what happens when you run dpkg on its own. Maybe apt-wrapped postinst invocations don't even have a TTY allocated; I'm not sure, offhand.

But I don't think that putting db_input in a postinst is even supported, so it may be difficult for you to fix it as is. If you really, really need to ask questions from the postinst script itself, you may be able to debug by setting $DEBCONF_DEBUG to "developer" in the environment where the debhelper commands run.

However, I think a more useful solution will be this: you really should use a debian/config script for db_input, as is recommended. What is stopping you?

这篇关于postinst中的db_input不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆