/[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.51
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.51 2003/09/08 02:10:46 azarah 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
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 ..."
480 479
481 # setup a file for testing usernames/groups 480 # setup a file for testing usernames/groups
482 local tmpfile="`mktemp -p ${T}`" 481 local tmpfile="`mktemp -p ${T}`"
483 touch ${tmpfile} 482 touch ${tmpfile}
484 chown ${euser} ${tmpfile} >& /dev/null 483 chown ${euser} ${tmpfile} >& /dev/null
485 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`" 484 local realuser="`ls -l ${tmpfile} | awk '{print $3}'`"
486 485
487 # see if user already exists 486 # see if user already exists
488 if [ "${euser}" == "${realuser}" ] ; then 487 if [ "${euser}" == "${realuser}" ] ; then
489 einfo "${euser} already exists on your system :)"
490 return 0 488 return 0
491 fi 489 fi
490 einfo "Adding user '${euser}' to your system ..."
492 491
493 # options to pass to useradd 492 # options to pass to useradd
494 local opts="" 493 local opts=""
495 494
496 # handle uid 495 # handle uid
586 local egroup="$1"; shift 585 local egroup="$1"; shift
587 if [ -z "${egroup}" ] ; then 586 if [ -z "${egroup}" ] ; then
588 eerror "No group specified !" 587 eerror "No group specified !"
589 die "Cannot call enewgroup without a group" 588 die "Cannot call enewgroup without a group"
590 fi 589 fi
591 einfo "Adding group '${egroup}' to your system ..."
592 590
593 # setup a file for testing groupname 591 # setup a file for testing groupname
594 local tmpfile="`mktemp -p ${T}`" 592 local tmpfile="`mktemp -p ${T}`"
595 touch ${tmpfile} 593 touch ${tmpfile}
596 chgrp ${egroup} ${tmpfile} >& /dev/null 594 chgrp ${egroup} ${tmpfile} >& /dev/null
597 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" 595 local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`"
598 596
599 # see if group already exists 597 # see if group already exists
600 if [ "${egroup}" == "${realgroup}" ] ; then 598 if [ "${egroup}" == "${realgroup}" ] ; then
601 einfo "${egroup} already exists on your system :)"
602 return 0 599 return 0
603 fi 600 fi
601 einfo "Adding group '${egroup}' to your system ..."
604 602
605 # options to pass to useradd 603 # options to pass to useradd
606 local opts="" 604 local opts=""
607 605
608 # handle gid 606 # handle gid
840# the proper offset from the script itself. 838# the proper offset from the script itself.
841unpack_makeself() { 839unpack_makeself() {
842 local src=$1 840 local src=$1
843 local skip=$2 841 local skip=$2
844 842
845 [ -z "${src}" ] && src=${A} 843 if [ -z "${src}" ] ; then
846 [ -e ./${src} ] \ 844 src="${DISTDIR}/${A}"
847 && src=${PWD}/${src} \ 845 else
846 if [ -e "${DISTDIR}/${src}" ] ; then
848 || src=${DISTDIR}/${src} 847 src="${DISTDIR}/${src}"
848 elif [ -e "${PWD}/${src}" ] ; then
849 src="${PWD}/${src}"
850 elif [ -e "${src}" ] ; then
851 src="${src}"
852 fi
853 fi
854 [ ! -e "${src}" ] && die "Could not find requested makeself archive ${src}"
855
849 local shrtsrc=`basename ${src}` 856 local shrtsrc=`basename ${src}`
850 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 857 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
851 if [ -z "${skip}" ] ; then 858 if [ -z "${skip}" ] ; then
852 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`" 859 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`"
853 local skip=0 860 local skip=0
860 ;; 867 ;;
861 2.1.1) 868 2.1.1)
862 skip=`grep -a ^offset= ${src} | awk '{print $2}' | cut -b2-` 869 skip=`grep -a ^offset= ${src} | awk '{print $2}' | cut -b2-`
863 let skip="skip + 1" 870 let skip="skip + 1"
864 ;; 871 ;;
872 2.1.2)
873 skip=`grep -a ^offset= ${src} | awk '{print $3}' | head -n 1`
874 let skip="skip + 1"
875 ;;
876 2.1.3)
877 skip=`grep -a ^offset= ${src} | awk '{print $3}'`
878 let skip="skip + 1"
879 ;;
865 *) 880 *)
866 eerror "I'm sorry, but I was unable to support the Makeself file." 881 eerror "I'm sorry, but I was unable to support the Makeself file."
867 eerror "The version I detected was '${ver}'." 882 eerror "The version I detected was '${ver}'."
868 eerror "Please file a bug about the file ${shrtsrc} at" 883 eerror "Please file a bug about the file ${shrtsrc} at"
869 eerror "http://bugs.gentoo.org/ so that support can be added." 884 eerror "http://bugs.gentoo.org/ so that support can be added."
873 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" 888 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset"
874 fi 889 fi
875 890
876 # we do this because otherwise a failure in gzip will cause 0 bytes to be sent 891 # 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 892 # 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 -`" 893 tail -n +${skip} ${src} | gzip -cd | tar -x --no-same-owner -f - 2>/dev/null
894 local pipestatus="${PIPESTATUS[*]}"
895 pipestatus="${pipestatus// }"
896 if [ "${pipestatus//0}" != "" ] ; then
897 # maybe it isnt gzipped ... they usually are, but not always ...
898 tail -n +${skip} ${src} | tar -x --no-same-owner -f - \
879 [ -z "${out}" ] && die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})" 899 || die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})"
900 fi
880} 901}

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

  ViewVC Help
Powered by ViewVC 1.1.20