Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[ebuild] Adventures on Planet Zephulor
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1896
Location: 127.0.0.1

PostPosted: Fri Jun 16, 2006 5:51 pm    Post subject: [ebuild] Adventures on Planet Zephulor Reply with quote

Salut,

Un petit ebuild, pour un jeu 2D écrit en python : Adventures on Planet Zephulor :mrgreen:

Le site : http://www.hollowworks.com/apz/

L'ebuild : zephulor-20041023.ebuild
Code:

# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Header: $

inherit eutils games

MY_PN="${PN}-source"
DESCRIPTION="Adventures on Planet Zephulor, a game written in python"
HOMEPAGE="http://www.hollowworks.com/apz/"
SRC_URI="http://www.hollowworks.com/downloads/adventuresonplanetzephulor/files/${MY_PN}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE=""

DEPEND=""
RDEPEND="dev-python/pygame"

S="${WORKDIR}/${MY_PN}"

src_install() {
   insinto "${GAMES_DATADIR}/${PN}"
   doins -r "${S}/data"
   doins -r "${S}/maptool"

   for GameFile in *.py; do
      doins "${S}/${GameFile}"
   done

   dodoc COPYING.txt LGPL.txt README.txt manual.txt \
   readme-chared.txt readme-maploadtool.txt readme-scnloadtool.txt
   newdoc maptool/manual.txt maptool-manual.txt

   rm ${D}/${GAMES_DATADIR}/${PN}/maptool/COPYING.txt \
   ${D}/${GAMES_DATADIR}/${PN}/maptool/manual.txt

   newgamesbin "${FILESDIR}"/wrapper ${PN}

   local game_dir=${GAMES_DATADIR}/${PN}

   sed -i \
      -e "s:GAME_DIR:${game_dir}:" "${D}"/${GAMES_BINDIR}/${PN} \
      || die "sed ${GAMES_BINDIR}/${PN} failed"

   doicon ${FILESDIR}/${PN}.png
   make_desktop_entry ${PN} 'Adventures on Planet Zephulor' ${PN}.png

   prepgamesdirs
}

Le wrapper du jeu : wrapper
Code:

#!/bin/bash

cd GAME_DIR
exec python -OO zephulor.py $@

L'icône : zephulor.png

La disposition des fichiers :
Quote:

$ ls -R /usr/local/portage/games-arcade/zephulor/
/usr/local/portage/games-arcade/zephulor/:
files zephulor-20041023.ebuild

/usr/local/portage/games-arcade/zephulor/files:
wrapper zephulor.png

En bleu les répertoires que vous devez créer.
Une fois les fichiers en place, un digest suivi d'un emerge :
Code:

# ebuild /usr/local/portage/games-arcade/zephulor/zephulor-20041023.ebuild digest
# emerge zephulor -pv


Testé avec succès sous ~x86, il reste à faire les wrappers pour les exécutables suivants :

  • maploadtool.py
  • scnloadtool.py
  • maptool.py
  • chared.py
  • mapload/main.py
  • mapload/chared.py

Je ne sais pas trop à quoi cela correspond, il doit y avoir un editeur de map, et d'autres choses, mais je n'ai pas testé : si quelqu'un trouve la motivation :wink:

Une fois le jeu lancé, vous appuyez une fois sur échap pour faire apparaître le menu, et faire quelque réglages à l'aide la souris.
Vala vala...
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1896
Location: 127.0.0.1

PostPosted: Sat Jun 24, 2006 10:53 am    Post subject: Reply with quote

Yop,

Deuxième version de l'ebuild : tant qu'à faire, autant le terminer proprement.

- ajout d'une fonction pour la création de wrappers spécifiques à ce jeu.
- ajout d'un useflag tools, permettant l'installation ou non des outils d'édition : ces outils ne sont pas installés par défaut, car l'un deux requiert le support tcl-tk de python : on ne va quand même pas demander de recompiler python juste pour çà :)

