Gentoo Archives: gentoo-osx

From: Christopher Chan <cchan@×××××××××××.com>
To: gentoo-osx@l.g.o
Subject: [gentoo-osx] [PREFIX] first cut prefix.eclass
Date: Wed, 26 Apr 2006 01:45:13
>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@g.o mailing list


Subject Author
Re: [gentoo-osx] [PREFIX] first cut prefix.eclass Grobian <grobian@g.o>