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

Diff of /eclass/portability.eclass

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

Revision 1.7 Revision 1.13
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/portability.eclass,v 1.7 2005/12/14 19:52:22 flameeyes Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.13 2009/03/27 08:00:56 drizzt Exp $
4# 4#
5# Author: Diego Pettenò <flameeyes@gentoo.org> 5# Author: Diego Pettenò <flameeyes@gentoo.org>
6# 6#
7# This eclass is created to avoid using non-portable GNUisms inside ebuilds 7# This eclass is created to avoid using non-portable GNUisms inside ebuilds
8# 8#
52 fi 52 fi
53} 53}
54 54
55# Gets the linker flag to link to dlopen() function 55# Gets the linker flag to link to dlopen() function
56dlopen_lib() { 56dlopen_lib() {
57 if [[ ${ELIBC} != *BSD ]]; then 57 # this might need a proper case statement, so far this seems to work as is
58 # - Solaris needs nothing
59 # - Darwin needs nothing
60 # - *BSD needs nothing
61 # - Linux needs -ldl (glibc and uclibc)
62 if [[ ${CHOST} == *-linux-gnu || ${CHOST} == *-linux-uclibc ]]; then
58 echo "-ldl" 63 echo "-ldl"
59 fi 64 fi
60} 65}
61 66
62# Gets the home directory for the specified user 67# Gets the home directory for the specified user
68 ent=$(egetent passwd $1) 73 ent=$(egetent passwd $1)
69 74
70 case ${CHOST} in 75 case ${CHOST} in
71 *-darwin*|*-freebsd*|*-dragonfly*) 76 *-darwin*|*-freebsd*|*-dragonfly*)
72 # Darwin, OSX, FreeBSD and DragonFly use position 9 to store homedir 77 # Darwin, OSX, FreeBSD and DragonFly use position 9 to store homedir
73 cut -d: -f9 <<<${ent} 78 echo ${ent} | cut -d: -f9
74 ;; 79 ;;
75 *) 80 *)
76 # Linux, NetBSD and OpenBSD use position 6 instead 81 # Linux, NetBSD and OpenBSD use position 6 instead
77 cut -d: -f6 <<<${ent} 82 echo ${ent} | cut -d: -f6
78 ;; 83 ;;
79 esac 84 esac
80} 85}
81 86
82# Gets the shell for the specified user 87# Gets the shell for the specified user
88 ent=$(egetent passwd "$1") 93 ent=$(egetent passwd "$1")
89 94
90 case ${CHOST} in 95 case ${CHOST} in
91 *-darwin*|*-freebsd*|*-dragonfly*) 96 *-darwin*|*-freebsd*|*-dragonfly*)
92 # Darwin, OSX, FreeBSD and DragonFly use position 9 to store homedir 97 # Darwin, OSX, FreeBSD and DragonFly use position 9 to store homedir
93 cut -d: -f10 <<<${ent} 98 echo ${ent} | cut -d: -f10
94 ;; 99 ;;
95 *) 100 *)
96 # Linux, NetBSD and OpenBSD use position 6 instead 101 # Linux, NetBSD and OpenBSD use position 6 instead
97 cut -d: -f7 <<<${ent} 102 echo ${ent} cut -d: -f7
98 ;; 103 ;;
99 esac 104 esac
100} 105}
101 106
102# Returns true if specified user has a shell that precludes logins 107# Returns true if specified user has a shell that precludes logins
127 echo bsdmake 132 echo bsdmake
128 else 133 else
129 echo pmake 134 echo pmake
130 fi 135 fi
131} 136}
137
138# Portable method of getting mount names and points.
139# Returns as "point node fs options"
140# Remember to convert 040 back to a space.
141get_mounts() {
142 local point= node= fs= opts= foo=
143
144 # Linux has /proc/mounts which should always exist
145 if [[ $(uname -s) == "Linux" ]] ; then
146 while read node point fs opts foo ; do
147 echo "${point} ${node} ${fs} ${opts}"
148 done < /proc/mounts
149 return
150 fi
151
152 # OK, pray we have a -p option that outputs mounts in fstab format
153 # using tabs as the seperator.
154 # Then pray that there are no tabs in the either.
155 # Currently only FreeBSD supports this and the other BSDs will
156 # have to be patched.
157 # Athough the BSD's may support /proc, they do NOT put \040 in place
158 # of the spaces and we should not force a /proc either.
159 local IFS=$'\t'
160 LC_ALL=C mount -p | while read node point fs foo ; do
161 opts=${fs#* }
162 fs=${fs%% *}
163 echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}"
164 done
165}
166

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20