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

Diff of /eclass/eutils.eclass

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

Revision 1.42 Revision 1.43
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.42 2003/07/18 15:10:13 wolf31o2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.43 2003/07/18 15:29:17 wolf31o2 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.
474 local euser="$1"; shift 474 local euser="$1"; shift
475 if [ -z "${euser}" ] ; then 475 if [ -z "${euser}" ] ; then
476 eerror "No username specified !" 476 eerror "No username specified !"
477 die "Cannot call enewuser without a username" 477 die "Cannot call enewuser without a username"
478 fi 478 fi
479 einfo "Adding user '${euser}' to your system ..."
479 480
480 # setup a file for testing usernames/groups 481 # setup a file for testing usernames/groups
481 local tmpfile="`mktemp -p ${T}`" 482 local tmpfile="`mktemp -p ${T}`"
482 touch ${tmpfile} 483 touch ${tmpfile}
483 chown ${euser} ${tmpfile} >& /dev/null 484 chown ${euser} ${tmpfile} >& /dev/null
484 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`" 485 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`"
485 486
486 # see if user already exists 487 # see if user already exists
487 if [ "${euser}" == "${realuser}" ] ; then 488 if [ "${euser}" == "${realuser}" ] ; then
489 einfo "${euser} already exists on your system :)"
488 return 0 490 return 0
489 fi 491 fi
490 einfo "Adding user '${euser}' to your system ..."
491 492
492 # options to pass to useradd 493 # options to pass to useradd
493 local opts="" 494 local opts=""
494 495
495 # handle uid 496 # handle uid
585 local egroup="$1"; shift 586 local egroup="$1"; shift
586 if [ -z "${egroup}" ] ; then 587 if [ -z "${egroup}" ] ; then
587 eerror "No group specified !" 588 eerror "No group specified !"
588 die "Cannot call enewgroup without a group" 589 die "Cannot call enewgroup without a group"
589 fi 590 fi
591 einfo "Adding group '${egroup}' to your system ..."
590 592
591 # setup a file for testing groupname 593 # setup a file for testing groupname
592 local tmpfile="`mktemp -p ${T}`" 594 local tmpfile="`mktemp -p ${T}`"
593 touch ${tmpfile} 595 touch ${tmpfile}
594 chgrp ${egroup} ${tmpfile} >& /dev/null 596 chgrp ${egroup} ${tmpfile} >& /dev/null
595 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" 597 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`"
596 598
597 # see if group already exists 599 # see if group already exists
598 if [ "${egroup}" == "${realgroup}" ] ; then 600 if [ "${egroup}" == "${realgroup}" ] ; then
601 einfo "${egroup} already exists on your system :)"
599 return 0 602 return 0
600 fi 603 fi
601 einfo "Adding group '${egroup}' to your system ..."
602 604
603 # options to pass to useradd 605 # options to pass to useradd
604 local opts="" 606 local opts=""
605 607
606 # handle gid 608 # handle gid
874 # we do this because otherwise a failure in gzip will cause 0 bytes to be sent 876 # we do this because otherwise a failure in gzip will cause 0 bytes to be sent
875 # to tar which will make tar not extract anything and exit with 0 877 # to tar which will make tar not extract anything and exit with 0
876 local out="`tail +${skip} ${src} | gzip -cd | tar -x --no-same-owner -v -f -`" 878 local out="`tail +${skip} ${src} | gzip -cd | tar -x --no-same-owner -v -f -`"
877 [ -z "${out}" ] && die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})" 879 [ -z "${out}" ] && die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})"
878} 880}
881
882# Add a function to force the user to press RETURN.
883# I basically needed this for the UT2003 ebuild to pause
884# the ebuild until the user swapped the CD in the drive.
885# I put it here in case anyone else could use it.
886# wolf31o2@gentoo.org
887
888pressreturn()
889{
890 local REPLY
891
892 echo -n "Press <RETURN> to continue..."
893 read REPLY
894}

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.20