From 5deeccbdae8b6c1f8b99eecec732928f898fa337 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 4 May 2010 16:29:03 -0400 Subject: [PATCH] pkgprefix: fixed bug in prefix request with -r, and sightly cleaned code --- lib/functions.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/functions.in b/lib/functions.in index 8374d55..f2fb465 100644 --- a/lib/functions.in +++ b/lib/functions.in @@ -2,7 +2,7 @@ # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: lib/functions.in -# Copyright (C) 2006 - 2009 The OpenSDE Project +# Copyright (C) 2006 - 2010 The OpenSDE Project # Copyright (C) 2004 - 2006 The T2 SDE Project # Copyright (C) 1998 - 2003 Clifford Wolf # @@ -579,13 +579,13 @@ pkginstalled() { # pkgprefix() { local type= pkg= - local dotest= addroot= abortmsg= + local dotest= addroot= wantsroot= abortmsg= local prefix= value= while [ $# -gt 1 ]; do case "$1" in -t) dotest=1 ;; - -r) addroot="${root:-/}" ;; + -r) addroot="$root" wantsroot="yes" ;; -*) abortmsg="invalid option $1" ;; *) break ;; esac @@ -621,7 +621,11 @@ pkgprefix() { echo "pkgprefix: $abortmsg" 1>&2 elif [ -z "$type" -o "$type" = "prefix" ]; then type="prefix" - value="$prefix" + if [ "$wantsroot" = "yes" ]; then + value="${prefix:+/$prefix}" + else + value="$prefix" + fi elif [ "$type" = "ver" ]; then value=$( grep "^Package Name and Version:" "$root/var/adm/packages/$pkg" | cut -d' ' -f6 ) else @@ -633,7 +637,7 @@ pkgprefix() { fi if [ -n "$value" -o "$type" = "prefix" ]; then - echo "$addroot$value" | sed -e 's|/\+/|/|g' -e 's|\(.\+\)/$|\1|' + echo "$addroot$value" else echo "PKGPREFIX_ERROR" fi