Simple tool to make list of patches with dependencies

utput can be later pushed through | tsort | tac to show order in which patches should be loaded to database.
parent 03ab222a
#!/bin/bash
# Simple tool to list dependencies in form suitable for tsort utility.
# Run this script like this:
# /some/path/list-dependencies-from-patches.sh *.sql
grep -hiE '^[[:space:]]*select _v.register_patch\(' "[email protected]" | \
sed 's/^[^(]*(//' | while read LINE
do
export PATCH_NAME="$( echo "$LINE" | cut -d\' -f2 )"
echo "$LINE" | sed "s/^[^']*'[^']\\+'[[:space:]]*,[[:space:]]*//" | \
perl -ne '
my @w;
if ( s/^ARRAY\s*\[// ) {
s/\].*//;
@w = /\047([^\047]+)\047/g;
}
pop @w, $ENV{"PATCH_NAME"} if 0 == ( scalar @w % 2 );
printf "%s %s\n", $ENV{"PATCH_NAME"}, $_ for @w;
'
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment