Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:diffupgrade

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
becki:linux:diffupgrade [2009-07-02 11:55]
becki created
becki:linux:diffupgrade [2011-06-08 16:26] (aktuell)
becki
Zeile 1: Zeile 1:
-====== Upgrading Configuration Files with the Diffutils ​== +====== Upgrading Configuration Files with a three-way File Merge == 
-===== Probelm ​==+===== Problem ​==
  
-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.+When upgrading ​software (e.g. with [[slack_upgrade|slackpkg]]) ​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 ​==+===== Solution ​==
  
-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/​'':​+The solution is exemplified ​with just 1 configuration ​file called ​''​conf'':​
  
-  ​mv new/conf new/conf.org +  ​* ''​conf.org''​ is the original config 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
-  ​diff3 -m new/conf.org .old/conf.org old/conf > new/conf+  ​* ''​conf''​ is your version of ''​conf.org''​You have customized to your needs. 
 +  * ''​conf.new''​ is the brandnew pristine version coming from the upgrade.
  
-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.+The following command merges both the differences between ​''​conf.org'' ​and ''​conf'' ​and the differences between ''​conf.org''​ and ''​conf.new''​ back into ''​conf'':​
  
-An alternateve approach is by using the diff/patch commands:+  merge conf conf.org conf.new
  
-  cd old +After merging it is advisable to rename ​conf.new ​to be prepared for a future update:
-  diff -u conf.org conf > conf.diff  +
-  cd ../new +
-  patch < ../​old/​conf.diff+
  
-===== Examples where the tools fail ==+  mv conf.new conf.org
  
-A manual check after the patch is applied ​is advisable, for there are sitiation where do not produce the expected results:+<note tip>All ''​*.org''​ files can serve as a reminder for you to trace back all the modifications you did to the system. But sometimes you have to create a config file which did not exist before (e.g. ''​myConfigFile''​). In order not to forget such files during update, it is advisable ​to create an //empty// counterpart file ''​myConfFile.org''​.</​note>​
  
-==== diff/patch Failure ​==+===== Example where the tools fail ==
  
-This is an example ​where diff/patch doesn'​t work as expected ​(but diff3 works):+A manual check after the patch is applied is advisable, for there are situations imaginable ​where the tools do not produce the expected ​results:
  
 <​code>​ <​code>​
-old/conf.org: ​ old/conf:   new/conf.org  ​desired: ​   result:+conf.org: ​     conf:       ​conf.new:     desired: ​   result:
  
 [mitwitz] ​     [mitwitz] ​  ​[coburg] ​     [coburg] ​   [coburg] [mitwitz] ​     [mitwitz] ​  ​[coburg] ​     [coburg] ​   [coburg]
Zeile 45: Zeile 43:
                            ​Franz=8 ​      ​Franz=-999 ​ Franz=8                            ​Franz=8 ​      ​Franz=-999 ​ Franz=8
                            ​Helga=9 ​      ​Helga=9 ​    ​Helga=9                            ​Helga=9 ​      ​Helga=9 ​    ​Helga=9
-                           ​Egon=10 ​      ​Egon=10 ​    ​Egon=10 
-                           ​Anton=11 ​     Anton=11 ​   Anton=11 
 </​code>​ </​code>​
  
-==== diff/patch and diff3 Failure ​==+===== Alternatives ​==
  
-This is an example where neither of the tools work as expected: +  * An alternative to the ''​merge''​ command ​is ''​diff3'',​ it should produce ​the same result:<​code ​bash
- +diff3 -m conf conf.org conf.new conf.out 
-<​code>​ +mv conf.out conf
-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+
 </​code>​ </​code>​
 +  * A 2nd alternative to merge are the diff/patch tools. See [[diff patch tips]]
  
becki/linux/diffupgrade.1246535721.txt.gz · Zuletzt geändert: 2009-07-02 11:55 von becki

Impressum - Datenschutzerklärung