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

Diff of /eclass/eutils.eclass

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

Revision 1.114 Revision 1.117
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
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.114 2004/10/06 04:21:08 usata Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.117 2004/10/09 18:25:43 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.
541 541
542# Cheap replacement for when debianutils (and thus mktemp) 542# Cheap replacement for when debianutils (and thus mktemp)
543# does not exist on the users system 543# does not exist on the users system
544# vapier@gentoo.org 544# vapier@gentoo.org
545# 545#
546# Takes just 1 parameter (the directory to create tmpfile in) 546# Takes just 1 optional parameter (the directory to create tmpfile in)
547mymktemp() { 547emktemp() {
548 local topdir="$1" 548 local topdir="$1"
549 549
550 [ -z "${topdir}" ] && topdir=/tmp 550 if [ -z "${topdir}" ]
551 if [ "`which mktemp 2>/dev/null`" ]
552 then 551 then
552 [ -z "${T}" ] \
553 && topdir="/tmp" \
554 || topdir="${T}"
555 fi
556
557 if [ -z "$(type -p mktemp)" ]
558 then
559 local tmp=/
560 while [ -e "${tmp}" ] ; do
561 tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}"
562 done
563 touch "${tmp}"
564 echo "${tmp}"
565 else
553 mktemp -p ${topdir} 566 mktemp -p "${topdir}"
554 else
555 local tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}"
556 touch ${tmp}
557 echo ${tmp}
558 fi 567 fi
559} 568}
560 569
561# Small wrapper for getent (Linux), nidump (Mac OS X), 570# Small wrapper for getent (Linux), nidump (Mac OS X),
562# and pw (FreeBSD) used in enewuser()/enewgroup() 571# and pw (FreeBSD) used in enewuser()/enewgroup()
690 local defgroup="" exgroups="" 699 local defgroup="" exgroups=""
691 700
692 export IFS="," 701 export IFS=","
693 for g in ${egroups} 702 for g in ${egroups}
694 do 703 do
704 export IFS="${oldifs}"
695 if [ -z "`egetent group \"${g}\"`" ] 705 if [ -z "`egetent group \"${g}\"`" ]
696 then 706 then
697 eerror "You must add group ${g} to the system first" 707 eerror "You must add group ${g} to the system first"
698 die "${g} is not a valid GID" 708 die "${g} is not a valid GID"
699 fi 709 fi
701 then 711 then
702 defgroup="${g}" 712 defgroup="${g}"
703 else 713 else
704 exgroups="${exgroups},${g}" 714 exgroups="${exgroups},${g}"
705 fi 715 fi
716 export IFS=","
706 done 717 done
707 export IFS="${oldifs}" 718 export IFS="${oldifs}"
708 719
709 opts="${opts} -g ${defgroup}" 720 opts="${opts} -g ${defgroup}"
710 if [ ! -z "${exgroups}" ] 721 if [ ! -z "${exgroups}" ]
728 dscl . create /users/${euser} uid ${euid} 739 dscl . create /users/${euser} uid ${euid}
729 dscl . create /users/${euser} shell ${eshell} 740 dscl . create /users/${euser} shell ${eshell}
730 dscl . create /users/${euser} home ${ehome} 741 dscl . create /users/${euser} home ${ehome}
731 dscl . create /users/${euser} realname "added by portage for ${PN}" 742 dscl . create /users/${euser} realname "added by portage for ${PN}"
732 ### Add the user to the groups specified 743 ### Add the user to the groups specified
744 local oldifs="${IFS}"
745 export IFS=","
733 for g in ${egroups} 746 for g in ${egroups}
734 do 747 do
735 # $egroups is , delimited, not space
736 ewarn "This is code is wrong; someone on the OS X team should fix it"
737 dscl . merge /groups/${g} users ${euser} 748 dscl . merge /groups/${g} users ${euser}
738 done 749 done
750 export IFS="${oldifs}"
739 else 751 else
740 einfo "Extra options are not supported on macos yet" 752 einfo "Extra options are not supported on macos yet"
741 einfo "Please report the ebuild along with the info below" 753 einfo "Please report the ebuild along with the info below"
742 einfo "eextra: ${eextra}" 754 einfo "eextra: ${eextra}"
743 die "Required function missing" 755 die "Required function missing"
1023 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1035 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1024 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` 1036 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"`
1025 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"` 1037 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"`
1026 1038
1027 # grab metadata for debug reasons 1039 # grab metadata for debug reasons
1028 local metafile="`mymktemp ${T}`" 1040 local metafile="$(emktemp)"
1029 tail -c +$((${metaskip}+1)) ${src} > ${metafile} 1041 tail -c +$((${metaskip}+1)) ${src} > ${metafile}
1030 1042
1031 # rip out the final file name from the metadata 1043 # rip out the final file name from the metadata
1032 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`" 1044 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`"
1033 datafile="`basename ${datafile}`" 1045 datafile="`basename ${datafile}`"
1034 1046
1035 # now lets uncompress/untar the file if need be 1047 # now lets uncompress/untar the file if need be
1036 local tmpfile="`mymktemp ${T}`" 1048 local tmpfile="$(emktemp)"
1037 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile} 1049 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile}
1038 1050
1039 local iscompressed="`file -b ${tmpfile}`" 1051 local iscompressed="`file -b ${tmpfile}`"
1040 if [ "${iscompressed:0:8}" == "compress" ] ; then 1052 if [ "${iscompressed:0:8}" == "compress" ] ; then
1041 iscompressed=1 1053 iscompressed=1
1143 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; 1155 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";;
1144 *) die "makeself cant handle exe '${exe}'" 1156 *) die "makeself cant handle exe '${exe}'"
1145 esac 1157 esac
1146 1158
1147 # lets grab the first few bytes of the file to figure out what kind of archive it is 1159 # lets grab the first few bytes of the file to figure out what kind of archive it is
1148 local tmpfile="$(mymktemp "${T}")" 1160 local tmpfile="$(emktemp)"
1149 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" 1161 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}"
1150 local filetype="$(file -b "${tmpfile}")" 1162 local filetype="$(file -b "${tmpfile}")"
1151 case ${filetype} in 1163 case ${filetype} in
1152 *tar\ archive) 1164 *tar\ archive)
1153 eval ${exe} | tar --no-same-owner -xf - 1165 eval ${exe} | tar --no-same-owner -xf -
1200 return 0 1212 return 0
1201 fi 1213 fi
1202 done 1214 done
1203 set +o noglob; set -$shopts #reset old shell opts 1215 set +o noglob; set -$shopts #reset old shell opts
1204 1216
1205 local licmsg="`mymktemp ${T}`" 1217 local licmsg="$(emktemp)"
1206 cat << EOF > ${licmsg} 1218 cat << EOF > ${licmsg}
1207********************************************************** 1219**********************************************************
1208The following license outlines the terms of use of this 1220The following license outlines the terms of use of this
1209package. You MUST accept this license for installation to 1221package. You MUST accept this license for installation to
1210continue. When you are done viewing, hit 'q'. If you 1222continue. When you are done viewing, hit 'q'. If you
1521 einfo "is not being removed. In order to make full use of this newer version," 1533 einfo "is not being removed. In order to make full use of this newer version,"
1522 einfo "you will need to execute the following command:" 1534 einfo "you will need to execute the following command:"
1523 einfo " revdep-rebuild --soname ${SONAME}" 1535 einfo " revdep-rebuild --soname ${SONAME}"
1524 einfo 1536 einfo
1525 einfo "After doing that, you can safely remove ${LIB}" 1537 einfo "After doing that, you can safely remove ${LIB}"
1538 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild"
1526 fi 1539 fi
1527} 1540}

Legend:
Removed from v.1.114  
changed lines
  Added in v.1.117

  ViewVC Help
Powered by ViewVC 1.1.20