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

Diff of /eclass/eutils.eclass

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

Revision 1.41 Revision 1.53
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.41 2003/07/14 04:47:17 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.53 2003/09/13 20:08:41 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.
10# NB: If you add anything, please comment it! 10# NB: If you add anything, please comment it!
11 11
12ECLASS=eutils 12ECLASS=eutils
13INHERITED="$INHERITED $ECLASS" 13INHERITED="$INHERITED $ECLASS"
14 14
15DEPEND="$DEPEND !bootstrap? ( sys-devel/patch )" 15newdepend "!bootstrap? ( sys-devel/patch )"
16 16
17DESCRIPTION="Based on the ${ECLASS} eclass" 17DESCRIPTION="Based on the ${ECLASS} eclass"
18 18
19# This function generate linker scripts in /usr/lib for dynamic 19# This function generate linker scripts in /usr/lib for dynamic
20# libs in /lib. This is to fix linking problems when you have 20# libs in /lib. This is to fix linking problems when you have
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#
474 local euser="$1"; shift 491 local euser="$1"; shift
475 if [ -z "${euser}" ] ; then 492 if [ -z "${euser}" ] ; then
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 einfo "Adding user '${euser}' to your system ..."
480 496
481 # setup a file for testing usernames/groups 497 # setup a file for testing usernames/groups
482 local tmpfile="`mktemp -p ${T}`" 498 local tmpfile="`mymktemp ${T}`"
483 touch ${tmpfile}
484 chown ${euser} ${tmpfile} >& /dev/null 499 chown ${euser} ${tmpfile} >& /dev/null
485 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`" 500 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`"
486 501
487 # see if user already exists 502 # see if user already exists
488 if [ "${euser}" == "${realuser}" ] ; then 503 if [ "${euser}" == "${realuser}" ] ; then
489 einfo "${euser} already exists on your system :)"
490 return 0 504 return 0
491 fi 505 fi
506 einfo "Adding user '${euser}' to your system ..."
492 507
493 # options to pass to useradd 508 # options to pass to useradd
494 local opts="" 509 local opts=""
495 510
496 # handle uid 511 # handle uid
586 local egroup="$1"; shift 601 local egroup="$1"; shift
587 if [ -z "${egroup}" ] ; then 602 if [ -z "${egroup}" ] ; then
588 eerror "No group specified !" 603 eerror "No group specified !"
589 die "Cannot call enewgroup without a group" 604 die "Cannot call enewgroup without a group"
590 fi 605 fi
591 einfo "Adding group '${egroup}' to your system ..."
592 606
593 # setup a file for testing groupname 607 # setup a file for testing groupname
594 local tmpfile="`mktemp -p ${T}`" 608 local tmpfile="`mymktemp ${T}`"
595 touch ${tmpfile}
596 chgrp ${egroup} ${tmpfile} >& /dev/null 609 chgrp ${egroup} ${tmpfile} >& /dev/null
597 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" 610 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`"
598 611
599 # see if group already exists 612 # see if group already exists
600 if [ "${egroup}" == "${realgroup}" ] ; then 613 if [ "${egroup}" == "${realgroup}" ] ; then
601 einfo "${egroup} already exists on your system :)"
602 return 0 614 return 0
603 fi 615 fi
616 einfo "Adding group '${egroup}' to your system ..."
604 617
605 # options to pass to useradd 618 # options to pass to useradd
606 local opts="" 619 local opts=""
607 620
608 # handle gid 621 # handle gid
667 local type=${4} 680 local type=${4}
668 local path=${5:-${GAMES_PREFIX}} 681 local path=${5:-${GAMES_PREFIX}}
669 if [ -z "${type}" ] ; then 682 if [ -z "${type}" ] ; then
670 case ${CATEGORY} in 683 case ${CATEGORY} in
671 app-emulation) type=Emulator ;; 684 app-emulation) type=Emulator ;;
672 app-games) type=Game ;; 685 games-*) type=Game ;;
673 *) type="" ;; 686 *) type="" ;;
674 esac 687 esac
675 fi 688 fi
676 local desktop=${T}/${exec}.desktop 689 local desktop=${T}/${exec}.desktop
677 690
840# the proper offset from the script itself. 853# the proper offset from the script itself.
841unpack_makeself() { 854unpack_makeself() {
842 local src=$1 855 local src=$1
843 local skip=$2 856 local skip=$2
844 857
845 [ -z "${src}" ] && src=${A} 858 if [ -z "${src}" ] ; then
846 [ -e ./${src} ] \ 859 src="${DISTDIR}/${A}"
847 && src=${PWD}/${src} \ 860 else
861 if [ -e "${DISTDIR}/${src}" ] ; then
848 || src=${DISTDIR}/${src} 862 src="${DISTDIR}/${src}"
863 elif [ -e "${PWD}/${src}" ] ; then
864 src="${PWD}/${src}"
865 elif [ -e "${src}" ] ; then
866 src="${src}"
867 fi
868 fi
869 [ ! -e "${src}" ] && die "Could not find requested makeself archive ${src}"
870
849 local shrtsrc=`basename ${src}` 871 local shrtsrc=`basename ${src}`
850 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 872 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
851 if [ -z "${skip}" ] ; then 873 if [ -z "${skip}" ] ; then
852 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`" 874 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`"
853 local skip=0 875 local skip=0
860 ;; 882 ;;
861 2.1.1) 883 2.1.1)
862 skip=`grep -a ^offset= ${src} | awk '{print $2}' | cut -b2-` 884 skip=`grep -a ^offset= ${src} | awk '{print $2}' | cut -b2-`
863 let skip="skip + 1" 885 let skip="skip + 1"
864 ;; 886 ;;
887 2.1.2)
888 skip=`grep -a ^offset= ${src} | awk '{print $3}' | head -n 1`
889 let skip="skip + 1"
890 ;;
891 2.1.3)
892 skip=`grep -a ^offset= ${src} | awk '{print $3}'`
893 let skip="skip + 1"
894 ;;
865 *) 895 *)
866 eerror "I'm sorry, but I was unable to support the Makeself file." 896 eerror "I'm sorry, but I was unable to support the Makeself file."
867 eerror "The version I detected was '${ver}'." 897 eerror "The version I detected was '${ver}'."
868 eerror "Please file a bug about the file ${shrtsrc} at" 898 eerror "Please file a bug about the file ${shrtsrc} at"
869 eerror "http://bugs.gentoo.org/ so that support can be added." 899 eerror "http://bugs.gentoo.org/ so that support can be added."
873 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" 903 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset"
874 fi 904 fi
875 905
876 # we do this because otherwise a failure in gzip will cause 0 bytes to be sent 906 # we do this because otherwise a failure in gzip will cause 0 bytes to be sent
877 # to tar which will make tar not extract anything and exit with 0 907 # to tar which will make tar not extract anything and exit with 0
878 local out="`tail +${skip} ${src} | gzip -cd | tar -x --no-same-owner -v -f -`" 908 tail -n +${skip} ${src} | gzip -cd | tar -x --no-same-owner -f - 2>/dev/null
909 local pipestatus="${PIPESTATUS[*]}"
910 pipestatus="${pipestatus// }"
911 if [ "${pipestatus//0}" != "" ] ; then
912 # maybe it isnt gzipped ... they usually are, but not always ...
913 tail -n +${skip} ${src} | tar -x --no-same-owner -f - \
879 [ -z "${out}" ] && die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})" 914 || die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})"
915 fi
880} 916}

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.53

  ViewVC Help
Powered by ViewVC 1.1.20