/[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.118
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.118 2004/10/13 14:33:01 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()
885} 894}
886 895
887# Make a desktop file ! 896# Make a desktop file !
888# Great for making those icons in kde/gnome startmenu ! 897# Great for making those icons in kde/gnome startmenu !
889# Amaze your friends ! Get the women ! Join today ! 898# Amaze your friends ! Get the women ! Join today !
890# gnome2 /usr/share/applications
891# gnome1 /usr/share/gnome/apps/
892# KDE ${KDEDIR}/share/applnk /usr/share/applnk
893# 899#
894# make_desktop_entry(<binary>, [name], [icon], [type], [path]) 900# make_desktop_entry(<binary>, [name], [icon], [type], [path])
895# 901#
896# binary: what binary does the app run with ? 902# binary: what binary does the app run with ?
897# name: the name that will show up in the menu 903# name: the name that will show up in the menu
898# icon: give your little like a pretty little icon ... 904# icon: give your little like a pretty little icon ...
899# this can be relative (to /usr/share/pixmaps) or 905# this can be relative (to /usr/share/pixmaps) or
900# a full path to an icon 906# a full path to an icon
901# type: what kind of application is this ? for categories: 907# type: what kind of application is this ? for categories:
902# http://www.freedesktop.org/standards/menu-spec/ 908# http://www.freedesktop.org/standards/menu-spec/
903# path: if your app needs to startup in a specific dir 909# path: if your app needs to startup in a specific dir
904make_desktop_entry() { 910make_desktop_entry() {
905 [ -z "$1" ] && eerror "You must specify the executable" && return 1 911 [ -z "$1" ] && eerror "make_desktop_entry: You must specify the executable" && return 1
906 912
907 local exec="${1}" 913 local exec="${1}"
908 local name="${2:-${PN}}" 914 local name="${2:-${PN}}"
909 local icon="${3:-${PN}.png}" 915 local icon="${3:-${PN}.png}"
910 local type="${4}" 916 local type="${4}"
942Exec=${exec} 948Exec=${exec}
943Path=${path} 949Path=${path}
944Icon=${icon} 950Icon=${icon}
945Categories=Application;${type};" > "${desktop}" 951Categories=Application;${type};" > "${desktop}"
946 952
947 if [ -d "/usr/share/applications" ]
948 then
949 insinto /usr/share/applications 953 insinto /usr/share/applications
950 doins "${desktop}" 954 doins "${desktop}"
951 fi
952
953 #if [ -d "/usr/share/gnome/apps" ]
954 #then
955 # insinto /usr/share/gnome/apps/Games
956 # doins ${desktop}
957 #fi
958
959 #if [ ! -z "`ls /usr/kde/* 2>/dev/null`" ]
960 #then
961 # for ver in /usr/kde/*
962 # do
963 # insinto ${ver}/share/applnk/Games
964 # doins ${desktop}
965 # done
966 #fi
967
968 if [ -d "/usr/share/applnk" ]
969 then
970 insinto /usr/share/applnk/${subdir}
971 doins "${desktop}"
972 fi
973 955
974 return 0 956 return 0
975} 957}
976 958
977# for internal use only (unpack_pdv and unpack_makeself) 959# for internal use only (unpack_pdv and unpack_makeself)
1026 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1008 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1027 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` 1009 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\"` 1010 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"`
1029 1011
1030 # grab metadata for debug reasons 1012 # grab metadata for debug reasons
1031 local metafile="`mymktemp ${T}`" 1013 local metafile="$(emktemp)"
1032 tail -c +$((${metaskip}+1)) ${src} > ${metafile} 1014 tail -c +$((${metaskip}+1)) ${src} > ${metafile}
1033 1015
1034 # rip out the final file name from the metadata 1016 # rip out the final file name from the metadata
1035 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`" 1017 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`"
1036 datafile="`basename ${datafile}`" 1018 datafile="`basename ${datafile}`"
1037 1019
1038 # now lets uncompress/untar the file if need be 1020 # now lets uncompress/untar the file if need be
1039 local tmpfile="`mymktemp ${T}`" 1021 local tmpfile="$(emktemp)"
1040 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile} 1022 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile}
1041 1023
1042 local iscompressed="`file -b ${tmpfile}`" 1024 local iscompressed="`file -b ${tmpfile}`"
1043 if [ "${iscompressed:0:8}" == "compress" ] ; then 1025 if [ "${iscompressed:0:8}" == "compress" ] ; then
1044 iscompressed=1 1026 iscompressed=1
1146 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; 1128 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";;
1147 *) die "makeself cant handle exe '${exe}'" 1129 *) die "makeself cant handle exe '${exe}'"
1148 esac 1130 esac
1149 1131
1150 # lets grab the first few bytes of the file to figure out what kind of archive it is 1132 # lets grab the first few bytes of the file to figure out what kind of archive it is
1151 local tmpfile="$(mymktemp "${T}")" 1133 local tmpfile="$(emktemp)"
1152 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" 1134 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}"
1153 local filetype="$(file -b "${tmpfile}")" 1135 local filetype="$(file -b "${tmpfile}")"
1154 case ${filetype} in 1136 case ${filetype} in
1155 *tar\ archive) 1137 *tar\ archive)
1156 eval ${exe} | tar --no-same-owner -xf - 1138 eval ${exe} | tar --no-same-owner -xf -
1203 return 0 1185 return 0
1204 fi 1186 fi
1205 done 1187 done
1206 set +o noglob; set -$shopts #reset old shell opts 1188 set +o noglob; set -$shopts #reset old shell opts
1207 1189
1208 local licmsg="`mymktemp ${T}`" 1190 local licmsg="$(emktemp)"
1209 cat << EOF > ${licmsg} 1191 cat << EOF > ${licmsg}
1210********************************************************** 1192**********************************************************
1211The following license outlines the terms of use of this 1193The following license outlines the terms of use of this
1212package. You MUST accept this license for installation to 1194package. You MUST accept this license for installation to
1213continue. When you are done viewing, hit 'q'. If you 1195continue. When you are done viewing, hit 'q'. If you

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

  ViewVC Help
Powered by ViewVC 1.1.20