Pathologicalのspecファイルを作った

Fedora8にPathologicalをインストールするではpacoを使ってインストールしたが、Fedoraのパッケージの方針と整合性が取れていないし、Debianのパッチを当てると開始ステージを選択出来るので、それらの修正を含めてFedora8用のspecファイルを書いてみた。
pathological.spec:

Summary: An enriched clone of the game "Logical" by Rainbow Arts
Name: pathological
Version: 1.1.3
Release: 1.tks8
License: GPLv2+
Group: Amusements/Games
URL: http://pathological.sourceforge.net/

Source: http://jaist.dl.sourceforge.net/sourceforge/pathological/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Patch:     %{name}.patch
BuildRequires: netpbm-progs
Requires: python, pygame

%description
Pathological is an enriched clone of the game "Logical" by Rainbow Arts. To
solve a level, fill each wheel with four marbles of matching color. Various
board elements such as teleporters, switches, filters, etc., make the game
interesting and challenging. New levels can be created using your favorite
text editor. 

%prep %{__rm} -rf %{buildroot}
%setup -q
%patch -p1
sed -i 's@/usr/games@/usr/bin@g;s@/X11R6/include/X11@/share@g;s@/var/games@/var/lib/games@g' Makefile
sed -i "s/^DESTDIR =.*/DESTDIR=${RPM_BUILD_ROOT//\//\\/}/g;" Makefile
%build
%{__make} %{?_smp_mflags}

%install
%{__rm} -rf %{buildroot}
mkdir -p $RPM_BUILD_ROOT/usr/bin
make install
mkdir -p %{buildroot}%{_datadir}/applications
cat <<EOF >%{buildroot}%{_datadir}/applications/pathological.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Pathological
Icon=pathological.xpm
GenericName=A puzzle game involving paths and marbles
Exec=pathological
Categories=Game;LogicGame;
EOF

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc LICENSE README TODO
%{_datadir}/pixmaps/pathological.xpm
%{_bindir}/pathological
%attr(02551,root,games)%{_libdir}/pathological/bin/write-highscores
%{_docdir}/pathological/
%{_datadir}/games/pathological
%{_mandir}/man6/pathological.6.gz
%attr(-,games,games)%config(noreplace)%{_localstatedir}/lib/games/pathological_scores
%{_datadir}/applications/pathological.desktop

%changelog
* Thu Apr 17 2008 tks 1.1.3-1.tks8
- Initial release.

pathological.patch:

--- pathological-1.1.3.orig/pathological.py
+++ pathological-1.1.3/pathological.py
@@ -1,6 +1,8 @@
 #!/usr/bin/python
