Hi, I use Gentoo for many, many years and I never reported the following bug, but today I have time :-) If you use etc-update and have configured it to use an editor: diff_command="vim -d %file1 %file2" using_editor=1 etc-update will fail with option 5 (example config), if a previously created foo.dis_0000 exists. The problem is the diff_command. I have extracted code fragments from etc-update to show the problem: ========================================================== #!/bin/bash diff_command="vim -d %file1 %file2" diff_command() { local cmd=${diff_command//%file1/$1} ${cmd//%file2/$2} } do_distconf() { # search for any previously saved distribution config # files and number the current one accordingly local file=$1 ofile=$2 local -i count local suffix local efile for (( count = 0; count <= 9999; ++count )) ; do suffix=$(printf ".dist_%04i" ${count}) efile="${ofile}${suffix}" if [[ ! -f ${efile} ]] ; then mv ${mv_opts} "${file}" "${efile}" break elif diff_command "${file}" "${efile}" &> /dev/null; then # replace identical copy mv "${file}" "${efile}" break fi done } do_distconf src dst exit 0 ========================================================== So if you create a file named src like echo "123" > src and run the script twice, you will see the same problem that etc-update has with option 5. The main bug is that the diff_command function does not honer "using_editor" and so it will deadlock. You need to background etc-update after this and kill it. It would be nice to have a fix for this. Reproducible: Always Steps to Reproduce: 1. Install update of some package. For example postfix 2. Run etc-update 3. Choose option 5 This will create for example /etc/postfix/main.cf.dist_0000 Next time you do the same, etc-update will deadlock, if main.cf.dis_0000 exists. Actual Results: Deadlock Expected Results: Using command "diff" when using "using_editor" would fix the problem
@Marc: Who could fix that?
A fix should be easy (I guess), by replacing: elif diff_command "${file}" "${efile}" &> /dev/null; then with: elif diff -uN "${file}" "${efile}" &> /dev/null; then
Created attachment 461874 [details, diff] /usr/sbin/etc-update Could PLEASE someone commit this patch and respond to my very old bug report. It is really annoying now
Indeed it seems like using diff_command here is wrong because it may be interactive. Since options/flags can be passed to diff, it may be a bit tricky if the user specified -b or something, so I guess it should respect editor indeed. Perhaps something like this? --- /usr/sbin/etc-update 2015-10-07 23:49:58.000000000 +0200 +++ /var/tmp/etc-update 2017-01-30 09:00:16.386340335 +0100 @@ -649,10 +649,21 @@ elif [[ -L ${efile} || -L ${file} ]] ; then # not the same file types continue - elif diff_command "${file}" "${efile}" &> /dev/null; then - # replace identical copy - mv "${file}" "${efile}" - break + else + local ret= + if [[ ${using_editor} == 0 ]] ; then + diff_command "${file}" "${efile}" &> /dev/null + ret=$? + else + # fall back to plain diff + diff -q "${file}" "${efile}" &> /dev/null + ret=$? + fi + if [[ ${ret} == 0 ]] ; then + # replace identical copy + mv "${file}" "${efile}" + break + fi fi done }
It is ok to just use "diff -uN" like in my patch, as it doesn't matter what the user specified in his configuration file. It is not interactive or something else :-) It only tries to figure out, if to *.dist_xxxx files are the same or not. And diff is always there, so the patch perfectly works. Can you please accept it and use it :-)
Why tell diff to produce unified diffs and treat non-existing files as empty ones if we just ensured both files exist? It just results in more output that we're going to ignore, hence my switch to -q.
This is in the master branch: https://gitweb.gentoo.org/proj/portage.git/commit/?id=246373bbe52c55e912381d8555cceb70db0ec41b
(In reply to Zac Medico from comment #7) > This is in the master branch: > > https://gitweb.gentoo.org/proj/portage.git/commit/ > ?id=246373bbe52c55e912381d8555cceb70db0ec41b Thanks :) Looking forward to see it in stable package :) Please leave me a note when it is available
Fixed in portage-2.3.5.