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

Diff of /eclass/eutils.eclass

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

Revision 1.45 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.45 2003/07/18 20:43:00 wolf31o2 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#
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
665 local type=${4} 680 local type=${4}
666 local path=${5:-${GAMES_PREFIX}} 681 local path=${5:-${GAMES_PREFIX}}
667 if [ -z "${type}" ] ; then 682 if [ -z "${type}" ] ; then
668 case ${CATEGORY} in 683 case ${CATEGORY} in
669 app-emulation) type=Emulator ;; 684 app-emulation) type=Emulator ;;
670 app-games) type=Game ;; 685 games-*) type=Game ;;
671 *) type="" ;; 686 *) type="" ;;
672 esac 687 esac
673 fi 688 fi
674 local desktop=${T}/${exec}.desktop 689 local desktop=${T}/${exec}.desktop
675 690
838# the proper offset from the script itself. 853# the proper offset from the script itself.
839unpack_makeself() { 854unpack_makeself() {
840 local src=$1 855 local src=$1
841 local skip=$2 856 local skip=$2
842 857
843 [ -z "${src}" ] && src=${A} 858 if [ -z "${src}" ] ; then
844 [ -e ./${src} ] \ 859 src="${DISTDIR}/${A}"
845 && src=${PWD}/${src} \ 860 else
861 if [ -e "${DISTDIR}/${src}" ] ; then
846 || 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
847 local shrtsrc=`basename ${src}` 871 local shrtsrc=`basename ${src}`
848 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 872 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
849 if [ -z "${skip}" ] ; then 873 if [ -z "${skip}" ] ; then
850 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`" 874 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`"
851 local skip=0 875 local skip=0
858 ;; 882 ;;
859 2.1.1) 883 2.1.1)
860 skip=`grep -a ^offset= ${src} | awk '{print $2}' | cut -b2-` 884 skip=`grep -a ^offset= ${src} | awk '{print $2}' | cut -b2-`
861 let skip="skip + 1" 885 let skip="skip + 1"
862 ;; 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 ;;
863 *) 895 *)
864 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."
865 eerror "The version I detected was '${ver}'." 897 eerror "The version I detected was '${ver}'."
866 eerror "Please file a bug about the file ${shrtsrc} at" 898 eerror "Please file a bug about the file ${shrtsrc} at"
867 eerror "http://bugs.gentoo.org/ so that support can be added." 899 eerror "http://bugs.gentoo.org/ so that support can be added."
871 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" 903 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset"
872 fi 904 fi
873 905
874 # 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
875 # 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
876 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 - \
877 [ -z "${out}" ] && die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})" 914 || die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})"
915 fi
878} 916}

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

  ViewVC Help
Powered by ViewVC 1.1.20