public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Portage Toys
@ 2004-09-30 23:43 Ned Ludd
  2004-10-05 19:07 ` Michael Tindal
  0 siblings, 1 reply; 11+ messages in thread
From: Ned Ludd @ 2004-09-30 23:43 UTC (permalink / raw
  To: gentoo-hardened; +Cc: gentoo-dev


[-- Attachment #1.1: Type: text/plain, Size: 3392 bytes --]

Portage has this really great feature-file that's often overlooked which
can be used in almost unlimited ways to customize your gentoo linux
install or preform tasks that you would otherwise have to open a bug
for. Sometimes your bug may not even be appropriate or suited for the
masses. But thankfully there is bashrc to the rescue.

quoting from the manpage:
"If needed this file can be used to setup a different environment for
ebuilds than the root environment. Syntax is the
same as any other bash script."

Ok sounds good lets take it for a drive..... 
Yada yada crunch etc and stuff...

About a week later here..

Ok so now I want to share an example which I'm now using on my own box
which have made my life easier.. these examples require bash3 but that
easy enough to backport.

------------------------------------------------------------------------

Per package CFLAGS
/etc/portage/package.cflags

Like many others I'm always fighting for space. I want some
optimizations on some packages but not the same optimizations on others
and portage has no way to handle this currently and I got tired of
waiting for package.env so I wrote a simple way to handle cflags on a
per package or category basis. (this is what started it all)

------------------------------------------------------------------------

I've seen alot of people ask about this feature. 
Never knew why it does not exists. None the less here you go.

FEATURES="distclean"
This feature will automatically remove files that portage downloads to
$DISTDIR based on what's defined in an ebuilds SRC_URI.

In one of the final ebuild phases of ebuild.sh (postinst) we check that
file exists and is a regular file then that the user (me) has
FEATURES="distclean" defined and all conditions are met we simply remove
the file to save space/memory after we don't need it anymore.

-------------------------------------------------------------------------

# Source Based Auto Auditing Features.

These two features for people who have nothing better to do that look
for flaws in packages via portage semi automatically.
This feature should not be used by people who have no clue what they are
doing.

FEATURES=flawfinder

Flawfinder searches through source code for potential security flaws,
listing potential security flaws sorted by risk, with the most
potentially dangerous flaws shown first. This risk level depends not
only on the function, but on the values of the parameters of the
function.
Flawfinder can only process .c / .cpp files.

FEATURES=rats
This feature is a lot like flawfinder. Only it can process c/cpp/php/pl
vs flawfinder c/cpp. Each auditing tool each has it's own advantages and
disadvantages. 

If FEATURE_AUDIT_LOGPATH is found in the environment then we will save
the audit logs to the dir defined by that variable.

To use either one of these you must have rats || flawfinder installed
accordingly.

------------------------------------------------------------------------
This code is all experimental and if it does not work for you, breaks
something or you think my bash sucks I really don't care. I just wanted
to share the idea that with /etc/portage/bashrc you can do some really
cool things.

-enjoy

-- 
Ned Ludd <solar@gentoo.org>
Gentoo (hardened,security,infrastructure,embedded,toolchain) Developer

[-- Attachment #1.2: bashrc --]
[-- Type: text/plain, Size: 5507 bytes --]

# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# - /etc/portage/bashrc

if [ "$0" = "/usr/lib/portage/bin/ebuild.sh" -o "$0" = "/usr/lib/portage/bin/ebuild-daemon.sh" ]; then

	if [ "${DEBUG}" != "" ]; then
		echo ----------------------------------------------------
		echo \$_=$_
		echo \$\*=$*
		echo \$@=$@

		echo PORTDIR=$PORTDIR
		echo CATEGORY=$CATEGORY
		echo PN=$PN
		echo PV=$PV
		echo PR=$PR
		echo PF=$PF
		echo P=$P

		echo USER=$USER
		echo HOME=$HOME
		echo PATH=${PATH}
		echo LD_PRELOAD=${LD_PRELOAD}
		echo ----------------------------------------------------
	fi

	eecho() {
		[ "$NOCOLOR" = "false" ] && echo -ne '\e[1;34m>\e[1;36m>\e[1;35m>\e[0m ' || echo -n ">>> "
		echo "$*"
	}
	
	package-pre-compile() {
		local i af1 af2 flaws audit line s_files
		local save_pwd=$PWD

		PATH=$PATH:/usr/sbin:/usr/bin:/bin:/sbin
		echo "FEATURES=$FEATURES"
		cd ${S} || return 0

		[ -z "${FEATURE_AUDIT_LOGPATH}" ] && export FEATURE_AUDIT_LOGPATH="/var/log/ebuildaudit"
		addwrite ${FEATURE_AUDIT_LOGPATH}
		for audit in flawfinder rats; do
			if [ "`has ${audit} ${FEATURES}`" != "" -a -x /usr/bin/${audit} ]; then
				flaws=""
				case "${audit}" in
					flawfinder)
						s_files="`find ${S} -name '*.c' -o -name '*.cpp'`"
						[ -z "${FEATURE_FLAWFINDER_MINLEVEL}" ] && export FEATURE_FLAWFINDER_MINLEVEL=5
					;;
					rats)
						s_files="`/usr/bin/find ${S} -name '*.c' -o -name '*.cpp' -o -name '*.php' -o -name '*.pl'`"
						[ -z "${FEATURE_RATS_WARNLEVEL}" ] && export FEATURE_RATS_WARNLEVEL=1
					;;
					*) : ;;
				esac
				if [ -n "$s_files" ]; then
					s_count=`echo ${s_files} | tr ' ' '\n' | wc -l | awk '{print $1}'`
					eecho "Running ${audit} on [$s_count] files"
					flaws=""
					[ "${audit}" == "flawfinder" ] &&
						flaws=$(/usr/bin/flawfinder --quiet --dataonly --minlevel=${FEATURE_FLAWFINDER_MINLEVEL} ${s_files})
	
					[ "${audit}" == "rats" ] &&
						flaws=$(/usr/bin/rats --quiet --resultsonly --warning ${FEATURE_RATS_WARNLEVEL} ${s_files})
	
					if [ -n "$flaws" ]; then
						line="------------------------------------------------------------------------"
						i=5;echo;while [ $i != 0 ]; do echo -ne ".\a" ; sleep 0.25 ; i=$(($i - 1)) ; done ;echo
						echo ${line}
						ewarn "${audit} report for ${PN} on $(date -u)"
						echo ${line} ; echo -e "${flaws}" ; echo ${line}
						i=5;echo;while [ $i != 0 ]; do echo -ne ".\a" ; sleep 0.25 ; i=$(($i - 1)) ; done ;echo
						if [ -d "${FEATURE_AUDIT_LOGPATH}" ]; then
							af1="${FEATURE_AUDIT_LOGPATH}/${PN}-${PV}_${audit}"
							af2="${FEATURE_AUDIT_LOGPATH}/${audit}.log"
							> $af1
							for a in $af1 $af2 ; do
								eecho "Saving audit data to $a"
								echo ${line} >> ${a}
								echo " * ${audit} report for ${PN} on $(date -u)" >> ${a}
								echo ${line} >> ${a}
								echo -e "${flaws}" >> ${a}
								echo ${line} >> ${a}
							done
						fi
					fi
				fi
			fi
		done
		cd ${save_pwd}
	}

	package-distdir-clean() {
		local a x
		for a in ${FEATURES} ; do 
			if [ "$a" = "distclean" ]; then
				for x in ${SRC_URI}; do
					x=$(/bin/basename $x)
					if [[ -f $DISTDIR/$x ]]; then
						size="$(/bin/ls -lh  ${DISTDIR}/${x} | /bin/awk '{print $5}')"
						eecho "All done with ${x} Removing it to save ${size}"
						/bin/rm ${DISTDIR}/${x}
					fi
				done
			fi
		done
	}

	append-cflags() {
		export CFLAGS="${CFLAGS} $*"
		export CXXFLAGS="${CXXFLAGS} $*"
		return 0
	}

	package-cflags() {
		local target flags flag i;

		# bail if file does not exist or is not readable.
		[ -r ${ROOT}/etc/portage/package.cflags ] || return 0

		# need bash >= 3
		if [ "${BASH_VERSINFO[0]}" -le 2 ]; then
			eecho "Need bash3 for this bashrc script to work"
			return 0
		fi

		while read -a target; do
			if [[ ${target[@]%%#*} ]]; then

				# valid syntax no >=<! operators
				# category CFLAGS
				# category/packagename CFLAGS
				if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
					skip=0
					if [[ ${target} != ${CATEGORY} ]] ; then
						if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
							skip=1
						fi
					fi
					if [ "${skip}" == 0 ] ; then
						flags=(${target[@]:1})
						if [[ ${flags[@]} =~ 'CFLAGS' ]]; then
							for (( i = 0; i < ${#flags[@]}; i++ )); do
								if [[ ${flags[$i]} =~ 'CFLAGS' ]]; then
									appened-cflags $(eval echo "${flags[$i]}")
									unset flags[$i]
								fi
							done
						fi
						for flag in ${flags[@]}; do
							if [[ ${CFLAGS} =~ ${flag} ]]; then
								continue 1
							else
								append-cflags "${flag}"
							fi
						done
						export -n C{,XX}FLAGS
						eecho "Using package.cflags entry for target ${target} for ${CATEGORY}/${PN}"
					fi
				fi
			fi
		done < ${ROOT}/etc/portage/package.cflags
	}

	case "$*"  in
		# stay really quiet here.
		depend) : ;;
		*)
			if [ "${LD_PRELOAD##*/}" = "libsandbox.so" ]; then
				[ "$NOCOLOR" = "false" ] && i=$(echo -ne '\e[1;32m+\e[0m') || i="+"
			else
				[ "$NOCOLOR" = "false" ] && i=$(echo -ne '\e[1;31m-\e[0m') || i="-"
			fi
			eecho "$USER ${i}sandbox($*)"
			package-cflags

			[ "$*" = "postinst" ] && package-distdir-clean
			[ "$*" = "compile" ] && package-pre-compile
		;;
	esac
else
	echo "This bashrc does not know anything about $0"
fi

[-- Attachment #1.3: package.cflags --]
[-- Type: text/plain, Size: 885 bytes --]

# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# - /etc/portage/package.cflags

##############
# Important: #
##############
# >=dev-blah/blah syntax is not supported by this files. 
# We can take individual category names
# Or we can take individual ebuild names
#

##############
# CATEGORIES #
##############
app-editors -Os
sys-apps -Os
sys-fs -Os
dev-libs -O1
net-misc -O2
net-www	 -O2
sys-boot -fno-stack-protector-all
sys-libs -O1
sys-devel -Os
gnome-base -Wl,-O1
gnome-extra -Wl,-O1
media-libs -O1
x11-misc -Wl,-O1 
x11-wm -Wl,-O1

#################
# PACKAGE NAMES #
#################
net-www/mozilla -O3 -Wl,-01
sys-apps/chpax -O1
sys-apps/paxctl -O1
mail-client/evolution -Wl,-O1
media-video/mplayer -O3 -mno-sse2 -fno-stack-protector -fno-stack-protector-all

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-09-30 23:43 [gentoo-dev] Portage Toys Ned Ludd
@ 2004-10-05 19:07 ` Michael Tindal
  2004-10-06  3:09   ` Michael Tindal
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Tindal @ 2004-10-05 19:07 UTC (permalink / raw
  To: solar; +Cc: gentoo-hardened, gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]

On Thu, 2004-09-30 at 19:43 -0400, Ned Ludd wrote:
> Portage has this really great feature-file that's often overlooked which
> can be used in almost unlimited ways to customize your gentoo linux
> install or preform tasks that you would otherwise have to open a bug
> for. Sometimes your bug may not even be appropriate or suited for the
> masses. But thankfully there is bashrc to the rescue.
> 
> quoting from the manpage:
> "If needed this file can be used to setup a different environment for
> ebuilds than the root environment. Syntax is the
> same as any other bash script."
> 
> Ok sounds good lets take it for a drive..... 
> Yada yada crunch etc and stuff...
> 
> About a week later here..
> 
> Ok so now I want to share an example which I'm now using on my own box
> which have made my life easier.. these examples require bash3 but that
> easy enough to backport.

Based on solar's excellent bashrc, I've added a few things.
Per-package/category FEATURES, arbitrary environment settings
per-package/category (not sure how useful this would be, but I figured
I'd go ahead and add it anyway), and category-wide USE flags.  Hope
someone finds this as useful as I found solar's :).

Mike

[-- Attachment #2: bashrc --]
[-- Type: text/plain, Size: 15503 bytes --]


# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# - /etc/portage/bashrc

alias usev=useq

if [ "$0" = "/usr/lib/portage/bin/ebuild.sh" -o "$0" = "/usr/lib/portage/bin/ebuild-daemon.sh" ]; then

	OLDPATH=$PATH
	PATH=/bin:$PATH
	
	if [ "${DEBUG}" != "" ]; then
                echo ----------------------------------------------------
                echo \$_=$_
                echo \$\*=$*
                echo \$@=$@

                echo PORTDIR=$PORTDIR
                echo CATEGORY=$CATEGORY
                echo PN=$PN
                echo PV=$PV
                echo PR=$PR
                echo PF=$PF
                echo P=$P

                echo USER=$USER
                echo HOME=$HOME
                echo PATH=${PATH}
                echo LD_PRELOAD=${LD_PRELOAD}
                echo ----------------------------------------------------
        fi

        eecho() {
                [ "$NOCOLOR" = "false" ] && echo -ne '\e[1;34m>\e[1;36m>\e[1;35m>\e[0m ' || echo -n ">>> "
                echo "$*"
        }
        
        package-pre-compile() {
                local i af1 af2 flaws audit line s_files
                local save_pwd=$PWD

                PATH=$PATH:/usr/sbin:/usr/bin:/bin:/sbin
                echo "FEATURES=$FEATURES"
                cd ${S} || return 0

                [ -z "${FEATURE_AUDIT_LOGPATH}" ] && export FEATURE_AUDIT_LOGPATH="/var/log/ebuildaudit"
                addwrite ${FEATURE_AUDIT_LOGPATH}
                for audit in flawfinder rats; do
                        if [ "`has ${audit} ${FEATURES}`" != "" -a -x /usr/bin/${audit} ]; then
                                flaws=""
                                case "${audit}" in
                                        flawfinder)
                                                s_files="`find ${S} -name '*.c' -o -name '*.cpp'`"
                                                [ -z "${FEATURE_FLAWFINDER_MINLEVEL}" ] && export FEATURE_FLAWFINDER_MINLEVEL=5
                                        ;;
                                        rats)
                                                s_files="`/usr/bin/find ${S} -name '*.c' -o -name '*.cpp' -o -name '*.php' -o -name '*.pl'`"
                                                [ -z "${FEATURE_RATS_WARNLEVEL}" ] && export FEATURE_RATS_WARNLEVEL=1
                                        ;;
                                        *) : ;;
                                esac
                                if [ -n "$s_files" ]; then
                                        s_count=`echo ${s_files} | tr ' ' '\n' | wc -l | awk '{print $1}'`
                                        eecho "Running ${audit} on [$s_count] files"
                                        flaws=""
                                        [ "${audit}" == "flawfinder" ] &&
                                                flaws=$(/usr/bin/flawfinder --quiet --dataonly --minlevel=${FEATURE_FLAWFINDER_MINLEVEL} ${s_files})
        
                                        [ "${audit}" == "rats" ] &&
                                                flaws=$(/usr/bin/rats --quiet --resultsonly --warning ${FEATURE_RATS_WARNLEVEL} ${s_files})
        
                                        if [ -n "$flaws" ]; then
                                                line="------------------------------------------------------------------------"
                                                i=5;echo;while [ $i != 0 ]; do echo -ne "." ; sleep 0.25 ; i=$(($i - 1)) ; done ;echo
                                                echo ${line}
                                                ewarn "${audit} report for ${PN} on $(date -u)"
                                                echo ${line} ; echo -e "${flaws}" ; echo ${line}
                                                i=5;echo;while [ $i != 0 ]; do echo -ne "." ; sleep 0.25 ; i=$(($i - 1)) ; done ;echo
                                                if [ -d "${FEATURE_AUDIT_LOGPATH}" ]; then
                                                        af1="${FEATURE_AUDIT_LOGPATH}/${PN}-${PV}_${audit}"
                                                        af2="${FEATURE_AUDIT_LOGPATH}/${audit}.log"
                                                        > $af1
                                                        for a in $af1 $af2 ; do
                                                                eecho "Saving audit data to $a"
                                                                echo ${line} >> ${a}
                                                                echo " * ${audit} report for ${PN} on $(date -u)" >> ${a}
                                                                echo ${line} >> ${a}
                                                                echo -e "${flaws}" >> ${a}
                                                                echo ${line} >> ${a}
                                                        done
                                                fi
                                        fi
                                fi
                        fi
                done
                cd ${save_pwd}
        }

        package-distdir-clean() {
                local a x
                for a in ${FEATURES} ; do 
                        if [ "$a" = "distclean" ]; then
                                for x in ${SRC_URI}; do
                                        x=$(/bin/basename $x)
                                        if [[ -f $DISTDIR/$x ]]; then
                                                size="$(/bin/ls -lh  ${DISTDIR}/${x} | /bin/awk '{print $5}')"
                                                eecho "All done with ${x} Removing it to save ${size}"
                                                /bin/rm ${DISTDIR}/${x}
                                        fi
                                done
                        fi
                done
        }

	has-char() {
		echo $1 | grep $2 > /dev/null 2>&1

		return $?
	}
	
        append-cflags() {
                export CFLAGS="${CFLAGS} $*"
                export CXXFLAGS="${CXXFLAGS} $*"
                return 0
        }
		
	append-features() {
		for feature in $*; do
			if has-char $feature '-'; then
				feature=$(echo `echo $feature | sed -e 's/^-//'`)
				export FEATURES=$(echo `echo ${FEATURES} | sed -e s/$feature//`)
			else
				export FEATURES="${FEATURES} $feature"
			fi
		done
		return 0
	}

	append-use() {
		for use in $*; do
			if has-char $use '-'; then
				use=$(echo `echo $use | sed -e 's/^-//'`)
				export USE=$(echo `echo ${USE} | sed -e s/$use//`)
			else
				export USE="${USE} $use"
			fi
		done
		return 0
	}
				
	
	append-env() {
		for env in $*; do
			if has-char $env '-'; then
				# ensure it doesnt have '='
				eecho Attempting to remove $env...
				if has-char $env '='; then
					# ignore value, we're unsetting
					env=`echo $env | sed -e 's/\=[^ ]*//' -e 's/^-//'`
				fi
				env=$(echo `echo $env | sed -e 's/^-//'`)
				unset $env
			else
				export $env
			fi
		done
	}
				

        package-cflags() {
                local target flags flag i;

                # bail if file does not exist or is not readable.
                [ -r ${ROOT}/etc/portage/package.cflags ] || return 0

                # need bash >= 3
                if [ "${BASH_VERSINFO[0]}" -le 2 ]; then
                        eecho "Need bash3 for this bashrc script to work"
                        return 0
                fi

                while read -a target; do
                        if [[ ${target[@]%%#*} ]]; then

                                # valid syntax no >=<! operators
                                # category CFLAGS
                                # category/packagename CFLAGS
                                if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
                                        skip=0
                                        if [[ ${target} != ${CATEGORY} ]] ; then
                                                if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
                                                        skip=1
                                                fi
                                        fi
                                        if [ "${skip}" == 0 ] ; then
                                                flags=(${target[@]:1})
                                                if [[ ${flags[@]} =~ 'CFLAGS' ]]; then
                                                        for (( i = 0; i < ${#flags[@]}; i++ )); do
                                                                if [[ ${flags[$i]} =~ 'CFLAGS' ]]; then
                                                                        appened-cflags $(eval echo "${flags[$i]}")
                                                                        unset flags[$i]
                                                                fi
                                                        done
                                                fi
                                                for flag in ${flags[@]}; do
                                                        if [[ ${CFLAGS} =~ ${flag} ]]; then
                                                                continue 1
                                                        else
                                                                append-cflags "${flag}"
                                                        fi
                                                done
                                                export -n C{,XX}FLAGS
                                                eecho "Using package.cflags entry for target ${target} for ${CATEGORY}/${PN}"
                                        fi
                                fi
                        fi
                done < ${ROOT}/etc/portage/package.cflags
        }

	package-features() {
		local target flags flag i;

		# bail if file does not exist or is not readable
		[ -r ${ROOT}/etc/portage/package.features ] || return 0

		while read -a target; do
                        if [[ ${target[@]%%#*} ]]; then

                                # valid syntax no >=<! operators
                                # category FEATURES
                                # category/packagename FEATURES
                                if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
                                        skip=0
                                        if [[ ${target} != ${CATEGORY} ]] ; then
                                                if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
                                                        skip=1
                                                fi
                                        fi
                                        if [ "${skip}" == 0 ] ; then
                                                flags=(${target[@]:1})
                                                if [[ ${flags[@]} =~ 'FEATURES' ]]; then
                                                        for (( i = 0; i < ${#flags[@]}; i++ )); do
                                                                if [[ ${flags[$i]} =~ 'FEATURES' ]]; then
                                                                        appened-features $(eval echo "${flags[$i]}")
                                                                        unset flags[$i]
                                                                fi
                                                        done
                                                fi
                                                for flag in ${flags[@]}; do
                                                        if [[ ${FEATURES} =~ ${flag} ]]; then
                                                                continue 1
                                                        else
                                                                append-features "${flag}"
                                                        fi
                                                done
                                                export -n FEATURES
                                                eecho "Using package.features entry for target ${target} for ${CATEGORY}/${PN}"
                                        fi
                                fi
                        fi
                done < ${ROOT}/etc/portage/package.features
	}

	package-env() {
		local target envi env i;

		[ -r ${ROOT}/etc/portage/package.env ] || return 0

		while read -a target; do
			if [[ ${target[@]%%#*} ]]; then

				# valid syntax no >=<! operators
				# category VAR0=VAL0 VAR1=VAL1 ... VARN=VALN
				# category/packagename VAR0=VAL0 VAR1=VAL1 ... VARN=VALN


				if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
					skip=0
					if [[ ${target} != ${CATEGORY} ]] ; then
						if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
							skip=1
						fi
					fi
					if [ "${skip}" == 0 ] ; then
						envi=(${target[@]:1})
						if [[ ${envi[@]} =~ 'ENVIRONMENT' ]]; then
							for (( i = 0; i < ${#envi[@]}; i++ )); do
								if [[ ${envi[$i]} =~ 'ENVIRONMENT' ]]; then
									append-env $(eval echo "${envi[$i]}")
									unset envi[$i]
								fi
							done
						fi
						for env in ${envi[@]}; do
							append-env "${env}"
						done
						eecho "Using package.env entry for target ${target} for ${CATEGORY}/${PN}"
					fi
				fi
			fi
		done < ${ROOT}/etc/portage/package.env
	}

	category-use() {
		local target usef use i;

		[ -r ${ROOT}/etc/portage/category.use ] || return 0

		while read -a target; do
			if [[ ${target[@]%%#*} ]]; then

				# valid syntax no >=<! operators
				# category USE...

				if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY})\>" ]]; then
					skip=0

					if [[ ${target} != ${CATEGORY} ]] ; then
						skip = 1
					fi
				
					if [ "${skip}" == 0 ] ; then
						usef=(${target[@]:1})
						if [[ ${usef[@]} =~ 'USE' ]]; then
							for (( i = 0; i < ${#usef[@]}; i++ )); do
								if [[ ${usef[$i]} =~ 'USE' ]]; then
									append-use $(eval echo "${usef[$i]}")
									unset usef[$i]
								fi
							done
						fi
						for use in ${usef[@]}; do
							append-use "${use}"
						done
						eecho "Using category.use entry for target ${target} for ${CATEGORY}/${PN}"
					fi
				fi
			fi
		done < ${ROOT}/etc/portage/category.use
	}
		
        case "$*"  in
                # stay really quiet here.
                depend) 
			package-features
			;;
                *)
                        if [ "${LD_PRELOAD##*/}" = "libsandbox.so" ]; then
                                [ "$NOCOLOR" = "false" ] && i=$(echo -ne '\e[1;32m+\e[0m') || i="+"
                        else
                                [ "$NOCOLOR" = "false" ] && i=$(echo -ne '\e[1;31m-\e[0m') || i="-"
                        fi
                        eecho "$USER ${i}sandbox($*)"
                        package-cflags
			package-features
			package-env
			category-use

                        [ "$*" = "postinst" ] && package-distdir-clean
                        [ "$*" = "compile" ] && package-pre-compile
                ;;
        esac

	PATH=$OLDPATH
else
        echo "This bashrc does not know anything about $0"
fi

[-- Attachment #3: category.use --]
[-- Type: text/plain, Size: 448 bytes --]

# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# - /etc/portage/category.use

##############
# Important: #
##############
# >=dev-blah/blah syntax is not supported by this files.
# We can take individual category names
# This file applies USE flags to an entire category, useful for things
# like sys-kernel.
#

##############
# CATEGORIES #
##############
sys-kernel -doc

[-- Attachment #4: package.features --]
[-- Type: text/plain, Size: 614 bytes --]

# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# - /etc/portage/package.features

##############
# Important: #
##############
# >=dev-blah/blah syntax is not supported by this files.
# We can take individual category names
# Or we can take individual ebuild names
#

##############
# CATEGORIES #
##############
sys-kernel -distclean -mirror

##############
#  PACKAGES  #
##############
app-editors/nano -distclean nodoc -maketest
x11-libs/gtk+ -maketest
media-video/nvidia-kernel -distclean -collision-protect
sys-apps/sysvinit keepwork

[-- Attachment #5: package.env --]
[-- Type: text/plain, Size: 430 bytes --]

# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# - /etc/portage/package.env

##############
# Important: #
##############
# >=dev-blah/blah syntax is not supported by this files.
# We can take individual category names
# Or we can take individual ebuild names
#

##############
# CATEGORIES #
##############

##############
#  PACKAGES  #
##############



[-- Attachment #6: Type: text/plain, Size: 37 bytes --]

--
gentoo-dev@gentoo.org mailing list

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-05 19:07 ` Michael Tindal
@ 2004-10-06  3:09   ` Michael Tindal
  2004-10-06 10:57     ` Jason Stubbs
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Tindal @ 2004-10-06  3:09 UTC (permalink / raw
  To: solar; +Cc: gentoo-hardened, gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 998 bytes --]

On Tue, 2004-10-05 at 15:07 -0400, Michael Tindal wrote:
> On Thu, 2004-09-30 at 19:43 -0400, Ned Ludd wrote:

Had some more talks with solar on IRC, and it turns out that the
package.env I had (partially) implemented was his original intention.
So 20 minutes later, after headscratching and talking to my mentor, I
came up with this.  My old bashrc didnt support package.env entires of
the form NAME="....", this has been fixed.

The format is something like
category/pkgname CFLAGS="...";LDFLAGS="...";USE="...";FEATURES="..."

And, yes, this negates the need for every other file used in the bashrc.
I left them because I'm an organization freak and I like having things
in seperate files.  Feel free to trim this down :)

Also, this is not the best solution, it was one that worked and did the
job well.  Not perfect, but well.

If someone wants to improve it (for the case of LDFLAGS="$(echo ; ; ;)",
by all means go for it.  This is as usual provided on an AS-IS basis.

Have fun kids!

Mike

[-- Attachment #2: bashrc --]
[-- Type: text/plain, Size: 15627 bytes --]


# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# - /etc/portage/bashrc

alias usev=useq

if [ "$0" = "/usr/lib/portage/bin/ebuild.sh" -o "$0" = "/usr/lib/portage/bin/ebuild-daemon.sh" ]; then

	OLDPATH=$PATH
	PATH=/bin:$PATH
	
	if [ "${DEBUG}" != "" ]; then
                echo ----------------------------------------------------
                echo \$_=$_
                echo \$\*=$*
                echo \$@=$@

                echo PORTDIR=$PORTDIR
                echo CATEGORY=$CATEGORY
                echo PN=$PN
                echo PV=$PV
                echo PR=$PR
                echo PF=$PF
                echo P=$P

                echo USER=$USER
                echo HOME=$HOME
                echo PATH=${PATH}
                echo LD_PRELOAD=${LD_PRELOAD}
                echo ----------------------------------------------------
        fi

        eecho() {
                [ "$NOCOLOR" = "false" ] && echo -ne '\e[1;34m>\e[1;36m>\e[1;35m>\e[0m ' || echo -n ">>> "
                echo "$*"
        }
        
        package-pre-compile() {
                local i af1 af2 flaws audit line s_files
                local save_pwd=$PWD

                PATH=$PATH:/usr/sbin:/usr/bin:/bin:/sbin
                echo "FEATURES=$FEATURES"
                cd ${S} || return 0

                [ -z "${FEATURE_AUDIT_LOGPATH}" ] && export FEATURE_AUDIT_LOGPATH="/var/log/ebuildaudit"
                addwrite ${FEATURE_AUDIT_LOGPATH}
                for audit in flawfinder rats; do
                        if [ "`has ${audit} ${FEATURES}`" != "" -a -x /usr/bin/${audit} ]; then
                                flaws=""
                                case "${audit}" in
                                        flawfinder)
                                                s_files="`find ${S} -name '*.c' -o -name '*.cpp'`"
                                                [ -z "${FEATURE_FLAWFINDER_MINLEVEL}" ] && export FEATURE_FLAWFINDER_MINLEVEL=5
                                        ;;
                                        rats)
                                                s_files="`/usr/bin/find ${S} -name '*.c' -o -name '*.cpp' -o -name '*.php' -o -name '*.pl'`"
                                                [ -z "${FEATURE_RATS_WARNLEVEL}" ] && export FEATURE_RATS_WARNLEVEL=1
                                        ;;
                                        *) : ;;
                                esac
                                if [ -n "$s_files" ]; then
                                        s_count=`echo ${s_files} | tr ' ' '\n' | wc -l | awk '{print $1}'`
                                        eecho "Running ${audit} on [$s_count] files"
                                        flaws=""
                                        [ "${audit}" == "flawfinder" ] &&
                                                flaws=$(/usr/bin/flawfinder --quiet --dataonly --minlevel=${FEATURE_FLAWFINDER_MINLEVEL} ${s_files})
        
                                        [ "${audit}" == "rats" ] &&
                                                flaws=$(/usr/bin/rats --quiet --resultsonly --warning ${FEATURE_RATS_WARNLEVEL} ${s_files})
        
                                        if [ -n "$flaws" ]; then
                                                line="------------------------------------------------------------------------"
                                                i=5;echo;while [ $i != 0 ]; do echo -ne "." ; sleep 0.25 ; i=$(($i - 1)) ; done ;echo
                                                echo ${line}
                                                ewarn "${audit} report for ${PN} on $(date -u)"
                                                echo ${line} ; echo -e "${flaws}" ; echo ${line}
                                                i=5;echo;while [ $i != 0 ]; do echo -ne "." ; sleep 0.25 ; i=$(($i - 1)) ; done ;echo
                                                if [ -d "${FEATURE_AUDIT_LOGPATH}" ]; then
                                                        af1="${FEATURE_AUDIT_LOGPATH}/${PN}-${PV}_${audit}"
                                                        af2="${FEATURE_AUDIT_LOGPATH}/${audit}.log"
                                                        > $af1
                                                        for a in $af1 $af2 ; do
                                                                eecho "Saving audit data to $a"
                                                                echo ${line} >> ${a}
                                                                echo " * ${audit} report for ${PN} on $(date -u)" >> ${a}
                                                                echo ${line} >> ${a}
                                                                echo -e "${flaws}" >> ${a}
                                                                echo ${line} >> ${a}
                                                        done
                                                fi
                                        fi
                                fi
                        fi
                done
                cd ${save_pwd}
        }

        package-distdir-clean() {
                local a x
                for a in ${FEATURES} ; do 
                        if [ "$a" = "distclean" ]; then
                                for x in ${SRC_URI}; do
                                        x=$(/bin/basename $x)
                                        if [[ -f $DISTDIR/$x ]]; then
                                                size="$(/bin/ls -lh  ${DISTDIR}/${x} | /bin/awk '{print $5}')"
                                                eecho "All done with ${x} Removing it to save ${size}"
                                                /bin/rm ${DISTDIR}/${x}
                                        fi
                                done
                        fi
                done
        }

	has-char() {
		echo $1 | grep ^$2 > /dev/null 2>&1

		return $?
	}
	
        append-cflags() {
                export CFLAGS="${CFLAGS} $*"
                export CXXFLAGS="${CXXFLAGS} $*"
                return 0
        }
		
	append-features() {
		for feature in $*; do
			if has-char $feature '-'; then
				feature=$(echo `echo $feature | sed -e 's/^-//'`)
				export FEATURES=$(echo `echo ${FEATURES} | sed -e s/$feature//`)
			else
				export FEATURES="${FEATURES} $feature"
			fi
		done
		return 0
	}

	append-use() {
		for use in $*; do
			if has-char $use '-'; then
				use=$(echo `echo $use | sed -e 's/^-//'`)
				export USE=$(echo `echo ${USE} | sed -e s/$use//`)
			else
				export USE="${USE} $use"
			fi
		done
		return 0
	}
				
	
	append-env() {
		for env in $*; do
			if has-char $env '-'; then
				# ensure it doesnt have '='
				eecho Attempting to remove $env...
				if has-char $env '='; then
					# ignore value, we're unsetting
					env=`echo $env | sed -e 's/\=[^;]*//' -e 's/^-//'`
				fi
				env=$(echo `echo $env | sed -e 's/^-//'`)
				unset $env
			else
				export $env
			fi
		done
	}
				

        package-cflags() {
                local target flags flag i;

                # bail if file does not exist or is not readable.
                [ -r ${ROOT}/etc/portage/package.cflags ] || return 0

                # need bash >= 3
                if [ "${BASH_VERSINFO[0]}" -le 2 ]; then
                        eecho "Need bash3 for this bashrc script to work"
                        return 0
                fi

                while read -a target; do
                        if [[ ${target[@]%%#*} ]]; then

                                # valid syntax no >=<! operators
                                # category CFLAGS
                                # category/packagename CFLAGS
                                if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
                                        skip=0
                                        if [[ ${target} != ${CATEGORY} ]] ; then
                                                if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
                                                        skip=1
                                                fi
                                        fi
                                        if [ "${skip}" == 0 ] ; then
                                                flags=(${target[@]:1})
                                                if [[ ${flags[@]} =~ 'CFLAGS' ]]; then
                                                        for (( i = 0; i < ${#flags[@]}; i++ )); do
                                                                if [[ ${flags[$i]} =~ 'CFLAGS' ]]; then
                                                                        appened-cflags $(eval echo "${flags[$i]}")
                                                                        unset flags[$i]
                                                                fi
                                                        done
                                                fi
                                                for flag in ${flags[@]}; do
                                                        if [[ ${CFLAGS} =~ ${flag} ]]; then
                                                                continue 1
                                                        else
                                                                append-cflags "${flag}"
                                                        fi
                                                done
                                                export -n C{,XX}FLAGS
                                                eecho "Using package.cflags entry for target ${target} for ${CATEGORY}/${PN}"
                                        fi
                                fi
                        fi
                done < ${ROOT}/etc/portage/package.cflags
        }

	package-features() {
		local target flags flag i;

		# bail if file does not exist or is not readable
		[ -r ${ROOT}/etc/portage/package.features ] || return 0

		while read -a target; do
                        if [[ ${target[@]%%#*} ]]; then

                                # valid syntax no >=<! operators
                                # category FEATURES
                                # category/packagename FEATURES
                                if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
                                        skip=0
                                        if [[ ${target} != ${CATEGORY} ]] ; then
                                                if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
                                                        skip=1
                                                fi
                                        fi
                                        if [ "${skip}" == 0 ] ; then
                                                flags=(${target[@]:1})
                                                if [[ ${flags[@]} =~ 'FEATURES' ]]; then
                                                        for (( i = 0; i < ${#flags[@]}; i++ )); do
                                                                if [[ ${flags[$i]} =~ 'FEATURES' ]]; then
                                                                        appened-features $(eval echo "${flags[$i]}")
                                                                        unset flags[$i]
                                                                fi
                                                        done
                                                fi
                                                for flag in ${flags[@]}; do
                                                        if [[ ${FEATURES} =~ ${flag} ]]; then
                                                                continue 1
                                                        else
                                                                append-features "${flag}"
                                                        fi
                                                done
                                                export -n FEATURES
                                                eecho "Using package.features entry for target ${target} for ${CATEGORY}/${PN}"
                                        fi
                                fi
                        fi
                done < ${ROOT}/etc/portage/package.features
	}

	package-env() {
		local target envi env i;

		[ -r ${ROOT}/etc/portage/package.env ] || return 0

		OLDIFS=$IFS

		while read -a target; do
			if [[ ${target[@]%%#*} ]]; then

				# valid syntax no >=<! operators
				# category VAR0=VAL0 VAR1=VAL1 ... VARN=VALN
				# category/packagename VAR0=VAL0 VAR1=VAL1 ... VARN=VALN
				# VARN="VALN0 VALN1 ... VALNX";VARM="VALM0 VALM1 ... VALMX" is also valid

				if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
					skip=0
					if [[ ${target} != ${CATEGORY} ]] ; then
						if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
							skip=1
						fi
					fi
					if [ "${skip}" == 0 ] ; then
						IFS=';'
						envi=(${target[@]:1})

						if [[ ${envi[@]} =~ 'ENVIRONMENT' ]]; then
							for (( i = 0; i < ${#envi[@]}; i++ )); do
								if [[ ${envi[$i]} =~ 'ENVIRONMENT' ]]; then
									append-env $(eval echo "${envi[$i]}")
									unset envi[$i]
								fi
							done
						fi
						for env in ${envi[@]}; do
							append-env "${env}"
						done
						eecho "Using package.env entry for target ${target} for ${CATEGORY}/${PN}"
					fi
				fi
			fi
		done < ${ROOT}/etc/portage/package.env

		IFS=$OLDIFS
	}

	category-use() {
		local target usef use i;

		[ -r ${ROOT}/etc/portage/category.use ] || return 0

		while read -a target; do
			if [[ ${target[@]%%#*} ]]; then

				# valid syntax no >=<! operators
				# category USE...

				if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY})\>" ]]; then
					skip=0

					if [[ ${target} != ${CATEGORY} ]] ; then
						skip = 1
					fi
				
					if [ "${skip}" == 0 ] ; then
						usef=(${target[@]:1})
						if [[ ${usef[@]} =~ 'USE' ]]; then
							for (( i = 0; i < ${#usef[@]}; i++ )); do
								if [[ ${usef[$i]} =~ 'USE' ]]; then
									append-use $(eval echo "${usef[$i]}")
									unset usef[$i]
								fi
							done
						fi
						for use in ${usef[@]}; do
							append-use "${use}"
						done
						eecho "Using category.use entry for target ${target} for ${CATEGORY}/${PN}"
					fi
				fi
			fi
		done < ${ROOT}/etc/portage/category.use
	}
		
        case "$*"  in
                # stay really quiet here.
                depend) 
			package-features
			;;
                *)
                        if [ "${LD_PRELOAD##*/}" = "libsandbox.so" ]; then
                                [ "$NOCOLOR" = "false" ] && i=$(echo -ne '\e[1;32m+\e[0m') || i="+"
                        else
                                [ "$NOCOLOR" = "false" ] && i=$(echo -ne '\e[1;31m-\e[0m') || i="-"
                        fi
                        eecho "$USER ${i}sandbox($*)"
                        package-cflags
			package-features
			package-env
			category-use

                        [ "$*" = "postinst" ] && package-distdir-clean
                        [ "$*" = "compile" ] && package-pre-compile
                ;;
        esac

	PATH=$OLDPATH
else
        echo "This bashrc does not know anything about $0"
fi


[-- Attachment #3: Type: text/plain, Size: 37 bytes --]

--
gentoo-dev@gentoo.org mailing list

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06  3:09   ` Michael Tindal
@ 2004-10-06 10:57     ` Jason Stubbs
  2004-10-06 21:29       ` Michael Tindal
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Stubbs @ 2004-10-06 10:57 UTC (permalink / raw
  To: gentoo-dev

On Wednesday 06 October 2004 12:09, Michael Tindal wrote:
> The format is something like
> category/pkgname CFLAGS="...";LDFLAGS="...";USE="...";FEATURES="..."

Unless you like things not compiling due to missing dependencies, don't use 
USE in this file. Same deal with ACCEPT_KEYWORDS and anything else that could 
possibly affect dependencies (which is nothing that I can think of at this 
stage).

Regards,
Jason Stubbs

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06 10:57     ` Jason Stubbs
@ 2004-10-06 21:29       ` Michael Tindal
  2004-10-06 22:53         ` Jason Stubbs
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Tindal @ 2004-10-06 21:29 UTC (permalink / raw
  To: Jason Stubbs; +Cc: gentoo-dev

On Wed, 2004-10-06 at 19:57 +0900, Jason Stubbs wrote:
> On Wednesday 06 October 2004 12:09, Michael Tindal wrote:
> > The format is something like
> > category/pkgname CFLAGS="...";LDFLAGS="...";USE="...";FEATURES="..."
> 
> Unless you like things not compiling due to missing dependencies, don't use 
> USE in this file. Same deal with ACCEPT_KEYWORDS and anything else that could 
> possibly affect dependencies (which is nothing that I can think of at this 
> stage).
> 
> Regards,
> Jason Stubbs

Hi Jason,

	That wasn't really the point of the exercise (USE and the like).
Portage already has files for that, so using this for that is pointless.
It was more for CFLAGS and LDFLAGS and such, and the example I gave was
off the top of my head.

Mike


--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06 21:29       ` Michael Tindal
@ 2004-10-06 22:53         ` Jason Stubbs
  2004-10-06 23:33           ` Ned Ludd
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Stubbs @ 2004-10-06 22:53 UTC (permalink / raw
  To: gentoo-dev

On Thursday 07 October 2004 06:29, Michael Tindal wrote:
> On Wed, 2004-10-06 at 19:57 +0900, Jason Stubbs wrote:
> > On Wednesday 06 October 2004 12:09, Michael Tindal wrote:
> > > The format is something like
> > > category/pkgname CFLAGS="...";LDFLAGS="...";USE="...";FEATURES="..."
> >
> > Unless you like things not compiling due to missing dependencies, don't
> > use USE in this file. Same deal with ACCEPT_KEYWORDS and anything else
> > that could possibly affect dependencies (which is nothing that I can
> > think of at this stage).
>
>  That wasn't really the point of the exercise (USE and the like).
> Portage already has files for that, so using this for that is pointless.
> It was more for CFLAGS and LDFLAGS and such, and the example I gave was
> off the top of my head.

No problem. I was mostly just pointing it out for the onlookers and to preempt 
invalid bug reports. Also worth pointing out is that most FEATURES would not 
be honoured as well, as bashrc is only used on the bash side of things 
whereas the python side of portage handles most of them.

Regards,
Jason Stubbs

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06 23:55             ` Jason Stubbs
@ 2004-10-06 22:59               ` Donnie Berkholz
  2004-10-06 23:05                 ` Donnie Berkholz
  0 siblings, 1 reply; 11+ messages in thread
From: Donnie Berkholz @ 2004-10-06 22:59 UTC (permalink / raw
  To: gentoo-dev

On Wed, 2004-10-06 at 16:55, Jason Stubbs wrote:
> Actually, I was wrong about ACCEPT_KEYWORDS above. It would simply be ignored 
> - unless ebuilds are actually reading that variable. As far as I know, 
> ebuilds only test the ARCH variable.

I will be testing FEATURES in the X builds shortly. They need custom
stripping that the portage functions aren't able to do, so I'm going to
check for nostrip in FEATURES to disable it. See
http://bugs.gentoo.org/show_bug.cgi?id=66531.
-- 
Donnie Berkholz
Gentoo Linux


--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06 22:59               ` Donnie Berkholz
@ 2004-10-06 23:05                 ` Donnie Berkholz
  0 siblings, 0 replies; 11+ messages in thread
From: Donnie Berkholz @ 2004-10-06 23:05 UTC (permalink / raw
  To: gentoo-dev

On Wed, 2004-10-06 at 15:59, Donnie Berkholz wrote:
> On Wed, 2004-10-06 at 16:55, Jason Stubbs wrote:
> > Actually, I was wrong about ACCEPT_KEYWORDS above. It would simply be ignored 
> > - unless ebuilds are actually reading that variable. As far as I know, 
> > ebuilds only test the ARCH variable.
> 
> I will be testing FEATURES in the X builds shortly. They need custom
> stripping that the portage functions aren't able to do, so I'm going to
> check for nostrip in FEATURES to disable it. See
> http://bugs.gentoo.org/show_bug.cgi?id=66531.

Does this even make sense? It seemed logical at the time, but now it
seemed ludicrous. Which time was I too tired?

Situation is: Ebuild sets RESTRICT="nostrip" then does custom stripping.
So, we want to have a way to enable/disable the custom stripping.
FEATURES="nostrip" seems like the best way.

Anyone got a better idea?
-- 
Donnie Berkholz
Gentoo Linux


--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06 22:53         ` Jason Stubbs
@ 2004-10-06 23:33           ` Ned Ludd
  2004-10-06 23:55             ` Jason Stubbs
  2004-10-06 23:59             ` Marius Mauch
  0 siblings, 2 replies; 11+ messages in thread
From: Ned Ludd @ 2004-10-06 23:33 UTC (permalink / raw
  To: Jason Stubbs; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1646 bytes --]

On Wed, 2004-10-06 at 18:53, Jason Stubbs wrote:
> On Thursday 07 October 2004 06:29, Michael Tindal wrote:
> > On Wed, 2004-10-06 at 19:57 +0900, Jason Stubbs wrote:
> > > On Wednesday 06 October 2004 12:09, Michael Tindal wrote:
> > > > The format is something like
> > > > category/pkgname CFLAGS="...";LDFLAGS="...";USE="...";FEATURES="..."
> > >
> > > Unless you like things not compiling due to missing dependencies, don't
> > > use USE in this file. Same deal with ACCEPT_KEYWORDS and anything else
> > > that could possibly affect dependencies (which is nothing that I can
> > > think of at this stage).
> >
> >  That wasn't really the point of the exercise (USE and the like).
> > Portage already has files for that, so using this for that is pointless.
> > It was more for CFLAGS and LDFLAGS and such, and the example I gave was
> > off the top of my head.
> 
> No problem. I was mostly just pointing it out for the onlookers and to preempt 
> invalid bug reports. Also worth pointing out is that most FEATURES would not 
> be honoured as well, as bashrc is only used on the bash side of things 
> whereas the python side of portage handles most of them.

Portage learns about FEATURES after it's sourced the ebuild in the
depend phase right? 
If so then it would seem that those functions-FEATURES/USE which have
todo with depgraph creation could be exported in the 'depend' phase from
a bashrc. Is my logic incorrect?
 
> 
> Regards,
> Jason Stubbs
> 
> --
> gentoo-dev@gentoo.org mailing list
-- 
Ned Ludd <solar@gentoo.org>
Gentoo (hardened,security,infrastructure,embedded,toolchain) Developer

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06 23:33           ` Ned Ludd
@ 2004-10-06 23:55             ` Jason Stubbs
  2004-10-06 22:59               ` Donnie Berkholz
  2004-10-06 23:59             ` Marius Mauch
  1 sibling, 1 reply; 11+ messages in thread
From: Jason Stubbs @ 2004-10-06 23:55 UTC (permalink / raw
  To: gentoo-dev

On Thursday 07 October 2004 08:33, Ned Ludd wrote:
> On Wed, 2004-10-06 at 18:53, Jason Stubbs wrote:
> > On Thursday 07 October 2004 06:29, Michael Tindal wrote:
> > > On Wed, 2004-10-06 at 19:57 +0900, Jason Stubbs wrote:
> > > > On Wednesday 06 October 2004 12:09, Michael Tindal wrote:
> > > > > The format is something like
> > > > > category/pkgname
> > > > > CFLAGS="...";LDFLAGS="...";USE="...";FEATURES="..."
> > > >
> > > > Unless you like things not compiling due to missing dependencies,
> > > > don't use USE in this file. Same deal with ACCEPT_KEYWORDS and
> > > > anything else that could possibly affect dependencies (which is
> > > > nothing that I can think of at this stage).
> > >
> > >  That wasn't really the point of the exercise (USE and the like).
> > > Portage already has files for that, so using this for that is
> > > pointless. It was more for CFLAGS and LDFLAGS and such, and the example
> > > I gave was off the top of my head.
> >
> > No problem. I was mostly just pointing it out for the onlookers and to
> > preempt invalid bug reports. Also worth pointing out is that most
> > FEATURES would not be honoured as well, as bashrc is only used on the
> > bash side of things whereas the python side of portage handles most of
> > them.
>
> Portage learns about FEATURES after it's sourced the ebuild in the
> depend phase right?
> If so then it would seem that those functions-FEATURES/USE which have
> todo with depgraph creation could be exported in the 'depend' phase from
> a bashrc. Is my logic incorrect?

The depend phase is only ran to build the cache. If the cache is current, it 
is read directly. If not, it is built and then read directly. The FEATURES 
that are enabled are built from the configuration (ie emerge info) and 
whatever the package might have in its RESTRICT.

Actually, I was wrong about ACCEPT_KEYWORDS above. It would simply be ignored 
- unless ebuilds are actually reading that variable. As far as I know, 
ebuilds only test the ARCH variable.

Regards,
Jason Stubbs

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [gentoo-dev] Portage Toys
  2004-10-06 23:33           ` Ned Ludd
  2004-10-06 23:55             ` Jason Stubbs
@ 2004-10-06 23:59             ` Marius Mauch
  1 sibling, 0 replies; 11+ messages in thread
From: Marius Mauch @ 2004-10-06 23:59 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]

On 10/06/04  Ned Ludd wrote:

> On Wed, 2004-10-06 at 18:53, Jason Stubbs wrote:
> > On Thursday 07 October 2004 06:29, Michael Tindal wrote:
> > > On Wed, 2004-10-06 at 19:57 +0900, Jason Stubbs wrote:
> > > > On Wednesday 06 October 2004 12:09, Michael Tindal wrote:
> > > > > The format is something like
> > > > > category/pkgname
> > > > > CFLAGS="...";LDFLAGS="...";USE="...";FEATURES="..."
> > > >
> > > > Unless you like things not compiling due to missing
> > > > dependencies, don't use USE in this file. Same deal with
> > > > ACCEPT_KEYWORDS and anything else that could possibly affect
> > > > dependencies (which is nothing that I can think of at this
> > > > stage).
> > >
> > >  That wasn't really the point of the exercise (USE and the like).
> > > Portage already has files for that, so using this for that is
> > > pointless. It was more for CFLAGS and LDFLAGS and such, and the
> > > example I gave was off the top of my head.
> > 
> > No problem. I was mostly just pointing it out for the onlookers and
> > to preempt invalid bug reports. Also worth pointing out is that most
> > FEATURES would not be honoured as well, as bashrc is only used on
> > the bash side of things whereas the python side of portage handles
> > most of them.
> 
> Portage learns about FEATURES after it's sourced the ebuild in the
> depend phase right? 
> If so then it would seem that those functions-FEATURES/USE which have
> todo with depgraph creation could be exported in the 'depend' phase
> from a bashrc. Is my logic incorrect?

Yes. The variables that affect the python side (which includes depgraph
stuff) come from the portage.config class which is initialized when
'import portage' is called. Also ebuild.sh (including your bashrc) is a
subprocess of emerge (including portage.py and the config class) and to
my knowledge you can't just export env-variables to the parent process,
so you'd need a more advanced communication.

Marius

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-10-07  0:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-30 23:43 [gentoo-dev] Portage Toys Ned Ludd
2004-10-05 19:07 ` Michael Tindal
2004-10-06  3:09   ` Michael Tindal
2004-10-06 10:57     ` Jason Stubbs
2004-10-06 21:29       ` Michael Tindal
2004-10-06 22:53         ` Jason Stubbs
2004-10-06 23:33           ` Ned Ludd
2004-10-06 23:55             ` Jason Stubbs
2004-10-06 22:59               ` Donnie Berkholz
2004-10-06 23:05                 ` Donnie Berkholz
2004-10-06 23:59             ` Marius Mauch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox