diff options
author | George Shapovalov <george@gentoo.org> | 2007-09-19 20:24:05 +0000 |
---|---|---|
committer | George Shapovalov <george@gentoo.org> | 2007-09-19 20:24:05 +0000 |
commit | ab14de94070ae06a8a1d95d5d45c48f3515dbc1d (patch) | |
tree | dd379f155e99b1e416684213f4454ae487d83e30 /app-admin/eselect-gnat | |
parent | Add eutils, bug#192958, thanks to Robert Kerr (diff) | |
download | historical-ab14de94070ae06a8a1d95d5d45c48f3515dbc1d.tar.gz historical-ab14de94070ae06a8a1d95d5d45c48f3515dbc1d.tar.bz2 historical-ab14de94070ae06a8a1d95d5d45c48f3515dbc1d.zip |
split off code common with gnat.eclass (##192505 and 167000)
Package-Manager: portage-2.1.3.9
Diffstat (limited to 'app-admin/eselect-gnat')
-rw-r--r-- | app-admin/eselect-gnat/ChangeLog | 8 | ||||
-rw-r--r-- | app-admin/eselect-gnat/Manifest | 23 | ||||
-rw-r--r-- | app-admin/eselect-gnat/eselect-gnat-1.1.ebuild | 32 | ||||
-rw-r--r-- | app-admin/eselect-gnat/files/digest-eselect-gnat-1.1 | 0 | ||||
-rw-r--r-- | app-admin/eselect-gnat/files/gnat-common.bash | 189 | ||||
-rw-r--r-- | app-admin/eselect-gnat/files/gnat.eselect-1.1 | 207 |
6 files changed, 454 insertions, 5 deletions
diff --git a/app-admin/eselect-gnat/ChangeLog b/app-admin/eselect-gnat/ChangeLog index 3091e59793de..d02c946160ca 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-2007 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/ChangeLog,v 1.14 2007/09/07 13:31:06 george Exp $ +# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/ChangeLog,v 1.15 2007/09/19 20:24:04 george Exp $ + +*eselect-gnat-1.1 (19 Sep 2007) + + 19 Sep 2007; <portage-cvs@gentoo.org> +files/gnat.eselect-1.1, + +files/gnat-common.bash, +eselect-gnat-1.1.ebuild: + split off code common with gnat.eclass (##192505 and 167000). 07 Sep 2007; George Shapovalov <george@gentoo.org> files/gnat.eselect-0.9, files/gnat.eselect-1.0, files/gnat.eselect-1.0-r1: diff --git a/app-admin/eselect-gnat/Manifest b/app-admin/eselect-gnat/Manifest index 415a5b1d9697..4cb361926ead 100644 --- a/app-admin/eselect-gnat/Manifest +++ b/app-admin/eselect-gnat/Manifest @@ -1,3 +1,7 @@ +AUX gnat-common.bash 5492 RMD160 f90976162f52a6378ebcd83ccf6e1fa01af1d465 SHA1 66d3d66eef5738815b758257b76649491581687c SHA256 ebb5f1f952a817e5dd02cc68ad24b103957be64d080aa7d15551bc500a988c6d +MD5 c08c30b4c39f7b8d63d99377b722a80f files/gnat-common.bash 5492 +RMD160 f90976162f52a6378ebcd83ccf6e1fa01af1d465 files/gnat-common.bash 5492 +SHA256 ebb5f1f952a817e5dd02cc68ad24b103957be64d080aa7d15551bc500a988c6d files/gnat-common.bash 5492 AUX gnat.eselect-0.9 8352 RMD160 c477ea4b9f74a80291d10997ca4b0238d8c9cd09 SHA1 f66537194fd5e3c8ffaee2b1d575b9a2def6fa97 SHA256 1db76f3e94f7f89bc2ebf431c956f9153761d746233a391ee7d86bf37edd0dab MD5 0304e9aa50c81043269c1a2f27757843 files/gnat.eselect-0.9 8352 RMD160 c477ea4b9f74a80291d10997ca4b0238d8c9cd09 files/gnat.eselect-0.9 8352 @@ -10,6 +14,10 @@ AUX gnat.eselect-1.0-r1 8543 RMD160 6a9cfa0b08fee4ea7448756ab103ff036e4406b6 SHA MD5 58479b633bb8cc45b3952f20a5a3681c files/gnat.eselect-1.0-r1 8543 RMD160 6a9cfa0b08fee4ea7448756ab103ff036e4406b6 files/gnat.eselect-1.0-r1 8543 SHA256 f284b06d1feae9cf55aded9edbbea5a25a2e199bd530bd181cc940bf04e16fc3 files/gnat.eselect-1.0-r1 8543 +AUX gnat.eselect-1.1 5272 RMD160 d3e9005aae997c5ed2ce9538aca158632d25a322 SHA1 328ef6622bedf0b65f21fe759dcda9b6adeb4b10 SHA256 6e40204edece64752ced89e52a3341d54dadc5c3d75626add7162d8ebe9a449f +MD5 3b6c17ae9c317c5c4067668bfe8d49ce files/gnat.eselect-1.1 5272 +RMD160 d3e9005aae997c5ed2ce9538aca158632d25a322 files/gnat.eselect-1.1 5272 +SHA256 6e40204edece64752ced89e52a3341d54dadc5c3d75626add7162d8ebe9a449f files/gnat.eselect-1.1 5272 EBUILD eselect-gnat-0.9.ebuild 630 RMD160 0d006dfa770e6b257b2583c9ead975885fef55e4 SHA1 0f6daa904261a7adb17fbd1cc7d5a48f7351f1cc SHA256 4361f3e7ed8a8a246d03e5ab2dacf3d68c8f12d4b7bc0531257a91805bf7f9b0 MD5 15901856238b3e8fa1f2da55600873cd eselect-gnat-0.9.ebuild 630 RMD160 0d006dfa770e6b257b2583c9ead975885fef55e4 eselect-gnat-0.9.ebuild 630 @@ -22,10 +30,14 @@ EBUILD eselect-gnat-1.0.ebuild 630 RMD160 428d39e90ef4844bc30a0603d5b1243347dd07 MD5 33469f34cc29b2bca05f107157db36a4 eselect-gnat-1.0.ebuild 630 RMD160 428d39e90ef4844bc30a0603d5b1243347dd07eb eselect-gnat-1.0.ebuild 630 SHA256 6072990789e3fa357e9bcb2c207471d828a039f65c83ad05e71015e39583885d eselect-gnat-1.0.ebuild 630 -MISC ChangeLog 2927 RMD160 c882302ff3f36c2d197e136bb3a772d1220b77bb SHA1 5610521112deae07caec18ca6828aacc51d9a937 SHA256 4e1ca5a70106e19628acc3dbf70d29e399e6a156c15e62837ed8516048d100d8 -MD5 75b6c086724e652ee0578efd0d90693e ChangeLog 2927 -RMD160 c882302ff3f36c2d197e136bb3a772d1220b77bb ChangeLog 2927 -SHA256 4e1ca5a70106e19628acc3dbf70d29e399e6a156c15e62837ed8516048d100d8 ChangeLog 2927 +EBUILD eselect-gnat-1.1.ebuild 762 RMD160 54abd5fa2e2344cafbad7e05892ad8a9bed7aa18 SHA1 3bd950cc562e9a5fd4deaa8f714de5320583d082 SHA256 a68037215cf39c7f0c41d4a5d952ad2c0cd1cb29aa0d71f119b90bff2910614e +MD5 a131d82906f3f1dd66bd447ce3ae5d07 eselect-gnat-1.1.ebuild 762 +RMD160 54abd5fa2e2344cafbad7e05892ad8a9bed7aa18 eselect-gnat-1.1.ebuild 762 +SHA256 a68037215cf39c7f0c41d4a5d952ad2c0cd1cb29aa0d71f119b90bff2910614e eselect-gnat-1.1.ebuild 762 +MISC ChangeLog 3143 RMD160 467d7f4faed760c6822cfcaec045538bc2c84383 SHA1 07b3816c1b5bdd7d324aa3dfe21ec22e7c2624a6 SHA256 733325f290a64af726cf9cee523232cc054465be838215dd72036008235f0f8a +MD5 ed96f91219b59b8b10f3a528f45dc780 ChangeLog 3143 +RMD160 467d7f4faed760c6822cfcaec045538bc2c84383 ChangeLog 3143 +SHA256 733325f290a64af726cf9cee523232cc054465be838215dd72036008235f0f8a ChangeLog 3143 MISC metadata.xml 244 RMD160 784e7fb6660b05dbdd027b1e23975e26e72b7a39 SHA1 e2df521788bf35a7cf98d8b44adca1a1b03df544 SHA256 c32a1e42a5f85acb0b69af3e2644f98213d48492817c90a82c833927d2881419 MD5 92e9934d7cc8cadaa1ca50badb669313 metadata.xml 244 RMD160 784e7fb6660b05dbdd027b1e23975e26e72b7a39 metadata.xml 244 @@ -39,3 +51,6 @@ SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 files/di MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-eselect-gnat-1.0-r1 0 RMD160 9c1185a5c5e9fc54612808977ee8f548b2258d31 files/digest-eselect-gnat-1.0-r1 0 SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 files/digest-eselect-gnat-1.0-r1 0 +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-eselect-gnat-1.1 0 +RMD160 9c1185a5c5e9fc54612808977ee8f548b2258d31 files/digest-eselect-gnat-1.1 0 +SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 files/digest-eselect-gnat-1.1 0 diff --git a/app-admin/eselect-gnat/eselect-gnat-1.1.ebuild b/app-admin/eselect-gnat/eselect-gnat-1.1.ebuild new file mode 100644 index 000000000000..f2089d7e97ad --- /dev/null +++ b/app-admin/eselect-gnat/eselect-gnat-1.1.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.1.ebuild,v 1.1 2007/09/19 20:24:04 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} + doins ${FILESDIR}/gnat-common.bash +} diff --git a/app-admin/eselect-gnat/files/digest-eselect-gnat-1.1 b/app-admin/eselect-gnat/files/digest-eselect-gnat-1.1 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/app-admin/eselect-gnat/files/digest-eselect-gnat-1.1 diff --git a/app-admin/eselect-gnat/files/gnat-common.bash b/app-admin/eselect-gnat/files/gnat-common.bash new file mode 100644 index 000000000000..88316ebaab7d --- /dev/null +++ b/app-admin/eselect-gnat/files/gnat-common.bash @@ -0,0 +1,189 @@ +# 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.bash,v 1.1 2007/09/19 20:24:05 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-" + + +# ------------------------------------ +# Helpers +# +# may be moved to a seperate eclass, if enough accumulated in this one and in +# gnatbuild.eclass.. + +# 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 +# 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 lest 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 + [[ -n ${specLine} ]] && envString="${envString}:${specLine}" + 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}" +} + diff --git a/app-admin/eselect-gnat/files/gnat.eselect-1.1 b/app-admin/eselect-gnat/files/gnat.eselect-1.1 new file mode 100644 index 000000000000..e58c58d4789e --- /dev/null +++ b/app-admin/eselect-gnat/files/gnat.eselect-1.1 @@ -0,0 +1,207 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id: gnat.eselect-1.1,v 1.1 2007/09/19 20:24:05 george Exp $ + +DESCRIPTION="Manage the talled gnat compilers" +MAINTAINER="ada@gentoo.org" +SVN_DATE='$Date: 2007/09/19 20:24:05 $' +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} + 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} + env-update &> /dev/null + fi +} |