michael@13: #!@l_prefix@/lib/openpkg/bash michael@13: ## michael@13: ## openpkg -- OpenPKG Tool Chain michael@13: ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. michael@13: ## Copyright (c) 2000-2007 Ralf S. Engelschall michael@13: ## michael@13: ## Permission to use, copy, modify, and distribute this software for michael@13: ## any purpose with or without fee is hereby granted, provided that michael@13: ## the above copyright notice and this permission notice appear in all michael@13: ## copies. michael@13: ## michael@13: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@13: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@13: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@13: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@13: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@13: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@13: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@13: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@13: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@13: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@13: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@13: ## SUCH DAMAGE. michael@13: ## michael@13: ## openpkg.sh: Execution Frontend (Language: Bourne-Shell) michael@13: ## michael@13: michael@13: ## michael@13: ## command line parsing michael@13: ## michael@13: michael@13: # command line options defaults michael@13: opt_prefix="" michael@13: opt_tools="" michael@13: opt_version=no michael@13: opt_help=no michael@13: michael@13: # process command line options by iterating over arguments michael@13: for opt michael@13: do michael@13: case "${opt}" in michael@13: -*=*) arg=`echo "${opt}" | sed 's/^[-_a-zA-Z0-9]*=//'` ;; michael@13: *) arg='' ;; michael@13: esac michael@13: case "${opt}" in michael@13: -v|--version ) opt_version=yes; shift ;; michael@13: -h|--help ) opt_help=yes; shift ;; michael@13: --prefix=* ) opt_prefix="${arg}"; shift ;; michael@13: --tools=* ) opt_tools="${arg}"; shift ;; michael@13: -* ) echo "openpkg:ERROR: Invalid command-line option \"${opt}\"." 1>&2 michael@13: echo "openpkg:ERROR: Run \"${0} --help\" for list of valid options" 1>&2; exit 1 ;; michael@13: * ) break ;; michael@13: esac michael@13: done michael@13: michael@13: ## michael@13: ## determine OpenPKG locations michael@13: ## michael@13: michael@13: # determine path to OpenPKG instance michael@13: openpkg_prefix="@l_prefix@" michael@13: if [ ".${OPENPKG_PREFIX}" != . ]; then michael@13: openpkg_prefix="${OPENPKG_PREFIX}" michael@13: fi michael@13: if [ ".${opt_prefix}" != . ]; then michael@13: openpkg_prefix="${opt_prefix}" michael@13: fi michael@13: if [ -x "${openpkg_prefix}/bin/openpkg" -a -x "${openpkg_prefix}/libexec/openpkg/rpm" ]; then michael@13: # OpenPKG 2.0 and higher michael@13: true michael@13: elif [ -f "${openpkg_prefix}/bin/rpm" -a -x "${openpkg_prefix}/lib/openpkg/rpm" ]; then michael@13: # OpenPKG 1.x michael@13: echo "openpkg:ERROR: OpenPKG 1.x instance found under \"${openpkg_prefix}\" (not supported)" 1>&2 michael@13: exit 1 michael@13: else michael@13: echo "openpkg:ERROR: no OpenPKG instance found under \"${openpkg_prefix}\"" 1>&2 michael@13: exit 1 michael@13: fi michael@13: michael@13: # allow convenient all-in-one specification of OpenPKG Tool Chain locations michael@13: # (assuming the filesystem layout of an uninstalled OpenPKG Tool Chain) michael@13: openpkg_tools="${OPENPKG_TOOLS}" michael@13: openpkg_tools_cmdpath="${OPENPKG_TOOLS_CMDPATH}" michael@13: openpkg_tools_apipath="${OPENPKG_TOOLS_APIPATH}" michael@13: if [ ".${opt_tool}" != . ]; then michael@13: openpkg_tools="${opt_tools}" michael@13: fi michael@13: if [ ".${openpkg_tools}" != . -a ".${openpkg_tools_cmdpath}" = . ]; then michael@13: openpkg_tools_cmdpath="${openpkg_tools}/cmd:@" michael@13: fi michael@13: if [ ".${openpkg_tools}" != . -a ".${openpkg_tools_apipath}" = . ]; then michael@13: openpkg_tools_apipath="${openpkg_tools}/api:@" michael@13: fi michael@13: michael@13: # determine path to OpenPKG Tool Chain commands michael@13: cmdpath="${openpkg_prefix}/libexec/openpkg" michael@13: if [ -d "${openpkg_prefix}/libexec/openpkg-tools" ]; then michael@13: # openpkg-tools package overrides michael@13: cmdpath="${openpkg_prefix}/libexec/openpkg-tools:${cmdpath}" michael@13: fi michael@13: if [ -d "${openpkg_prefix}/libexec/openpkg-audit" ]; then michael@13: # openpkg-audit package overrides michael@13: cmdpath="${openpkg_prefix}/libexec/openpkg-audit:${cmdpath}" michael@13: fi michael@13: if [ ".${openpkg_tools_cmdpath}" != . ]; then michael@13: # user supplied path overrides michael@13: cmdpath=`echo "${openpkg_tools_cmdpath}" | sed -e "s;@;${cmdpath};"` michael@13: fi michael@13: openpkg_tools_cmdpath=`echo "${cmdpath}" | sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'` michael@13: michael@13: # determine path to OpenPKG Tool Chain API michael@13: apipath="" michael@13: if [ -d "${openpkg_prefix}/lib/openpkg-tools" ]; then michael@13: # openpkg-tools package overrides michael@13: apipath="${openpkg_prefix}/lib/openpkg-tools:${apipath}" michael@13: fi michael@13: if [ ".${openpkg_tools_apipath}" != . ]; then michael@13: # user supplied path overrides michael@13: apipath=`echo "${openpkg_tools_apipath}" | sed -e "s;@;${apipath};"` michael@13: fi michael@13: openpkg_tools_apipath=`echo "${apipath}" | sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'` michael@13: michael@13: ## michael@13: ## execute stand-alone option commands in advance michael@13: ## michael@13: michael@13: # implement stand-alone "--help" option michael@13: if [ ".${opt_help}" = .yes ]; then michael@13: release=`${openpkg_prefix}/libexec/openpkg/rpm --eval '%{l_openpkg_release}'` michael@13: echo "" michael@13: echo "This is ${release} " michael@13: echo "Cross-Platform Unix Software Packaging Facility" michael@13: echo "" michael@13: echo "Copyright (c) 2000-2007 OpenPKG Foundation e.V. " michael@13: echo "Copyright (c) 2000-2007 Ralf S. Engelschall " michael@13: echo "" michael@13: echo "The command \"${openpkg_prefix}/bin/openpkg\" is the official command-line" michael@13: echo "execution frontend of the OpenPKG tool chain. Its usage is:" michael@13: echo "" michael@13: echo " \$ ${openpkg_prefix}/bin/openpkg [