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

Diff of /eclass/eutils.eclass

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

Revision 1.116 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.116 2004/10/07 06:02:39 eradicator 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()
1026 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1035 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1027 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` 1036 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"`
1028 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\"`
1029 1038
1030 # grab metadata for debug reasons 1039 # grab metadata for debug reasons
1031 local metafile="`mymktemp ${T}`" 1040 local metafile="$(emktemp)"
1032 tail -c +$((${metaskip}+1)) ${src} > ${metafile} 1041 tail -c +$((${metaskip}+1)) ${src} > ${metafile}
1033 1042
1034 # rip out the final file name from the metadata 1043 # rip out the final file name from the metadata
1035 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`" 1044 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`"
1036 datafile="`basename ${datafile}`" 1045 datafile="`basename ${datafile}`"
1037 1046
1038 # now lets uncompress/untar the file if need be 1047 # now lets uncompress/untar the file if need be
1039 local tmpfile="`mymktemp ${T}`" 1048 local tmpfile="$(emktemp)"
1040 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}
1041 1050
1042 local iscompressed="`file -b ${tmpfile}`" 1051 local iscompressed="`file -b ${tmpfile}`"
1043 if [ "${iscompressed:0:8}" == "compress" ] ; then 1052 if [ "${iscompressed:0:8}" == "compress" ] ; then
1044 iscompressed=1 1053 iscompressed=1
1146 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}'";;
1147 *) die "makeself cant handle exe '${exe}'" 1156 *) die "makeself cant handle exe '${exe}'"
1148 esac 1157 esac
1149 1158
1150 # 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
1151 local tmpfile="$(mymktemp "${T}")" 1160 local tmpfile="$(emktemp)"
1152 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" 1161 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}"
1153 local filetype="$(file -b "${tmpfile}")" 1162 local filetype="$(file -b "${tmpfile}")"
1154 case ${filetype} in 1163 case ${filetype} in
1155 *tar\ archive) 1164 *tar\ archive)
1156 eval ${exe} | tar --no-same-owner -xf - 1165 eval ${exe} | tar --no-same-owner -xf -
1203 return 0 1212 return 0
1204 fi 1213 fi
1205 done 1214 done
1206 set +o noglob; set -$shopts #reset old shell opts 1215 set +o noglob; set -$shopts #reset old shell opts
1207 1216
1208 local licmsg="`mymktemp ${T}`" 1217 local licmsg="$(emktemp)"
1209 cat << EOF > ${licmsg} 1218 cat << EOF > ${licmsg}
1210********************************************************** 1219**********************************************************
1211The following license outlines the terms of use of this 1220The following license outlines the terms of use of this
1212package. You MUST accept this license for installation to 1221package. You MUST accept this license for installation to
1213continue. When you are done viewing, hit 'q'. If you 1222continue. When you are done viewing, hit 'q'. If you

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

  ViewVC Help
Powered by ViewVC 1.1.20