mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-02 22:24:26 +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:
parent
101e4233b8
commit
46de51f467
|
@ -2,6 +2,7 @@
|
|||
Demos=/res/icons/16x16/demos.png
|
||||
Development=/res/icons/16x16/development.png
|
||||
Games=/res/icons/16x16/games.png
|
||||
Games/Puzzles=/res/icons/16x16/games.png
|
||||
Graphics=/res/icons/16x16/graphics.png
|
||||
Internet=/res/icons/16x16/internet.png
|
||||
Settings=/res/icons/16x16/settings.png
|
||||
|
|
|
@ -95,29 +95,45 @@ ensure_build() {
|
|||
fi
|
||||
}
|
||||
|
||||
install_launcher() {
|
||||
if [ -z "$launcher_name" ] || [ -z "${launcher_category}" ] || [ -z "${launcher_command}" ]; then
|
||||
return
|
||||
install_main_launcher() {
|
||||
if [ -n "$launcher_name" ] && [ -n "$launcher_category" ] && [ -n "$launcher_command" ]; then
|
||||
install_launcher "$launcher_name" "$launcher_category" "$launcher_command"
|
||||
fi
|
||||
script_name="${launcher_name,,}"
|
||||
script_name="${script_name// /}"
|
||||
mkdir -p $DESTDIR/usr/local/libexec
|
||||
cat >$DESTDIR/usr/local/libexec/$script_name <<SCRIPT
|
||||
}
|
||||
|
||||
install_launcher() {
|
||||
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
|
||||
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:-}"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -17,5 +17,4 @@ configure() {
|
|||
|
||||
install() {
|
||||
run cp cmatrix "${SERENITY_INSTALL_ROOT}/bin"
|
||||
install_launcher
|
||||
}
|
||||
|
|
|
@ -47,6 +47,4 @@ install() {
|
|||
)
|
||||
|
||||
ln -sf /usr/local/games/openttd $DESTDIR/usr/local/bin/openttd
|
||||
|
||||
install_launcher
|
||||
}
|
||||
|
|
|
@ -17,5 +17,4 @@ configure() {
|
|||
|
||||
install() {
|
||||
run make install
|
||||
install_launcher
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue