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

Diff of /eclass/eutils.eclass

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

Revision 1.163 Revision 1.168
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 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.163 2005/03/26 06:33:16 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.168 2005/04/29 03:59:15 vapier Exp $
4# 4#
5# Author: Martin Schlemmer <azarah@gentoo.org> 5# Author: Martin Schlemmer <azarah@gentoo.org>
6# 6#
7# This eclass is for general purpose functions that most ebuilds 7# This eclass is for general purpose functions that most ebuilds
8# have to implement themselves. 8# have to implement themselves.
14INHERITED="$INHERITED $ECLASS" 14INHERITED="$INHERITED $ECLASS"
15 15
16DEPEND="!bootstrap? ( sys-devel/patch )" 16DEPEND="!bootstrap? ( sys-devel/patch )"
17 17
18DESCRIPTION="Based on the ${ECLASS} eclass" 18DESCRIPTION="Based on the ${ECLASS} eclass"
19
20# ecpu_check
21# Usage:
22#
23# ecpu_check array_of_cpu_flags
24#
25# array_of_cpu_flags - An array of cpu flags to check against USE flags
26#
27# Checks user USE related cpu flags against /proc/cpuinfo. If user enables a
28# cpu flag that is not supported in their processor flags, it will warn the
29# user if CROSSCOMPILE is not set to 1 ( because cross compile users are
30# obviously using different cpu flags than their own cpu ). Examples:
31#
32# CPU_FLAGS=(mmx mmx2 sse sse2)
33# ecpu_check CPU_FLAGS
34# Chris White <chriswhite@gentoo.org> (03 Feb 2005)
35
36ecpu_check() {
37 # Think about changing below to: if [ "${CROSSCOMPILE}" -ne 1 -a -e "/proc/cpuinfo" ]
38 # and dropping the else if you do not plan on adding anything to that
39 # empty block ....
40 # PS: also try to add some quoting, and consider rather using ${foo} than $foo ...
41 if [ "${CROSSCOMPILE}" != "1" -a -e "/proc/cpuinfo" ]
42 then
43 CPU_FLAGS=${1}
44 USER_CPU=`grep "flags" /proc/cpuinfo`
45
46 for flags in `seq 1 ${#CPU_FLAGS[@]}`
47 do
48 if has ${CPU_FLAGS[${flags} - 1]} ${USER_CPU} && ! has ${CPU_FLAGS[${flags} - 1]} ${USE}
49 then
50 ewarn "Your system is ${CPU_FLAGS[${flags} - 1]} capable but you don't have it enabled!"
51 ewarn "You might be cross compiling (in this case set CROSSCOMPILE to 1 to disable this warning."
52 fi
53
54 if ! has ${CPU_FLAGS[${flags} - 1]} ${USER_CPU} && has ${CPU_FLAGS[${flags} -1]} ${USE}
55 then
56 ewarn "You have ${CPU_FLAGS[${flags} - 1]} support enabled but your processor doesn't"
57 ewarn "Seem to support it! You might be cross compiling or do not have /proc filesystem"
58 ewarn "enabled. If either is the case, set CROSSCOMPILE to 1 to disable this warning."
59 fi
60 done
61 fi
62}
63 19
64# Wait for the supplied number of seconds. If no argument is supplied, defaults 20# Wait for the supplied number of seconds. If no argument is supplied, defaults
65# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not 21# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not
66# outputting to a terminal, don't wait. For compatability purposes, the argument 22# outputting to a terminal, don't wait. For compatability purposes, the argument
67# must be an integer greater than zero. 23# must be an integer greater than zero.
126 fperms a+x "/usr/${libdir}/${lib}" 82 fperms a+x "/usr/${libdir}/${lib}"
127 done 83 done
128} 84}
129 85
130# Simple function to draw a line consisting of '=' the same length as $* 86# Simple function to draw a line consisting of '=' the same length as $*
87# - only to be used by epatch()
131# 88#
132# <azarah@gentoo.org> (11 Nov 2002) 89# <azarah@gentoo.org> (11 Nov 2002)
133# 90#
134draw_line() { 91draw_line() {
135 local i=0 92 local i=0
217 local x="" 174 local x=""
218 175
219 if [ "$#" -gt 1 ] 176 if [ "$#" -gt 1 ]
220 then 177 then
221 local m="" 178 local m=""
222 einfo "${#} patches to apply ..."
223 for m in "$@" ; do 179 for m in "$@" ; do
224 epatch "${m}" 180 epatch "${m}"
225 done 181 done
226 return 0 182 return 0
227 fi 183 fi
1052# make_desktop_entry(<title>, <command>) 1008# make_desktop_entry(<title>, <command>)
1053# title: File to execute to start the Window Manager 1009# title: File to execute to start the Window Manager
1054# command: Name of the Window Manager 1010# command: Name of the Window Manager
1055 1011
1056make_session_desktop() { 1012make_session_desktop() {
1057
1058 [ -z "$1" ] && eerror "make_session_desktop: You must specify the title" && return 1 1013 [[ -z $1 ]] && eerror "make_session_desktop: You must specify the title" && return 1
1059 [ -z "$2" ] && eerror "make_session_desktop: You must specify the command" && return 1 1014 [[ -z $2 ]] && eerror "make_session_desktop: You must specify the command" && return 1
1060 1015
1061 local title="${1}" 1016 local title=$1
1062 local command="${2}" 1017 local command=$2
1063 local desktop="${T}/${wm}.desktop" 1018 local desktop=${T}/${wm}.desktop
1064 1019
1065echo "[Desktop Entry] 1020echo "[Desktop Entry]
1066Encoding=UTF-8 1021Encoding=UTF-8
1067Name=${title} 1022Name=${title}
1068Comment=This session logs you into ${title} 1023Comment=This session logs you into ${title}
1070TryExec=${command} 1025TryExec=${command}
1071Type=Application" > "${desktop}" 1026Type=Application" > "${desktop}"
1072 1027
1073 insinto /usr/share/xsessions 1028 insinto /usr/share/xsessions
1074 doins "${desktop}" 1029 doins "${desktop}"
1075
1076 return 0
1077} 1030}
1078 1031
1079domenu() { 1032domenu() {
1080 local i 1033 local i j
1081 local j
1082 insinto /usr/share/applications 1034 insinto /usr/share/applications
1083 for i in ${@} 1035 for i in "$@" ; do
1084 do
1085 if [ -f "${i}" ]; 1036 if [[ -f ${i} ]] ; then
1086 then
1087 doins ${i} 1037 doins "${i}"
1088 elif [ -d "${i}" ]; 1038 elif [[ -d ${i} ]] ; then
1089 then
1090 for j in ${i}/*.desktop 1039 for j in "${i}"/*.desktop ; do
1091 do
1092 doins ${j} 1040 doins "${j}"
1093 done 1041 done
1094 fi 1042 fi
1095 done 1043 done
1096} 1044}
1045newmenu() {
1046 insinto /usr/share/applications
1047 newins "$1" "$2"
1048}
1097 1049
1098doicon() { 1050doicon() {
1099 local i 1051 local i j
1100 local j
1101 insinto /usr/share/pixmaps 1052 insinto /usr/share/pixmaps
1102 for i in ${@} 1053 for i in "$@" ; do
1103 do
1104 if [ -f "${i}" ]; 1054 if [[ -f ${i} ]] ; then
1105 then
1106 doins ${i} 1055 doins "${i}"
1107 elif [ -d "${i}" ]; 1056 elif [[ -d ${i} ]] ; then
1108 then
1109 for j in ${i}/*.png 1057 for j in "${i}"/*.png ; do
1110 do
1111 doins ${j} 1058 doins "${j}"
1112 done 1059 done
1113 fi 1060 fi
1114 done 1061 done
1062}
1063newicon() {
1064 insinto /usr/share/pixmaps
1065 newins "$1" "$2"
1115} 1066}
1116 1067
1117############################################################## 1068##############################################################
1118# END: Handle .desktop files and menu entries # 1069# END: Handle .desktop files and menu entries #
1119############################################################## 1070##############################################################
1598 else 1549 else
1599 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" 1550 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA"
1600 fi 1551 fi
1601 done 1552 done
1602 if [[ -z ${newls} ]] ; then 1553 if [[ -z ${newls} ]] ; then
1603 unset LINGUAS 1554 export LINGUAS=""
1604 else 1555 else
1605 export LINGUAS=${newls:1} 1556 export LINGUAS=${newls:1}
1606 fi 1557 fi
1607} 1558}
1608 1559
1763# -- wolf31o2 1714# -- wolf31o2
1764# $1 == wrapper name 1715# $1 == wrapper name
1765# $2 == binary to run 1716# $2 == binary to run
1766# $3 == directory to chdir before running binary 1717# $3 == directory to chdir before running binary
1767# $4 == extra LD_LIBRARY_PATH's (make it : delimited) 1718# $4 == extra LD_LIBRARY_PATH's (make it : delimited)
1719# $5 == path for wrapper
1768make_wrapper() { 1720make_wrapper() {
1769 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 1721 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5
1770 local tmpwrapper=$(emktemp) 1722 local tmpwrapper=$(emktemp)
1771 cat << EOF > "${tmpwrapper}" 1723 cat << EOF > "${tmpwrapper}"
1772#!/bin/sh 1724#!/bin/sh
1773cd "${chdir}" 1725cd "${chdir}"
1774export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}" 1726export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
1775exec ${bin} "\$@" 1727exec ${bin} "\$@"
1776EOF 1728EOF
1777 chmod go+rx "${tmpwrapper}" 1729 chmod go+rx "${tmpwrapper}"
1730 if [ -n "${5}" ]
1731 then
1732 exeinto ${5}
1733 newexe "${tmpwrapper}" "${wrapper}"
1734 else
1778 newbin "${tmpwrapper}" "${wrapper}" 1735 newbin "${tmpwrapper}" "${wrapper}"
1736 fi
1779} 1737}

Legend:
Removed from v.1.163  
changed lines
  Added in v.1.168

  ViewVC Help
Powered by ViewVC 1.1.20