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

Diff of /eclass/portability.eclass

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

Revision 1.17 Revision 1.18
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.17 2010/09/24 14:29:49 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.18 2011/10/27 07:16:08 vapier 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#
9# NB: If you add anything, please comment it! 9# NB: If you add anything, please comment it!
10
11inherit user
10 12
11# treecopy orig1 orig2 orig3 .... dest 13# treecopy orig1 orig2 orig3 .... dest
12# 14#
13# mimic cp --parents copy, but working on BSD userland as well 15# mimic cp --parents copy, but working on BSD userland as well
14treecopy() { 16treecopy() {
79 echo "-ldl" 81 echo "-ldl"
80 ;; 82 ;;
81 esac 83 esac
82} 84}
83 85
84# Gets the home directory for the specified user
85# it's a wrap around egetent as the position of the home directory in the line
86# varies depending on the os used.
87#
88# To use that, inherit eutils, not portability!
89egethome() {
90 ent=$(egetent passwd $1)
91
92 case ${CHOST} in
93 *-darwin*|*-freebsd*|*-dragonfly*)
94 # Darwin, OSX, FreeBSD and DragonFly use position 9 to store homedir
95 echo ${ent} | cut -d: -f9
96 ;;
97 *)
98 # Linux, NetBSD and OpenBSD use position 6 instead
99 echo ${ent} | cut -d: -f6
100 ;;
101 esac
102}
103
104# Gets the shell for the specified user
105# it's a wrap around egetent as the position of the home directory in the line
106# varies depending on the os used.
107#
108# To use that, inherit eutils, not portability!
109egetshell() {
110 ent=$(egetent passwd "$1")
111
112 case ${CHOST} in
113 *-darwin*|*-freebsd*|*-dragonfly*)
114 # Darwin, OSX, FreeBSD and DragonFly use position 9 to store homedir
115 echo ${ent} | cut -d: -f10
116 ;;
117 *)
118 # Linux, NetBSD and OpenBSD use position 6 instead
119 echo ${ent} cut -d: -f7
120 ;;
121 esac
122}
123
124# Returns true if specified user has a shell that precludes logins
125# on whichever operating system.
126is-login-disabled() {
127 shell=$(egetshell "$1")
128
129 case ${shell} in
130 /bin/false|/usr/bin/false|/sbin/nologin|/usr/sbin/nologin)
131 return 0 ;;
132 *)
133 return 1 ;;
134 esac
135}
136
137# Gets the name of the BSD-ish make command (pmake from NetBSD) 86# Gets the name of the BSD-ish make command (pmake from NetBSD)
138# 87#
139# This will return make (provided by system packages) for BSD userlands, 88# This will return make (provided by system packages) for BSD userlands,
140# or bsdmake for Darwin userlands and pmake for the rest of userlands, 89# or bsdmake for Darwin userlands and pmake for the rest of userlands,
141# both of which are provided by sys-devel/pmake package. 90# both of which are provided by sys-devel/pmake package.
178 opts=${fs#* } 127 opts=${fs#* }
179 fs=${fs%% *} 128 fs=${fs%% *}
180 echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}" 129 echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}"
181 done 130 done
182} 131}
183

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.20