Gentoo Archives: gentoo-dev

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