Du coup, l'ebuild se complique légèrement.

Code:

# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Header: $

inherit eutils games

MY_PN="${PN}-source"
DESCRIPTION="Adventures on Planet Zephulor : little 2D game, written in python"
HOMEPAGE="http://www.hollowworks.com/apz/"
SRC_URI="http://www.hollowworks.com/downloads/adventuresonplanetzephulor/files/${MY_PN}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE="tools"

DEPEND=""
RDEPEND="dev-python/pygame"

S="${WORKDIR}/${MY_PN}"

# Create new wrapper for zephulor
#
# Usage: new_zephulor_wrapper <BINARY> [<BINARY_DIRECTORY>]
#    ex: new_zephulor_wrapper main maptool
#    ex: new_zephulor_wrapper zephulor
#
# Notes: - BINARY_DIRECTORY is optional, but if given,
#          it must be relative to ${GAMES_DATADIR}/${PN}, and
#          must be a subdir of ${GAMES_DATADIR}/${PN}
#        - you must NOT specify .py for BINARY
#        - wrapper's name is defined with the 3 first lines
#          of the function : warning : only one wrapper by subdir is allowed !
new_zephulor_wrapper() {
   local WRAPPER_NAME=${PN}
   [[ "${1}" != "${PN}" ]] && WRAPPER_NAME=${PN}-${1}
   [[ ! -z ${2} ]] && WRAPPER_NAME=${PN}-${2}
   
   local ZEPHULOR_DATADIR=${GAMES_DATADIR}/${PN}
   [[ ! -z ${2} ]] && ZEPHULOR_DATADIR=${ZEPHULOR_DATADIR}/${2}

   local THIS_WRAPPER_PATH=${GAMES_BINDIR}/${WRAPPER_NAME}
   
   einfo "creating ${WRAPPER_NAME} wrapper ..."
   newgamesbin "${FILESDIR}"/wrapper ${WRAPPER_NAME}

   sed -i \
      -e "s:BINARY_PATH:${ZEPHULOR_DATADIR}:" ${D}/${THIS_WRAPPER_PATH} \
      || die "sed ${THIS_WRAPPER_PATH} failed"
   
   sed -i \
      -e "s:BINARY:${1}:" ${D}/${THIS_WRAPPER_PATH} \
      || die "sed ${THIS_WRAPPER_PATH} failed"
}

pkg_setup() {
   if use tools && ! built_with_use virtual/python tcltk; then
      eerror "Zephulor's tools need python's tcltk support."
      die "Please rebuild python with tcltk support."
   fi

   if ! use tools; then
      einfo "Editor tools are available, but are not installed by default."
      einfo "To have them, please rebuild ${PN} with the \"tools\" useflag."
   fi

   games_pkg_setup
}

src_install() {
   insinto "${GAMES_DATADIR}/${PN}"
   doins -r "${S}/data"

   # if tools useflag not set, we remove tools binaries at the end
   for GameFile in *.py; do
      doins "${S}/${GameFile}"
   done

   dodoc COPYING.txt LGPL.txt README.txt manual.txt

   # game wrapper
   new_zephulor_wrapper ${PN}

   doicon ${FILESDIR}/${PN}.png
   make_desktop_entry ${PN} 'Adventures on Planet Zephulor' ${PN}.png

   if use tools; then
      # tools wrappers
      for BINARY in chared scnloadtool maploadtool; do
         new_zephulor_wrapper ${BINARY}
      done

      # map editor wrapper
      new_zephulor_wrapper main maptool

      insinto "${GAMES_DATADIR}/${PN}"
      doins -r "${S}/maptool"

      rm ${D}/${GAMES_DATADIR}/${PN}/maptool/COPYING.txt \
      ${D}/${GAMES_DATADIR}/${PN}/maptool/manual.txt

      dodoc readme-chared.txt readme-maploadtool.txt readme-scnloadtool.txt
      newdoc maptool/manual.txt maptool-manual.txt

      ewarn
      ewarn "Please read ${PN}'s documentation before using tools wrappers."
      ewarn

   else
      # tools useflag not set, removing binaries
      cd ${D}/${GAMES_DATADIR}/${PN}
      rm chared.py scnloadtool.py maploadtool.py

   fi

   prepgamesdirs
}


