From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Si7hb-0003VY-3t for garchives@archives.gentoo.org; Fri, 22 Jun 2012 17:31:23 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0CD63E090A; Fri, 22 Jun 2012 17:29:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id C11D5E08BA for ; Fri, 22 Jun 2012 17:29:25 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3CCD61B4019 for ; Fri, 22 Jun 2012 17:29:25 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id CA9B9E5448 for ; Fri, 22 Jun 2012 17:29:22 +0000 (UTC) From: "Ulrich Mueller" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Mueller" Message-ID: <1181426548.3cb40485bd2f466917d962cec35745ecc71102e8.ulm@gentoo> Subject: [gentoo-commits] proj/emacs-tools:eselect-emacs-1.1 commit in: / X-VCS-Repository: proj/emacs-tools X-VCS-Files: env-emacs.eselect X-VCS-Directories: / X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Mueller X-VCS-Revision: 3cb40485bd2f466917d962cec35745ecc71102e8 X-VCS-Branch: eselect-emacs-1.1 Date: Fri, 22 Jun 2012 17:29:22 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: cd9bd892-56db-4d68-97a0-e9d1a1499e21 X-Archives-Hash: a88a37d1c8a1d5606a0f1f03583127fe commit: 3cb40485bd2f466917d962cec35745ecc71102e8 Author: Ulrich M=C3=BCller gentoo org> AuthorDate: Sat Jun 9 22:02:28 2007 +0000 Commit: Ulrich Mueller gentoo org> CommitDate: Sat Jun 9 22:02:28 2007 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/emacs-tools.g= it;a=3Dcommit;h=3D3cb40485 Add env-emacs.eselect, taken from eselect-1.0.9. svn path=3D/emacs-extra/eselect-emacs/; revision=3D380 --- env-emacs.eselect | 291 +++++++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 291 insertions(+), 0 deletions(-) diff --git a/env-emacs.eselect b/env-emacs.eselect new file mode 100644 index 0000000..5b977bf --- /dev/null +++ b/env-emacs.eselect @@ -0,0 +1,291 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +inherit config multilib + +DESCRIPTION=3D"Manage environment variables set in /etc/env.d/" +MAINTAINER=3D"kugelfang@gentoo.org" +SVN_DATE=3D'$Date$' +VERSION=3D$(svn_date_to_version "${SVN_DATE}" ) + +# Classes of env-vars +SPACE_CLASS=3D"CONFIG_PROTECT + CONFIG_PROTECT_MASK" +PATH_CLASS=3D"ADA_INCLUDE_PATH + ADA_OBJECT_PATH + CLASSPATH + INFODIR + INFOPATH + KDEDIRS + LDPATH + MANPATH + PATH + PKG_CONFIG_PATH + PRELINK_PATH + PRELINK_PATH_MASK + PYTHONPATH + ROOTPATH" + +# Recognized file formats: +MIME_WHITELIST=3D"text/plain text/x-makefile" + +# Configuration files +ENVPROFILE=3D"${ROOT}/etc/profile.env" +LDCONFIG=3D"${ROOT}/etc/ld.so.conf" +PRELINK=3D"${ROOT}/etc/prelink.conf" +LDMTIMEDB=3D"${ROOT}/var/lib/eselect/env/ld-mtimedb" + +# Keep all stored LDPATHS +ESELECT_LDPATH=3D( ) + +# is_envd_file() +# Return successfuly when file can be sourced. +is_envfile() { + local mime envfile=3D${1} + + # Make sure it is a file and no backup file + [[ -f ${envfile} ]] || return 1 + [[ -n ${envfile##*~} ]] || return 1 + [[ ${envfile##*.} !=3D bak ]] || return 1 + + mime=3D$(file -i ${envfile} | cut -d ' ' -f 2 | sed -e 's/;$//') + if ! has ${mime} ${MIME_WHITELIST} ; then + echo "Skipping non-text file ${envfile}." + return 1 + fi + + return 0 +} + +# update_envvar_classes() +# Update the contents of *_CLASS based on env,d files. +update_envvar_classes() { + local -a envfiles + local value + envfiles=3D( ${ROOT}/etc/env.d/* ) + + for envfile in ${envfiles[@]} ; do + is_envfile ${envfile} || continue + + value=3D$(load_config ${envfile} COLON_SEPARATED) + for x in ${value} ; do + has ${x} ${PATH_CLASS} && continue + PATH_CLASS=3D"${PATH_CLASS} ${x}" + done + + value=3D$(load_config ${envfile} SPACE_SEPARATED) + for x in ${value} ; do + has ${x} ${SPACE_CLASS} && continue + SPACE_CLASS=3D"${SPACE_CLASS} ${x}" + done + done +} + +# create_profile_env() +# Create profile.env file +create_profile_env() { + local -a envfiles + local vars store items tmpprofile + envfiles=3D( ${ROOT}/etc/env.d/* ) +=09 + # Blank the file first! + tmpprofile=3D"$(mktemp ${ROOT}/tmp/profile.XXXXXX)" + [[ $? =3D 0 ]] || die "Couldn't create temporary file!" + + # Gather ye classes while ye may! + update_envvar_classes + + # Parse all files in env.d + for envfile in ${envfiles[@]} ; do + is_envfile ${envfile} || continue + + # Which vars are to be loaded? + # TODO: Change to bash magic? + vars=3D$(sed \ + -e '/^#/d' -e '/^\s*$/d' -e '/^.*=3D/s/^\([^=3D]*\)=3D.*/\1/' \ + ${envfile}) + [[ -z ${vars} ]] && continue + for var in ${vars} ; do + # Colon separated?... + if has ${var} ${PATH_CLASS} ; then + store=3D$(load_config ${tmpprofile} ${var}) + if [[ -z ${store} ]] ; then + store=3D$(load_config ${envfile} ${var}) + else + items=3D"$(load_config ${envfile} ${var})" + items=3D( ${items//:/ } ) + for item in ${items[@]} ; do + has ${item} ${store//:/ } && continue + store=3D"${store}:${item}" + done + fi + store_config ${tmpprofile} ${var} "${store#:}" + continue + fi + # Space separated!... + if has ${var} ${SPACE_CLASS} ; then + store=3D( $(load_config ${tmpprofile} ${var}) ) + if [[ -z ${store[@]} ]] ; then + store=3D( $(load_config ${envfile} ${var}) ) + else + items=3D( $(load_config ${envfile} ${var}) ) + for item in ${items[@]} ; do + has ${item} ${store[@]} && continue + store=3D( ${store[@]} ${item} ) + done + fi + store_config ${tmpprofile} ${var} "${store[@]}" + continue + fi + # Ok, just a non-cummultative var. + store_config \ + ${tmpprofile} \ + ${var} \ + "$(load_config ${envfile} ${var})" + done +=09 + has LDPATH ${vars} || continue + # Store LDPATH for later processing + items=3D$(load_config ${envfile} LDPATH) + items=3D( ${items//:/ } ) + for item in ${items[@]} ; do + has ${item} ${LDPATH[@]} && continue=20 + ESELECT_LDPATH=3D( ${ESELECT_LDPATH[@]} ${item} ) + done + done + + # Move new file onto old one + ENVPROFILE=3D$(canonicalise ${ENVPROFILE}) + chmod a+r ${tmpprofile} + mv ${tmpprofile} ${ENVPROFILE} \ + || die "Couldn't move ${tmpprofile} to ${ENVPROFILE}!\n + Original profile.env remains unchanged." +} + +# create_ld_so_conf() +# Create ld.so.conf file based upon gathered LDPATHs +create_ld_so_conf() { + [[ -z ${ESELECT_LDPATH[@]} ]] && die -q 'No LDPATHs found in ${ROOT}/et= c/env.d/*' + + local str + str=3D"# ld.so.conf autogenerated by eselect\n" + str=3D"${str}# Make all changes to /etc/env.d files\n" + for x in ${ESELECT_LDPATH[@]} ; do + str=3D"${str}${x}\n" + done + echo -e "${str}" > $(canonicalise ${LDCONFIG}) +} + +# create_prelink_conf() +# Create prelink.conf file based upon existing profile.env +create_prelink_conf() { + [[ -z ${ESELECT_LDPATH[@]} ]] && die -q 'No LDPATHs found in ${ROOT}/et= c/env.d/*' + local str + str=3D"# prelink.conf autogenerated by eselect\n" + str=3D"${str}# Make all changes to /etc/env.d files\n" + # Add default items + for x in /bin /sbin /usr/bin /usr/sbin ; do + str=3D"${str}-l ${x}\n"=09 + done + for x in $(list_libdirs) ; do + [[ -e ${ROOT}/${x} ]] && str=3D"${str}-l /${x}\n" + [[ -e ${ROOT}/usr/${x} ]] && str=3D"${str}-l /usr/${x}\n" + done + prelink_mask=3D$(load_config ${ENVPROFILE} PRELINK_PATH_MASK) + prelink_mask=3D( ${prelink_mask//:/ } ) + prelink=3D"$(load_config ${ENVPROFILE} PATH)" + prelink=3D"${prelink} $(load_config ${ENVPROFILE} PRELINK_PATH)" + prelink=3D( ${prelink//:/ } ${ESELECT_LDPATH[@]} ) + for x in ${prelink[@]} ; do + has ${x} ${prelink_mask} && continue + [[ -z ${x##*/} ]] || x=3D"${x}/" + str=3D"${str}-h ${x}\n" + done + for x in ${prelink_mask[@]} ; do + str=3D"${str}-b ${x}\n" + done + echo -e "${str}" > $(canonicalise ${PRELINK}) +} + +# need_links() +# Returns true if any item of ${LDPATH} has been modified. +need_links() { + local ret=3D1 + for x in ${ESELECT_LDPATH[@]} ; do + y=3D${x//\//_} + y=3D${y//-/_} + y=3D${y//./_} + y=3D${y//+/_} + oldmtime=3D$(load_config ${LDMTIMEDB} "mtime${y}") + newmtime=3D$(stat -c %Y ${x} 2> /dev/null) + if [[ ${oldmtime} !=3D ${newmtime} ]] ; then + ret=3D0 + store_config ${LDMTIMEDB} "mtime${y}" ${newmtime} + fi + done + return ${ret} +} + +# update_ldcache() +# Update ld.so.cache using ldconfig +update_ldcache() { + case $(uname -s) in + FreeBSD | DragonFly) + echo "Regenerating ${ROOT}/var/run/ld-elf.so.hints..." + ( + cd / + ldconfig -elf -i -f "${ROOT:-/}var/run/ld-elf.so.hints" \ + "${ROOT:-/}etc/ld.so.conf" + ) + ;; + *) + echo "Regenerating ${ROOT}/etc/ld.so.cache..." + ( + cd / + ldconfig ${1} -r ${ROOT:-/} + ) + ;; + esac +} + +### update action + +describe_update() { + echo "Collect environment variables from all scripts in /etc/env.d/" +} + +describe_update_parameters() { + echo "" +} + +describe_update_options() { + echo "makelinks : Specify \"makelinks\" to force updating of links" +} + +do_update() { + if [[ -e ${ROOT}/etc/profile.env ]] ; then + [[ -w ${ROOT}/etc/profile.env ]] \ + || die -q "You need to be root!" + else + touch ${ROOT}/etc/profile.env + fi +=09 + # Create configuration files + create_profile_env + create_ld_so_conf + [[ -e ${ROOT}/usr/sbin/prelink ]] && create_prelink_conf + makelinks=3D$( ( need_links || [[ ${1} =3D=3D makelinks ]] ) && echo "-= X" ) + update_ldcache ${makelinks} + =09 + # fix up ${ENVPROFILE} + cp ${ENVPROFILE} ${ENVPROFILE/.env/.csh} + sed -i \ + -e "s/^\(.*\)=3D\"\(.*\)\"/export \1=3D'\2'/" \ + $(canonicalise ${ENVPROFILE}) + sed -i \ + -e "s/^\(.*\)=3D\"\(.*\)\"/setenv \1 '\2'/" \ + $(canonicalise ${ENVPROFILE/.env/.csh}) +} + +# vim: ft=3Deselect