summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gentoo.org>2005-09-20 13:13:42 +0000
committerDiego Elio Pettenò <flameeyes@gentoo.org>2005-09-20 13:13:42 +0000
commitbd25d4ecdd22e3894c484daf852902d78be4264f (patch)
tree71a681a4230f927fb54b094047f180e308d8c51f /eclass/portability.eclass
parentversion bump (diff)
downloadgentoo-2-bd25d4ecdd22e3894c484daf852902d78be4264f.tar.gz
gentoo-2-bd25d4ecdd22e3894c484daf852902d78be4264f.tar.bz2
gentoo-2-bd25d4ecdd22e3894c484daf852902d78be4264f.zip
Added egethome function to portability eclass.
Diffstat (limited to 'eclass/portability.eclass')
-rw-r--r--eclass/portability.eclass18
1 files changed, 17 insertions, 1 deletions
diff --git a/eclass/portability.eclass b/eclass/portability.eclass
index a83e35441482..3af218eb7f34 100644
--- a/eclass/portability.eclass
+++ b/eclass/portability.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.1 2005/09/18 17:33:44 flameeyes Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.2 2005/09/20 13:13:42 flameeyes Exp $
#
# Author: Diego Pettenò <flameeyes@gentoo.org>
#
@@ -73,3 +73,19 @@ dlopen_lib() {
fi
}
+# Gets the home directory for the specified user
+# it's a wrap around egetent as the position of the home directory in the line
+# varies depending on the os used.
+#
+# To use that, inherit eutils, not portability!
+egethome() {
+ ent=$(egetent passwd $1)
+
+ if [[ "${USERLAND}" == "Darwin" || "${ELIBC}" == "FreeBSD" ]]; then
+ # Darwin/OSX and FreeBSD uses position 9 to store the home dir
+ cut -d: -f9 <<<${ent}
+ else
+ # Linux and NetBSD uses position 6 instead
+ cut -d: -f6 <<<${ent}
+ fi
+}