Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When upgrading Ubuntu (and probably other *nixes), the upgrade process will show a diff of changed configuration files and ask whether I'd like to replace them, keep the old version, or manually merge them. I couldn't find any such programs with Google or searching through the Ubuntu packaging documentation. Do you know of any such programs which have the following features?

  • Few or no dependencies (ideally a single shell script).
  • Shell only (ideally without curses).
  • Does not try to be "clever," for example by automatically merging.

Edit: I've written this small thing to do some preliminary checks and ask the user what to do, but it's not very flexible or nice:

for path
do
    if [ ! -e "${path}.new" ]
    then
        # No new revision; skip
        continue
    fi

    if [[ $(diff "${path}"{,.new} | grep '^[<>]' | grep -v '^[<>][[:space:]]*\(#\|START=\)' | wc -l) -eq 0 ]]
    then
        # No interesting lines; skip
        continue
    fi

    clear
    diff -u "${path}"{,.new}

    unset action
    while [[ ! "${action-}" =~ ^[sr]$ ]]
    do
        echo "Do you want to replace $path with ${path}.new?"
        read -s -n 1 -p $'[s]kip, [r]eplace: \n' action
    done

    case "$action" in
        s)
            continue
            ;;
        r)
            cp -v "${path}"{,.new}
            ;;
        *)
            echo "Invalid action ${action}!"
            exit 2
    esac
done
share|improve this question
    
Just for clarification: which system are you on? Ubuntu? –  phunehehe Nov 3 '11 at 11:57
    
@phunehehe: Linux from Scratch and Ubuntu. –  l0b0 Nov 3 '11 at 12:13
    
I'd much rather leverage version control. In fact, I wish Debian packages systematically checked the upstream versions into a branch and let me set up a merge policy. Etckeeper goes part of the way with version control for /etc, but it doesn't record upstream versions, which means you can't go merges. –  Gilles Nov 3 '11 at 22:45

1 Answer 1

I strongly suspect the program you've seen is dpkg the low-level of package management in Debian-ish distributions (using apt(itude)). see here for a blog post explaining its configuration file management.

You could probably hijack this function, i.e., create your own .deb packages - which, I suspect, might be pretty much hassle for what you're trying to achieve.

There's another way to go, you could have a look at NetBSD's etcupdate tool (while it's rather NetBSD-specific, you might find its source (shell script) interesting nonetheless). Apparently, Gentoo has an etc-update, too, but I could find neither sources nor more information (the link also mentions dispatch-conf, could be interesting, too; I don't know.)

share|improve this answer
2  
etc-update is a bash script, and I have uploaded the copy on my machine. –  phunehehe Nov 3 '11 at 15:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.