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

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.
This commit is contained in:
Gunnar Beutner 2021-06-03 23:39:01 +02:00 committed by Andreas Kling
parent 101e4233b8
commit 46de51f467
8 changed files with 35 additions and 20 deletions

View file

@ -2,6 +2,7 @@
Demos=/res/icons/16x16/demos.png Demos=/res/icons/16x16/demos.png
Development=/res/icons/16x16/development.png Development=/res/icons/16x16/development.png
Games=/res/icons/16x16/games.png Games=/res/icons/16x16/games.png
Games/Puzzles=/res/icons/16x16/games.png
Graphics=/res/icons/16x16/graphics.png Graphics=/res/icons/16x16/graphics.png
Internet=/res/icons/16x16/internet.png Internet=/res/icons/16x16/internet.png
Settings=/res/icons/16x16/settings.png Settings=/res/icons/16x16/settings.png

View file

@ -95,29 +95,45 @@ ensure_build() {
fi fi
} }
install_launcher() { install_main_launcher() {
if [ -z "$launcher_name" ] || [ -z "${launcher_category}" ] || [ -z "${launcher_command}" ]; then if [ -n "$launcher_name" ] && [ -n "$launcher_category" ] && [ -n "$launcher_command" ]; then
return install_launcher "$launcher_name" "$launcher_category" "$launcher_command"
fi fi
script_name="${launcher_name,,}" }
script_name="${script_name// /}"
mkdir -p $DESTDIR/usr/local/libexec install_launcher() {
cat >$DESTDIR/usr/local/libexec/$script_name <<SCRIPT if [ "$#" -lt 3 ]; then
echo "Syntax: install_launcher <name> <category> <command>"
exit 1
fi
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 #!/bin/sh
set -e set -e
exec $(printf '%q ' $launcher_command) exec $(printf '%q ' $launcher_command)
SCRIPT SCRIPT
chmod +x $DESTDIR/usr/local/libexec/$script_name chmod +x "$DESTDIR/$launcher_executable"
;;
chmod +x $DESTDIR/usr/local/libexec *)
launcher_executable="$launcher_command"
;;
esac
mkdir -p $DESTDIR/res/apps mkdir -p $DESTDIR/res/apps
cat >$DESTDIR/res/apps/$script_name.af <<CONFIG cat >$DESTDIR/res/apps/$launcher_filename.af <<CONFIG
[App] [App]
Name=$launcher_name Name=$launcher_name
Executable=/usr/local/libexec/$script_name Executable=$launcher_executable
Category=$launcher_category Category=$launcher_category
CONFIG 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. # 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() { func_defined() {
@ -285,7 +301,6 @@ func_defined build || build() {
} }
func_defined install || install() { func_defined install || install() {
run make DESTDIR=$DESTDIR $installopts install run make DESTDIR=$DESTDIR $installopts install
install_launcher
} }
func_defined post_install || post_install() { func_defined post_install || post_install() {
echo echo
@ -397,6 +412,7 @@ do_install() {
ensure_build ensure_build
echo "Installing $port!" echo "Installing $port!"
install install
install_main_launcher
post_install post_install
addtodb "${1:-}" addtodb "${1:-}"
} }

View file

@ -18,5 +18,4 @@ configure() {
install() { install() {
mkdir -p "${SERENITY_INSTALL_ROOT}/opt/PrinceOfPersia" mkdir -p "${SERENITY_INSTALL_ROOT}/opt/PrinceOfPersia"
run cp -r prince data SDLPoP.ini "${SERENITY_INSTALL_ROOT}/opt/PrinceOfPersia" run cp -r prince data SDLPoP.ini "${SERENITY_INSTALL_ROOT}/opt/PrinceOfPersia"
install_launcher
} }

View file

@ -18,5 +18,4 @@ configure() {
install() { install() {
run mkdir -p "${SERENITY_INSTALL_ROOT}/opt/Super_Mario" run mkdir -p "${SERENITY_INSTALL_ROOT}/opt/Super_Mario"
run cp -r uMario app.ico icon2.ico files "${SERENITY_INSTALL_ROOT}/opt/Super_Mario" run cp -r uMario app.ico icon2.ico files "${SERENITY_INSTALL_ROOT}/opt/Super_Mario"
install_launcher
} }

View file

@ -17,5 +17,4 @@ configure() {
install() { install() {
run cp cmatrix "${SERENITY_INSTALL_ROOT}/bin" run cp cmatrix "${SERENITY_INSTALL_ROOT}/bin"
install_launcher
} }

View file

@ -47,6 +47,4 @@ install() {
) )
ln -sf /usr/local/games/openttd $DESTDIR/usr/local/bin/openttd ln -sf /usr/local/games/openttd $DESTDIR/usr/local/bin/openttd
install_launcher
} }

View file

@ -17,5 +17,4 @@ configure() {
install() { install() {
run make install run make install
install_launcher
} }

View file

@ -13,4 +13,8 @@ configure() {
install() { install() {
run make 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
} }