From afe2632631100fe36c968f96ea34a9060a5571f5 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 25 May 2007 18:31:55 +0000 Subject: [PATCH] Upgrade only if the user asked for upgrade in debconf --- debian/postinst | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/debian/postinst b/debian/postinst index 3b09dcc..80b0827 100644 --- a/debian/postinst +++ b/debian/postinst @@ -25,16 +25,17 @@ case "$1" in # dbconfig-common but for sqlite, there is no way to add a # column to a table. Therefore, we dump here the table and add # the column. - case "$dbc_dbtype" in - sqlite) - db="${dbc_basepath}/${dbc_dbname}" + [ "$dbc_upgrade" = "true" ] && { + case "$dbc_dbtype" in + sqlite) + db="${dbc_basepath}/${dbc_dbname}" # OK, we need to check if the table contains html_signature - if ! sqlite "$db" '.schema identities' | grep -q html_signature; then - # We need to add it - echo -n "Need to upgrade 'identities' table in $db... " - upgrade_tmp=$(mktemp -t roundcube.sqlite.XXXXXXXXXX) - ( - cat < $upgrade_tmp - sqlite "$db" < $upgrade_tmp - rm $upgrade_tmp - echo "OK" - fi - ;; - *) - # Do nothing - ;; - esac + # We dump and keep only inserts + sqlite "$db" '.dump identities' | \ + awk '/^INSERT INTO/ {start = 1} {if (start == 1) print}' | \ + head -n -2 | \ + sed 's/^\(INSERT INTO identities \)/\1(identity_id, user_id, del, standard, name, organization, email, "reply-to", bcc, signature) /' + echo 'COMMIT;' ) > $upgrade_tmp + sqlite "$db" < $upgrade_tmp + rm $upgrade_tmp + echo "OK" + fi + ;; + *) + # Do nothing + ;; + esac + } CONFFILE=/etc/roundcube/main.inc.php touch $CONFFILE.ucftmp -- 2.39.2