[haiku-commits] r43059 - in haiku/trunk/3rdparty: . pulkomandy

  • From: pulkomandy@xxxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 1 Nov 2011 13:40:51 +0100 (CET)

Author: pulkomandy
Date: 2011-11-01 13:40:51 +0100 (Tue, 01 Nov 2011)
New Revision: 43059
Changeset: https://dev.haiku-os.org/changeset/43059

Added:
   haiku/trunk/3rdparty/pulkomandy/
   haiku/trunk/3rdparty/pulkomandy/catmerge.sh
Log:
Add catmerge.sh, a shellscript for easily merging an existing but outdated
catalog with a newer one in another language. I was not sure where to put it,
is this the right place ?


Added: haiku/trunk/3rdparty/pulkomandy/catmerge.sh
===================================================================
--- haiku/trunk/3rdparty/pulkomandy/catmerge.sh                         (rev 0)
+++ haiku/trunk/3rdparty/pulkomandy/catmerge.sh 2011-11-01 12:40:51 UTC (rev 
43059)
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+if [ $# -eq 2 ]
+  then
+       OLD=$1
+       NEW=$2
+
+       # We need a tab character as a field separator
+       TAB=`echo -e "\t"`
+
+       #Temporary storage
+       TEMPFILE=`mktemp /tmp/catmerge.XXXXX`
+
+       # Extract the list of keys to remove
+       # Compare (diff) the keys only (cut) ; keep only 'removed' lines (grep 
-),
+       # Ignore diff header and headlines from both files (tail), remove diff's
+       # prepended stuff (cut)
+       # Put the result in our tempfile.
+       diff -u <(cut -f 1,2 $OLD) <(cut -f 1,2 $NEW) |grep ^-|\
+               tail -n +3|cut -b2- > $TEMPFILE
+
+       # Reuse the headline from the new file (including fingerprint). This 
gets
+       # the language wrong, but it isn't actually used anywhere
+       head -1 $NEW
+       # Sort-merge old and new, inserting lines from NEW into OLD (sort);
+       #       Exclude the headline from that (tail -n +2)
+       # Then, filter out the removed strings (fgrep)
+       sort -u -t"$TAB" -k 1,2 <(tail -n +2 $OLD) <(tail -n +2 $NEW)|\
+               fgrep -v -f $TEMPFILE
+
+       rm $TEMPFILE
+
+  else
+       echo "$0 OLD NEW"
+       echo "merges OLD and NEW catalogs, such that all the keys in NEW that 
are"
+       echo "not yet in OLD are added to it, and the one in OLD but not in NEW 
are"
+       echo "removed. The fingerprint is also updated."
+fi


Property changes on: haiku/trunk/3rdparty/pulkomandy/catmerge.sh
___________________________________________________________________
Added: svn:executable
   + *


Other related posts: