Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-osx
Navigation:
Lists: gentoo-osx: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-osx@g.o
From: Michael Haubenwallner <michael.haubenwallner@...>
Subject: Re: [PREFIX] LD_LIBRARY_PATH issue
Date: Thu, 07 Sep 2006 14:43:14 +0200
(Apologies if you get this mail a second time - first i tried with
baselayout-prefix/files attached as a tar.gz-ball and did not see this
mail in gmane.org for hours. Now these files are attached separately.)


On Wed, 2006-09-06 at 21:20 +0200, Grobian wrote:
> On 06-09-2006 15:37:31 +0200, Michael Haubenwallner wrote:
> With respect, but I think the reason we don't use toolbox is because I
> never got it to bootstrap anything :(

IIRC you did not manage to inform it where to download things from.
But it's ok for me to have a bootstrap-script in the tree, even i don't
plan to use it.


Well, here are the two portage patches for dynamically duping
environment values. Patch-Numbers fit into my previous mail containing a
bunch of other patches [1].

[06-env-conf+ext.patch]
Let portage create /etc/env.conf containing somewhat a dump of the
environment bits found in /etc/env.d/*, to be read by /sbin/extenv, see
below (the baselayout-prefix.ebuild).

[07-env-dup.patch]
Interpret variables PORTAGE_ENVDUP* found in /etc/env.d/*, to dupe
values from one environment variable to another. Example is to dupe
values from LDPATH to LD_LIBRARY_PATH, SHLIB_PATH or LIBPATH, see below
(the baselayout-linux.ebuild).


[baselayout-prefix-0.1.ebuild]
files: [0.1-extenv] [0.1-inputrc] [0.1-profile] [0.1-unprofile]
Installs these files:
  /etc/profile
    The entry point for this eprefix.
    Utilizes /sbin/extenv to add values the environment.
    It also sets up an alias 'eenv-clear', which sources /etc/unprofile,
    to be able to remove all the environment values for this eprefix.
  /sbin/extenv
    Interprets /etc/env.conf and generates a list of shell commands (for
    sh and csh) adding values to the environment.
  /etc/unprofile
    The exit point from this eprefix.
    Also utilizes /sbin/extenv to remove values from the environment.
    Also unaliases 'eenv-clear'.
  /etc/env.d/98secondary
    Contains values for PATH,ROOTPATH,LDPATH,... for this eprefix.
  /var/spool/emerge/doasroot
    Create it as empty file, currently not in use.
    Intention is to collect commands from enewuser/enewgroup/... when
    not run as real root (uid 0).
  /etc/inputrc
    Some maybe out-of-date inputrc, could be unneccesary here.

Additionally, two symlinks are created:
   /sbin/functions.sh -> /usr/lib/portage/bin/isolated-functions.sh
   /etc/init.d/functions.sh -> /sbin/functions.sh

I use /usr/lib/portage/bin/isolated-functions.sh because i did not know
better where to get those /sbin/functions.sh from.


[baselayout-linux-0.1.ebuild]
Installs only one file:
  /etc/env.d/99system
    Only contains two lines:
      PORTAGE_ENVDUP="LDPATH"
      PORTAGE_ENVDUP_LDPATH="LD_LIBRARY_PATH"
    This configures portage (with 07-env-dup.patch) to dupe collected
    values from LDPATH into LD_LIBRARY_PATH.

Idea is to let make.profile symlink unmask different packages for hpux
and aix, to dupe LDPATH value into SHLIB_PATH and LIBPATH respectively.

Comments welcome!

[1] http://thread.gmane.org/gmane.linux.gentoo.macosx/1080/focus=1080

-haubi-
-- 
Michael Haubenwallner                    SALOMON Automation GmbH
Forschung & Entwicklung                  A-8114 Friesach bei Graz
mailto:michael.haubenwallner@...  http://www.salomon.at
No HTML/MIME please, see http://expita.com/nomime.html
Attachment:
06-env-conf+ext.patch (Text Data)
Attachment:
07-env-dup.patch (Text Data)
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /cvsroot/secondary-portage/sys-apps/baselayout-secondary/baselayout-secondary-0.1.ebuild,v 1.4 2005/09/14 06:59:13 haubi Exp $

DESCRIPTION="Baselayout for Secondary Package Manager extending the environment"
HOMEPAGE=""
SRC_URI=""

LICENSE=""
SLOT="0"
EAPI="prefix"
KEYWORDS="x86"
IUSE=""

#PDEPEND=">=portage-2.1_pre"
DEPEND="app-shells/bash"
RDEPEND=""

src_install() {
	insinto /etc || die
	newins ${FILESDIR}/${PV}-inputrc inputrc || die
	newins ${FILESDIR}/${PV}-profile profile || die
	newins ${FILESDIR}/${PV}-unprofile unprofile || die
	into /
	newsbin ${FILESDIR}/${PV}-extenv extenv || die
	cu_bash=${BASH}
	test -r "${ROOT}/bin/bash" && cu_bash="${EPREFIX}/bin/bash"
	dosed "s,@EPREFIX@,${EPREFIX},g
		  ;s,@BASH@,${cu_bash},g
		  ;s,@rootuser@,${PORTAGE_ROOTUSER:-$(id -un)},
		" \
		/etc/profile \
		/etc/unprofile \
		/sbin/extenv \
	|| die
	fperms a+x /sbin/extenv
	insinto /etc/env.d
	cat >> "${D}"/etc/env.d/98secondary <<-EOE
		# /${EPREFIX}etc/env.d/98secondary

		PATH='${EPREFIX}/usr/bin:${EPREFIX}/bin'
		ROOTPATH='${EPREFIX}/usr/sbin:${EPREFIX}/sbin:${EPREFIX}/usr/bin:${EPREFIX}/bin'
		LDPATH='${EPREFIX}/usr/lib:${EPREFIX}/lib'
		INFODIR='${EPREFIX}/usr/share/info'
		INFOPATH='${EPREFIX}/usr/share/info'
		MANPATH='${EPREFIX}/usr/share/man'
	EOE

	dodir /etc/init.d || die
	dosym /usr/lib/portage/bin/isolated-functions.sh /sbin/functions.sh || die
	dosym /sbin/functions.sh /etc/init.d/functions.sh || die
	dodir /var/spool/emerge || die
	touch "${D}"/var/spool/emerge/doasroot || die
}
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /cvsroot/secondary-portage/sys-apps/baselayout-secondary/baselayout-secondary-0.1.ebuild,v 1.4 2005/09/14 06:59:13 haubi Exp $

DESCRIPTION="Baselayout for Secondary Package Manager extending the environment"
HOMEPAGE=""
SRC_URI=""

LICENSE=""
SLOT="0"
EAPI="prefix"
KEYWORDS="x86"
IUSE=""

DEPEND=""
RDEPEND="sys-apps/baselayout-prefix"
PROVIDE="virtual/baselayout"

src_install() {
	cat >> "${T}"/99system <<-EOE
		# /${EPREFIX}etc/env.d/99system

		PORTAGE_ENVDUP="LDPATH"
		PORTAGE_ENVDUP_LDPATH="LD_LIBRARY_PATH"
	EOE
	doenvd "${T}"/99system || die
}
#! @BASH@

envfile="@EPREFIX@/etc/env.conf"

die() {
	[ "$*" ] && echo "$@" >&2
	exit 1
}

echo_setenv() {
	local var=$1
	var=$1
	shift
	eval "local val=\"$*\""

	eval "${var}=\"${val}\""

	case "${shelltype}" in
	sh)
		if [ -n "${val}" ]
		then
			echo "${var}='${val}' ;"
			echo "export ${var} ;"
		else
			echo "unset ${var} ;"
		fi
		;;
	csh)
		if [ -n "${val}" ]
		then
			echo "setenv ${var} '${val:0:1000}' ;"
			val=${val:1000}
			while [ -n "${val}" ]
			do
				echo "setenv ${var} \"\${${var}}\"'${val:0:1000}' ;"
				val=${val:1000}
			done
		else
			echo "unsetenv ${var} ;"
		fi
		;;
	esac
}

parse_envfile() { (
	local envfile=$1
	local var
	eval $(
		. ${envfile} || die
		echo "PORTAGE_ENVEXT=\$'${PORTAGE_ENVEXT-}'"
		echo "PORTAGE_ENVSET=\$'${PORTAGE_ENVSET-}'"
	)

	for var in ${PORTAGE_ENVEXT-} ${PORTAGE_ENVSET-}
	do
		unset ${var}
	done

	. ${envfile} || { echo abort ; die ; }
	for var in ${PORTAGE_ENVEXT-}
	do
		echo "extenv_var=\$'${var}'"
		eval echo extenv_sep=\\\$\\\'\${PORTAGE_EXTSEP_${var}- }\\\'
		eval echo extenv_val=\\\$\\\'\${${var}-}\\\'
	done

	for var in ${PORTAGE_ENVSET-}
	do
		echo "setenv_var=\$'${var}'"
		eval echo setenv_val=\\\$\\\'\${${var}-}\\\'
	done
) }

extenv_set() {
	local envfile=$1

	while read line
	do
		case "${line}" in
		abort)
			die
			;;
		extenv_var=*)
			# extend environment variable
			eval ${line}
			# extenv_sep
			read line
			eval ${line}
			# extenv_val
			read line
			eval ${line}

			[ -n "${extenv_val}" ] || continue

			eval extenv_oldval=\${${extenv_var}}
			case "${extenv_sep}${extenv_oldval}${extenv_sep}" in
			"${extenv_sep}${extenv_sep}")
				# variable to be extended is empty
				echo_setenv ${extenv_var} "${extenv_val}"
				;;
			*"${extenv_sep}${extenv_val}${extenv_sep}"*)
				# variable to be extended already contains extval
				;;
			"${extenv_sep}${extenv_sep}"*)
				# separator is already there
				echo_setenv ${extenv_var} "${extenv_val}${extenv_oldval}"
				;;
			*)
				# expand with separator
				echo_setenv ${extenv_var} "${extenv_val}${extenv_sep}${extenv_oldval}"
				;;
			esac
			;;
		setenv_var=*)
			# set environment variable
			eval "${line}"
			# setenv_val
			read line
			eval "${line}"

			echo_setenv ${setenv_var} "${setenv_val}"
			;;
		esac
	done <<-EOE
	$(parse_envfile ${envfile})
	EOE
}

extenv_unset() {
	local envfile=$1

	while read line
	do
		case "${line}" in
		abort)
			die
			;;
		extenv_var=*)
			# extend environment variable
			eval "${line}"
			# extenv_sep
			read line
			eval "${line}"
			# extenv_val
			read line
			eval "${line}"

			eval extenv_oldval=\"\${${extenv_var}}\"
			extenv_testval="${extenv_sep}${extenv_oldval}${extenv_sep}"
			save_IFS=$IFS
			IFS=$extenv_sep
			extenv_newval=
			for ov in ${extenv_oldval}
			do
				case "${extenv_sep}${extenv_val}${extenv_sep}" in
				*"${extenv_sep}${ov}${extenv_sep}"*)
					continue
					;;
				esac
				extenv_newval="${extenv_newval}${extenv_newval:+${extenv_sep}}${ov}"
			done
			IFS=$save_IFS
			echo_setenv ${extenv_var} "${extenv_newval}"
			;;
		setenv_var=*)
			# set environment variable
			eval "${line}"
			# setenv_val
			read line
			eval "${line}"

			# unset variable
			echo_setenv ${setenv_var} ""
			;;
		esac
	done <<-EOE
	$(parse_envfile ${envfile})
	EOE
}

extenv_none() { :;}

known_functions="set unset"

action=none
case "${SHELL}" in
*csh) shelltype=csh ;;
*) shelltype=sh ;;
esac

for arg in "$@"
do
	case "X${arg}" in
		X--debug) set -xv ; continue ;;
		X--sh) shelltype=sh ; continue ;;
		X--csh) shelltype=csh ; continue ;;
	esac

	for func in ${known_functions}
	do
		case "X${arg}" in
		X--${func})
			action=${func}
			continue 2
			;;
		esac
	done

	case "X${arg}" in
	X--*) die "invalid argument '${arg}'" ;;
	esac

	envfile="${arg}"
done

extenv_${action} ${envfile}
# /etc/inputrc:
# $Header: /cvsroot/secondary-portage/sys-apps/baselayout-secondary/files/0.1-inputrc,v 1.1 2005/05/27 15:45:21 haubi Exp $

# do not bell on tab-completion
#set bell-style none

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on

# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on

$if mode=emacs

# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word

# for rxvt
"\e[8~": end-of-line

# for non RH/Debian xterm, can't hurt for RH/Debian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif

# fix Home and End for German users
"\e[7~": beginning-of-line
"\e[8~": end-of-line

# @EPREFIX@/etc/profile
# $Header: /cvsroot/secondary-portage/sys-apps/baselayout-secondary/files/0.1-profile,v 1.1 2005/07/08 07:03:42 haubi Exp $

if [ -e "@EPREFIX@/etc/env.conf" ]
then
	ROOTPATH=${PATH}
	export ROOTPATH
	eval `@EPREFIX@/sbin/extenv --set --sh @EPREFIX@/etc/env.conf`
fi

case "`/usr/bin/whoami`" in
"root"|"@rootuser@")
    export PATH="${ROOTPATH}"
	;;
*)
esac
unset ROOTPATH

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]
then
    export INPUTRC="@EPREFIX@/etc/inputrc"
fi

# Extract the value of EDITOR
[ -z "${EDITOR-}" ] && EDITOR="`. @EPREFIX@/etc/rc.conf 2>/dev/null; echo ${EDITOR-}`"
[ -z "${EDITOR-}" ] && EDITOR="`. @EPREFIX@/etc/conf.d/basic 2>/dev/null; echo ${EDITOR-}`"
[ -z "${EDITOR-}" ] && EDITOR="@EPREFIX@/bin/nano"
export EDITOR

for x in @EPREFIX@/etc/profile.d/*.sh
do
    if [ -x ${x} ]
    then
        . ${x}
    fi
done
unset x

if [ -e @EPREFIX@/etc/unprofile ]
then
	alias eenv-clear='. @EPREFIX@/etc/unprofile'
fi
# @EPREFIX@/etc/unprofile
# $Header: /cvsroot/secondary-portage/sys-apps/baselayout-secondary/files/0.1-unprofile,v 1.1 2005/07/08 07:03:42 haubi Exp $

for x in @EPREFIX@/etc/profile.d/*.unsh
do
    if [ -x ${x} ]
    then
        . ${x}
    fi
done
unset x

if [ -e @EPREFIX@/etc/env.conf ]
then
	ROOTPATH=${PATH}
	export ROOTPATH
	eval `@EPREFIX@/sbin/extenv --unset --sh @EPREFIX@/etc/env.conf`
fi

case "`/usr/bin/whoami`" in
"root")
    export PATH="${ROOTPATH}"
	;;
"@rootuser@")
    export PATH="${ROOTPATH}"
	;;
*)
esac
unset ROOTPATH

if [ "${INPUTRC-}" = "@EPREFIX@/etc/inputrc" ]
then
    unset INPUTRC
fi

case "${EDITOR-}" in
"@EPREFIX@/"*) unset EDITOR ;;
esac

unalias eenv-clear 2>/dev/null
References:
[PREFIX] LD_LIBRARY_PATH issue
-- Grobian
Re: [PREFIX] LD_LIBRARY_PATH issue
-- Michael Haubenwallner
Re: [PREFIX] LD_LIBRARY_PATH issue
-- Grobian
Navigation:
Lists: gentoo-osx: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: [PREFIX] LD_LIBRARY_PATH issue
Next by thread:
RE: [PREFIX] LD_LIBRARY_PATH issue
Previous by date:
Re: [PREFIX] LD_LIBRARY_PATH issue
Next by date:
[PREFIX] status update for this week


Updated Jun 17, 2009

Summary: Archive of the gentoo-osx mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.