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

Diff of /eclass/eutils.eclass

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

Revision 1.59 Revision 1.69
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.59 2003/09/22 22:44:49 azarah Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.69 2003/11/26 22:13:35 mr_bones_ 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.
529 fi 529 fi
530 einfo " - Userid: ${euid}" 530 einfo " - Userid: ${euid}"
531 531
532 # handle shell 532 # handle shell
533 local eshell="$1"; shift 533 local eshell="$1"; shift
534 if [ ! -z "${eshell}" ] 534 if [ ! -z "${eshell}" ] && [ "${eshell}" != "-1" ]
535 then 535 then
536 if [ ! -e "${eshell}" ] 536 if [ ! -e "${eshell}" ]
537 then 537 then
538 eerror "A shell was specified but it does not exist !" 538 eerror "A shell was specified but it does not exist !"
539 die "${eshell} does not exist" 539 die "${eshell} does not exist"
544 einfo " - Shell: ${eshell}" 544 einfo " - Shell: ${eshell}"
545 opts="${opts} -s ${eshell}" 545 opts="${opts} -s ${eshell}"
546 546
547 # handle homedir 547 # handle homedir
548 local ehome="$1"; shift 548 local ehome="$1"; shift
549 if [ -z "${ehome}" ] 549 if [ -z "${ehome}" ] && [ "${eshell}" != "-1" ]
550 then 550 then
551 ehome="/dev/null" 551 ehome="/dev/null"
552 fi 552 fi
553 einfo " - Home: ${ehome}" 553 einfo " - Home: ${ehome}"
554 opts="${opts} -d ${ehome}" 554 opts="${opts} -d ${ehome}"
665# Simple script to replace 'dos2unix' binaries 665# Simple script to replace 'dos2unix' binaries
666# vapier@gentoo.org 666# vapier@gentoo.org
667# 667#
668# edos2unix(file, <more files>...) 668# edos2unix(file, <more files>...)
669edos2unix() { 669edos2unix() {
670 for f in $@ 670 for f in "$@"
671 do 671 do
672 cp ${f} ${T}/edos2unix 672 cp "${f}" ${T}/edos2unix
673 sed 's/\r$//' ${T}/edos2unix > ${f} 673 sed 's/\r$//' ${T}/edos2unix > "${f}"
674 done 674 done
675} 675}
676 676
677# Make a desktop file ! 677# Make a desktop file !
678# Great for making those icons in kde/gnome startmenu ! 678# Great for making those icons in kde/gnome startmenu !
705 "app-emulation") 705 "app-emulation")
706 type=Emulator 706 type=Emulator
707 ;; 707 ;;
708 "games-"*) 708 "games-"*)
709 type=Game 709 type=Game
710 ;;
711 "net-"*)
712 type=Network;
710 ;; 713 ;;
711 *) 714 *)
712 type= 715 type=
713 ;; 716 ;;
714 esac 717 esac
959 ;; 962 ;;
960 esac 963 esac
961 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" 964 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset"
962 fi 965 fi
963 966
964 # we do this because otherwise a failure in gzip will cause 0 bytes to be sent 967 # lets grab the first few bytes of the file to figure out what kind of archive it is
965 # to tar which will make tar not extract anything and exit with 0 968 local tmpfile="`mymktemp ${T}`"
966 tail -n +${skip} ${src} | gzip -cd | tar -x --no-same-owner -f - 2>/dev/null 969 tail -n +${skip} ${src} 2>/dev/null | head -c 512 > ${tmpfile}
967 local pipestatus="${PIPESTATUS[*]}" 970 local filetype="`file -b ${tmpfile}`"
968 pipestatus="${pipestatus// }" 971 case ${filetype} in
969 if [ "${pipestatus//0}" != "" ] 972 *tar\ archive)
970 then
971 # maybe it isnt gzipped ... they usually are, but not always ...
972 tail -n +${skip} ${src} | tar -x --no-same-owner -f - \ 973 tail -n +${skip} ${src} | tar -xf -
974 ;;
975 bzip2*)
976 tail -n +${skip} ${src} | bzip2 -dc | tar -xf -
977 ;;
978 gzip*)
979 tail -n +${skip} ${src} | tar -xzf -
980 ;;
981 *)
982 false
983 ;;
984 esac
973 || die "failure unpacking makeself ${shrtsrc} ('${ver}' +${skip})" 985 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
974 fi
975} 986}
976 987
977# Display a license for user to accept. 988# Display a license for user to accept.
978# 989#
979# Usage: check_license [license] 990# Usage: check_license [license]
980# - If the file is not specified then ${LICENSE} is used. 991# - If the file is not specified then ${LICENSE} is used.
981check_license() { 992check_license() {
982 local src="$1" 993 local lic=$1
983
984 if [ -z "${src}" ] 994 if [ -z "${lic}" ] ; then
985 then
986 src="${PORTDIR}/licenses/${LICENSE}" 995 lic="${PORTDIR}/licenses/${LICENSE}"
987 else 996 else
988 if [ -e "${PORTDIR}/licenses/${src}" ] 997 if [ -e "${PORTDIR}/licenses/${src}" ] ; then
989 then
990 src="${PORTDIR}/licenses/${src}" 998 lic="${PORTDIR}/licenses/${src}"
991 elif [ -e "${PWD}/${src}" ] 999 elif [ -e "${PWD}/${src}" ] ; then
992 then
993 src="${PWD}/${src}" 1000 lic="${PWD}/${src}"
994 elif [ -e "${src}" ] 1001 elif [ -e "${src}" ] ; then
995 then
996 src="${src}" 1002 lic="${src}"
997 fi
998 fi 1003 fi
1004 fi
999 [ ! -e "${src}" ] && die "Could not find requested license ${src}" 1005 [ ! -f "${lic}" ] && die "Could not find requested license ${src}"
1006 local l="`basename ${lic}`"
1000 1007
1001 # here is where we check for the license... 1008 # here is where we check for the licenses the user already
1002 # if we don't find one, we ask the user for it 1009 # accepted ... if we don't find a match, we make the user accept
1003 if [ ! -d "/usr/share/licenses" ] 1010 local alic
1004 then 1011 for alic in ${ACCEPT_LICENSE} ; do
1005 mkdir -p /usr/share/licenses 1012 [ "${alic}" == "*" ] && return 0
1006 fi 1013 [ "${alic}" == "${l}" ] && return 0
1007 if [ -f "/usr/share/licenses/${LICENSE}" ] 1014 done
1008 then 1015
1009 einfo "The license for this application has already been accepted." 1016 local licmsg="`mymktemp ${T}`"
1010 else 1017 cat << EOF > ${licmsg}
1018**********************************************************
1019The following license outlines the terms of use of this
1011 ewarn "You MUST accept this license for installation to continue." 1020package. You MUST accept this license for installation to
1021continue. When you are done viewing, hit 'q'. If you
1012 eerror "If you CTRL+C out of this, the install will not run!" 1022CTRL+C out of this, the install will not run!
1013 echo 1023**********************************************************
1014 1024
1015 ${PAGER} ${src} || die "Could not execute ${PAGER} ${src}" 1025EOF
1026 cat ${lic} >> ${licmsg}
1027 ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}"
1016 einfo "Do you accept the terms of this license? [yes/no]" 1028 einfon "Do you accept the terms of this license (${l})? [yes/no] "
1017 read ACCEPT_TERMS 1029 read alic
1018 case ${ACCEPT_TERMS} in 1030 case ${alic} in
1019 "yes"|"Yes"|"y"|"Y") 1031 yes|Yes|y|Y)
1020 cp ${src} /usr/share/licenses 1032 return 0
1021 exit 0
1022 ;; 1033 ;;
1023 *) 1034 *)
1035 echo;echo;echo
1024 eerror "You MUST accept the license to continue! Exiting!" 1036 eerror "You MUST accept the license to continue! Exiting!"
1025 die "Failed to accept license" 1037 die "Failed to accept license"
1026 ;; 1038 ;;
1027 esac 1039 esac
1028 fi
1029} 1040}
1030

Legend:
Removed from v.1.59  
changed lines
  Added in v.1.69

  ViewVC Help
Powered by ViewVC 1.1.20