Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/Mk/Scripts/check-desktop-entries.sh
16461 views
1
#!/bin/sh
2
#
3
# MAINTAINER: [email protected]
4
5
set -e
6
set -o pipefail
7
8
. "${dp_SCRIPTSDIR}/functions.sh"
9
10
validate_env dp_CURDIR dp_ECHO_CMD dp_ECHO_MSG dp_EXPR dp_GREP dp_PKGNAME \
11
dp_SED dp_TR dp_MAKE
12
13
[ -n "${DEBUG_MK_SCRIPTS}" ] || [ -n "${DEBUG_MK_SCRIPTS_CHECK_DESKTOP_ENTRIES}" ] && set -x
14
15
set -u
16
17
# http://standards.freedesktop.org/menu-spec/menu-spec-latest.html
18
DESKTOP_CATEGORIES_MAIN='AudioVideo Audio Video Development Education Game
19
Graphics Network Office Science Settings System Utility'
20
DESKTOP_CATEGORIES_ADDITIONAL='Building Debugger IDE GUIDesigner Profiling
21
RevisionControl Translation Calendar ContactManagement Database Dictionary
22
Chart Email Finance FlowChart PDA ProjectManagement Presentation Spreadsheet
23
WordProcessor 2DGraphics VectorGraphics RasterGraphics 3DGraphics Scanning OCR
24
Photography Publishing Viewer TextTools DesktopSettings HardwareSettings
25
Printing PackageManager Dialup InstantMessaging Chat IRCClient Feed
26
FileTransfer HamRadio News P2P RemoteAccess Telephony TelephonyTools
27
VideoConference WebBrowser WebDevelopment Midi Mixer Sequencer Tuner TV
28
AudioVideoEditing Player Recorder DiscBurning ActionGame AdventureGame
29
ArcadeGame BoardGame BlocksGame CardGame KidsGame LogicGame RolePlaying Shooter
30
Simulation SportsGame StrategyGame Art Construction Music Languages
31
ArtificialIntelligence Astronomy Biology Chemistry ComputerScience
32
DataVisualization Economy Electricity Geography Geology Geoscience History
33
Humanities ImageProcessing Literature Maps Math NumericalAnalysis
34
MedicalSoftware Physics Robotics Spirituality Sports ParallelComputing
35
Amusement Archiving Compression Electronics Emulator Engineering FileTools
36
FileManager TerminalEmulator Filesystem Monitor Security Accessibility
37
Calculator Clock TextEditor Documentation Adult Core KDE GNOME MATE XFCE GTK Qt
38
Motif Java ConsoleOnly'
39
DESKTOP_CATEGORIES_RESERVED='Screensaver TrayIcon Applet Shell'
40
41
VALID_DESKTOP_CATEGORIES="${dp_VALID_DESKTOP_CATEGORIES} ${DESKTOP_CATEGORIES_MAIN} ${DESKTOP_CATEGORIES_ADDITIONAL} ${DESKTOP_CATEGORIES_RESERVED}"
42
43
if [ "$(${dp_EXPR} $# % 6)" -ne 0 ]; then
44
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: the DESKTOP_ENTRIES list must contain one or more groups of 6 elements"
45
exit 1
46
fi
47
48
num=0
49
50
while [ $# -ge 6 ]; do
51
num=$(${dp_EXPR} ${num} + 1)
52
entry="#${num}"
53
54
Name="${1}"
55
#Comment="${2}" # Not Used
56
Icon="${3}"
57
Exec="${4}"
58
Categories="${5}"
59
StartupNotify="${6}"
60
61
shift 6
62
63
if [ -n "${Exec}" ]; then
64
entry="${entry} (${Exec})"
65
elif [ -n "${Name}" ]; then
66
entry="${entry} (${Name})"
67
fi
68
69
if [ -z "${Name}" ]; then
70
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 1 (Name) is empty"
71
exit 1
72
fi
73
74
if ${dp_EXPR} '(' "${Icon}" : '.*\.xpm$' ')' '|' '(' "${Icon}" : '.*\.png$' ')' '|' '(' "${Icon}" : '.*\.svg$' ')' > /dev/null; then
75
if ! echo "${Icon}" | ${dp_GREP} -qe '^/' ; then
76
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile warning: in desktop entry ${entry}: field 3 (Icon) should be either absolute path or icon name without extension if installed icons follow Icon Theme Specification"
77
fi
78
fi
79
80
if [ -z "${Exec}" ]; then
81
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 4 (Exec) is empty"
82
exit 1
83
fi
84
85
if [ -n "${Categories}" ]; then
86
for c in $(${dp_ECHO_CMD} "${Categories}" | ${dp_TR} ';' ' '); do
87
if ! ${dp_ECHO_CMD} "${VALID_DESKTOP_CATEGORIES}" | ${dp_GREP} -wq "${c}"; then
88
${dp_ECHO_CMD} "${dp_PKGNAME}: Makefile warning: in desktop entry ${entry}: category ${c} is not a valid desktop category"
89
fi
90
done
91
92
if ! ${dp_ECHO_CMD} "${Categories}" | ${dp_GREP} -Eq "$(${dp_ECHO_CMD} "${DESKTOP_CATEGORIES_MAIN}" | ${dp_SED} -E 's,[[:blank:]]+,\|,g')"; then
93
${dp_ECHO_CMD} "${dp_PKGNAME}: Makefile warning: in desktop entry ${entry}: field 5 (Categories) must contain at least one main desktop category (make -VDESKTOP_CATEGORIES_MAIN)"
94
fi
95
96
if ! ${dp_EXPR} "${Categories}" : '.*;$' > /dev/null; then
97
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 5 (Categories) does not end with a semicolon"
98
exit 1
99
fi
100
else
101
if [ -z "$(cd "${dp_CURDIR}" && ${dp_MAKE} desktop-categories)" ]; then
102
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 5 (Categories) is empty and could not be deduced from the CATEGORIES variable"
103
exit 1
104
fi
105
fi
106
107
if [ "${StartupNotify}" != "true" ] && [ "${StartupNotify}" != "false" ] && [ -n "${StartupNotify}" ]; then
108
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 6 (StartupNotify) is not \"true\", \"false\" or \"\"(empty)"
109
exit 1
110
fi
111
done
112
113