summaryrefslogtreecommitdiff
path: root/Ports/.port_include.sh
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-06-03 23:39:01 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-04 09:38:25 +0200
commit46de51f467256ca7e030a4a40deed4589f50cc60 (patch)
treed151e3d27ac97b774547d96650bf6040820504dd /Ports/.port_include.sh
parent101e4233b8ac27ecfc38bd41c3e5a063b4563fcd (diff)
downloadserenity-46de51f467256ca7e030a4a40deed4589f50cc60.zip
Ports: Create launchers for the stpuzzles port
This changes the .port_include.sh script so that ports can more easily create more than one launcher by making the install_launcher function available to the port's package.sh script. This creates launchers for the stpuzzles port in the Games/Puzzles category.
Diffstat (limited to 'Ports/.port_include.sh')
-rwxr-xr-xPorts/.port_include.sh42
1 files changed, 29 insertions, 13 deletions
diff --git a/Ports/.port_include.sh b/Ports/.port_include.sh
index c944dc9c19..16d9c78ae3 100755
--- a/Ports/.port_include.sh
+++ b/Ports/.port_include.sh
@@ -95,29 +95,45 @@ ensure_build() {
fi
}
+install_main_launcher() {
+ if [ -n "$launcher_name" ] && [ -n "$launcher_category" ] && [ -n "$launcher_command" ]; then
+ install_launcher "$launcher_name" "$launcher_category" "$launcher_command"
+ fi
+}
+
install_launcher() {
- if [ -z "$launcher_name" ] || [ -z "${launcher_category}" ] || [ -z "${launcher_command}" ]; then
- return
+ if [ "$#" -lt 3 ]; then
+ echo "Syntax: install_launcher <name> <category> <command>"
+ exit 1
fi
- script_name="${launcher_name,,}"
- script_name="${script_name// /}"
- mkdir -p $DESTDIR/usr/local/libexec
- cat >$DESTDIR/usr/local/libexec/$script_name <<SCRIPT
+ launcher_name="$1"
+ launcher_category="$2"
+ launcher_command="$3"
+ launcher_filename="${launcher_name,,}"
+ launcher_filename="${launcher_filename// /}"
+ case "$launcher_command" in
+ *\ *)
+ mkdir -p $DESTDIR/usr/local/libexec
+ launcher_executable="/usr/local/libexec/$launcher_filename"
+ cat >"$DESTDIR/$launcher_executable" <<SCRIPT
#!/bin/sh
set -e
exec $(printf '%q ' $launcher_command)
SCRIPT
- chmod +x $DESTDIR/usr/local/libexec/$script_name
-
- chmod +x $DESTDIR/usr/local/libexec
+ chmod +x "$DESTDIR/$launcher_executable"
+ ;;
+ *)
+ launcher_executable="$launcher_command"
+ ;;
+ esac
mkdir -p $DESTDIR/res/apps
- cat >$DESTDIR/res/apps/$script_name.af <<CONFIG
+ cat >$DESTDIR/res/apps/$launcher_filename.af <<CONFIG
[App]
Name=$launcher_name
-Executable=/usr/local/libexec/$script_name
+Executable=$launcher_executable
Category=$launcher_category
CONFIG
- unset script_name
+ unset launcher_filename
}
# Checks if a function is defined. In this case, if the function is not defined in the port's script, then we will use our defaults. This way, ports don't need to include these functions every time, but they can override our defaults if needed.
func_defined() {
@@ -285,7 +301,6 @@ func_defined build || build() {
}
func_defined install || install() {
run make DESTDIR=$DESTDIR $installopts install
- install_launcher
}
func_defined post_install || post_install() {
echo
@@ -397,6 +412,7 @@ do_install() {
ensure_build
echo "Installing $port!"
install
+ install_main_launcher
post_install
addtodb "${1:-}"
}