/[gentoo-x86]/eclass/eutils.eclass
Gentoo

Diff of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.384 Revision 1.385
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.384 2012/02/26 13:20:59 pacho Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.385 2012/03/01 07:00:40 ulm Exp $
4 4
5# @ECLASS: eutils.eclass 5# @ECLASS: eutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: many extra (but common) functions that are used in ebuilds 8# @BLURB: many extra (but common) functions that are used in ebuilds
16# different from the overall eclass! 16# different from the overall eclass!
17 17
18if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then 18if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then
19___ECLASS_ONCE_EUTILS="recur -_+^+_- spank" 19___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
20 20
21inherit multilib portability user 21inherit multilib user
22 22
23DESCRIPTION="Based on the ${ECLASS} eclass" 23DESCRIPTION="Based on the ${ECLASS} eclass"
24 24
25if has "${EAPI:-0}" 0 1 2; then 25if has "${EAPI:-0}" 0 1 2; then
26 26
952 # wrap the env here so that the 'insinto' call 952 # wrap the env here so that the 'insinto' call
953 # doesn't corrupt the env of the caller 953 # doesn't corrupt the env of the caller
954 insinto /usr/share/pixmaps 954 insinto /usr/share/pixmaps
955 newins "$@" 955 newins "$@"
956 ) 956 )
957}
958
959# @FUNCTION: cdrom_get_cds
960# @USAGE: <file on cd1> [file on cd2] [file on cd3] [...]
961# @DESCRIPTION:
962# Aquire cd(s) for those lovely cd-based emerges. Yes, this violates
963# the whole 'non-interactive' policy, but damnit I want CD support !
964#
965# With these cdrom functions we handle all the user interaction and
966# standardize everything. All you have to do is call cdrom_get_cds()
967# and when the function returns, you can assume that the cd has been
968# found at CDROM_ROOT.
969#
970# The function will attempt to locate a cd based upon a file that is on
971# the cd. The more files you give this function, the more cds
972# the cdrom functions will handle.
973#
974# Normally the cdrom functions will refer to the cds as 'cd #1', 'cd #2',
975# etc... If you want to give the cds better names, then just export
976# the appropriate CDROM_NAME variable before calling cdrom_get_cds().
977# Use CDROM_NAME for one cd, or CDROM_NAME_# for multiple cds. You can
978# also use the CDROM_NAME_SET bash array.
979#
980# For those multi cd ebuilds, see the cdrom_load_next_cd() function.
981cdrom_get_cds() {
982 # first we figure out how many cds we're dealing with by
983 # the # of files they gave us
984 local cdcnt=0
985 local f=
986 for f in "$@" ; do
987 ((++cdcnt))
988 export CDROM_CHECK_${cdcnt}="$f"
989 done
990 export CDROM_TOTAL_CDS=${cdcnt}
991 export CDROM_CURRENT_CD=1
992
993 # now we see if the user gave use CD_ROOT ...
994 # if they did, let's just believe them that it's correct
995 if [[ -n ${CD_ROOT}${CD_ROOT_1} ]] ; then
996 local var=
997 cdcnt=0
998 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
999 ((++cdcnt))
1000 var="CD_ROOT_${cdcnt}"
1001 [[ -z ${!var} ]] && var="CD_ROOT"
1002 if [[ -z ${!var} ]] ; then
1003 eerror "You must either use just the CD_ROOT"
1004 eerror "or specify ALL the CD_ROOT_X variables."
1005 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables."
1006 die "could not locate CD_ROOT_${cdcnt}"
1007 fi
1008 done
1009 export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}}
1010 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1011 export CDROM_SET=-1
1012 for f in ${CDROM_CHECK_1//:/ } ; do
1013 ((++CDROM_SET))
1014 [[ -e ${CDROM_ROOT}/${f} ]] && break
1015 done
1016 export CDROM_MATCH=${f}
1017 return
1018 fi
1019
1020 # User didn't help us out so lets make sure they know they can
1021 # simplify the whole process ...
1022 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1023 einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}"
1024 echo
1025 einfo "If you do not have the CD, but have the data files"
1026 einfo "mounted somewhere on your filesystem, just export"
1027 einfo "the variable CD_ROOT so that it points to the"
1028 einfo "directory containing the files."
1029 echo
1030 einfo "For example:"
1031 einfo "export CD_ROOT=/mnt/cdrom"
1032 echo
1033 else
1034 if [[ -n ${CDROM_NAME_SET} ]] ; then
1035 # Translate the CDROM_NAME_SET array into CDROM_NAME_#
1036 cdcnt=0
1037 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1038 ((++cdcnt))
1039 export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}"
1040 done
1041 fi
1042
1043 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds."
1044 cdcnt=0
1045 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1046 ((++cdcnt))
1047 var="CDROM_NAME_${cdcnt}"
1048 [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}"
1049 done
1050 echo
1051 einfo "If you do not have the CDs, but have the data files"
1052 einfo "mounted somewhere on your filesystem, just export"
1053 einfo "the following variables so they point to the right place:"
1054 einfon ""
1055 cdcnt=0
1056 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1057 ((++cdcnt))
1058 echo -n " CD_ROOT_${cdcnt}"
1059 done
1060 echo
1061 einfo "Or, if you have all the files in the same place, or"
1062 einfo "you only have one cdrom, you can export CD_ROOT"
1063 einfo "and that place will be used as the same data source"
1064 einfo "for all the CDs."
1065 echo
1066 einfo "For example:"
1067 einfo "export CD_ROOT_1=/mnt/cdrom"
1068 echo
1069 fi
1070
1071 export CDROM_SET=""
1072 export CDROM_CURRENT_CD=0
1073 cdrom_load_next_cd
1074}
1075
1076# @FUNCTION: cdrom_load_next_cd
1077# @DESCRIPTION:
1078# Some packages are so big they come on multiple CDs. When you're done reading
1079# files off a CD and want access to the next one, just call this function.
1080# Again, all the messy details of user interaction are taken care of for you.
1081# Once this returns, just read the variable CDROM_ROOT for the location of the
1082# mounted CD. Note that you can only go forward in the CD list, so make sure
1083# you only call this function when you're done using the current CD.
1084cdrom_load_next_cd() {
1085 local var
1086 ((++CDROM_CURRENT_CD))
1087
1088 unset CDROM_ROOT
1089 var=CD_ROOT_${CDROM_CURRENT_CD}
1090 [[ -z ${!var} ]] && var="CD_ROOT"
1091 if [[ -z ${!var} ]] ; then
1092 var="CDROM_CHECK_${CDROM_CURRENT_CD}"
1093 _cdrom_locate_file_on_cd ${!var}
1094 else
1095 export CDROM_ROOT=${!var}
1096 fi
1097
1098 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1099}
1100
1101# this is used internally by the cdrom_get_cds() and cdrom_load_next_cd()
1102# functions. this should *never* be called from an ebuild.
1103# all it does is try to locate a give file on a cd ... if the cd isn't
1104# found, then a message asking for the user to insert the cdrom will be
1105# displayed and we'll hang out here until:
1106# (1) the file is found on a mounted cdrom
1107# (2) the user hits CTRL+C
1108_cdrom_locate_file_on_cd() {
1109 local mline=""
1110 local showedmsg=0 showjolietmsg=0
1111
1112 while [[ -z ${CDROM_ROOT} ]] ; do
1113 local i=0
1114 local -a cdset=(${*//:/ })
1115 if [[ -n ${CDROM_SET} ]] ; then
1116 cdset=(${cdset[${CDROM_SET}]})
1117 fi
1118
1119 while [[ -n ${cdset[${i}]} ]] ; do
1120 local dir=$(dirname ${cdset[${i}]})
1121 local file=$(basename ${cdset[${i}]})
1122
1123 local point= node= fs= foo=
1124 while read point node fs foo ; do
1125 [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && \
1126 ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \
1127 && continue
1128 point=${point//\040/ }
1129 [[ ! -d ${point}/${dir} ]] && continue
1130 [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue
1131 export CDROM_ROOT=${point}
1132 export CDROM_SET=${i}
1133 export CDROM_MATCH=${cdset[${i}]}
1134 return
1135 done <<< "$(get_mounts)"
1136
1137 ((++i))
1138 done
1139
1140 echo
1141 if [[ ${showedmsg} -eq 0 ]] ; then
1142 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1143 if [[ -z ${CDROM_NAME} ]] ; then
1144 einfo "Please insert+mount the cdrom for ${PN} now !"
1145 else
1146 einfo "Please insert+mount the ${CDROM_NAME} cdrom now !"
1147 fi
1148 else
1149 if [[ -z ${CDROM_NAME_1} ]] ; then
1150 einfo "Please insert+mount cd #${CDROM_CURRENT_CD} for ${PN} now !"
1151 else
1152 local var="CDROM_NAME_${CDROM_CURRENT_CD}"
1153 einfo "Please insert+mount the ${!var} cdrom now !"
1154 fi
1155 fi
1156 showedmsg=1
1157 fi
1158 einfo "Press return to scan for the cd again"
1159 einfo "or hit CTRL+C to abort the emerge."
1160 echo
1161 if [[ ${showjolietmsg} -eq 0 ]] ; then
1162 showjolietmsg=1
1163 else
1164 ewarn "If you are having trouble with the detection"
1165 ewarn "of your CD, it is possible that you do not have"
1166 ewarn "Joliet support enabled in your kernel. Please"
1167 ewarn "check that CONFIG_JOLIET is enabled in your kernel."
1168 ebeep 5
1169 fi
1170 read || die "something is screwed with your system"
1171 done
1172} 957}
1173 958
1174# @FUNCTION: strip-linguas 959# @FUNCTION: strip-linguas
1175# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>] 960# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
1176# @DESCRIPTION: 961# @DESCRIPTION:

Legend:
Removed from v.1.384  
changed lines
  Added in v.1.385

  ViewVC Help
Powered by ViewVC 1.1.20