This is an automated email from the git hooks/post-receive script.

cbaines-guest pushed a commit to branch debconf
in repository tilelite.

commit 0098fdbfe014c62115fc356567eff968fd7182b2
Author: Christopher Baines <m...@cbaines.net>
Date:   Mon Sep 7 22:34:24 2015 +0100

    Attempt to fix an issue with db_get returning a error message as the RET
    
    When running in developer mode, I was seeing output like this. 
Unfortunately I
    am no longer able to get debconf to give the same responses.
    
    debconf (developer): <-- GET tilelite/tilesets
    debconf (developer): --> 10 tilelite/tilesets doesn't exist
    
    I think by checking the return code from db_get, I am able to use a default
    value instead of the RET, which means things don't break when debconf 
decides
    to act in this way.
---
 debian/config | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/debian/config b/debian/config
index d38f9b6..5a441ea 100755
--- a/debian/config
+++ b/debian/config
@@ -18,6 +18,20 @@ TILESET_QUESTIONS=(processname mapfile url user group)
 
 TILESET_QUESTIONS_WITHOUT_PROCESSNAME=(mapfile url user group)
 
+db_get_or_default() {
+    local key=$1
+    local default=$2
+
+    db_get $key
+    local return_value=$?
+
+    if ! db_get $key; then
+        $RET=$default
+    fi
+
+    return 0
+}
+
 containsElement() {
        # https://stackoverflow.com/a/8574392
        local e
@@ -123,7 +137,7 @@ change_tileset() {
 
                db_go || return 0 # user has canceled
 
-               db_get tilelite/change-tileset && processname="$RET"
+               db_get_or_default tilelite/change-tileset "" && 
processname="$RET"
        else
                processname=${TILESETS[0]}
 
@@ -146,7 +160,7 @@ change_tileset() {
 
        db_go
 
-       db_get tilelite/processname && new_processname="$RET"
+       db_get_or_default tilelite/processname "" && new_processname="$RET"
 
        if [ "$new_processname" != "$processname" ]; then
                # change the name of the tileset
@@ -159,7 +173,7 @@ change_tileset() {
                for question in ${TILESET_QUESTIONS_WITHOUT_PROCESSNAME[@]}; do
                        db_register tilelite/$question "$new_prefix$question" 
|| return 1
 
-                       db_get "$old_prefix$question" && answer="$RET"
+                       db_get_or_default "$old_prefix$question" "" && 
answer="$RET"
 
                        db_set "$new_prefix$question" "$answer"  || return 1
 
@@ -193,7 +207,7 @@ remove_tileset() {
 
                db_go || return 0
 
-               db_get tilelite/remove-tileset && processname="$RET"
+               db_get_or_default tilelite/remove-tileset "" && 
processname="$RET"
        else
                processname=${TILESETS[0]}
 
@@ -206,7 +220,7 @@ remove_tileset() {
 
        db_go || return 0 # user has canceled
 
-       db_get tilelite/confirm-tileset-removal && confirm_removal="$RET"
+       db_get_or_default tilelite/confirm-tileset-removal "" && 
confirm_removal="$RET"
 
        if ! $confirm_removal; then
                log "user has not confirmed removal, going back"
@@ -241,7 +255,7 @@ select_action() {
                return 0 # user has canceled
        fi
 
-       db_get tilelite/select-action && action="$RET"
+       db_get_or_default tilelite/select-action "" && action="$RET"
 
        case "$action" in
                Add) add_tileset || return 1
@@ -255,7 +269,7 @@ select_action() {
 
 configure() {
        while true; do
-               db_get tilelite/tilesets
+               db_get_or_default tilelite/tilesets ""
 
                local joined_tilesets="$RET"
 
@@ -274,7 +288,7 @@ configure() {
 
                        db_go
 
-                       db_get tilelite/add-tileset && add="$RET"
+                       db_get_or_default tilelite/add-tileset "" && add="$RET"
                        if $add; then
                                add_tileset
                        else
@@ -294,7 +308,7 @@ configure() {
                        return 1
                fi
 
-               db_get tilelite/finished && finished="$RET"
+               db_get_or_default tilelite/finished "" && finished="$RET"
 
                if $finished; then
                        break

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/tilelite.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to