Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Thu, 30 Nov 2017 19:10:31
Message-Id: 1512068968.8424e28557354983c49b021ea13a4f4be923978d.ulm@gentoo
1 commit: 8424e28557354983c49b021ea13a4f4be923978d
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 23 23:39:55 2017 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 30 19:09:28 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8424e285
7
8 desktop.eclass: Split off desktop, menu, and icon functions from eutils.
9
10 Split off functions make_desktop_entry, make_session_desktop, domenu,
11 newmenu, doicon, and newicon from eutils.eclass into a dedicated
12 desktop.eclass. These functions are independent of the rest of eutils,
13 therefore moving them into their own eclass will help clarifying
14 eclass inheritance in ebuilds.
15
16 For backwards compatibility, eutils inherits the new eclass in
17 existing EAPIs.
18
19 eclass/desktop.eclass | 395 +++++++++++++++++++++++++++++++++++++++++++++++++
20 eclass/eutils.eclass | 401 ++------------------------------------------------
21 2 files changed, 404 insertions(+), 392 deletions(-)
22
23 diff --git a/eclass/desktop.eclass b/eclass/desktop.eclass
24 new file mode 100644
25 index 00000000000..d65b0d0bf07
26 --- /dev/null
27 +++ b/eclass/desktop.eclass
28 @@ -0,0 +1,395 @@
29 +# Copyright 1999-2017 Gentoo Foundation
30 +# Distributed under the terms of the GNU General Public License v2
31 +
32 +# @ECLASS: desktop.eclass
33 +# @MAINTAINER:
34 +# base-system@g.o
35 +# @BLURB: support for desktop files, menus, and icons
36 +
37 +if [[ -z ${_DESKTOP_ECLASS} ]]; then
38 +_DESKTOP_ECLASS=1
39 +
40 +# @FUNCTION: make_desktop_entry
41 +# @USAGE: make_desktop_entry(<command>, [name], [icon], [type], [fields])
42 +# @DESCRIPTION:
43 +# Make a .desktop file.
44 +#
45 +# @CODE
46 +# binary: what command does the app run with ?
47 +# name: the name that will show up in the menu
48 +# icon: the icon to use in the menu entry
49 +# this can be relative (to /usr/share/pixmaps) or
50 +# a full path to an icon
51 +# type: what kind of application is this?
52 +# for categories:
53 +# https://specifications.freedesktop.org/menu-spec/latest/apa.html
54 +# if unset, function tries to guess from package's category
55 +# fields: extra fields to append to the desktop file; a printf string
56 +# @CODE
57 +make_desktop_entry() {
58 + [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable"
59 +
60 + local exec=${1}
61 + local name=${2:-${PN}}
62 + local icon=${3:-${PN}}
63 + local type=${4}
64 + local fields=${5}
65 +
66 + if [[ -z ${type} ]] ; then
67 + local catmaj=${CATEGORY%%-*}
68 + local catmin=${CATEGORY##*-}
69 + case ${catmaj} in
70 + app)
71 + case ${catmin} in
72 + accessibility) type="Utility;Accessibility";;
73 + admin) type=System;;
74 + antivirus) type=System;;
75 + arch) type="Utility;Archiving";;
76 + backup) type="Utility;Archiving";;
77 + cdr) type="AudioVideo;DiscBurning";;
78 + dicts) type="Office;Dictionary";;
79 + doc) type=Documentation;;
80 + editors) type="Utility;TextEditor";;
81 + emacs) type="Development;TextEditor";;
82 + emulation) type="System;Emulator";;
83 + laptop) type="Settings;HardwareSettings";;
84 + office) type=Office;;
85 + pda) type="Office;PDA";;
86 + vim) type="Development;TextEditor";;
87 + xemacs) type="Development;TextEditor";;
88 + esac
89 + ;;
90 +
91 + dev)
92 + type="Development"
93 + ;;
94 +
95 + games)
96 + case ${catmin} in
97 + action|fps) type=ActionGame;;
98 + arcade) type=ArcadeGame;;
99 + board) type=BoardGame;;
100 + emulation) type=Emulator;;
101 + kids) type=KidsGame;;
102 + puzzle) type=LogicGame;;
103 + roguelike) type=RolePlaying;;
104 + rpg) type=RolePlaying;;
105 + simulation) type=Simulation;;
106 + sports) type=SportsGame;;
107 + strategy) type=StrategyGame;;
108 + esac
109 + type="Game;${type}"
110 + ;;
111 +
112 + gnome)
113 + type="Gnome;GTK"
114 + ;;
115 +
116 + kde)
117 + type="KDE;Qt"
118 + ;;
119 +
120 + mail)
121 + type="Network;Email"
122 + ;;
123 +
124 + media)
125 + case ${catmin} in
126 + gfx)
127 + type=Graphics
128 + ;;
129 + *)
130 + case ${catmin} in
131 + radio) type=Tuner;;
132 + sound) type=Audio;;
133 + tv) type=TV;;
134 + video) type=Video;;
135 + esac
136 + type="AudioVideo;${type}"
137 + ;;
138 + esac
139 + ;;
140 +
141 + net)
142 + case ${catmin} in
143 + dialup) type=Dialup;;
144 + ftp) type=FileTransfer;;
145 + im) type=InstantMessaging;;
146 + irc) type=IRCClient;;
147 + mail) type=Email;;
148 + news) type=News;;
149 + nntp) type=News;;
150 + p2p) type=FileTransfer;;
151 + voip) type=Telephony;;
152 + esac
153 + type="Network;${type}"
154 + ;;
155 +
156 + sci)
157 + case ${catmin} in
158 + astro*) type=Astronomy;;
159 + bio*) type=Biology;;
160 + calc*) type=Calculator;;
161 + chem*) type=Chemistry;;
162 + elec*) type=Electronics;;
163 + geo*) type=Geology;;
164 + math*) type=Math;;
165 + physics) type=Physics;;
166 + visual*) type=DataVisualization;;
167 + esac
168 + type="Education;Science;${type}"
169 + ;;
170 +
171 + sys)
172 + type="System"
173 + ;;
174 +
175 + www)
176 + case ${catmin} in
177 + client) type=WebBrowser;;
178 + esac
179 + type="Network;${type}"
180 + ;;
181 +
182 + *)
183 + type=
184 + ;;
185 + esac
186 + fi
187 + local slot=${SLOT%/*}
188 + if [[ ${slot} == "0" ]] ; then
189 + local desktop_name="${PN}"
190 + else
191 + local desktop_name="${PN}-${slot}"
192 + fi
193 + local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop"
194 + #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop
195 +
196 + # Don't append another ";" when a valid category value is provided.
197 + type=${type%;}${type:+;}
198 +
199 + if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
200 + ewarn "As described in the Icon Theme Specification, icon file extensions are not"
201 + ewarn "allowed in .desktop files if the value is not an absolute path."
202 + icon=${icon%.*}
203 + fi
204 +
205 + cat <<-EOF > "${desktop}"
206 + [Desktop Entry]
207 + Name=${name}
208 + Type=Application
209 + Comment=${DESCRIPTION}
210 + Exec=${exec}
211 + TryExec=${exec%% *}
212 + Icon=${icon}
213 + Categories=${type}
214 + EOF
215 +
216 + if [[ ${fields:-=} != *=* ]] ; then
217 + # 5th arg used to be value to Path=
218 + ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}"
219 + fields="Path=${fields}"
220 + fi
221 + [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}"
222 +
223 + (
224 + # wrap the env here so that the 'insinto' call
225 + # doesn't corrupt the env of the caller
226 + insinto /usr/share/applications
227 + doins "${desktop}"
228 + ) || die "installing desktop file failed"
229 +}
230 +
231 +# @FUNCTION: make_session_desktop
232 +# @USAGE: <title> <command> [command args...]
233 +# @DESCRIPTION:
234 +# Make a GDM/KDM Session file. The title is the file to execute to start the
235 +# Window Manager. The command is the name of the Window Manager.
236 +#
237 +# You can set the name of the file via the ${wm} variable.
238 +make_session_desktop() {
239 + [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1
240 + [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1
241 +
242 + local title=$1
243 + local command=$2
244 + local desktop=${T}/${wm:-${PN}}.desktop
245 + shift 2
246 +
247 + cat <<-EOF > "${desktop}"
248 + [Desktop Entry]
249 + Name=${title}
250 + Comment=This session logs you into ${title}
251 + Exec=${command} $*
252 + TryExec=${command}
253 + Type=XSession
254 + EOF
255 +
256 + (
257 + # wrap the env here so that the 'insinto' call
258 + # doesn't corrupt the env of the caller
259 + insinto /usr/share/xsessions
260 + doins "${desktop}"
261 + )
262 +}
263 +
264 +# @FUNCTION: domenu
265 +# @USAGE: <menus>
266 +# @DESCRIPTION:
267 +# Install the list of .desktop menu files into the appropriate directory
268 +# (/usr/share/applications).
269 +domenu() {
270 + (
271 + # wrap the env here so that the 'insinto' call
272 + # doesn't corrupt the env of the caller
273 + local i j ret=0
274 + insinto /usr/share/applications
275 + for i in "$@" ; do
276 + if [[ -f ${i} ]] ; then
277 + doins "${i}"
278 + ((ret+=$?))
279 + elif [[ -d ${i} ]] ; then
280 + for j in "${i}"/*.desktop ; do
281 + doins "${j}"
282 + ((ret+=$?))
283 + done
284 + else
285 + ((++ret))
286 + fi
287 + done
288 + exit ${ret}
289 + )
290 +}
291 +
292 +# @FUNCTION: newmenu
293 +# @USAGE: <menu> <newname>
294 +# @DESCRIPTION:
295 +# Like all other new* functions, install the specified menu as newname.
296 +newmenu() {
297 + (
298 + # wrap the env here so that the 'insinto' call
299 + # doesn't corrupt the env of the caller
300 + insinto /usr/share/applications
301 + newins "$@"
302 + )
303 +}
304 +
305 +# @FUNCTION: _iconins
306 +# @INTERNAL
307 +# @DESCRIPTION:
308 +# function for use in doicon and newicon
309 +_iconins() {
310 + (
311 + # wrap the env here so that the 'insinto' call
312 + # doesn't corrupt the env of the caller
313 + local funcname=$1; shift
314 + local size dir
315 + local context=apps
316 + local theme=hicolor
317 +
318 + while [[ $# -gt 0 ]] ; do
319 + case $1 in
320 + -s|--size)
321 + if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
322 + size=${2%%x*}
323 + else
324 + size=${2}
325 + fi
326 + case ${size} in
327 + 16|22|24|32|36|48|64|72|96|128|192|256|512)
328 + size=${size}x${size};;
329 + scalable)
330 + ;;
331 + *)
332 + eerror "${size} is an unsupported icon size!"
333 + exit 1;;
334 + esac
335 + shift 2;;
336 + -t|--theme)
337 + theme=${2}
338 + shift 2;;
339 + -c|--context)
340 + context=${2}
341 + shift 2;;
342 + *)
343 + if [[ -z ${size} ]] ; then
344 + insinto /usr/share/pixmaps
345 + else
346 + insinto /usr/share/icons/${theme}/${size}/${context}
347 + fi
348 +
349 + if [[ ${funcname} == doicon ]] ; then
350 + if [[ -f $1 ]] ; then
351 + doins "${1}"
352 + elif [[ -d $1 ]] ; then
353 + shopt -s nullglob
354 + doins "${1}"/*.{png,svg}
355 + shopt -u nullglob
356 + else
357 + eerror "${1} is not a valid file/directory!"
358 + exit 1
359 + fi
360 + else
361 + break
362 + fi
363 + shift 1;;
364 + esac
365 + done
366 + if [[ ${funcname} == newicon ]] ; then
367 + newins "$@"
368 + fi
369 + ) || die
370 +}
371 +
372 +# @FUNCTION: doicon
373 +# @USAGE: [options] <icons>
374 +# @DESCRIPTION:
375 +# Install icon into the icon directory /usr/share/icons or into
376 +# /usr/share/pixmaps if "--size" is not set.
377 +# This is useful in conjunction with creating desktop/menu files.
378 +#
379 +# @CODE
380 +# options:
381 +# -s, --size
382 +# !!! must specify to install into /usr/share/icons/... !!!
383 +# size of the icon, like 48 or 48x48
384 +# supported icon sizes are:
385 +# 16 22 24 32 36 48 64 72 96 128 192 256 512 scalable
386 +# -c, --context
387 +# defaults to "apps"
388 +# -t, --theme
389 +# defaults to "hicolor"
390 +#
391 +# icons: list of icons
392 +#
393 +# example 1: doicon foobar.png fuqbar.svg suckbar.png
394 +# results in: insinto /usr/share/pixmaps
395 +# doins foobar.png fuqbar.svg suckbar.png
396 +#
397 +# example 2: doicon -s 48 foobar.png fuqbar.png blobbar.png
398 +# results in: insinto /usr/share/icons/hicolor/48x48/apps
399 +# doins foobar.png fuqbar.png blobbar.png
400 +# @CODE
401 +doicon() {
402 + _iconins ${FUNCNAME} "$@"
403 +}
404 +
405 +# @FUNCTION: newicon
406 +# @USAGE: [options] <icon> <newname>
407 +# @DESCRIPTION:
408 +# Like doicon, install the specified icon as newname.
409 +#
410 +# @CODE
411 +# example 1: newicon foobar.png NEWNAME.png
412 +# results in: insinto /usr/share/pixmaps
413 +# newins foobar.png NEWNAME.png
414 +#
415 +# example 2: newicon -s 48 foobar.png NEWNAME.png
416 +# results in: insinto /usr/share/icons/hicolor/48x48/apps
417 +# newins foobar.png NEWNAME.png
418 +# @CODE
419 +newicon() {
420 + _iconins ${FUNCNAME} "$@"
421 +}
422 +
423 +fi
424
425 diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
426 index 972a2138aad..7d4193e76b5 100644
427 --- a/eclass/eutils.eclass
428 +++ b/eclass/eutils.eclass
429 @@ -20,7 +20,7 @@ _EUTILS_ECLASS=1
430 # implicitly inherited (now split) eclasses
431 case ${EAPI:-0} in
432 0|1|2|3|4|5|6)
433 - inherit epatch estack ltprune multilib toolchain-funcs
434 + inherit desktop epatch estack ltprune multilib toolchain-funcs
435 ;;
436 esac
437
438 @@ -115,397 +115,6 @@ edos2unix() {
439 sed -i 's/\r$//' -- "$@" || die
440 }
441
442 -# @FUNCTION: make_desktop_entry
443 -# @USAGE: make_desktop_entry(<command>, [name], [icon], [type], [fields])
444 -# @DESCRIPTION:
445 -# Make a .desktop file.
446 -#
447 -# @CODE
448 -# binary: what command does the app run with ?
449 -# name: the name that will show up in the menu
450 -# icon: the icon to use in the menu entry
451 -# this can be relative (to /usr/share/pixmaps) or
452 -# a full path to an icon
453 -# type: what kind of application is this?
454 -# for categories:
455 -# https://specifications.freedesktop.org/menu-spec/latest/apa.html
456 -# if unset, function tries to guess from package's category
457 -# fields: extra fields to append to the desktop file; a printf string
458 -# @CODE
459 -make_desktop_entry() {
460 - [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable"
461 -
462 - local exec=${1}
463 - local name=${2:-${PN}}
464 - local icon=${3:-${PN}}
465 - local type=${4}
466 - local fields=${5}
467 -
468 - if [[ -z ${type} ]] ; then
469 - local catmaj=${CATEGORY%%-*}
470 - local catmin=${CATEGORY##*-}
471 - case ${catmaj} in
472 - app)
473 - case ${catmin} in
474 - accessibility) type="Utility;Accessibility";;
475 - admin) type=System;;
476 - antivirus) type=System;;
477 - arch) type="Utility;Archiving";;
478 - backup) type="Utility;Archiving";;
479 - cdr) type="AudioVideo;DiscBurning";;
480 - dicts) type="Office;Dictionary";;
481 - doc) type=Documentation;;
482 - editors) type="Utility;TextEditor";;
483 - emacs) type="Development;TextEditor";;
484 - emulation) type="System;Emulator";;
485 - laptop) type="Settings;HardwareSettings";;
486 - office) type=Office;;
487 - pda) type="Office;PDA";;
488 - vim) type="Development;TextEditor";;
489 - xemacs) type="Development;TextEditor";;
490 - esac
491 - ;;
492 -
493 - dev)
494 - type="Development"
495 - ;;
496 -
497 - games)
498 - case ${catmin} in
499 - action|fps) type=ActionGame;;
500 - arcade) type=ArcadeGame;;
501 - board) type=BoardGame;;
502 - emulation) type=Emulator;;
503 - kids) type=KidsGame;;
504 - puzzle) type=LogicGame;;
505 - roguelike) type=RolePlaying;;
506 - rpg) type=RolePlaying;;
507 - simulation) type=Simulation;;
508 - sports) type=SportsGame;;
509 - strategy) type=StrategyGame;;
510 - esac
511 - type="Game;${type}"
512 - ;;
513 -
514 - gnome)
515 - type="Gnome;GTK"
516 - ;;
517 -
518 - kde)
519 - type="KDE;Qt"
520 - ;;
521 -
522 - mail)
523 - type="Network;Email"
524 - ;;
525 -
526 - media)
527 - case ${catmin} in
528 - gfx)
529 - type=Graphics
530 - ;;
531 - *)
532 - case ${catmin} in
533 - radio) type=Tuner;;
534 - sound) type=Audio;;
535 - tv) type=TV;;
536 - video) type=Video;;
537 - esac
538 - type="AudioVideo;${type}"
539 - ;;
540 - esac
541 - ;;
542 -
543 - net)
544 - case ${catmin} in
545 - dialup) type=Dialup;;
546 - ftp) type=FileTransfer;;
547 - im) type=InstantMessaging;;
548 - irc) type=IRCClient;;
549 - mail) type=Email;;
550 - news) type=News;;
551 - nntp) type=News;;
552 - p2p) type=FileTransfer;;
553 - voip) type=Telephony;;
554 - esac
555 - type="Network;${type}"
556 - ;;
557 -
558 - sci)
559 - case ${catmin} in
560 - astro*) type=Astronomy;;
561 - bio*) type=Biology;;
562 - calc*) type=Calculator;;
563 - chem*) type=Chemistry;;
564 - elec*) type=Electronics;;
565 - geo*) type=Geology;;
566 - math*) type=Math;;
567 - physics) type=Physics;;
568 - visual*) type=DataVisualization;;
569 - esac
570 - type="Education;Science;${type}"
571 - ;;
572 -
573 - sys)
574 - type="System"
575 - ;;
576 -
577 - www)
578 - case ${catmin} in
579 - client) type=WebBrowser;;
580 - esac
581 - type="Network;${type}"
582 - ;;
583 -
584 - *)
585 - type=
586 - ;;
587 - esac
588 - fi
589 - local slot=${SLOT%/*}
590 - if [[ ${slot} == "0" ]] ; then
591 - local desktop_name="${PN}"
592 - else
593 - local desktop_name="${PN}-${slot}"
594 - fi
595 - local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop"
596 - #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop
597 -
598 - # Don't append another ";" when a valid category value is provided.
599 - type=${type%;}${type:+;}
600 -
601 - if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
602 - ewarn "As described in the Icon Theme Specification, icon file extensions are not"
603 - ewarn "allowed in .desktop files if the value is not an absolute path."
604 - icon=${icon%.*}
605 - fi
606 -
607 - cat <<-EOF > "${desktop}"
608 - [Desktop Entry]
609 - Name=${name}
610 - Type=Application
611 - Comment=${DESCRIPTION}
612 - Exec=${exec}
613 - TryExec=${exec%% *}
614 - Icon=${icon}
615 - Categories=${type}
616 - EOF
617 -
618 - if [[ ${fields:-=} != *=* ]] ; then
619 - # 5th arg used to be value to Path=
620 - ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}"
621 - fields="Path=${fields}"
622 - fi
623 - [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}"
624 -
625 - (
626 - # wrap the env here so that the 'insinto' call
627 - # doesn't corrupt the env of the caller
628 - insinto /usr/share/applications
629 - doins "${desktop}"
630 - ) || die "installing desktop file failed"
631 -}
632 -
633 -# @FUNCTION: _eutils_eprefix_init
634 -# @INTERNAL
635 -# @DESCRIPTION:
636 -# Initialized prefix variables for EAPI<3.
637 -_eutils_eprefix_init() {
638 - has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
639 -}
640 -
641 -# @FUNCTION: make_session_desktop
642 -# @USAGE: <title> <command> [command args...]
643 -# @DESCRIPTION:
644 -# Make a GDM/KDM Session file. The title is the file to execute to start the
645 -# Window Manager. The command is the name of the Window Manager.
646 -#
647 -# You can set the name of the file via the ${wm} variable.
648 -make_session_desktop() {
649 - [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1
650 - [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1
651 -
652 - local title=$1
653 - local command=$2
654 - local desktop=${T}/${wm:-${PN}}.desktop
655 - shift 2
656 -
657 - cat <<-EOF > "${desktop}"
658 - [Desktop Entry]
659 - Name=${title}
660 - Comment=This session logs you into ${title}
661 - Exec=${command} $*
662 - TryExec=${command}
663 - Type=XSession
664 - EOF
665 -
666 - (
667 - # wrap the env here so that the 'insinto' call
668 - # doesn't corrupt the env of the caller
669 - insinto /usr/share/xsessions
670 - doins "${desktop}"
671 - )
672 -}
673 -
674 -# @FUNCTION: domenu
675 -# @USAGE: <menus>
676 -# @DESCRIPTION:
677 -# Install the list of .desktop menu files into the appropriate directory
678 -# (/usr/share/applications).
679 -domenu() {
680 - (
681 - # wrap the env here so that the 'insinto' call
682 - # doesn't corrupt the env of the caller
683 - local i j ret=0
684 - insinto /usr/share/applications
685 - for i in "$@" ; do
686 - if [[ -f ${i} ]] ; then
687 - doins "${i}"
688 - ((ret+=$?))
689 - elif [[ -d ${i} ]] ; then
690 - for j in "${i}"/*.desktop ; do
691 - doins "${j}"
692 - ((ret+=$?))
693 - done
694 - else
695 - ((++ret))
696 - fi
697 - done
698 - exit ${ret}
699 - )
700 -}
701 -
702 -# @FUNCTION: newmenu
703 -# @USAGE: <menu> <newname>
704 -# @DESCRIPTION:
705 -# Like all other new* functions, install the specified menu as newname.
706 -newmenu() {
707 - (
708 - # wrap the env here so that the 'insinto' call
709 - # doesn't corrupt the env of the caller
710 - insinto /usr/share/applications
711 - newins "$@"
712 - )
713 -}
714 -
715 -# @FUNCTION: _iconins
716 -# @INTERNAL
717 -# @DESCRIPTION:
718 -# function for use in doicon and newicon
719 -_iconins() {
720 - (
721 - # wrap the env here so that the 'insinto' call
722 - # doesn't corrupt the env of the caller
723 - local funcname=$1; shift
724 - local size dir
725 - local context=apps
726 - local theme=hicolor
727 -
728 - while [[ $# -gt 0 ]] ; do
729 - case $1 in
730 - -s|--size)
731 - if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
732 - size=${2%%x*}
733 - else
734 - size=${2}
735 - fi
736 - case ${size} in
737 - 16|22|24|32|36|48|64|72|96|128|192|256|512)
738 - size=${size}x${size};;
739 - scalable)
740 - ;;
741 - *)
742 - eerror "${size} is an unsupported icon size!"
743 - exit 1;;
744 - esac
745 - shift 2;;
746 - -t|--theme)
747 - theme=${2}
748 - shift 2;;
749 - -c|--context)
750 - context=${2}
751 - shift 2;;
752 - *)
753 - if [[ -z ${size} ]] ; then
754 - insinto /usr/share/pixmaps
755 - else
756 - insinto /usr/share/icons/${theme}/${size}/${context}
757 - fi
758 -
759 - if [[ ${funcname} == doicon ]] ; then
760 - if [[ -f $1 ]] ; then
761 - doins "${1}"
762 - elif [[ -d $1 ]] ; then
763 - shopt -s nullglob
764 - doins "${1}"/*.{png,svg}
765 - shopt -u nullglob
766 - else
767 - eerror "${1} is not a valid file/directory!"
768 - exit 1
769 - fi
770 - else
771 - break
772 - fi
773 - shift 1;;
774 - esac
775 - done
776 - if [[ ${funcname} == newicon ]] ; then
777 - newins "$@"
778 - fi
779 - ) || die
780 -}
781 -
782 -# @FUNCTION: doicon
783 -# @USAGE: [options] <icons>
784 -# @DESCRIPTION:
785 -# Install icon into the icon directory /usr/share/icons or into
786 -# /usr/share/pixmaps if "--size" is not set.
787 -# This is useful in conjunction with creating desktop/menu files.
788 -#
789 -# @CODE
790 -# options:
791 -# -s, --size
792 -# !!! must specify to install into /usr/share/icons/... !!!
793 -# size of the icon, like 48 or 48x48
794 -# supported icon sizes are:
795 -# 16 22 24 32 36 48 64 72 96 128 192 256 512 scalable
796 -# -c, --context
797 -# defaults to "apps"
798 -# -t, --theme
799 -# defaults to "hicolor"
800 -#
801 -# icons: list of icons
802 -#
803 -# example 1: doicon foobar.png fuqbar.svg suckbar.png
804 -# results in: insinto /usr/share/pixmaps
805 -# doins foobar.png fuqbar.svg suckbar.png
806 -#
807 -# example 2: doicon -s 48 foobar.png fuqbar.png blobbar.png
808 -# results in: insinto /usr/share/icons/hicolor/48x48/apps
809 -# doins foobar.png fuqbar.png blobbar.png
810 -# @CODE
811 -doicon() {
812 - _iconins ${FUNCNAME} "$@"
813 -}
814 -
815 -# @FUNCTION: newicon
816 -# @USAGE: [options] <icon> <newname>
817 -# @DESCRIPTION:
818 -# Like doicon, install the specified icon as newname.
819 -#
820 -# @CODE
821 -# example 1: newicon foobar.png NEWNAME.png
822 -# results in: insinto /usr/share/pixmaps
823 -# newins foobar.png NEWNAME.png
824 -#
825 -# example 2: newicon -s 48 foobar.png NEWNAME.png
826 -# results in: insinto /usr/share/icons/hicolor/48x48/apps
827 -# newins foobar.png NEWNAME.png
828 -# @CODE
829 -newicon() {
830 - _iconins ${FUNCNAME} "$@"
831 -}
832 -
833 # @FUNCTION: strip-linguas
834 # @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
835 # @DESCRIPTION:
836 @@ -555,6 +164,14 @@ strip-linguas() {
837 export LINGUAS=${newls:1}
838 }
839
840 +# @FUNCTION: _eutils_eprefix_init
841 +# @INTERNAL
842 +# @DESCRIPTION:
843 +# Initialized prefix variables for EAPI<3.
844 +_eutils_eprefix_init() {
845 + has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
846 +}
847 +
848 # @FUNCTION: preserve_old_lib
849 # @USAGE: <libs to preserve> [more libs]
850 # @DESCRIPTION: