-
Notifications
You must be signed in to change notification settings - Fork 93
/
build
executable file
·106 lines (90 loc) · 3.51 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Version 18
### User Variables
qtMinVer="5.12"
kfMinVer="5.68"
plasmaMinVer="5.18"
filenameTag="-plasma${plasmaMinVer}"
packageExt="plasmoid"
### Misc
startDir=$PWD
### Colors
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
# https://stackoverflow.com/questions/911168/how-can-i-detect-if-my-shell-script-is-running-through-a-pipe
TC_Red='\033[31m'; TC_Orange='\033[33m';
TC_LightGray='\033[90m'; TC_LightRed='\033[91m'; TC_LightGreen='\033[92m'; TC_Yellow='\033[93m'; TC_LightBlue='\033[94m';
TC_Reset='\033[0m'; TC_Bold='\033[1m';
if [ ! -t 1 ]; then
TC_Red=''; TC_Orange='';
TC_LightGray=''; TC_LightRed=''; TC_LightGreen=''; TC_Yellow=''; TC_LightBlue='';
TC_Bold=''; TC_Reset='';
fi
function echoTC() {
text="$1"
textColor="$2"
echo -e "${textColor}${text}${TC_Reset}"
}
function echoGray { echoTC "$1" "$TC_LightGray"; }
function echoRed { echoTC "$1" "$TC_Red"; }
function echoGreen { echoTC "$1" "$TC_LightGreen"; }
### Check QML Versions
# See https://zren.github.io/kde/versions/ for distro versions
if [ -f checkimports.py ]; then
python3 checkimports.py --qt="$qtMinVer" --kf="$kfMinVer" --plasma="$plasmaMinVer"
if [ $? == 1 ]; then
exit 1
fi
fi
### Translations
if [ -d "package/translate" ]; then
echoGray "[build] translate dir found, running merge."
(cd package/translate && sh ./merge)
(cd package/translate && sh ./build)
if type "git" > /dev/null; then
# echo "[build] Git found, running translation diff check."
if [ "$(git diff --stat package/translate)" != "" ]; then
echoRed "[build] Changed detected. Cancelling build."
git diff --stat .
exit 1
fi
else
echoGray "[build] Git not found, skipping translation diff check."
fi
fi
### Variables
packageNamespace=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="X-KDE-PluginInfo-Name"`
packageName="${packageNamespace##*.}" # Strip namespace (Eg: "org.kde.plasma.")
packageVersion=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="X-KDE-PluginInfo-Version"`
packageAuthor=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="X-KDE-PluginInfo-Author"`
packageAuthorEmail=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="X-KDE-PluginInfo-Email"`
packageWebsite=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="X-KDE-PluginInfo-Website"`
packageComment=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="Comment"`
### metadata.desktop => metadata.json
if command -v desktoptojson &> /dev/null ; then
genOutput=`desktoptojson --serviceType="plasma-applet.desktop" -i "$PWD/package/metadata.desktop" -o "$PWD/package/metadata.json"`
if [ "$?" != "0" ]; then
exit 1
fi
# Tabify metadata.json
sed -i '{s/ \{4\}/\t/g}' "$PWD/package/metadata.json"
fi
### *.plasmoid
if ! type "zip" > /dev/null; then
echoRed "[error] 'zip' command not found."
if type "zypper" > /dev/null; then
echoRed "[error] Opensuse detected, please run: ${TC_Bold}sudo zypper install zip"
fi
exit 1
fi
filename="${packageName}-v${packageVersion}${filenameTag}.${packageExt}"
rm ${packageName}-v*.${packageExt} # Cleanup
echoGray "[${packageExt}] Zipping '${filename}'"
(cd package \
&& zip -r $filename * \
&& mv $filename $startDir/$filename \
)
cd $startDir
echoGray "[${packageExt}] md5: $(md5sum $filename | awk '{ print $1 }')"
echoGray "[${packageExt}] sha256: $(sha256sum $filename | awk '{ print $1 }')"
### Done
cd $startDir