SIGs/Games/Packaging

From FedoraProject

Jump to: navigation, search


Fedora Games Packaging guidelines

In addition to the standard Packaging/Guidelines , there are a few other strong recommendations when packaging games.

#!cplusplus


/* Keep a global pointer to the scoreboard file.  I know, global vars are
* ugly and should be avoided.  Your application might do this differently.
* This is just an example.
*/
extern FILE *scoreboard_filehandle;

/*
* Notice that we deal with dropping setgid immediately in main() after opening
* the scoreboard file, and before doing _anything_ else.  This minimizes the amount
* of code that is run setuid/setgid.
*/
int main(int argc, char **argv) {
gid_t realgid;
uid_t realuid;

/* Open the scoreboard file.  This could be NULL!  Users of this
* variable must check before using and not bother writing a
* scoreboard if it is null.
*
* The file is opened with mode "r+" to preserve the existing contents.
* This allows the program to first read the scoreboard and then write
* it out again with new values.  Just make sure you don't close() the file
* after reading it or you won't be able to write to it again.
*/
scoreboard_filehandle=fopen(SCOREBOARDFILE, "r+");

/* Figure out who we really are.
*/
realgid = getgid();
realuid = getuid();

/* This is where we drop our setuid/setgid privileges.
*/
if (setresgid(-1, realgid, realgid) != 0) {
perror("Could not drop setgid privileges.  Aborting.");
exit(1);
}
if (setresuid(-1, realuid, realuid) != 0) {
perror("Could not drop setuid privileges.  Aborting.");
exit(1);
}
/* ...Continue setting up the game... */

1. creates a directory for the game in the user's home 1. populates it with symlinks to the files in the game dir under /usr/share/%{name} 1. cd into that dir and run the real binary Such a script could look like this :

#!/bin/sh
GAME_LOCAL_DIR=$HOME/.mygame
GAME_DATA_DIR=/usr/share/mygame
GAME_EXECUTABLE=/usr/libexec/mygame/mygame
mkdir -p $GAME_LOCAL_DIR
cd $GAME_LOCAL_DIR
for dir in techs data maps tilesets; do
ln -snf $GAME_DATA_DIR/$dir $dir
done
test -d savegames || mkdir savegames
test -e mygame.ini || cp $GAME_DATA_DIR/mygame.ini mygame.ini
exec $GAME_EXECUTABLE "$@"

OpenGL Wrapper

What you must do is: 1. Add: Requires: opengl-games-utils 1. Add to %install:

ln -s opengl-game-wrapper.sh $RPM_BUILD_ROOT%{_bindir}/%{name}-wrapper

1. Add %{_bindir}/%{name}-wrapper to %files 1. Change the .desktop file Exec entry from %{name} to %{name}-wrapper

This all assumes your main binary name == %{name}, otherwise adapt as necessary.

If you already have a wrapper script for one reason or the other, you can incorperate the checkDriOk function directly into your wrapper, no need todo a wrapper wrapper, see vegastrike's vegastrike-wrapper.sh CVS file as example.

Games Documentation

After importing a game, there are a couple of extra steps that you should take: