1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

Ports: Notify user of missing ImageMagick binaries

This commit is contained in:
Jelle Raaijmakers 2021-08-04 10:50:27 +02:00 committed by Linus Groh
parent 6f2640d031
commit 546af2d9ef

View file

@ -99,7 +99,8 @@ ensure_build() {
install_main_icon() { install_main_icon() {
if [ -n "$icon_file" ] && [ -n "$launcher_command" ]; then if [ -n "$icon_file" ] && [ -n "$launcher_command" ]; then
install_icon "$icon_file" "$launcher_command" local launcher_binary="${launcher_command%% *}"
install_icon "$icon_file" "${launcher_binary}"
fi fi
} }
@ -108,27 +109,29 @@ install_icon() {
echo "Syntax: install_icon <icon> <launcher>" echo "Syntax: install_icon <icon> <launcher>"
exit 1 exit 1
fi fi
icon="$1" local icon="$1"
launcher="$2" local launcher="$2"
command -v convert >/dev/null 2>&1 command -v convert >/dev/null || true
convert_exists=$? local convert_exists=$?
command -v identify >/dev/null || true
local identify_exists=$?
command -v identify >/dev/null 2>&1 if [ "${convert_exists}" != "0" ] || [ "${identify_exists}" != 0 ]; then
identify_exists=$? echo 'Unable to install icon: missing convert or identify, did you install ImageMagick?'
return
if [ "$convert_exists" == "0" ] && [ "$identify_exists" == "0" ]; then
for icon_size in "16x16" "32x32"; do
index=$(run identify "$icon" | grep "$icon_size" | grep -oE "\[[0-9]+\]" | tr -d "[]" | head -n1)
if [ -n "$index" ]; then
run convert "${icon}[${index}]" "app-${icon_size}.png"
else
run convert "$icon" -resize $icon_size "app-${icon_size}.png"
fi
done
run objcopy --add-section serenity_icon_s="app-16x16.png" "${DESTDIR}${launcher}"
run objcopy --add-section serenity_icon_m="app-32x32.png" "${DESTDIR}${launcher}"
fi fi
for icon_size in "16x16" "32x32"; do
index=$(run identify "$icon" | grep "$icon_size" | grep -oE "\[[0-9]+\]" | tr -d "[]" | head -n1)
if [ -n "$index" ]; then
run convert "${icon}[${index}]" "app-${icon_size}.png"
else
run convert "$icon" -resize $icon_size "app-${icon_size}.png"
fi
done
run objcopy --add-section serenity_icon_s="app-16x16.png" "${DESTDIR}${launcher}"
run objcopy --add-section serenity_icon_m="app-32x32.png" "${DESTDIR}${launcher}"
} }
install_main_launcher() { install_main_launcher() {