MAKE_PROFILE_PATH=/etc/make.profile
MAKE_CONF_BACKUP_PATH=/etc/make.conf.euse_backup
-MODE="showhelp" # available operation modes: showhelp, showversion, showdesc, showflags, modify
+[ -z "${MODE}" ] && MODE="showhelp" # available operation modes: showhelp, showversion, showdesc, showflags, modify
parse_arguments() {
if [ -z "${1}" ]; then
echo "Notes: ${PROGRAM_NAME} currently only works for global flags defined"
echo " in make.globals, make.defaults or make.conf, it doesn't handle"
echo " use.defaults, use.mask or package.use yet (see portage(5) for details on"
- echo " these files)."
+ echo " these files). It also might have issues with cascaded profiles."
echo " If multiple options are specified only the last one will be used."
}
source "${MAKE_CONF_PATH}"
ACTIVE_FLAGS[1]="${USE}"
USE=""
- source $(get_make_defaults)
- ACTIVE_FLAGS[2]="${USE}"
+ for x in $(get_all_make_defaults); do
+ source "${x}"
+ ACTIVE_FLAGS[2]="${ACTIVE_FLAGS[2]} ${USE}"
+ done
USE=""
source "${MAKE_GLOBALS_PATH}"
ACTIVE_FLAGS[3]="${USE}"
fi
}
+# get all make.defaults by traversing the cascaded profile directories
+get_all_make_defaults() {
+ local curdir
+ local parent
+ local rvalue
+
+ curdir="$(readlink -f ${MAKE_PROFILE_PATH})"
+
+ while [ -f "${curdir}/parent" ]; do
+ [ -f "${curdir}/make.defaults" ] && rvalue="${curdir}/make.defaults ${rvalue}"
+ parent="$(egrep -v '(^#|^ *$)' ${curdir}/parent)"
+ curdir="$(readlink -f ${curdir}/${parent})"
+ done
+
+ echo "${rvalue}"
+}
+
# get the path to make.defaults by traversing the cascaded profile directories
get_make_defaults() {
local curdir
- local notfound
local parent
- notfound=1
curdir="$(readlink -f ${MAKE_PROFILE_PATH})"
while [ ! -f "${curdir}/make.defaults" -a -f "${curdir}/parent" ]; do
if [ -z "${PORTDIR}" ]; then
use_backup="${USE}"
source "${MAKE_GLOBALS_PATH}"
- source "$(get_make_defaults)"
+ for x in $(get_all_make_defaults); do
+ source "${x}"
+ done
source "${MAKE_CONF_PATH}"
USE="${use_backup}"
fi
##### main program comes now #####
+# disable globbing as it fucks up with args=*
set -f
parse_arguments "$@"
check_sanity