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

Diff of /eclass/eutils.eclass

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

Revision 1.51 Revision 1.52
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
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.51 2003/09/08 02:10:46 azarah Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.52 2003/09/13 19:24:21 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.
454 export MAKEOPTS="${MAKEOPTS} -j${jobs}" 454 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
455 fi 455 fi
456 fi 456 fi
457} 457}
458 458
459# Cheap replacement for when debianutils (and thus mktemp)
460# do not exist on the users system
461# vapier@gentoo.org
462#
463# Takes just 1 parameter (the directory to create tmpfile in)
464mymktemp() {
465 local topdir=$1
466 [ -z "${topdir}" ] && topdir=/tmp
467 if [ `which mktemp 2>/dev/null` ] ; then
468 mktemp -p ${topdir}
469 else
470 local tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}"
471 touch ${tmp}
472 echo ${tmp}
473 fi
474}
475
459# Simplify/standardize adding users to the system 476# Simplify/standardize adding users to the system
460# vapier@gentoo.org 477# vapier@gentoo.org
461# 478#
462# enewuser(username, uid, shell, homedir, groups, extra options) 479# enewuser(username, uid, shell, homedir, groups, extra options)
463# 480#
476 eerror "No username specified !" 493 eerror "No username specified !"
477 die "Cannot call enewuser without a username" 494 die "Cannot call enewuser without a username"
478 fi 495 fi
479 496
480 # setup a file for testing usernames/groups 497 # setup a file for testing usernames/groups
481 local tmpfile="`mktemp -p ${T}`" 498 local tmpfile="`mymktemp ${T}`"
482 touch ${tmpfile}
483 chown ${euser} ${tmpfile} >& /dev/null 499 chown ${euser} ${tmpfile} >& /dev/null
484 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`" 500 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`"
485 501
486 # see if user already exists 502 # see if user already exists
487 if [ "${euser}" == "${realuser}" ] ; then 503 if [ "${euser}" == "${realuser}" ] ; then
587 eerror "No group specified !" 603 eerror "No group specified !"
588 die "Cannot call enewgroup without a group" 604 die "Cannot call enewgroup without a group"
589 fi 605 fi
590 606
591 # setup a file for testing groupname 607 # setup a file for testing groupname
592 local tmpfile="`mktemp -p ${T}`" 608 local tmpfile="`mymktemp ${T}`"
593 touch ${tmpfile}
594 chgrp ${egroup} ${tmpfile} >& /dev/null 609 chgrp ${egroup} ${tmpfile} >& /dev/null
595 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" 610 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`"
596 611
597 # see if group already exists 612 # see if group already exists
598 if [ "${egroup}" == "${realgroup}" ] ; then 613 if [ "${egroup}" == "${realgroup}" ] ; then

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.52

  ViewVC Help
Powered by ViewVC 1.1.20