| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2011 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/user.eclass,v 1.14 2011/11/26 07:20:31 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/user.eclass,v 1.15 2011/11/29 19:01:28 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: user.eclass |
5 | # @ECLASS: user.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org (Linux) |
7 | # base-system@gentoo.org (Linux) |
| 8 | # Joe Jezak <josejx@gmail.com> (OS X) |
8 | # Joe Jezak <josejx@gmail.com> (OS X) |
| … | |
… | |
| 18 | # @USAGE: <calling func name> |
18 | # @USAGE: <calling func name> |
| 19 | _assert_pkg_ebuild_phase() { |
19 | _assert_pkg_ebuild_phase() { |
| 20 | case ${EBUILD_PHASE} in |
20 | case ${EBUILD_PHASE} in |
| 21 | setup|preinst|postinst) ;; |
21 | setup|preinst|postinst) ;; |
| 22 | *) |
22 | *) |
| 23 | eerror "'$1()' called from '${EBUILD_PHASE}()' which is not a pkg_* function." |
23 | eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:" |
|
|
24 | eerror "You may only call from pkg_{setup,preinst,postinst} functions." |
| 24 | eerror "Package fails at QA and at life. Please file a bug." |
25 | eerror "Package fails at QA and at life. Please file a bug." |
| 25 | die "Bad package! $1 is only for use in pkg_* functions!" |
26 | die "Bad package! $1 is only for use in some pkg_* functions!" |
| 26 | esac |
27 | esac |
| 27 | } |
28 | } |
| 28 | |
29 | |
| 29 | # @FUNCTION: egetent |
30 | # @FUNCTION: egetent |
| 30 | # @USAGE: <database> <key> |
31 | # @USAGE: <database> <key> |
| … | |
… | |
| 101 | # Same as enewgroup, you are not required to understand how to properly add |
102 | # Same as enewgroup, you are not required to understand how to properly add |
| 102 | # a user to the system. The only required parameter is the username. |
103 | # a user to the system. The only required parameter is the username. |
| 103 | # Default uid is (pass -1 for this) next available, default shell is |
104 | # Default uid is (pass -1 for this) next available, default shell is |
| 104 | # /bin/false, default homedir is /dev/null, and there are no default groups. |
105 | # /bin/false, default homedir is /dev/null, and there are no default groups. |
| 105 | enewuser() { |
106 | enewuser() { |
| 106 | _assert_pkg_ebuild_phase enewuser |
107 | _assert_pkg_ebuild_phase ${FUNCNAME} |
| 107 | |
108 | |
| 108 | # get the username |
109 | # get the username |
| 109 | local euser=$1; shift |
110 | local euser=$1; shift |
| 110 | if [[ -z ${euser} ]] ; then |
111 | if [[ -z ${euser} ]] ; then |
| 111 | eerror "No username specified !" |
112 | eerror "No username specified !" |
| … | |
… | |
| 270 | # This function does not require you to understand how to properly add a |
271 | # This function does not require you to understand how to properly add a |
| 271 | # group to the system. Just give it a group name to add and enewgroup will |
272 | # group to the system. Just give it a group name to add and enewgroup will |
| 272 | # do the rest. You may specify the gid for the group or allow the group to |
273 | # do the rest. You may specify the gid for the group or allow the group to |
| 273 | # allocate the next available one. |
274 | # allocate the next available one. |
| 274 | enewgroup() { |
275 | enewgroup() { |
| 275 | _assert_pkg_ebuild_phase enewgroup |
276 | _assert_pkg_ebuild_phase ${FUNCNAME} |
| 276 | |
277 | |
| 277 | # get the group |
278 | # get the group |
| 278 | local egroup=$1; shift |
279 | local egroup=$1; shift |
| 279 | if [[ -z ${egroup} ]] ; then |
280 | if [[ -z ${egroup} ]] ; then |
| 280 | eerror "No group specified !" |
281 | eerror "No group specified !" |