Mailing List Archive

[PREFIX] first cut prefix.eclass
>Maybe you can make the first version of $(prefix [package]) function in
>that case. It should return the prefix that was used when installing
>package, or when no package given, the default prefix, so it can be used
>also in --with-xxxxx=$(prefix xxxxxx)/usr/bin/xxxxxx or something.
>
>There has been some discussions on this issue on this list before. Not
>sure if I reword the idea correctly.

Here's my initial stab at one. Don't know if I completely understood the fcn
you had in mind with $(prefix [package]), if not. please explain.

===========================================================================

inherit eutils

# EXPORTED FUNCTION - FOR USE IN EBUILDS
#
# ------------------------------------------------------------------------
# Adds EPREFIX to the parameter, it will check to see if prefix is
# already added
#
# @param $1 - directory path to add EPREFIX
#
# ------------------------------------------------------------------------

function prefix () {
local dir="$1"

## check for already existing prefix
if [ "${dir}" != "$(strip_prefix ${dir})" ]; then
ewarn "${dir} is already prefixed"
else
## make sure only one "/"
if [ "${dir:0:1}" = "/" ]; then
dir=${EPREFIX}${dir}
else
dir=${EPREFIX}/${dir}
fi
echo "${dir}"
fi
}

# ------------------------------------------------------------------------
# Strips EPREFIX from the parameter.
#
# @param $1 - directory path to remove prefix
#
# ------------------------------------------------------------------------
function strip_prefix () {
local dir="$1"

echo "${dir}" | sed -e "s:^${EPREFIX}::"
}



--
gentoo-osx@gentoo.org mailing list
Re: [PREFIX] first cut prefix.eclass [ In reply to ]
On 25-04-2006 19:43:11 -0700, Christopher Chan wrote:
> Here's my initial stab at one. Don't know if I completely understood the fcn
> you had in mind with $(prefix [package]), if not. please explain.

Your functions look ok to me. Here is the thread that deals with the
idea I talked about:

http://thread.gmane.org/gmane.linux.gentoo.macosx/809/focus=809

thanks!

--
Fabian Groffen
Gentoo for Mac OS X Project
--
gentoo-osx@gentoo.org mailing list