| 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.60 2003/09/23 01:26:58 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. |
| … | |
… | |
| 977 | # Display a license for user to accept. |
977 | # Display a license for user to accept. |
| 978 | # |
978 | # |
| 979 | # Usage: check_license [license] |
979 | # Usage: check_license [license] |
| 980 | # - If the file is not specified then ${LICENSE} is used. |
980 | # - If the file is not specified then ${LICENSE} is used. |
| 981 | check_license() { |
981 | check_license() { |
| 982 | local src="$1" |
982 | local lic=$1 |
| 983 | |
|
|
| 984 | if [ -z "${src}" ] |
983 | if [ -z "${lic}" ] ; then |
| 985 | then |
|
|
| 986 | src="${PORTDIR}/licenses/${LICENSE}" |
984 | lic="${PORTDIR}/licenses/${LICENSE}" |
| 987 | else |
985 | else |
| 988 | if [ -e "${PORTDIR}/licenses/${src}" ] |
986 | if [ -e "${PORTDIR}/licenses/${src}" ] ; then |
| 989 | then |
|
|
| 990 | src="${PORTDIR}/licenses/${src}" |
987 | lic="${PORTDIR}/licenses/${src}" |
| 991 | elif [ -e "${PWD}/${src}" ] |
988 | elif [ -e "${PWD}/${src}" ] ; then |
| 992 | then |
|
|
| 993 | src="${PWD}/${src}" |
989 | lic="${PWD}/${src}" |
| 994 | elif [ -e "${src}" ] |
990 | elif [ -e "${src}" ] ; then |
| 995 | then |
|
|
| 996 | src="${src}" |
991 | lic="${src}" |
| 997 | fi |
|
|
| 998 | fi |
992 | fi |
|
|
993 | fi |
| 999 | [ ! -e "${src}" ] && die "Could not find requested license ${src}" |
994 | [ ! -f "${lic}" ] && die "Could not find requested license ${src}" |
| 1000 | |
995 | |
| 1001 | # here is where we check for the license... |
996 | # here is where we check for the licenses the user already |
| 1002 | # if we don't find one, we ask the user for it |
997 | # accepted ... if we don't find a match, we make the user accept |
| 1003 | if [ ! -d "/usr/share/licenses" ] |
998 | local alic |
| 1004 | then |
999 | for alic in ${ACCEPT_LICENSE} ; do |
| 1005 | mkdir -p /usr/share/licenses |
1000 | [ "${alic}" == "*" ] && return 0 |
| 1006 | fi |
1001 | [ "${alic}" == "${lic}" ] && return 0 |
| 1007 | if [ -f "/usr/share/licenses/${LICENSE}" ] |
1002 | done |
| 1008 | then |
1003 | |
| 1009 | einfo "The license for this application has already been accepted." |
1004 | local licmsg="`mymktemp ${T}`" |
| 1010 | else |
1005 | cat << EOF > ${licmsg} |
|
|
1006 | ********************************************************** |
|
|
1007 | The following license outlines the terms of use of this |
| 1011 | ewarn "You MUST accept this license for installation to continue." |
1008 | package. You MUST accept this license for installation to |
|
|
1009 | continue. When you are done viewing, hit 'q'. If you |
| 1012 | eerror "If you CTRL+C out of this, the install will not run!" |
1010 | CTRL+C out of this, the install will not run! |
| 1013 | echo |
1011 | ********************************************************** |
| 1014 | |
1012 | |
| 1015 | ${PAGER} ${src} || die "Could not execute ${PAGER} ${src}" |
1013 | EOF |
|
|
1014 | cat ${lic} >> ${licmsg} |
|
|
1015 | ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}" |
| 1016 | einfo "Do you accept the terms of this license? [yes/no]" |
1016 | einfon "Do you accept the terms of this license? [yes/no] " |
| 1017 | read ACCEPT_TERMS |
1017 | read alic |
| 1018 | case ${ACCEPT_TERMS} in |
1018 | case ${alic} in |
| 1019 | "yes"|"Yes"|"y"|"Y") |
1019 | yes|Yes|y|Y) |
| 1020 | cp ${src} /usr/share/licenses |
1020 | return 0 |
| 1021 | exit 0 |
|
|
| 1022 | ;; |
1021 | ;; |
| 1023 | *) |
1022 | *) |
|
|
1023 | echo;echo;echo |
| 1024 | eerror "You MUST accept the license to continue! Exiting!" |
1024 | eerror "You MUST accept the license to continue! Exiting!" |
| 1025 | die "Failed to accept license" |
1025 | die "Failed to accept license" |
| 1026 | ;; |
1026 | ;; |
| 1027 | esac |
1027 | esac |
| 1028 | fi |
|
|
| 1029 | } |
1028 | } |
| 1030 | |
|
|