Package: ucf
Version: 3.0018
Severity: important
Tags: patch
User: [email protected]
Usertags: origin-ubuntu karmic ubuntu-patch

Hi Manoj,

There are many bug reports in Ubuntu resulting from users invoking the
three-way-merge option in ucf and getting maintainer script errors as a
result of failed merges.  It should be possible to handle merge failures in
a more user-friendly manner, instead of propagating a non-zero exit code to
the calling maintainer script and causing cascading failures that make a
mess of a dist-upgrade.

Specifically, since anything the user could possibly want to do to resolve
the conflict can be done from the ucf debconf menu anyway, and after
resolving the conflict the user will still have to call the maintainer
script again to get the package into the right state, why not trap this
error and return the user to the menu to finish up?

The attached patch implements precisely this.  I'm uploading this change to
Ubuntu; changelog entry for that upload:

  * On a three-way merge conflict, output the error message using a debconf
    error and then return to the debconf menu - instead of throwing a
    non-zero error code and causing the package install to abort.  Anything
    the user needs to do to fix up the broken merge can be done as well
    from the debconf menu as from after the install failure, and this way we
    don't have a logjam of failed package installs on dist-upgrade.
    LP: #269539, #293687.

FWIW, the patch does not attempt to implement a debconf fallback; while I
see that you haven't completely removed all of the non-debconf code from
ucf, I don't expect there to be any future need to support debconfless
prompting in this script so I haven't bothered with that fallback path.

Cheers,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
[email protected]                                     [email protected]
diff -Nru ucf-3.0018/debian/templates.master 
ucf-3.0018ubuntu1/debian/templates.master
--- ucf-3.0018/debian/templates.master  2008-05-29 23:31:26.000000000 -0700
+++ ucf-3.0018ubuntu1/debian/templates.master   2009-08-25 15:52:36.000000000 
-0700
@@ -35,3 +35,12 @@
 #flag:translate!:2
 _Description: Line by line differences between versions
  ${DIFF}
+
+Template: ucf/conflicts_found
+Type: error
+_Description: Conflicts found in three-way merge
+ Conflicts found during three-way merge! Please edit `${dest_file}' and sort
+ them out manually.
+ .
+ The file `${dest_file}.${NEW_SUFFIX}' has a record of the failed merge of
+ the configuration file.
diff -Nru ucf-3.0018/ucf ucf-3.0018ubuntu1/ucf
--- ucf-3.0018/ucf      2009-03-21 21:38:37.000000000 -0700
+++ ucf-3.0018ubuntu1/ucf       2009-08-25 16:00:26.000000000 -0700
@@ -1003,22 +1003,22 @@
                         0)
                            new_file="$dest_file.${NEW_SUFFIX}"
                            RETAIN_OLD=YES
-                           replace_conf_file;
+                           replace_conf_file
+                           rm -f "$dest_file.${NEW_SUFFIX}" # don't need this 
around no mo'
+                           exit 0
                             ;;
                         *)
-                           echo >&2
-                           echo >&2 " Conflicts found! Please edit" \
-                               "\`$dest_file' and sort them out manually."
-                           echo >&2 " The file \`$dest_file.${NEW_SUFFIX}' has 
a" \
-                               "record of the failed merge of the 
configuration file."
-                           echo >&2
-                            exit 3                            
+                           db_subst ucf/conflicts_found dest_file "$dest_file"
+                           db_subst ucf/conflicts_found NEW_SUFFIX 
"${NEW_SUFFIX}"
+                           db_input critical ucf/conflicts_found || true
+                           db_go || true
+                           ;;
                     esac
                else 
-                   replace_conf_file;
+                   replace_conf_file
+                   rm -f "$dest_file.${NEW_SUFFIX}" # don't need this around 
no mo'
+                   exit 0
                fi
-                rm -f "$dest_file.${NEW_SUFFIX}" # don't need this around no 
mo'
-                exit 0
                ;;
            shell|Z|z)
                 if tty -s; then

Attachment: signature.asc
Description: Digital signature

Reply via email to