rpms/Maelstrom/devel Maelstrom-3.0.6-install.patch, NONE, 1.1 Maelstrom-3.0.6-setgid.patch, NONE, 1.1 Maelstrom.desktop, NONE, 1.1 Maelstrom.spec, 1.6, 1.7 Maelstrom-3.0.5-setgid.patch, 1.1, NONE
Bill Nottingham (notting)
fedora-extras-commits at redhat.com
Tue May 9 05:38:19 UTC 2006
Author: notting
Update of /cvs/extras/rpms/Maelstrom/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8385
Modified Files:
Maelstrom.spec
Added Files:
Maelstrom-3.0.6-install.patch Maelstrom-3.0.6-setgid.patch
Maelstrom.desktop
Removed Files:
Maelstrom-3.0.5-setgid.patch
Log Message:
use full source URL
tweak buildroot
tweak summary
move out of /usr/games to /usr/share/Maelstrom
move score file to /var
use desktop-file-install
drop gid completely on startup, rework setgid code
Maelstrom-3.0.6-install.patch:
--- NEW FILE Maelstrom-3.0.6-install.patch ---
--- Maelstrom-3.0.6/configure.foo 2006-05-09 00:08:43.000000000 -0400
+++ Maelstrom-3.0.6/configure 2006-05-09 00:09:00.000000000 -0400
@@ -3232,7 +3232,7 @@
GAME_INSTALLDIR="\$(prefix)/games/$PACKAGE"
;;
*)
- GAME_INSTALLDIR="\$(prefix)/games/$PACKAGE"
+ GAME_INSTALLDIR="\$(datadir)/$PACKAGE"
;;
esac
Maelstrom-3.0.6-setgid.patch:
--- NEW FILE Maelstrom-3.0.6-setgid.patch ---
diff -ru Maelstrom-3.0.6/main.cpp Maelstrom-3.0.6-new/main.cpp
--- Maelstrom-3.0.6/main.cpp 2002-10-19 22:53:32.000000000 -0400
+++ Maelstrom-3.0.6-new/main.cpp 2006-05-09 01:05:07.000000000 -0400
@@ -170,12 +170,21 @@
/* Command line flags */
int doprinthigh = 0;
int speedtest = 0;
+ gid_t gid;
+
Uint32 video_flags = SDL_SWSURFACE;
/* Normal variables */
SDL_Event event;
LibPath::SetExePath(argv[0]);
+ GetScoreFile();
+ gid = getgid();
+ if (setresgid(-1,gid,gid) != 0) {
+ error("Could not drop privleges. -- Exiting.\n");
+ exit(1);
+ }
+
#ifndef __WIN95__
/* The first thing we do is calculate our checksum */
(void) checksum();
diff -ru Maelstrom-3.0.6/scores.cpp Maelstrom-3.0.6-new/scores.cpp
--- Maelstrom-3.0.6/scores.cpp 2000-09-24 13:55:39.000000000 -0400
+++ Maelstrom-3.0.6-new/scores.cpp 2006-05-09 01:26:19.000000000 -0400
@@ -4,6 +4,8 @@
*/
#ifdef unix
+#include <arpa/inet.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
@@ -15,22 +17,40 @@
#include "load.h"
#include "dialog.h"
-#define MAELSTROM_SCORES "Maelstrom-Scores"
+#define MAELSTROM_SCORES "/var/games/Maelstrom-Scores"
#define NUM_SCORES 10 // Do not change this!
/* Everyone can write to scores file if defined to 0 */
-#define SCORES_PERMMASK 0
+#define SCORES_PERMMASK 002
#define CLR_DIALOG_WIDTH 281
#define CLR_DIALOG_HEIGHT 111
Bool gNetScores = 0;
Scores hScores[NUM_SCORES];
+int gScoreFile = -1;
+
+void GetScoreFile(void)
+{
+#ifdef unix
+ int omask;
+#endif
+ int f;
+
+#ifdef unix
+ omask=umask(SCORES_PERMMASK);
+#endif
+ f = open(MAELSTROM_SCORES,O_RDWR|O_CREAT);
+ if (f == -1)
+ f = open(MAELSTROM_SCORES,O_RDONLY);
+ gScoreFile = f;
+#ifdef unix
+ umask(omask);
+#endif
+}
void LoadScores(void)
{
- LibPath path;
- SDL_RWops *scores_src;
int i;
/* Try to load network scores, if we can */
@@ -44,50 +64,50 @@
}
memset(&hScores, 0, sizeof(hScores));
- scores_src = SDL_RWFromFile(path.Path(MAELSTROM_SCORES), "rb");
- if ( scores_src != NULL ) {
+ if (gScoreFile != -1) {
+ lseek(gScoreFile,0,SEEK_SET);
for ( i=0; i<NUM_SCORES; ++i ) {
- SDL_RWread(scores_src, hScores[i].name,
- sizeof(hScores[i].name), 1);
- hScores[i].wave = SDL_ReadBE32(scores_src);
- hScores[i].score = SDL_ReadBE32(scores_src);
+ Uint32 tmp;
+
+ if (read(gScoreFile,hScores[i].name,sizeof(hScores[i].name)) != sizeof(hScores[i].name))
+ break;
+ if (read(gScoreFile,&tmp,sizeof(Uint32)) != sizeof(Uint32))
+ break;
+ hScores[i].wave = ntohl(tmp);
+ if (read(gScoreFile,&tmp,sizeof(Uint32)) != sizeof(Uint32))
+ break;
+ hScores[i].score = ntohl(tmp);
}
- SDL_RWclose(scores_src);
}
}
void SaveScores(void)
{
- LibPath path;
- SDL_RWops *scores_src;
int i;
-#ifdef unix
- int omask;
-#endif
/* Don't save network scores */
if ( gNetScores )
return;
-
-#ifdef unix
- omask=umask(SCORES_PERMMASK);
-#endif
- scores_src = SDL_RWFromFile(path.Path(MAELSTROM_SCORES), "wb");
- if ( scores_src != NULL ) {
+
+ if (gScoreFile != -1) {
+ lseek(gScoreFile,0,SEEK_SET);
for ( i=0; i<NUM_SCORES; ++i ) {
- SDL_RWwrite(scores_src, hScores[i].name,
- sizeof(hScores[i].name), 1);
- SDL_WriteBE32(scores_src, hScores[i].wave);
- SDL_WriteBE32(scores_src, hScores[i].score);
+ Uint32 tmp;
+
+ if (write(gScoreFile, hScores[i].name, sizeof(hScores[i].name)) != sizeof(hScores[i].name))
+ goto out_err;
+ tmp = htonl(hScores[i].wave);
+ if (write(gScoreFile, &tmp,sizeof(Uint32)) != sizeof(Uint32))
+ goto out_err;
+ tmp = htonl(hScores[i].score);
+ if (write(gScoreFile, &tmp,sizeof(Uint32)) != sizeof(Uint32))
+ goto out_err;
}
- SDL_RWclose(scores_src);
- } else {
- error("Warning: Couldn't save scores to %s\n",
- path.Path(MAELSTROM_SCORES));
+ fsync(gScoreFile);
+ return;
}
-#ifdef unix
- umask(omask);
-#endif
+out_err:
+ error("Warning: Couldn't save scores to %s\n", MAELSTROM_SCORES);
}
/* Just show the high scores */
diff -ru Maelstrom-3.0.6/scores.h Maelstrom-3.0.6-new/scores.h
--- Maelstrom-3.0.6/scores.h 1998-07-13 21:50:17.000000000 -0400
+++ Maelstrom-3.0.6-new/scores.h 2006-05-09 01:05:25.000000000 -0400
@@ -2,6 +2,7 @@
// Functions from scores.cc
extern void LoadScores(void);
extern void SaveScores(void);
+extern void GetScoreFile(void);
extern int ZapHighScores(void);
extern int GetStartLevel(void);
extern void PrintHighScores(void);
--- NEW FILE Maelstrom.desktop ---
[Desktop Entry]
Name=Maelstrom
Comment=Space combat game
Exec=Maelstrom
Icon=maelstrom.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Application;Game;ArcadeGame;
Index: Maelstrom.spec
===================================================================
RCS file: /cvs/extras/rpms/Maelstrom/devel/Maelstrom.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Maelstrom.spec 14 Feb 2006 06:54:43 -0000 1.6
+++ Maelstrom.spec 9 May 2006 05:38:19 -0000 1.7
@@ -1,17 +1,19 @@
-Summary: A space combat game.
+Summary: Space combat game
Name: Maelstrom
Version: 3.0.6
-Release: 10
+Release: 11
License: LGPL
Group: Amusements/Games
-Source0: Maelstrom-%{version}.tar.gz
-Source1: maelstrom.png
-Patch0: Maelstrom-3.0.5-setgid.patch
+Source0: http://www.devolution.com/~slouken/Maelstrom/src/Maelstrom-%{version}.tar.gz
+Source1: maelstrom.png
+Source2: Maelstrom.desktop
+Patch0: Maelstrom-3.0.6-setgid.patch
Patch1: Maelstrom-3.0.6-gcc34.patch
Patch2: Maelstrom-3.0.6-64bit.patch
+Patch3: Maelstrom-3.0.6-install.patch
URL: http://www.devolution.com/~slouken/Maelstrom/
-BuildRoot: %{_tmppath}/Maelstrom-%{PACKAGE_VERSION}-root
-BuildPrereq: SDL-devel, SDL_net-devel
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+BuildPrereq: SDL-devel, SDL_net-devel, desktop-file-utils
%description
Maelstrom is a space combat game, originally ported from the Macintosh
@@ -21,12 +23,12 @@
%prep
%setup -q
-%patch0 -p1 -b .setgid
+#%patch0 -p1 -b .setgid
%patch1 -p1 -b .gcc34
%patch2 -p1 -b .64bit
+%patch3 -p1 -b .install
%build
-touch Makefile.in
%configure
make %{?_smp_mflags}
@@ -37,17 +39,9 @@
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
-cat > $RPM_BUILD_ROOT%{_datadir}/applications/net-Maelstrom.desktop << EOF
-[Desktop Entry]
-Name=Maelstrom
-Comment=Space combat game
-Exec=%{_bindir}/Maelstrom
-Icon=maelstrom.png
-Terminal=false
-Type=Application
-Encoding=UTF-8
-Categories=Application;Game;ArcadeGame;X-Red-Hat-Base;
-EOF
+desktop-file-install --vendor fedora --dir \
+ $RPM_BUILD_ROOT%{_datadir}/applications \
+ --add-category X-Fedora %{SOURCE2}
# remove unpackaged files from the buildroot
rm -f $RPM_BUILD_ROOT%{_bindir}/{Maelstrom-netd,macres,playwave,snd2wav}
@@ -56,25 +50,43 @@
install -m 644 %{SOURCE1} $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/48x48/apps
+mkdir -p -m 755 $RPM_BUILD_ROOT%{_localstatedir}/lib/games
+mv $RPM_BUILD_ROOT%{_datadir}/Maelstrom/*Scores $RPM_BUILD_ROOT%{_localstatedir}/lib/games
+
%clean
rm -rf $RPM_BUILD_ROOT
+%post
+touch --no-create %{_datadir}/icons/hicolor || :
+if [ -x %{_bindir}/gtk-update-icon-cache ]; then
+ %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
+fi
+
+%postun
+touch --no-create /usr/share/icons/hicolor
+if [ -x /usr/bin/gtk-update-icon-cache ]; then
+ gtk-update-icon-cache -q /usr/share/icons/hicolor
+fi
+
+
%files
-%defattr(-, root, games)
+%defattr(-, root, root)
%doc COPYING CREDITS README* Changelog Docs
%attr(2755,root,games) %{_bindir}/Maelstrom
-%attr(0575,root,games) %dir %{_prefix}/games/Maelstrom
-%config %attr(0060,root,games) %{_prefix}/games/Maelstrom/Maelstrom-Scores
-%{_prefix}/games/Maelstrom/icon*
-%{_prefix}/games/Maelstrom/Images
-%{_prefix}/games/Maelstrom/Maelstrom_Fonts
-%{_prefix}/games/Maelstrom/Maelstrom_Sounds
-%{_prefix}/games/Maelstrom/Maelstrom_Sprites
-%defattr(-, root, root)
-%{_datadir}/applications/net-Maelstrom.desktop
+%{_datadir}/Maelstrom
+%{_datadir}/applications/*
%{_datadir}/icons
+%config(noreplace) %attr(0664,root,games) %{_localstatedir}/lib/games/Maelstrom-Scores
%changelog
+* Tue May 9 2006 Bill Nottingham <notting at redhat.com> 3.0.6-11
+- various fixes from review:
+ - update the icon cache
+ - move out of /usr/games
+ - move scores to /var
+ - rework setuid code
+ - use desktop-file-install
+
* Mon Feb 13 2006 Bill Nottingham <notting at redhat.com> 3.0.6-10
- rebuild
--- Maelstrom-3.0.5-setgid.patch DELETED ---
More information about the scm-commits
mailing list