+# -*- coding: iso-8859-1 -*-
 """
 Copyright (C) 2003  John-Paul Gignac
+          (C) 2004  Joe Wreschnig
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -1562,7 +1564,7 @@
 		pygame.display.update( popup_rc[1])
 
 class Game:
-	def __init__(self, screen, circuit, highscores):
+	def __init__(self, screen, circuit, highscores, level = 0):
 		self.screen = screen
 		self.circuit = circuit
 		self.highscores = highscores
@@ -1578,7 +1580,7 @@
 		f.close()
 		self.numlevels = j / vert_tiles
 
-		self.level = 0
+		self.level = level
 		self.score = 0
 		self.lives = initial_lives
 
@@ -1829,6 +1831,7 @@
 class IntroScreen:
 	menu = ("Start Game", "High Scores", "Fullscreen:", "Music:",
 		"Sound Effects:", "Quit Game")
+	start_level = 1
 	menu_width = 240
 	menu_pos = ((800 - menu_width)/2, 145)
 	menu_font_height = 32
@@ -1914,6 +1917,14 @@
 			self.screen.blit( menu_option, (self.menu_pos[0], y))
 			y += self.menu_font_height
 
+		levelt = self.menu_font.render("(Lvl. %d)" %
+					       IntroScreen.start_level,
+					       1, self.menu_color)
+		lt_r = levelt.get_rect()
+		lt_r.right = self.menu_pos[0] + self.menu_option_left + 40
+		lt_r.top = self.menu_pos[1]
+		self.screen.blit(levelt, lt_r)
+
 		if fullscreen: offon = 'On'
 		else: offon = 'Off'
 		offon = self.menu_font.render( offon, 1, self.menu_color)
@@ -1966,6 +1977,15 @@
 		self.curpage = 1
 		self.draw_menu()
 
+	def inc_level(self):
+		if (IntroScreen.start_level <
+		    max([s[2] for s in self.highscores.scores])):
+			IntroScreen.start_level += 1
+
+	def dec_level(self):
+		if IntroScreen.start_level > 1:
+			IntroScreen.start_level -= 1
+
 	def do(self, show_highscores=0):
 		self.scroller_pos = -self.scroller_rect[2]
 
@@ -2028,7 +2048,15 @@
 						self.draw_menu()
 					elif event.key == K_SPACE or event.key == K_RETURN:
 						rc = self.menu_select( self.menu_cursor)
-						if rc < 1: return rc
+						if rc: return rc
+					elif event.key == K_LEFT:
+						if self.menu_cursor == 0:
+							self.dec_level()
+							self.draw_menu()
+					elif event.key == K_RIGHT:
+						if self.menu_cursor == 0:
+							self.inc_level()
+							self.draw_menu()
 					continue
 				elif event.type is MOUSEBUTTONDOWN:
 					if self.curpage == 1:
@@ -2044,9 +2072,8 @@
 					if pos[1] < self.menu_pos[1]: continue
 					i = (pos[1] - self.menu_pos[1]) / self.menu_font_height
 					if i >= len(self.menu): continue
-
 					rc = self.menu_select( i)
-					if rc < 1: return rc
+					if rc: return rc
 
 			pygame.display.update( self.dirty_rects)
 
@@ -2057,7 +2084,7 @@
 	#  1 - Unknown option
 	def menu_select( self, i):
 		if i == 0:
-			return 0
+			return IntroScreen.start_level
 		elif i == 1:
 			play_sound( menu_select)
 			self.go_to_highscores()
@@ -2075,7 +2102,7 @@
 			self.draw_menu()
 		elif i == 5:
 			return -1
-		return 1
+		return 0
 
 	hs_font_height = 24
 	hs_width = 320
@@ -2157,7 +2184,15 @@
 		pygame.mixer.pre_init(44100,-16,1,4096)
 
 	# Initialize the game module
-	pygame.init()
+	pygame.display.init()
+	try:
+	  pygame.mixer.init()
+	except:
+	  print "error on pygame.mixer.init() inside setup_everything():"
+	  print sys.exc_info()[0],":",sys.exc_info()[1]
+	  print "...ignoring it"
+	pygame.font.init()
+	pygame.key.set_repeat(500, 30)
 
 	if not pygame.font: print 'Warning, fonts disabled'
 	if not pygame.mixer: print 'Warning, sound disabled'
@@ -2189,7 +2224,8 @@
 
 	if rc < 0: break   # Handle the QUIT message
 
-	game = Game(screen, 'all-boards', highscores)
+	# If rc is positive, it's a level.
+	game = Game(screen, 'all-boards', highscores, rc - 1)
 
 	show_highscores = 1
 
--- pathological-1.1.3.orig/pathological
+++ pathological-1.1.3/pathological
@@ -32,8 +32,4 @@
 
 cd /usr/share/games/pathological
 
-if [ -z "$scoresfile" ]; then
-	scoresfile=/var/games/pathological_scores
-fi
-
-exec ./pathological.py $options $scoresfile
+exec ./pathological.py $options

使い方:
netpbm-progs、pythonpygame及び、まだrpm開発環境を整備していないならrpmdevtoolsもインストールしておく。
pathological.specは~/rpmbuild/SPEC/に、pathological.patch及びpathological-1.1.3.tar.gzは~/rpmbuild/SOURCE/に置いておく。続いてrpmbuild、インストール。


$ []cd ~/rpmbuild/SPEC[]
$ []rpmbuild -bb pathological.spec --target i686[]
$ []sudo rpm -ivh ~/rpmbuild/RPMS/i686/pathological-1.1.3-1.tks8.i686.rpm[]