aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-05-19 19:24:56 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-05-23 23:04:44 +0800
commitfa45a6a4d9cd33f79d3837a6e7759a8f843bf72f (patch)
tree027371c2c8723ea923272305d04a1dc725cd70b3 /utils
parentParser: fix var_ref in arithmetic expansion (diff)
downloadlibbash-fa45a6a4d9cd33f79d3837a6e7759a8f843bf72f.tar.gz
libbash-fa45a6a4d9cd33f79d3837a6e7759a8f843bf72f.tar.bz2
libbash-fa45a6a4d9cd33f79d3837a6e7759a8f843bf72f.zip
Utility: add a script for metadata correctness statistic
Diffstat (limited to 'utils')
-rwxr-xr-xutils/metadata_diff.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/metadata_diff.sh b/utils/metadata_diff.sh
new file mode 100755
index 0000000..1e9d60f
--- /dev/null
+++ b/utils/metadata_diff.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+source /etc/make.conf
+
+outputdir=${1:-$(mktemp -d)}
+
+if [[ ! (-d $outputdir && -w $outputdir) ]]
+then
+ echo "$outputdir is not writable"
+fi
+
+echo "Generating metadata at $outputdir"
+
+./instruo -D ${PORTDIR:-/usr/portage/} -o $outputdir 2>$outputdir/error_output
+
+echo "Running diff..."
+
+declare -i error_count=0 total_num=0
+
+for category_dir in ${PORTDIR:-/usr/portage}/*
+do
+ category=${category_dir##*\/}
+ cache_dir=${PORTDIR:-/usr/portage}/metadata/cache/${category}
+ if [[ -d $cache_dir ]]
+ then
+ for path in $cache_dir/*
+ do
+ filename=${path##*\/}
+ diff -u $cache_dir/$file $outputdir/$category/$filename > $outputdir/$category/$filename.diff
+ error_count+=$?
+ total_num+=1
+ done
+ fi
+done
+
+echo "$((total_num - error_count)) out of $total_num metadata files are correct. See file.diff for more details."