steffen: server/kolabd/kolabd/namespace kolab.in, NONE, 1.1 kolab, 1.3, NONE

cvs at intevation.de cvs at intevation.de
Tue Sep 13 16:38:24 CEST 2005


Author: steffen

Update of /kolabrepository/server/kolabd/kolabd/namespace
In directory doto:/tmp/cvs-serv22600/kolabd/namespace

Added Files:
	kolab.in 
Removed Files:
	kolab 
Log Message:
kolabd autoconfiscated!

--- NEW FILE: kolab.in ---
#!@bash_exec@
##
##  Kolab Namespace tool 
##  Derived with acknowledgement from: openpkg -- OpenPKG Tool Chain
##
##  Copyright (c) 2004-2005 Code Fusion cc. <http://www.codefusion.co.za>
##  Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
##  Copyright (c) 2000-2004 Ralf S. Engelschall <rse at engelschall.com>
##  Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.com/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

##
##  command line parsing
##

#   command line options defaults
opt_prefix=""
opt_tools=""
opt_version=no
opt_help=no

#   process command line options by iterating over arguments
for opt
do
    case "${opt}" in
        -*=*) arg=`echo "${opt}" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
           *) arg='' ;;
    esac
    case "${opt}" in
        -v|--version ) opt_version=yes;     shift ;;
        -h|--help    ) opt_help=yes;        shift ;;
        --prefix=*   ) opt_prefix="${arg}"; shift ;;
        --tools=*    ) opt_tools="${arg}";  shift ;;
        -* ) echo "kolab:ERROR: Invalid command-line option \"${opt}\"." 1>&2
             echo "kolab:ERROR: Run \"${0} --help\" for list of valid options" 1>&2; exit 1 ;;
        *  ) break ;;
    esac
done

##
##  determine OpenPKG locations
##

#   determine path to OpenPKG instance
openpkg_prefix="@prefix@"
if [ ".${OPENPKG_PREFIX}" != . ]; then
    openpkg_prefix="${OPENPKG_PREFIX}"
fi
# FIXME: to be removed
if [ ".${opt_prefix}" != . ]; then
    openpkg_prefix="${opt_prefix}"
fi
if [ -x "@bindir@/openpkg" -a -x "@libexecdir@/openpkg/rpm" ]; then
    #   OpenPKG 2.0 and higher
    true
elif [ -f "@bindir@/rpm" -a -x "@libdir@/openpkg/rpm" ]; then
    #   OpenPKG 1.x
    echo "kolab:ERROR: OpenPKG 1.x instance found under \"@prefix@\" (not supported)" 1>&2
    exit 1
else
    echo "kolab:ERROR: no OpenPKG instance found under \"@prefix@\"" 1>&2
    exit 1
fi

#   allow convenient all-in-one specification of OpenPKG Tool Chain locations
#   (assuming the filesystem layout of an uninstalled OpenPKG Tool Chain)
kolab_tools="${KOLAB_TOOLS}"
openpkg_tools="${OPENPKG_TOOLS}"
openpkg_tools_cmdpath="${OPENPKG_TOOLS_CMDPATH}"
openpkg_tools_apipath="${OPENPKG_TOOLS_APIPATH}"
if [ ".${opt_tool}" != . ]; then
    kolab_tools="${opt_tools}"
fi
if [ ".${openpkg_tools}" != . -a ".${openpkg_tools_cmdpath}" = . ]; then
    openpkg_tools_cmdpath="${openpkg_tools}/cmd:@"
fi
if [ ".${openpkg_tools}" != . -a ".${openpkg_tools_apipath}" = . ]; then
    openpkg_tools_apipath="${openpkg_tools}/api:@"
fi

#   determine path to Kolab Namespace commands
cmdpath="@libexecdir@/kolab"
if [ -d "@libexecdir@/kolab-tools" ]; then
    #   openpkg-tools package overrides
    cmdpath="@libexecdir@/kolab-tools:${cmdpath}"
fi
if [ ".${kolab_tools}" != . ]; then
    #   user supplied path overrides
    cmdpath=`echo "${kolab_tools}" | sed -e "s;@;${cmdpath};"`
fi
openpkg_tools_cmdpath=`echo "${cmdpath}" | sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`

#   determine path to OpenPKG Tool Chain API
apipath=""
if [ -d "@libdir@/openpkg-tools" ]; then
    #   openpkg-tools package overrides
    apipath="@libdir@/openpkg-tools:${apipath}"
fi
if [ ".${openpkg_tools_apipath}" != . ]; then
    #   user supplied path overrides
    apipath=`echo "${openpkg_tools_apipath}" | sed -e "s;@;${apipath};"`
fi
openpkg_tools_apipath=`echo "${apipath}" | sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`

##
##  execute stand-alone option commands in advance
##

#   implement stand-alone "--help" option
if [ ".${opt_help}" = .yes ]; then
    release=`@libexecdir@/openpkg/rpm -q kolab`
    echo ""
    echo "${release} <http://www.kolab.org/>"
    echo "Kolab Server Tool"
    echo ""
    echo "Copyright (c) 2004,2005 Code Fusion cc."
    echo ""
    echo "  \$ @bindir@/kolab [<option> ...] \\"
    echo "     <command> [<command-option> ...] [<command-argument> ...]"
    echo ""
    echo "where <option> is one of the following global options:"
    echo "  -v, --version   display Kolab version/release"
    echo "  -h, --help      display this usage help message"
    echo ""
    echo "where <command> is one of the following commands:"
    #   install command intentionally left out in above display!

    #   dynamically figure out add-on commands
    for cmd in rpm rpmbuild rpm2cpio rpm-config uuid rc lsync man install; do
        id=`echo "${cmd}" | sed -e 's/-/_/g'`
        eval "__cmd_seen_${id}=yes"
    done
    OIFS="${IFS}"; IFS=":"
    for dir in ${openpkg_tools_cmdpath}; do
        IFS="${OIFS}"
        if [ ! -d ${dir} ]; then
            continue
        fi
        for cmd in `cd ${dir} 2>/dev/null && echo *`; do
            name=`echo "${cmd}" | sed -e 's/\.sh$//' -e 's/\.pl$//' \
                 -e 's/^/X/' -e 's/^X\([a-z][a-zA-Z0-9_-]*\)$/\1/' -e 's/^X.*$//'`
            if [ ".${name}" != . ]; then
                if [ -f ${dir}/${cmd} ]; then
                    id=`echo "${name}" | sed -e 's/-/_/g'`
                    eval "seen=\$__cmd_seen_${id}"
                    if [ ".${seen}" != .yes ]; then
		    	#Try to get help
			hashelp=`grep HASHELP ${openpkg_tools_cmdpath}/${name}`
			if [ ".$hashelp" != "." ]; then
				helpstring=`${openpkg_tools_cmdpath}/${name} --showhelp`
			fi
			if [ ".$helpstring" = "." ]; then
	                        echo "${name}" | awk '{ printf("  %-15s (no help provided)\n", $0); }'
			else
	                        echo "${name}" | awk '{ printf("  %-15s ", $0); }'
				echo "${helpstring}"
			fi
			hashelp=""; helpstring="";
                        eval "__cmd_seen_${id}=yes"
                    fi
                fi
            fi
        done
    done
    IFS="${OIFS}"
    echo ""
    echo "where <command-option> and <command-argument> are <command> specific"
    echo "options and arguments. Run \"@bindir@/kolab <command> --help\""
    echo "and \"@bindir@/openpkg man <command>\" for more details."
    echo ""
    exit 0
fi

#   implement stand-alone "--version" option
if [ ".${opt_version}" = .yes ]; then
    release=`${openpkg_prefix}/libexec/openpkg/rpm --eval '%{l_openpkg_release}'`
    version=`${openpkg_prefix}/libexec/openpkg/rpm -q --qf '%{version}' openpkg`
    echo "${release} (${version})"
    exit 0
fi

##
##  determine command details and execute command appropriately
##

#   command line sanity check
if [ ${#} -eq 0 ]; then
    echo "kolab:ERROR: Invalid command-line arguments." 1>&2
    echo "kolab:ERROR: Run \"@bindir@/kolab --help\" for list of valid arguments." 1>&2
    exit 1
fi

#   search command by iterating over all command directories
cmd="${1}"
shift
cmd_path=""
cmd_shell=""
cmd_stack="${OPENPKG_TOOLS_CMDSTACK}"
OIFS="${IFS}"; IFS=":"
for dir in ${openpkg_tools_cmdpath}; do
    IFS="${OIFS}"

    #   skip (currently) not existing directory
    if [ ! -d ${dir} ]; then
        continue
    fi

    #   check for various command implementations
    if [ -x ${dir}/${cmd} ]; then
        #   found executable stand-alone binary
        cmd_path="${dir}/${cmd}"
        cmd_shell=""
    elif [ -f ${dir}/${cmd}.sh ]; then
        #   found non-executable Bourne-Shell script
        cmd_path="${dir}/${cmd}.sh"
        cmd_shell="@bash_exec@"
    elif [ -f ${dir}/${cmd}.pl ]; then
        #   found non-executable Perl script
        cmd_path="${dir}/${cmd}.pl"
        if [ -x @perl_exec@ ]; then
            cmd_shell="@perl_exec@"
        else
            cmd_shell=`@libdir@/openpkg/shtool path -m perl 2>&1`
            if [ ".${cmd_shell}" = . ]; then
                echo "openpkg:ERROR: No Perl interpreter found in \${PATH}" 1>&2
                exit 1
            fi
        fi
        #   provide Perl module include path(s) to API
        OIFS="${IFS}"; IFS=":"
        for dir2 in ${openpkg_tools_apipath}; do
            IFS="${OIFS}"
            if [ ! -d ${dir2} ]; then
                continue
            fi
            cmd_shell="${cmd_shell} -I${dir2}"
        done
        IFS="${OIFS}"
    else
        #   command not found, continue searching
        continue
    fi

    #   check whether to use this found command or to continue searching
    #   for next command implementation in sequence (in order to support
    #   flexible nested command wrapping)
    cmd_last=`echo "${cmd_stack}" | sed -e 's;:.*$;;'`
    if [ ".${cmd_last}" = ".${cmd}" ]; then
        #   we were last command on stack, so pop us from call
        #   stack and continue searching for next implementation
        cmd_stack=`echo "${cmd_stack}" | sed -e 's;^[^:][^:]*:*;;'`
        continue
    else
        #   last command on stack was different, so stop
        #   searching because we found the implementation
        break
    fi
done
IFS="${OIFS}"

#   sanity check search result
if [ ".${cmd_path}" = . ]; then
    echo "kolab:ERROR: No such command \"${cmd}\" found in command path" 1>&2
    echo "kolab:ERROR: (${openpkg_tools_cmdpath})." 1>&2
    echo "kolab:ERROR: Set \${OPENPKG_TOOLS_CMDPATH} appropriately." 1>&2
    echo "kolab:ERROR: Run \"@bindir@/openpkg --help\" for list of valid commands." 1>&2
    exit 1
fi

#   export essential run-time information to command
export OPENPKG_PREFIX="@prefix@"
export OPENPKG_TOOLS_CMDPROG="${0}"
export OPENPKG_TOOLS_CMDNAME="${cmd}"
export OPENPKG_TOOLS_CMDSTACK=`echo "${OPENPKG_TOOLS_CMDSTACK}" | sed -e 's;^\(.\);:\1;' -e "s;^;${cmd};"`

#   execute command
eval "exec ${cmd_shell} ${cmd_path} \${1+\"\$@\"}"


--- kolab DELETED ---





More information about the commits mailing list