Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:diffupgrade

Dies ist eine alte Version des Dokuments!


Upgrading Configuration Files with the Diffutils

Probelm

When upgrading e.g. web based software or the Linux OS you usually have customized the config files to your personal need. Now the config files of the new software version also differ from the original version. What you want is an easy way to get your own modifications into the new config files.

Basic Principle

The directory old/ contains the files of the old version of the software (with personal costumizations) whereas new/ is the brandnew pristine version. The following commands merge the personal modifications of the exemplary file conf from old/ into new/:

mv new/conf new/conf.org
diff3 -m new/conf.org .old/conf.org old/conf > new/conf

An alternative approach is by using the diff/patch commands:

cd old
diff -u conf.org conf > conf.diff 
cd ../new
patch < ../old/conf.diff

Note that you need old/conf.org, which is the original file of old version of the software. Eighter you have created that file by copying before you made any modifications to conf or you can get it again by downloading the old version of the software.

Sometimes you have to create a file which did not exist before (e.g. myConfFile). In order not to forget such files during update, it is advisable to create an empty counterpart file myConfFile.org.

Examples where the tools fail

A manual check after the patch is applied is advisable, for there are sitiation where do not produce the expected results:

diff/patch Failure

This is an example where diff/patch doesn't work as expected (but diff3 works):

old/conf.org:  old/conf:   new/conf.org  desired:    result:

[mitwitz]      [mitwitz]   [coburg]      [coburg]    [coburg]
Otto=5         Otto=5      Otto=5        Otto=5      Otto=5
Guenter=6      Guenter=6   Guenter=6     Guenter=6   Guenter=6
Harry=7        Harry=7     Harry=7       Harry=7     Harry=7
Franz=8        Franz=-999  Franz=8       Franz=8     Franz=-999
Helga=9        Helga=9     Helga=9       Helga=9     Helga=9
Egon=10        Egon=10     Egon=10       Egon=10     Egon=10
Anton=11       Anton=11    Anton=11      Anton=11    Anton=11
                           [mitwitz]     [mitwitz]   [mitwitz]
                           Otto=5        Otto=5      Otto=5
                           Guenter=6     Guenter=6   Guenter=6
                           Harry=7       Harry=7     Harry=7
                           Franz=8       Franz=-999  Franz=8
                           Helga=9       Helga=9     Helga=9
                           Egon=10       Egon=10     Egon=10
                           Anton=11      Anton=11    Anton=11

diff/patch and diff3 Failure

This is an example where neither of the tools work as expected:

old/conf.org:  old/conf:   new/conf.org  desired:    result:

[mitwitz]      [mitwitz]   [coburg]      [coburg]    [coburg]
Otto=5         Otto=5      Otto=5        Otto=5      Otto=5
Guenter=6      Guenter=6   Guenter=6     Guenter=6   Guenter=6
Harry=7        Harry=7     Harry=7       Harry=7     Harry=7
Franz=8        Franz=-999  Franz=8       Franz=8     Franz=-999
Helga=9        Helga=9     Helga=9       Helga=9     Helga=9
Egon=10        Egon=10     Egon=10       Egon=10     Egon=10
Anton=11       Anton=11    Anton=11      Anton=11    Anton=11
                           [mitwitz]     [mitwitz]   [mitwitz]
                           Otto=5        Otto=5      Otto=5
                           Guenter=6     Guenter=6   Guenter=6
                           Harry=7       Harry=7     Harry=7
                           Franz=8       Franz=-999  Franz=8
                           Helga=9       Helga=9     Helga=9
Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/diffupgrade.1246701504.txt.gz · Zuletzt geändert: 2009-07-04 09:58 von becki

Impressum - Datenschutzerklärung