summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Shapovalov <george@gentoo.org>2006-05-12 13:28:41 +0000
committerGeorge Shapovalov <george@gentoo.org>2006-05-12 13:28:41 +0000
commit7939612350dde6902eec1efdc5fc1aaf64406106 (patch)
treefa3e91df651ad34a4dae4cf29fd6ff8a6de3455f /app-admin/eselect-gnat
parentStable on sparc wrt #132931 (diff)
downloadgentoo-2-7939612350dde6902eec1efdc5fc1aaf64406106.tar.gz
gentoo-2-7939612350dde6902eec1efdc5fc1aaf64406106.tar.bz2
gentoo-2-7939612350dde6902eec1efdc5fc1aaf64406106.zip
new version - fixes ROOTPATH issue + cosmetics
(Portage version: 2.1_pre10-r5)
Diffstat (limited to 'app-admin/eselect-gnat')
-rw-r--r--app-admin/eselect-gnat/ChangeLog8
-rw-r--r--app-admin/eselect-gnat/eselect-gnat-0.8.ebuild25
-rw-r--r--app-admin/eselect-gnat/files/digest-eselect-gnat-0.81
-rw-r--r--app-admin/eselect-gnat/files/gnat.eselect-0.8295
4 files changed, 328 insertions, 1 deletions
diff --git a/app-admin/eselect-gnat/ChangeLog b/app-admin/eselect-gnat/ChangeLog
index 73f5a6734562..e67ff7cd1322 100644
--- a/app-admin/eselect-gnat/ChangeLog
+++ b/app-admin/eselect-gnat/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for app-admin/eselect-gnat
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/ChangeLog,v 1.5 2006/05/02 15:47:50 george Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/ChangeLog,v 1.6 2006/05/12 13:28:41 george Exp $
+
+*eselect-gnat-0.8 (12 May 2006)
+
+ 12 May 2006; George Shapovalov <george@gentoo.org>
+ +files/gnat.eselect-0.8, +eselect-gnat-0.8.ebuild:
+ new version - fixes ROOTPATH + some cosmetic changes
02 May 2006; George Shapovalov <george@gentoo.org> files/gnat.eselect-0.7:
small fix to the do_show and do_list methods (so that they actually show libs)
diff --git a/app-admin/eselect-gnat/eselect-gnat-0.8.ebuild b/app-admin/eselect-gnat/eselect-gnat-0.8.ebuild
new file mode 100644
index 000000000000..e4b9915e65f8
--- /dev/null
+++ b/app-admin/eselect-gnat/eselect-gnat-0.8.ebuild
@@ -0,0 +1,25 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/eselect-gnat-0.8.ebuild,v 1.1 2006/05/12 13:28:41 george Exp $
+
+inherit eutils
+
+DESCRIPTION="gnat module for eselect."
+HOMEPAGE="http://www.gentoo.org"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+IUSE=""
+RDEPEND="app-admin/eselect"
+
+MODULEDIR="/usr/share/eselect/modules"
+
+src_install() {
+ dodir ${MODULEDIR}
+ insinto ${MODULEDIR}
+ doins ${FILESDIR}/gnat.eselect-${PV}
+ mv ${D}${MODULEDIR}/gnat.eselect-${PV} ${D}${MODULEDIR}/gnat.eselect
+}
diff --git a/app-admin/eselect-gnat/files/digest-eselect-gnat-0.8 b/app-admin/eselect-gnat/files/digest-eselect-gnat-0.8
new file mode 100644
index 000000000000..8b137891791f
--- /dev/null
+++ b/app-admin/eselect-gnat/files/digest-eselect-gnat-0.8
@@ -0,0 +1 @@
+
diff --git a/app-admin/eselect-gnat/files/gnat.eselect-0.8 b/app-admin/eselect-gnat/files/gnat.eselect-0.8
new file mode 100644
index 000000000000..80ea8aef01b5
--- /dev/null
+++ b/app-admin/eselect-gnat/files/gnat.eselect-0.8
@@ -0,0 +1,295 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: gnat.eselect-0.8,v 1.1 2006/05/12 13:28:41 george Exp $
+
+DESCRIPTION="Manage the talled gnat compilers"
+MAINTAINER="ada@gentoo.org"
+SVN_DATE='$Date: 2006/05/12 13:28:41 $'
+VERSION=$(svn_date_to_version "${SVN_DATE}" )
+
+SPECSDIR="/usr/share/gnat/eselect"
+ENVDIR="/etc/env.d"
+MARKER="55gnat-"
+#LibMarker="56"
+
+### Phylosophy
+# Each gnat installs a "specs" file named ${ARCH}-${PN}-${SLOT} under ${SPECSDIR}
+# Each lib creates a dir with its name under ${SPECSDIR} and populates it with
+# similar specs files (same name scheme)
+# Recognizing gnat specs from lib specs is then eazy - test entry for being a
+# dir, then just check what gnat profiles are installed for each lib..
+# doset then creates env file that combines settings for gnat and for the
+# corresponding profile of each installed lib..
+
+
+### Helpers
+
+# create a list of all gnat env.d files
+# for now use trivial implementation - store name of active profile in the
+# env file name, so it gets called 55gnat-${ARCH}-${PN}-${SLOT}
+get_env_list() {
+ for fn in ${ENVDIR}/${MARKER}*; do
+ echo $(basename ${fn})
+ done
+}
+
+# return *the* name of the active profile, checking that we do not have multiple
+# env files.
+# There can be only one!
+get_current_gnat() {
+ local profiles=( $(get_env_list) )
+
+ if [ ${profiles[@]} == "${MARKER}*" ]; then exit; fi
+
+ if (( 1 == ${#profiles[@]} )); then
+ local active=${profiles[0]#${MARKER}}
+ else
+ die -q "${ENVDIR} contains multiple gnat profiles, please cleanup!"
+ fi
+
+ if [ -f ${SPECSDIR}/${active} ]; then
+ echo ${active}
+ else
+ die -q "the active env.d profile does not correspond to any installed gnat!"
+ fi
+}
+
+# find installed compilers and return a list
+find_compilers() {
+ [ ! -d ${SPECSDIR} ] && exit
+ for fn in ${SPECSDIR}/*; do
+ [ ! -d ${fn} ] && echo $(basename ${fn});
+ done
+}
+
+# find installed libs and return a list
+find_all_libs() {
+ [ ! -d ${SPECSDIR} ] && exit
+ for fn in ${SPECSDIR}/*; do
+ [ -d ${fn} ] && echo $(basename ${fn});
+ done
+}
+
+# find libs that have been built for a given profile
+# Arguments:
+# $1 - gnat profile for which to detect active libs
+find_libs4profile() {
+ libs=( $(find_all_libs) )
+
+ for (( i = 0 ; i < ${#libs[@]} ; i = i + 1 )) ; do
+ [ -f ${SPECSDIR}/${libs[$i]}/$1 ] && echo "${libs[$i]}"
+ done
+}
+
+# check if the passed arg represents the installed gnat and return it or
+# not_found
+# takes args:
+# $1 - list ID to check
+get_name_from_list() {
+ compiler=$1
+
+ compilers=( $(find_compilers) )
+ for (( i = 0 ; i < ${#compilers[@]} ; i = i + 1 )) ; do
+ if [[ ${compilers[$i]} == ${compiler} ]] ; then
+ echo ${compiler}
+ return
+ fi
+ done
+
+ echo "(not-found)"
+}
+
+
+# extracts values of the passed var definition from given spec file
+# params:
+# $1: spec file (as generated by gnabuild.eclass)
+# $2: variable name
+get_var_from_spec() {
+ local var=$(grep -e "^ *$2=" $1|cut -d= -f2)
+ echo ${var}
+}
+
+
+# Cycle through given libs and form a : separated list of settings for the given
+# var. Returned string starts with ":" if there is any non-empty setting,
+# otherwise returns empty string
+# params:
+# $1 - list of libs to check (to avoid its composition every time)
+# $2 - name of gnat profile
+# $3 - name of env var to process
+get_lib_var_settings() {
+ local libList=$1
+ #echo "get_lib_var_settings: ${libList[@]}" >> rep.rep
+ if [[ ! ${libList[0]} == "none" ]]; then
+
+ local envString
+ for (( i = 0 ; i < ${#libList[@]} ; i = i + 1 )) ; do
+ #echo "lib $i = ${libList[$i]}" >> rep.rep
+ specLine=$(get_var_from_spec ${SPECSDIR}/${libList[$i]}/$2 $3)
+ [[ -n ${specLine} ]] && envString="${envString}:${specLine}"
+ done
+ echo "${envString}"
+ fi
+}
+
+
+# removes env files (for compiler and libs)
+# params:
+# $1: the name of profile for which to remove env file
+unset_env() {
+ rm -f ${ENVDIR}/${MARKER}$1 &> /dev/null
+}
+
+
+# Stuff common for do_set and do_update
+#
+# params:
+# $1 - profile to set (toset param inside)
+# $2 - envfile
+
+generate_envFile() {
+ local toset=$1
+ local envfile=$2
+
+ local binpath="$(get_var_from_spec ${SPECSDIR}/${toset} binpath)"
+ local libexecpath="$(get_var_from_spec ${SPECSDIR}/${toset} libexecpath)"
+ local libs=( $(find_libs4profile ${toset}) )
+ if (( 0 == ${#libs[@]} )); then
+ libs="none"
+ fi
+
+ local MyPath="${binpath}:${libexecpath}$(get_lib_var_settings ${libs} ${toset} PATH)"
+ echo "PATH=${MyPath}" > "${envfile}"
+ echo "ROOTPATH=${MyPath}" >> "${envfile}"
+ echo "MANPATH=$(get_var_from_spec ${SPECSDIR}/${toset} manpath)$(get_lib_var_settings ${libs} ${toset} MANPATH)" >> "${envfile}"
+ echo "INFOPATH=$(get_var_from_spec ${SPECSDIR}/${toset} infopath)$(get_lib_var_settings ${libs} ${toset} INFOPATH)" >> "${envfile}"
+ echo "ADA_INCLUDE_PATH=$(get_var_from_spec ${SPECSDIR}/${toset} ldpath)/adainclude$(get_lib_var_settings ${libs} ${toset} ADA_INCLUDE_PATH)" >> "${envfile}"
+ echo "ADA_OBJECTS_PATH=$(get_var_from_spec ${SPECSDIR}/${toset} ldpath)/adalib$(get_lib_var_settings ${libs} ${toset} ADA_OBJECTS_PATH)" >> "${envfile}"
+}
+
+### show action ###
+
+describe_show() {
+ echo "Show the active gnat compiler/profile and installed libs"
+}
+
+do_show() {
+ write_list_start "Current gnat version:"
+ active=$(get_current_gnat)
+ if [ ! -z ${active} ] ; then # not sure why [ -n ] does not do the same
+ write_kv_list_entry "$active" ""
+ libs=( $(find_libs4profile ${active}) )
+ write_list_start "Active libs:"
+ write_numbered_list "${libs[@]}"
+ else
+ write_kv_list_entry "(none set)" ""
+ fi
+}
+
+### list action ###
+
+describe_list() {
+ echo "List installed gnat compilers and libs"
+}
+
+do_list() {
+ compilers=( $(find_compilers ) )
+ active=$(get_current_gnat)
+
+ write_list_start "Available gnat compilers:"
+
+ if [[ -n ${compilers[@]} ]] ; then
+ local i
+ for (( i = 0 ; i < ${#compilers[@]} ; i = i + 1 )) ; do
+ linkversion=${compilers[${i}]}
+
+ [[ $linkversion == $active ]] && \
+ compilers[${i}]="${compilers[${i}]} $(highlight '*' )"
+ done
+ write_numbered_list "${compilers[@]}"
+
+ # now the libs
+ libs=( $(find_all_libs) )
+ write_list_start "Installed libs:"
+ for (( i = 0 ; i < ${#libs[@]} ; i = i + 1 )) ; do
+ [ -f ${SPECSDIR}/${libs[$i]}/${active} ] && \
+ libs[${i}]="${libs[${i}]} $(highlight '*' )"
+ done
+ write_numbered_list "${libs[@]}"
+ else
+ write_kv_list_entry "(none found)" ""
+ fi
+}
+
+
+### set action ###
+
+describe_set() {
+ echo "Set active gnat compiler"
+}
+
+# The set action. Parameters:
+# $1 - name of profile to set, obligatory, passed by eselect
+# $2 - optional, name of env file to generate. Used from gnat.eclass.
+do_set() {
+ if [[ -z ${1} ]] ; then
+ # no parameter
+ die -q "You didn't tell me which gnat to use"
+ fi
+
+ local toset=$(get_name_from_list $1)
+ if [[ ${toset} == "(not-found)" ]] ; then
+ die -q "I don't recognise the selection"
+ fi
+
+ # the action!
+ # in this implementation simply create an appropriate env file
+ local active=$(get_current_gnat)
+ if [[ -z ${2} ]] ; then
+ local envfile="${ENVDIR}/${MARKER}${toset}"
+
+ # now we need to remove an old env file, which is guaranteed to
+ # be unique by get_current_gnat above
+ if [[ -n ${active} ]] ; then
+ unset_env ${active}
+ fi
+ # just for a good measure remove the one we are going to write
+ unset_env ${toset}
+ else
+ local envfile="$2"
+ fi
+
+ generate_envFile ${toset} ${envfile}
+}
+
+
+
+### update action ###
+#
+# This action regenerates the /etc/env.d file for the current profile. Basically
+# the same as set, only it does not take any parameters. It should be called from ebuilds
+# installing Ada libs
+
+describe_update() {
+ echo "Update active gnat profile picking up new libs."
+}
+
+do_update() {
+ local toset=$(get_current_gnat)
+ local envfile="${ENVDIR}/${MARKER}${toset}"
+ generate_envFile ${toset} ${envfile}
+}
+
+### unset action ###
+
+describe_unset() {
+ echo "Remove settings for currently active gnat"
+}
+
+do_unset() {
+ local active=$(get_current_gnat)
+ # check whether we have any profile set before removing anything..
+ if [[ -n ${active} ]] ; then
+ unset_env ${active}
+ fi
+}