Add compare xml script and move/update relink-binaries.sh

Add script to compare string values between 2 language xml files
which will make it easier to identify strings that are missing
between the 2 files.

Move relink-binaries.sh to scripts folder and update it to handle
relinking 64 bit binaries.

Change-Id: Ia7a8bdbeea02256b3b864ab77e15912795275d33
diff --git a/prebuilt/relink-binaries.sh b/prebuilt/relink-binaries.sh
deleted file mode 100755
index 3752853..0000000
--- a/prebuilt/relink-binaries.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-process_file()
-{
-   src=$1
-   dst=$1-1 #/$(basename $2)
-   cp -f -p $src $dst
-
-   sed "s|/system/bin/linker\x0|/sbin/linker\x0\x0\x0\x0\x0\x0\x0|g" $dst | sed "s|/system/bin/sh\x0|/sbin/sh\x0\x0\x0\x0\x0\x0\x0|g" > $dst-mod
-   #sed "s|/sbin/linker\x0|/system/bin/linker\x0\x0\x0\x0\x0\x0\x0|g" $dst | sed "s|/sbin/sh\x0|/system/bin/sh\x0\x0\x0\x0\x0\x0\x0|g" > $dst-mod
-   rm $dst
-}
-
-
-dest=$1
-for ARG in $*
-do
-   process_file $dest $ARG
-done
\ No newline at end of file
diff --git a/scripts/README b/scripts/README
new file mode 100644
index 0000000..ff8b366
--- /dev/null
+++ b/scripts/README
@@ -0,0 +1,27 @@
+relink-binaries.sh
+
+Intended to "relink" or change the linker path for a linked binary. Normally
+linked binaries are looking for the linker in /system/bin/linker (or
+/system/bin/linker64 for 64 bit devices). In recovery, we want to avoid
+mounting or using anything /system to allow us to install different
+ROMs or firmware. This script will run various sed commands to update the
+path to the linker to /sbin/linker64 or /sbin/linker which is sometimes
+needed especially for qseecomd (decrypt) or in some cases with user space
+touch screen binaries. Usage:
+
+./relink-binaries.sh filename
+
+The script will leave the existing file untouched and make a new file
+named filename-1-mod
+
+
+
+compare_xml.py
+
+Intended to compare two different language xml files to determine if any
+strings do not match up between the two files. Sometimes we add or rename
+or misspell string names. This script will help identify the discrepancies.
+Usage:
+
+python compare_xml.py -o target.xml
+
diff --git a/scripts/compare_xml.py b/scripts/compare_xml.py
new file mode 100644
index 0000000..bec41c0
--- /dev/null
+++ b/scripts/compare_xml.py
@@ -0,0 +1,62 @@
+from xml.dom import minidom
+import sys
+import getopt
+
+HELP = """
+  compare_xml.py [ -o file.xml ]
+                   -f file.xml
+                   -h - help info
+"""
+
+enfile = "en.xml"
+otherfile = ""
+
+try:
+	opts, args = getopt.getopt(sys.argv[1:], "hfo:koz", ["device="])
+except getopt.GetoptEror:
+	print HELP
+	sys.stdout.flush()
+	sys.exit(2)
+
+for opt, arg in opts:
+	if opt == "-h":
+		print HELP
+		sys.stdout.flush()
+		sys.exit()
+	elif opt == "-o":
+		otherfile = arg
+	elif opt == "-f":
+		enfile = arg
+
+if otherfile == "":
+	print HELP
+	exit()
+
+print "Comparing %s and %s" % (enfile, otherfile)
+print ""
+
+endoc = minidom.parse(enfile)
+enstrings = endoc.getElementsByTagName('string')
+
+otherdoc = minidom.parse(otherfile)
+otherstrings = otherdoc.getElementsByTagName('string')
+
+for ens in enstrings:
+	found = False
+	for others in otherstrings:
+		if ens.attributes['name'].value == others.attributes['name'].value:
+			found = True
+			break
+	if found == False:
+		print "'%s' present in %s and not in %s" % (ens.attributes['name'].value, enfile, otherfile)
+
+print ""
+
+for others in otherstrings:
+	found = False
+	for ens in enstrings:
+		if ens.attributes['name'].value == others.attributes['name'].value:
+			found = True
+			break
+	if found == False:
+		print "'%s' present in %s and not in %s" % (others.attributes['name'].value, otherfile, enfile)
diff --git a/scripts/relink-binaries.sh b/scripts/relink-binaries.sh
new file mode 100644
index 0000000..0188560
--- /dev/null
+++ b/scripts/relink-binaries.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+process_file()
+{
+   src=$1
+   dst=$1-1 #/$(basename $2)
+   cp -f -p $src $dst
+
+   sed "s|/system/bin/linker64\x0|/sbin/linker64\x0\x0\x0\x0\x0\x0\x0|g" $dst | sed "s|/system/bin/linker\x0|/sbin/linker\x0\x0\x0\x0\x0\x0\x0|g" | sed "s|/system/bin/sh\x0|/sbin/sh\x0\x0\x0\x0\x0\x0\x0|g" > $dst-mod
+   #sed "s|/sbin/linker\x0|/system/bin/linker\x0\x0\x0\x0\x0\x0\x0|g" $dst | sed "s|/sbin/sh\x0|/system/bin/sh\x0\x0\x0\x0\x0\x0\x0|g" > $dst-mod
+   rm $dst
+}
+
+
+dest=$1
+for ARG in $*
+do
+   process_file $dest $ARG
+done