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

Diff of /eclass/eutils.eclass

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

Revision 1.393 Revision 1.394
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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.393 2012/05/28 16:45:57 phajdan.jr Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.394 2012/06/05 17:40:12 hasufell Exp $
4 4
5# @ECLASS: eutils.eclass 5# @ECLASS: eutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: many extra (but common) functions that are used in ebuilds 8# @BLURB: many extra (but common) functions that are used in ebuilds
942 insinto /usr/share/applications 942 insinto /usr/share/applications
943 newins "$@" 943 newins "$@"
944 ) 944 )
945} 945}
946 946
947# @FUNCTION: doicon 947# @FUNCTION: _iconins
948# @USAGE: <list of icons> 948# @INTERNAL
949# @DESCRIPTION: 949# @DESCRIPTION:
950# Install the list of icons into the icon directory (/usr/share/pixmaps). 950# function for use in doicon and newicon
951# This is useful in conjunction with creating desktop/menu files. 951_iconins() {
952doicon() {
953 ( 952 (
954 # wrap the env here so that the 'insinto' call 953 # wrap the env here so that the 'insinto' call
955 # doesn't corrupt the env of the caller 954 # doesn't corrupt the env of the caller
956 local i j ret 955 local funcname=$1; shift
956 local size dir
957 local context=apps
958 local theme=hicolor
959
960 while [[ $# -gt 0 ]] ; do
961 case $1 in
962 -s|--size)
963 if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
964 size=${2%%x*}
965 else
966 size=${2}
967 fi
968 case ${size} in
969 16|22|24|32|36|48|64|72|96|128|192|256)
970 size=${size}x${size};;
971 scalable)
972 ;;
973 *)
974 eerror "${size} is an unsupported icon size!"
975 exit 1;;
976 esac
977 shift 2;;
978 -t|--theme)
979 theme=${2}
980 shift 2;;
981 -c|--context)
982 context=${2}
983 shift 2;;
984 *)
985 if [[ -z ${size} ]] ; then
957 insinto /usr/share/pixmaps 986 insinto /usr/share/pixmaps
958 for i in "$@" ; do
959 if [[ -f ${i} ]] ; then
960 doins "${i}"
961 ((ret+=$?))
962 elif [[ -d ${i} ]] ; then
963 for j in "${i}"/*.png ; do
964 doins "${j}"
965 ((ret+=$?))
966 done
967 else 987 else
968 ((++ret)) 988 insinto /usr/share/icons/${theme}/${size}/${context}
969 fi 989 fi
990
991 if [[ ${funcname} == doicon ]] ; then
992 if [[ -f $1 ]] ; then
993 doins "${1}"
994 elif [[ -d $1 ]] ; then
995 shopt -s nullglob
996 doins "${1}"/*.{png,svg}
997 shopt -u nullglob
998 else
999 eerror "${1} is not a valid file/directory!"
1000 exit 1
1001 fi
1002 else
1003 break
1004 fi
1005 shift 1;;
1006 esac
970 done 1007 done
971 exit ${ret} 1008 if [[ ${funcname} == newicon ]] ; then
972 ) 1009 newins "$@"
1010 fi
1011 ) || die
1012}
1013
1014# @FUNCTION: doicon
1015# @USAGE: [options] <icons>
1016# @DESCRIPTION:
1017# Install icon into the icon directory /usr/share/icons or into
1018# /usr/share/pixmaps if "--size" is not set.
1019# This is useful in conjunction with creating desktop/menu files.
1020#
1021# @CODE
1022# options:
1023# -s, --size
1024# !!! must specify to install into /usr/share/icons/... !!!
1025# size of the icon, like 48 or 48x48
1026# supported icon sizes are:
1027# 16 22 24 32 36 48 64 72 96 128 192 256 scalable
1028# -c, --context
1029# defaults to "apps"
1030# -t, --theme
1031# defaults to "hicolor"
1032#
1033# icons: list of icons
1034#
1035# example 1: doicon foobar.png fuqbar.svg
1036# results in: insinto /usr/share/pixmaps
1037# doins foobar.png fuqbar.svg
1038#
1039# example 2: doicon -s 48 foobar.png fuqbar.png
1040# results in: insinto /usr/share/icons/hicolor/48x48/apps
1041# doins foobar.png fuqbar.png
1042# @CODE
1043doicon() {
1044 _iconins ${FUNCNAME} "$@"
973} 1045}
974 1046
975# @FUNCTION: newicon 1047# @FUNCTION: newicon
976# @USAGE: <icon> <newname> 1048# @USAGE: [options] <icon> <newname>
977# @DESCRIPTION: 1049# @DESCRIPTION:
978# Like all other new* functions, install the specified icon as newname. 1050# Like doicon, install the specified icon as newname.
1051#
1052# @CODE
1053# example 1: newicon foobar.png NEWNAME.png
1054# results in: insinto /usr/share/pixmaps
1055# newins foobar.png NEWNAME.png
1056#
1057# example 2: newicon -s 48 foobar.png NEWNAME.png
1058# results in: insinto /usr/share/icons/hicolor/48x48/apps
1059# newins foobar.png NEWNAME.png
1060# @CODE
979newicon() { 1061newicon() {
980 ( 1062 _iconins ${FUNCNAME} "$@"
981 # wrap the env here so that the 'insinto' call
982 # doesn't corrupt the env of the caller
983 insinto /usr/share/pixmaps
984 newins "$@"
985 )
986} 1063}
987 1064
988# @FUNCTION: strip-linguas 1065# @FUNCTION: strip-linguas
989# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>] 1066# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
990# @DESCRIPTION: 1067# @DESCRIPTION:

Legend:
Removed from v.1.393  
changed lines
  Added in v.1.394

  ViewVC Help
Powered by ViewVC 1.1.20