summaryrefslogtreecommitdiff
path: root/Ports
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
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')
-rwxr-xr-xPorts/.port_include.sh42
-rwxr-xr-xPorts/SDLPoP/package.sh1
-rwxr-xr-xPorts/Super-Mario/package.sh1
-rwxr-xr-xPorts/cmatrix/package.sh1
-rwxr-xr-xPorts/openttd/package.sh2
-rwxr-xr-xPorts/opentyrian/package.sh1
-rwxr-xr-xPorts/stpuzzles/package.sh4
7 files changed, 33 insertions, 19 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:-}"
}
diff --git a/Ports/SDLPoP/package.sh b/Ports/SDLPoP/package.sh
index 3c24fb87a7..ba36ab7e7e 100755
--- a/Ports/SDLPoP/package.sh
+++ b/Ports/SDLPoP/package.sh
@@ -18,5 +18,4 @@ configure() {
install() {
mkdir -p "${SERENITY_INSTALL_ROOT}/opt/PrinceOfPersia"
run cp -r prince data SDLPoP.ini "${SERENITY_INSTALL_ROOT}/opt/PrinceOfPersia"
- install_launcher
}
diff --git a/Ports/Super-Mario/package.sh b/Ports/Super-Mario/package.sh
index e09ba226ec..b4453d1208 100755
--- a/Ports/Super-Mario/package.sh
+++ b/Ports/Super-Mario/package.sh
@@ -18,5 +18,4 @@ configure() {
install() {
run mkdir -p "${SERENITY_INSTALL_ROOT}/opt/Super_Mario"
run cp -r uMario app.ico icon2.ico files "${SERENITY_INSTALL_ROOT}/opt/Super_Mario"
- install_launcher
}
diff --git a/Ports/cmatrix/package.sh b/Ports/cmatrix/package.sh
index ac6ca7bbe8..002e9e1b13 100755
--- a/Ports/cmatrix/package.sh
+++ b/Ports/cmatrix/package.sh
@@ -17,5 +17,4 @@ configure() {
install() {
run cp cmatrix "${SERENITY_INSTALL_ROOT}/bin"
- install_launcher
}
diff --git a/Ports/openttd/package.sh b/Ports/openttd/package.sh
index 2ac6889be1..22c7d09a46 100755
--- a/Ports/openttd/package.sh
+++ b/Ports/openttd/package.sh
@@ -47,6 +47,4 @@ install() {
)
ln -sf /usr/local/games/openttd $DESTDIR/usr/local/bin/openttd
-
- install_launcher
}
diff --git a/Ports/opentyrian/package.sh b/Ports/opentyrian/package.sh
index ecb7ba1fa7..454ff5ff0c 100755
--- a/Ports/opentyrian/package.sh
+++ b/Ports/opentyrian/package.sh
@@ -17,5 +17,4 @@ configure() {
install() {
run make install
- install_launcher
}
diff --git a/Ports/stpuzzles/package.sh b/Ports/stpuzzles/package.sh
index b30b02dfa7..11b9a537ae 100755
--- a/Ports/stpuzzles/package.sh
+++ b/Ports/stpuzzles/package.sh
@@ -13,4 +13,8 @@ configure() {
install() {
run make install
+
+ for puzzle in bridges cube dominosa fifteen filling flip flood galaxies guess inertia keen lightup loopy magnets map mines mosaic net netslide palisade pattern pearl pegs range rect samegame signpost singles sixteen slant solo tents towers tracks twiddle undead unequal unruly untangle; do
+ install_launcher "$puzzle" "Games/Puzzles" "/usr/local/bin/$puzzle"
+ done
}