From 31b5b854cb513546e65f1aee4abfd1ebc38de152 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sat, 28 Jul 2007 17:08:29 +0000 Subject: [PATCH] * moved pkgsel parser from lib/sde-config/functions.in to it's own tool, lib/sde-config/pkgsel2awk.sh git-svn-id: svn://svn.opensde.net/opensde/opensde/trunk@21854 10447126-35f2-4685-b0cf-6dd780d3921f --- lib/sde-config/functions.in | 79 -------------------------------- lib/sde-config/pkgsel2awk.sh | 89 ++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 79 deletions(-) create mode 100755 lib/sde-config/pkgsel2awk.sh diff --git a/lib/sde-config/functions.in b/lib/sde-config/functions.in index 023bb61..1e7b2da 100644 --- a/lib/sde-config/functions.in +++ b/lib/sde-config/functions.in @@ -203,85 +203,6 @@ pkgchecklicense() { done < <(grep "^X" $cfgtmpdir/config/packages) } -# Convert a pkg selection rule into awk format -# -# Usage: -# 1. call pkgsel_init -# 2. call pkgsel_parse as often as necessary -# 3. call pkgsel_finish -# Result: -# awk script for package selection, see config.in for its usage -# -# Example: -# pkgsel X python -# Result: ( / [^/]*\/python / ) { $1="X"; } -# pkgsel "O perl/*" -# Result: ( / perl\/[^/]* / ) { $1="O"; } -# pkgsel_parse < config/${config}/pkgsel -# Result: creates pkgsel.awk output -# pkgsel include file -# Result: continues processing file specified -pkgsel_parse() { - local action patterlist pattern - local address first others - while read action patternlist ; do - case "$action" in - [xX]) - action='$1="X"' ;; - [oO]) - action='$1="O"' ;; - -) - action='next' ;; - =) - action='$1=def' ;; - include) - pkgsel_parse < $patternlist - continue ;; - *) - echo '{ exit; }' - continue ;; - esac - address="" - while read xpattern ; do - pattern="${xpattern#\!}" - [ "$pattern" = "$xpattern" ]; neg=$? - [ "${pattern}" = "${pattern//\//}" ] && pattern="*/$pattern" - pattern="$( echo "$pattern" | sed \ - -e 's,[^a-zA-Z0-9_/\*+\-\[\]],,g' \ - -e 's,[/\.\+],\\\\&,g' \ - -e 's,\*,[^/]*,g' )" - if [ $neg -eq 0 ]; then - address="$address${address:+ && }( \$5 ~ \"^${pattern}\$\" )" - else - address="$address${address:+ && }( \$5 !~ \"^${pattern}\$\" )" - fi - done < <( echo "$patternlist" | tr '\t ' '\n\n' ) - echo "{ if ( $address ) { $action; } }" - done < <( if [ "$*" ]; then echo "$*"; else cat | egrep -v "^((^#.*$)|())$"; fi) -} - -pkgsel_init() { - cat <