summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Shapovalov <george@gentoo.org>2007-12-14 12:14:00 +0000
committerGeorge Shapovalov <george@gentoo.org>2007-12-14 12:14:00 +0000
commit154ba1bfc74a959d33b60f065acc95edc187cd28 (patch)
treee68ae7b58831f6c8e943c4e939afe7233fea4f4f /app-admin/eselect-gnat
parentVersion bump (diff)
downloadhistorical-154ba1bfc74a959d33b60f065acc95edc187cd28.tar.gz
historical-154ba1bfc74a959d33b60f065acc95edc187cd28.tar.bz2
historical-154ba1bfc74a959d33b60f065acc95edc187cd28.zip
new version, supports unified libs layout
Package-Manager: portage-2.1.3.19
Diffstat (limited to 'app-admin/eselect-gnat')
-rw-r--r--app-admin/eselect-gnat/ChangeLog11
-rw-r--r--app-admin/eselect-gnat/Manifest23
-rw-r--r--app-admin/eselect-gnat/eselect-gnat-1.2.ebuild32
-rw-r--r--app-admin/eselect-gnat/files/digest-eselect-gnat-1.20
-rw-r--r--app-admin/eselect-gnat/files/gnat-common-1.2.bash220
-rw-r--r--app-admin/eselect-gnat/files/gnat.eselect-1.2207
6 files changed, 487 insertions, 6 deletions
diff --git a/app-admin/eselect-gnat/ChangeLog b/app-admin/eselect-gnat/ChangeLog
index 4e707ef18521..a5e224226f58 100644
--- a/app-admin/eselect-gnat/ChangeLog
+++ b/app-admin/eselect-gnat/ChangeLog
@@ -1,12 +1,19 @@
# ChangeLog for app-admin/eselect-gnat
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/ChangeLog,v 1.16 2007/12/11 23:46:45 george Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/ChangeLog,v 1.17 2007/12/14 12:13:59 george Exp $
+
+*eselect-gnat-1.2 (14 Dec 2007)
+
+ 14 Dec 2007; George Shapovalov <george@gentoo.org>
+ +files/gnat.eselect-1.2, +files/gnat-common-1.2.bash,
+ +eselect-gnat-1.2.ebuild:
+ new version, supports unified libs layout
*eselect-gnat-1.1-r1 (11 Dec 2007)
11 Dec 2007; George Shapovalov <george@gentoo.org>
+files/gnat.eselect-1.1-r1, +eselect-gnat-1.1-r1.ebuild:
- replaced env0update with do_action env update, #179880
+ replaced env-update with do_action env update, #179880
*eselect-gnat-1.1 (19 Sep 2007)
diff --git a/app-admin/eselect-gnat/Manifest b/app-admin/eselect-gnat/Manifest
index ef839409752d..a51f5937d7f2 100644
--- a/app-admin/eselect-gnat/Manifest
+++ b/app-admin/eselect-gnat/Manifest
@@ -1,3 +1,7 @@
+AUX gnat-common-1.2.bash 7020 RMD160 b97f0b72dd97ea8a9a811115d5a21ec106fe2032 SHA1 521ccf56eba14ab35046a4d31f3440aabaf54a3e SHA256 26adff0b6bc5cfdaa968204e546e4cafe9630edcf27e63bbf7831299e0b75b36
+MD5 35f7b940ff7ae07e3da7543ca25707ef files/gnat-common-1.2.bash 7020
+RMD160 b97f0b72dd97ea8a9a811115d5a21ec106fe2032 files/gnat-common-1.2.bash 7020
+SHA256 26adff0b6bc5cfdaa968204e546e4cafe9630edcf27e63bbf7831299e0b75b36 files/gnat-common-1.2.bash 7020
AUX gnat-common.bash 5393 RMD160 00586b919b0cded2c67f1b605fe08590ef4dd9be SHA1 38ae31a106ca695e5678b6d7189219ec574ac12c SHA256 70f0e90d0798e38900f4ac9da02b4d399a7dab3bf470abab45e332c37c63fe40
MD5 1285a8dfab6fd2d7f80832f4736dd162 files/gnat-common.bash 5393
RMD160 00586b919b0cded2c67f1b605fe08590ef4dd9be files/gnat-common.bash 5393
@@ -22,6 +26,10 @@ AUX gnat.eselect-1.1-r1 5295 RMD160 5742c00425baabdcede82242ea9abf15265934b9 SHA
MD5 75b92d2e5606f8cd5e07bff7f64e440a files/gnat.eselect-1.1-r1 5295
RMD160 5742c00425baabdcede82242ea9abf15265934b9 files/gnat.eselect-1.1-r1 5295
SHA256 50ef90ac7e613ee5646d573b1f25f94b6cc2aab9ae96468d774c626910246b50 files/gnat.eselect-1.1-r1 5295
+AUX gnat.eselect-1.2 5295 RMD160 ffe82cc91a960c747ea11e1d6c216458019e718e SHA1 a63a6eee419dac265164a6579b7cd1ecce548787 SHA256 e7bc45fabba2060403ae0c5d5f822a1095c32543afc3078b91ad8fe4ac6d607b
+MD5 efe2eae31d90bb6aa1c97068088e4699 files/gnat.eselect-1.2 5295
+RMD160 ffe82cc91a960c747ea11e1d6c216458019e718e files/gnat.eselect-1.2 5295
+SHA256 e7bc45fabba2060403ae0c5d5f822a1095c32543afc3078b91ad8fe4ac6d607b files/gnat.eselect-1.2 5295
EBUILD eselect-gnat-0.9.ebuild 636 RMD160 3a337cd38dbc36f91e41b311eef9fd8c0207e67f SHA1 f712a79ad8ccb81af7b0e3df8452abf679ad60ea SHA256 c0e771e30fb3704f93ac45ac51a50bdf3428d3d2d20f52a5a8dc00a4becf02eb
MD5 5920a8a137fc073ee90e8111b441589a eselect-gnat-0.9.ebuild 636
RMD160 3a337cd38dbc36f91e41b311eef9fd8c0207e67f eselect-gnat-0.9.ebuild 636
@@ -42,10 +50,14 @@ EBUILD eselect-gnat-1.1.ebuild 766 RMD160 9b44df397d59fbf288a29ec6624e916db205a4
MD5 ca1e0084257d4e92453477ed0fc54c06 eselect-gnat-1.1.ebuild 766
RMD160 9b44df397d59fbf288a29ec6624e916db205a4e6 eselect-gnat-1.1.ebuild 766
SHA256 abfc32da8ae1f75a34084536601bf6534b32fabe7ee64ef7b4b1d4d2a26a3da2 eselect-gnat-1.1.ebuild 766
-MISC ChangeLog 3349 RMD160 f3d5c502f03a7c339b1fae4cd1640a9884360031 SHA1 ecb35fda33602b14d32f17af990063a1069890f0 SHA256 c11ebf2e24057eb1d5b843d1eb6a6ff378d4e912608e26bb998155d3d107f422
-MD5 37ef60ff7cc7f4a90a03e13a8167e859 ChangeLog 3349
-RMD160 f3d5c502f03a7c339b1fae4cd1640a9884360031 ChangeLog 3349
-SHA256 c11ebf2e24057eb1d5b843d1eb6a6ff378d4e912608e26bb998155d3d107f422 ChangeLog 3349
+EBUILD eselect-gnat-1.2.ebuild 791 RMD160 e5eeca40433eab1191c0faf6dc8312fb6af8f554 SHA1 5c887a408105c643ac1d410a2cdecba078df8cb3 SHA256 6eed4a5ad89e33c25c08022a058a7b70b2c17dc056b721671390ad6aae00be9c
+MD5 79ffb4310cb9f50e7f4643a9e7d2ac1b eselect-gnat-1.2.ebuild 791
+RMD160 e5eeca40433eab1191c0faf6dc8312fb6af8f554 eselect-gnat-1.2.ebuild 791
+SHA256 6eed4a5ad89e33c25c08022a058a7b70b2c17dc056b721671390ad6aae00be9c eselect-gnat-1.2.ebuild 791
+MISC ChangeLog 3564 RMD160 20c2dcf934b900fbabc0985208e8ee0341efca06 SHA1 beeb376fc6516c29b0a6cea52c3f6245ede77805 SHA256 b7c2399a4338cc55abddb97e3859f0e9c8e5473a1012b22178c4ce7f0b2dd760
+MD5 cb11255103377ab98dde40473976a04f ChangeLog 3564
+RMD160 20c2dcf934b900fbabc0985208e8ee0341efca06 ChangeLog 3564
+SHA256 b7c2399a4338cc55abddb97e3859f0e9c8e5473a1012b22178c4ce7f0b2dd760 ChangeLog 3564
MISC metadata.xml 244 RMD160 784e7fb6660b05dbdd027b1e23975e26e72b7a39 SHA1 e2df521788bf35a7cf98d8b44adca1a1b03df544 SHA256 c32a1e42a5f85acb0b69af3e2644f98213d48492817c90a82c833927d2881419
MD5 92e9934d7cc8cadaa1ca50badb669313 metadata.xml 244
RMD160 784e7fb6660b05dbdd027b1e23975e26e72b7a39 metadata.xml 244
@@ -65,3 +77,6 @@ SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 files/di
MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-eselect-gnat-1.1-r1 0
RMD160 9c1185a5c5e9fc54612808977ee8f548b2258d31 files/digest-eselect-gnat-1.1-r1 0
SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 files/digest-eselect-gnat-1.1-r1 0
+MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-eselect-gnat-1.2 0
+RMD160 9c1185a5c5e9fc54612808977ee8f548b2258d31 files/digest-eselect-gnat-1.2 0
+SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 files/digest-eselect-gnat-1.2 0
diff --git a/app-admin/eselect-gnat/eselect-gnat-1.2.ebuild b/app-admin/eselect-gnat/eselect-gnat-1.2.ebuild
new file mode 100644
index 000000000000..86212a2a3843
--- /dev/null
+++ b/app-admin/eselect-gnat/eselect-gnat-1.2.ebuild
@@ -0,0 +1,32 @@
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/eselect-gnat-1.2.ebuild,v 1.1 2007/12/14 12:13:59 george Exp $
+
+inherit eutils
+
+DESCRIPTION="gnat module for eselect."
+HOMEPAGE="http://www.gentoo.org"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~x86"
+
+IUSE=""
+RDEPEND="app-admin/eselect"
+
+MODULEDIR="/usr/share/eselect/modules"
+
+# NOTE!!
+# This path is duplicated in gnat-eselect module,
+# adjust in both locations!
+LIBDIR="/usr/share/gnat/lib"
+
+src_install() {
+ dodir ${MODULEDIR}
+ insinto ${MODULEDIR}
+ newins "${FILESDIR}"/gnat.eselect-${PVR} gnat.eselect
+ dodir ${LIBDIR}
+ insinto ${LIBDIR}
+ newins "${FILESDIR}"/gnat-common-${PWR}.bash gnat-common.bash
+}
diff --git a/app-admin/eselect-gnat/files/digest-eselect-gnat-1.2 b/app-admin/eselect-gnat/files/digest-eselect-gnat-1.2
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/app-admin/eselect-gnat/files/digest-eselect-gnat-1.2
diff --git a/app-admin/eselect-gnat/files/gnat-common-1.2.bash b/app-admin/eselect-gnat/files/gnat-common-1.2.bash
new file mode 100644
index 000000000000..a1a1d8d0885a
--- /dev/null
+++ b/app-admin/eselect-gnat/files/gnat-common-1.2.bash
@@ -0,0 +1,220 @@
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/files/gnat-common-1.2.bash,v 1.1 2007/12/14 12:14:00 george Exp $
+
+#
+# Original Author: George Shapovalov <george@gentoo.org>
+# Purpose: Contains common vars/locations and functions for use by gnat.eclass,
+# gnat.eselect and gnatbuild.eclass.
+#
+# NOTE!!!
+# This eclass should just define vars (tyr to limit these!) and simple functions.
+# No bash extensions!!
+# That is, no portage or eclass internals are allowed!
+#
+
+
+
+# ----------------------------------
+# Globals
+
+# Environmantal stuff (for env update)
+SPECSDIR="/usr/share/gnat/eselect"
+ENVDIR="/etc/env.d"
+MARKER="55gnat-"
+
+## Lib install locations
+##
+## Gnat profile dependent files go under under ${LibTop}/${Gnat_Profile}/${PN}
+## and common files go unde SpecsDir, DataDir
+#PREFIX=/usr
+## Replace %LIBDIR% below with $(get_libdir) in eclasses and ebuilds (top level Ok, inherit multilib)
+## or $(profile2libdir ${profile}) in this code, eselect module or anywhere
+## outside portage (as profile will be available only during actual execution, this only should
+## be done inside corresponding functions).
+#AdalibSpecsDir=${PREFIX}/include/ada
+#AdalibDataDir=${PREFIX}/share/ada
+#AdalibLibTop=${PREFIX}/%LIBDIR%/ada
+
+
+## ------------------------------------
+## multilib's get_libdir issue
+##
+## As we cannot rely on portage or even a tree being present at the point of run-time call,
+## we cannot simply source multilib.eclass (won't even work without bunch of portage preprocessing actually)
+## or even use the relevant /etc/make.profile/make.defaults.
+## Instead I define below vars of the form gnatProfile_LIBDIR=dirname, one for each supported arch.
+## These are to be directly or via the call to $(profile2libdir profile) func.
+## profile (gnatProfile) corresponds to the output of get_gnat_Arch
+#
+#x86_64-pc-linux-gnu_LIBDIR=
+#i686-pc-linux-gnu_LIBDIR=
+#powerpc-unknown-linux-gnu_LIBDIR=
+
+# ------------------------------------
+# Helpers
+#
+
+# get_all_profile_components splits gnat profile and returns pace separated list of its components:
+# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> x86_64-pc-linux-gnu gcc 4.1
+# args:
+# $1 - the string to split
+get_all_profile_components() {
+ local GnatSLOT=${1##*-}
+ local remainder=${1%-*}
+ local GnatPkg=${remainder##*-}
+ remainder=${remainder%-gnat-*}
+ echo "${remainder} ${GnatPkg} ${GnatSLOT}"
+}
+
+# similar to above, returns only SLOT component:
+# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> 4.1
+# args:
+# $1 - the string to extract the slot from
+get_gnat_SLOT() {
+ echo "${1##*-}"
+}
+
+# returns only Pkg component:
+# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> gcc
+# args:
+# $1 - the string to extract the slot from
+get_gnat_Pkg() {
+ local remainder=${1%-*}
+ echo "${remainder##*-}"
+}
+
+# returns only Arch component:
+# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> x86_64-pc-linux-gnu
+# args:
+# $1 - the string to extract the slot from
+get_gnat_Arch() {
+ echo ${1%-gnat-*}
+}
+
+
+
+## -------------------------------------------
+# gnat profile and lib detection functions
+
+
+# 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
+}
+
+
+
+# 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
+}
+
+
+
+
+## -----------------------
+# princial action - central part of do_set and helpers
+
+
+# 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. Repeating settings are omitted, that is
+# unique entry is added only first time it is encountered. No need to have some
+# common dir listed many times in PATH for example.
+#
+# params:
+# $1 - name of env var to process
+# $2 - name of gnat profile
+# $3.. - list of libs to check (to avoid its composition every time)
+# - the list is expanded to list of args at the point of call
+get_lib_var_settings() {
+ local envVar=$1
+ local toset=$2
+ #echo "get_lib_var_settings params:$@" >> /tmp/eselect-gnat.rep
+ if [[ "none" != ${3} ]]; then
+ local envString
+ local specLine
+ while [[ -n $3 ]]; do
+ specLine=$(get_var_from_spec ${SPECSDIR}/$3/${toset} ${envVar})
+ #echo "$3:${specLine}." >> /tmp/eselect-gnat.rep
+ if [[ -n ${specLine} ]] && [[ ! ${envString} =~ ${specLine} ]]; then
+ envString="${envString}:${specLine}"
+ fi
+ shift
+ done
+ echo "${envString}"
+ fi
+}
+
+
+
+# The action!
+# Part common for do_set and do_update of gnat.eselect, also used in gnat.eclass
+# to set environment during lib build and installation
+#
+# 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}) )
+ #echo "generate_envFile: ${libs[@]}" >> /tmp/eselect-gnat.rep
+ if (( 0 == ${#libs[@]} )); then
+ libs="none"
+ fi
+
+ local MyPath="${binpath}:${libexecpath}$(get_lib_var_settings PATH ${toset} ${libs[@]})"
+ echo "PATH=${MyPath}" > "${envfile}"
+ echo "ROOTPATH=${MyPath}" >> "${envfile}"
+ echo "MANPATH=$(get_var_from_spec ${SPECSDIR}/${toset} manpath)$(get_lib_var_settings MANPATH ${toset} ${libs[@]})" >> "${envfile}"
+ echo "INFOPATH=$(get_var_from_spec ${SPECSDIR}/${toset} infopath)$(get_lib_var_settings INFOPATH ${toset} ${libs[@]})" >> "${envfile}"
+ # the next three use the common base
+ local libBase=$(get_var_from_spec ${SPECSDIR}/${toset} ldpath)
+ echo "LDPATH=${libBase}:${libBase}/adalib$(get_lib_var_settings LDPATH ${toset} ${libs[@]})" >> "${envfile}"
+ echo "ADA_INCLUDE_PATH=${libBase}/adainclude$(get_lib_var_settings ADA_INCLUDE_PATH ${toset} ${libs[@]})" >> "${envfile}"
+ echo "ADA_OBJECTS_PATH=${libBase}/adalib$(get_lib_var_settings ADA_OBJECTS_PATH ${toset} ${libs[@]})" >> "${envfile}"
+ echo "ADA_PROJECT_PATH=${libBase}/adalib$(get_lib_var_settings ADA_PROJECT_PATH ${toset} ${libs[@]})" >> "${envfile}"
+}
+
diff --git a/app-admin/eselect-gnat/files/gnat.eselect-1.2 b/app-admin/eselect-gnat/files/gnat.eselect-1.2
new file mode 100644
index 000000000000..23a6ad1eb3c3
--- /dev/null
+++ b/app-admin/eselect-gnat/files/gnat.eselect-1.2
@@ -0,0 +1,207 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: gnat.eselect-1.2,v 1.1 2007/12/14 12:14:00 george Exp $
+
+DESCRIPTION="Manage the installed gnat compilers"
+MAINTAINER="ada@gentoo.org"
+SVN_DATE='$Date: 2007/12/14 12:14:00 $'
+VERSION=$(svn_date_to_version "${SVN_DATE}" )
+
+# "inheriting" common stuff
+# this crude sourcing should be replaced by a call to function in
+# libs/package-manager.bash eventually
+. /usr/share/gnat/lib/gnat-common.bash
+
+
+### 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
+
+# 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
+}
+
+# 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)"
+}
+
+
+# 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
+}
+
+
+### 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}
+
+ # force update environment
+ # should be replaced with "do_action env update" when #172472 gets resolved
+ env-update &> /dev/null
+}
+
+
+
+### 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}
+ do_action env update &> /dev/null
+}
+
+### 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}
+ do_action env update &> /dev/null
+ fi
+}