Et la base des wrappers :
Code:

#!/bin/bash

cd BINARY_PATH
exec python -OO BINARY.py $@


J'ai testé sur ~x86 et x86, çà a l'air de rouler. M'en vais voir le projet sunrise, j'ai un autre ebuild en préparation 8)
Back to top
View user's profile Send private message
SnowBear
l33t
l33t


Joined: 03 Sep 2005
Posts: 773
Location: France - Bordeaux

PostPosted: Tue Jun 27, 2006 9:29 am    Post subject: Reply with quote

Salut,
je viens de tester ton ebuild et je suis tombé sur une erreur au lancement :
Code:
snowbear@palouma ~ $ zephulor
/usr/games/bin/zephulor: line 3: cd: GAME_DIR: Aucun fichier ou répertoire de ce type
python: can't open file 'zephulor.py': [Errno 2] No such file or directory



Mes fichiers d'emerge :
Code:
palouma ~ # ls -lR /usr/local/portage/games-arcade/zephulor/
/usr/local/portage/games-arcade/zephulor/:
total 12
drwxr-xr-x 2 root root 4096 jun 27 11:18 files
-rw-r--r-- 1 root root 1720 jun 27 11:24 Manifest
-rw-r--r-- 1 root root 3355 jun 27 11:20 zephulor-20041023.ebuild

/usr/local/portage/games-arcade/zephulor/files:
total 12
-rw-r--r-- 1 root root  250 jun 27 11:17 digest-zephulor-20041023
-rwxr-xr-x 1 root root   87 jun 27 11:23 wrapper
-rw-r--r-- 1 root root 3367 jun 27 11:18 zephulor.png


Contenu du wrapper :
Code:
palouma ~ # cat /usr/local/portage/games-arcade/zephulor/files/wrapper
#!/bin/bash

cd GAME_DIR
exec python -OO zephulor.py $@
exec python -OO BINARY.py $@

En modifiant le wrapper comme ceci :
Code:
palouma zephulor # cat /usr/local/portage/games-arcade/zephulor/files/wrapper
#!/bin/bash

cd ${GAME_DIR}
exec python -OO zephulor.py $@
exec python -OO BINARY.py $@

En mettant GAME_DIR comme une variable j'obtient l'erreur suivante à l'exécution en utilisateur normal :
Code:
snowbear@palouma ~ $ zephulor
python: can't open file 'zephulor.py': [Errno 2] No such file or directory


J'en conclu que la variable est "vide" ?
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1896
Location: 127.0.0.1

PostPosted: Tue Jun 27, 2006 9:45 am    Post subject: Reply with quote

Le fichier wrapper dans l'overlay devrait contenir ceci :
Code:

$ cat /usr/local/portage/games-arcade/zephulor/files/wrapper
#!/bin/bash

cd BINARY_PATH
exec python -OO BINARY.py $@

et non :
Code:

# cat /usr/local/portage/games-arcade/zephulor/files/wrapper
#!/bin/bash

cd GAME_DIR
exec python -OO zephulor.py $@
exec python -OO BINARY.py $@

Ensuite, réemerge, et çà devrait fonctionner.
Back to top
View user's profile Send private message
SnowBear
l33t
l33t


Joined: 03 Sep 2005
Posts: 773
Location: France - Bordeaux

PostPosted: Tue Jun 27, 2006 9:57 am    Post subject: Reply with quote

:oops:
En fait j'ai fait un mix des 2 wrapper :x

Effectivement ça marche mieu comme ça :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum