Ports: .port_include.sh add install_icon function
This commit is contained in:
parent
23d5b99fbf
commit
b889bfe0f6
Notes:
sideshowbarker
2024-07-18 12:34:03 +09:00
Author: https://github.com/maxtrussell 🔰 Commit: https://github.com/SerenityOS/serenity/commit/b889bfe0f68 Pull-request: https://github.com/SerenityOS/serenity/pull/7834 Issue: https://github.com/SerenityOS/serenity/issues/7782 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/linusg
2 changed files with 37 additions and 0 deletions
|
@ -69,6 +69,7 @@ shift
|
|||
: "${launcher_name:=}"
|
||||
: "${launcher_category:=}"
|
||||
: "${launcher_command:=}"
|
||||
: "${icon_file:=}"
|
||||
|
||||
run_nocd() {
|
||||
echo "+ $@ (nocd)"
|
||||
|
@ -95,6 +96,36 @@ ensure_build() {
|
|||
fi
|
||||
}
|
||||
|
||||
install_main_icon() {
|
||||
if [ -n "$icon_file" ] && [ -n "$launcher_command" ]; then
|
||||
install_icon "$icon_file" "$launcher_command"
|
||||
fi
|
||||
}
|
||||
|
||||
install_icon() {
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Syntax: install_icon <icon> <launcher>"
|
||||
exit 1
|
||||
fi
|
||||
icon="$1"
|
||||
launcher="$2"
|
||||
|
||||
command -v convert >/dev/null 2>&1
|
||||
convert_exists=$?
|
||||
|
||||
command -v identify >/dev/null 2>&1
|
||||
identify_exists=$?
|
||||
|
||||
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)
|
||||
run convert "${icon}[${index}]" "app-${icon_size}.png"
|
||||
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
|
||||
}
|
||||
|
||||
install_main_launcher() {
|
||||
if [ -n "$launcher_name" ] && [ -n "$launcher_category" ] && [ -n "$launcher_command" ]; then
|
||||
install_launcher "$launcher_name" "$launcher_category" "$launcher_command"
|
||||
|
@ -413,6 +444,7 @@ do_install() {
|
|||
echo "Installing $port!"
|
||||
install
|
||||
install_main_launcher
|
||||
install_main_icon
|
||||
post_install
|
||||
addtodb "${1:-}"
|
||||
}
|
||||
|
|
|
@ -186,6 +186,11 @@ compressed file, it will be extracted.
|
|||
If a file is an `.asc` file (PGP signature) it will be imported into `gpg`'s
|
||||
keyring and can later be used for verification using [`auth_opts`](#auth_opts).
|
||||
|
||||
#### `icon_file`
|
||||
|
||||
The file to use for the port launcher icon. The icon file is assumed to have a
|
||||
16x16 as well as a 32x32 layer.
|
||||
|
||||
#### `installopts`
|
||||
|
||||
Options passed to `make install` in the default `install` function.
|
||||
|
|
Loading…
Add table
Reference in a new issue