Browse Source

* 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
misl/sde-wrapper
Alejandro Mery 17 years ago
parent
commit
31b5b854cb
2 changed files with 89 additions and 79 deletions
  1. +0
    -79
      lib/sde-config/functions.in
  2. +89
    -0
      lib/sde-config/pkgsel2awk.sh

+ 0
- 79
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 <<EOF
{
def=\$1 ;
repo=\$4 ;
pkg=\$5 ;
\$5 = \$4 "/" \$5 ;
\$4 = "placeholder" ;
}
EOF
}
pkgsel_finish() {
cat <<EOF
{
\$4=repo ;
\$5=pkg ;
print ;
}
EOF
}
comment() {
bprof comment start
if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ] && \

+ 89
- 0
lib/sde-config/pkgsel2awk.sh

@ -0,0 +1,89 @@
#!/bin/bash
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: lib/sde-config/pkgsel2awk.sh
# Copyright (C) 2006 - 2007 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
# Convert a pkg selection rule into awk format
#
# 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)
egrep -v "^((^#.*$)|())$" $patternlist | pkgsel_parse
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
}
cat <<EOF
{
def=\$1 ;
repo=\$4 ;
pkg=\$5 ;
\$5 = \$4 "/" \$5 ;
\$4 = "placeholder" ;
}
EOF
for pkgsel; do
egrep -v "^((^#.*$)|())$" $pkgsel | pkgsel_parse
done
cat <<EOF
{
\$4=repo ;
\$5=pkg ;
print ;
}
EOF

Loading…
Cancel
Save