清除Debian软件包丢弃数据库

时间:2014-04-27 13:59:05

标签: database deb

我正在为ubuntu创建一个deb包

在我的postinst脚本中我使用

# Configure database
dbc_mysql_createdb_encoding="UTF8"

if ! dbc_go portal3 $@ ; then
    echo 'Automatic configuration using dbconfig-db_version 2.0common failed!'
fi

创建数据库的工作正常。

在postrm文件中我有:

echo "Remove database"
if [ -f /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
fi
if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
    . /usr/share/dbconfig-common/dpkg/postrm
    if ! dbc_go portal3 $@ ; then
        echo 'Automatic configuration using dbconfig-common failed!'
    fi
fi

但这不会删除创建的用户或数据库。 控制台或其他任何可以帮助我调试问题的响应都没有。

有人知道如何删除安装时创建的数据库和用户吗?

1 个答案:

答案 0 :(得分:0)

它还需要像

这样的prerm脚本
#!/bin/sh
set -e

. /usr/share/debconf/confmodule
. /usr/share/dbconfig-common/dpkg/prerm.mysql
if ! dbc_go portal3 $@ ; then
    echo 'Automatic configuration using dbconfig-common failed!'
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

exit 0

否则dbconfig-commond不知道什么数据库需要dropt。