commit 55feb02626476f395cb510a802f9ddf08f0c5775
Author: Hans de Goede <hdegoede(a)redhat.com>
Date: Mon Feb 26 19:34:55 2018 +0100
Rebase to now github upstream, which calls itself version 0.9
0.9 uses SDL2 instead of SDL-1.2
Fix abuse crashing at startup, making it playable again (rf#4276)
Modernize spec file a bit
.gitignore | 1 +
...ointer-deref-when-built-with-gcc-O1-or-O2.patch | 91 ++++++++++++++++++++++
abuse.desktop | 3 +-
abuse.spec | 71 +++++++++--------
sources | 1 +
5 files changed, 135 insertions(+), 32 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index c7a3ab3..ef3128f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
abuse-0.8.tar.gz
+/abuse-3c674b1.tar.gz
diff --git a/0001-Fix-NULL-pointer-deref-when-built-with-gcc-O1-or-O2.patch
b/0001-Fix-NULL-pointer-deref-when-built-with-gcc-O1-or-O2.patch
new file mode 100644
index 0000000..afac196
--- /dev/null
+++ b/0001-Fix-NULL-pointer-deref-when-built-with-gcc-O1-or-O2.patch
@@ -0,0 +1,91 @@
+From 77a34f69569815e73b95d99268fb7ba1cd64c17b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede(a)redhat.com>
+Date: Mon, 26 Feb 2018 18:28:17 +0100
+Subject: [PATCH] Fix NULL pointer deref when built with gcc -O1 or -O2
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The C++ spec says "this" is always NON-NULL, recent versions of gcc will warn
+about this and optimizes the "if (this)" we use in some places away:
+"warning: nonnull argument ‘this’ compared to NULL [-Wnonnull-compare]"
+
+We rely on "if (this)" checks in several places and refactoring this
+is non trivial, so this commit adds a workaround using a helper function
+for (this == NULL) checks which is marked as __attribute__((optimize("O0")))
+when building with gcc.
+
+Signed-off-by: Hans de Goede <hdegoede(a)redhat.com>
+---
+ src/lisp/lisp.cpp | 6 +++---
+ src/lisp/lisp.h | 23 ++++++++++++++++++++++-
+ 2 files changed, 25 insertions(+), 4 deletions(-)
+
+diff --git a/src/lisp/lisp.cpp b/src/lisp/lisp.cpp
+index 363d310..8e604bf 100644
+--- a/src/lisp/lisp.cpp
++++ b/src/lisp/lisp.cpp
+@@ -860,7 +860,7 @@ size_t LList::GetLength()
+ size_t ret = 0;
+
+ #ifdef TYPE_CHECKING
+- if (this && item_type(this) != (ltype)L_CONS_CELL)
++ if (item_type(this) != (ltype)L_CONS_CELL)
+ {
+ Print();
+ lbreak(" is not a sequence\n");
+@@ -1268,7 +1268,7 @@ void LObject::Print()
+ switch (item_type(this))
+ {
+ case L_CONS_CELL:
+- if (!this)
++ if (ptr_is_null(this))
+ {
+ lprint_string("nil");
+ }
+@@ -3068,7 +3068,7 @@ LObject *LObject::Eval()
+
+ LObject *ret = NULL;
+
+- if (this)
++ if (!ptr_is_null(this))
+ {
+ switch (item_type(this))
+ {
+diff --git a/src/lisp/lisp.h b/src/lisp/lisp.h
+index 2c68bee..d1e2183 100644
+--- a/src/lisp/lisp.h
++++ b/src/lisp/lisp.h
+@@ -250,7 +250,28 @@ private:
+
+ static inline LObject *&CAR(void *x) { return ((LList *)x)->m_car; }
+ static inline LObject *&CDR(void *x) { return ((LList *)x)->m_cdr; }
+-static inline ltype item_type(void *x) { if (x) return *(ltype *)x; return L_CONS_CELL;
}
++
++#ifdef __GNUC__
++/*
++ * C++ spec says "this" is always NON-NULL, recent versions of gcc will warn
++ * about this and optimizes the "if (this)" we use in some places away:
++ * "warning: nonnull argument ‘this’ compared to NULL [-Wnonnull-compare]"
++ * We rely on "if (this)" checks in several places and refactoring this is
++ * non trivial. So we use this little helper marked with
++ * __attribute__((optimize("O0"))) to workaround this.
++ */
++static inline bool __attribute__((optimize("O0"))) ptr_is_null(void *ptr)
++{
++ return ptr == NULL;
++}
++#else
++static inline bool ptr_is_null(void *ptr)
++{
++ return ptr == NULL;
++}
++#endif
++
++static inline ltype item_type(void *x) { if (!ptr_is_null(x)) return *(ltype *)x; return
L_CONS_CELL; }
+
+ void perm_space();
+ void tmp_space();
+--
+2.14.3
+
diff --git a/abuse.desktop b/abuse.desktop
index f9e613e..e5721d0 100644
--- a/abuse.desktop
+++ b/abuse.desktop
@@ -1,8 +1,9 @@
[Desktop Entry]
Name=Abuse
Comment=Dark 2D side-scrolling platform game
-Exec=abuse -fullscreen -datadir /usr/share/abuse
+Exec=abuse -datadir /usr/share/games/abuse
Icon=abuse
Terminal=false
Type=Application
Categories=Game;ArcadeGame;ActionGame;
+Keywords=game;arcade;run;gun;shooter;
diff --git a/abuse.spec b/abuse.spec
index 677e001..3e48ed7 100644
--- a/abuse.spec
+++ b/abuse.spec
@@ -1,8 +1,10 @@
+%global commit 3c674b19c6ccb5fe4943658f41bb188a8dd19d5c
+%global shortcommit %(c=%{commit}; echo ${c:0:7})
+
Name: abuse
-Version: 0.8
-Release: 8%{?dist}
+Version: 0.9
+Release: 1%{?dist}
Summary: The classic Crack-Dot-Com game
-Group: Amusements/Games
# The engine is GPLv2+, the data files are mostly in the public domain, except
# for the music and sfx files, which may be distributed freely, but not
# modified, and for the claudio addon, which states: "this ... can be used and
@@ -10,62 +12,69 @@ Group: Amusements/Games
# depends heavily on the claudio addon now a days, so it cannot be removed.
License: GPLv2+ and redistributable
URL:
http://abuse.zoy.org/
-Source0:
http://abuse.zoy.org/raw-attachment/wiki/download/%{name}-%{version}.tar.gz
-Source1: %{name}.png
-Source2: %{name}.desktop
-BuildRequires: SDL-devel SDL_mixer-devel alsa-lib-devel libGLU-devel
-BuildRequires: desktop-file-utils ImageMagick
+Source0:
https://github.com/Xenoveritas/%{name}/archive/%{commit}/%{name}-%{shortc...
+# We use the original 0.8 sources for the non-free sfx and music
+Source1:
http://abuse.zoy.org/raw-attachment/wiki/download/%{name}-0.8.tar.gz
+Source2: %{name}.png
+Source3: %{name}.desktop
+# Fix NULL pointer deref at startup
+Patch0: 0001-Fix-NULL-pointer-deref-when-built-with-gcc-O1-or-O2.patch
+BuildRequires: SDL2-devel SDL2_mixer-devel alsa-lib-devel libGLU-devel
+BuildRequires: cmake desktop-file-utils ImageMagick
Requires: hicolor-icon-theme
-# abuse 0.8 comes with the data bundled
-Obsoletes: fRaBs < 2.11-7
-Provides: fRaBs = 2.11-7
%description
-This is the SDL version of Abuse, the classic Crack-Dot-Com game. It can run in
-a window or fullscreen and it has stereo sound with sound panning.
+This is the SDL version of Abuse, the classic Crack-Dot-Com game. It can run
+in a window or fullscreen and it has stereo sound with sound panning.
%prep
-%setup -q
+%autosetup -p1 -n %{name}-%{commit} -a 1
+mv abuse-0.8/data/sfx abuse-0.8/data/music data
+sed -i 's/@VERSION@/%{version}/' doc/abuse*.6.in
%build
-%configure --with-assetdir=%{_datadir}/%{name}
+mkdir build
+pushd build
+# BUILD_SHARED_LIBS:BOOL=OFF -> make builtin helper libs static
+%cmake -DBUILD_SHARED_LIBS:BOOL=OFF ..
make %{?_smp_mflags}
+popd
%install
+pushd build
%make_install INSTALL="install -p"
+popd
+
mkdir -p $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/256x256/apps
convert -background transparent -resize 256x256 -extent 256x256-28+0 \
- %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
+ %{SOURCE2} $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
-desktop-file-install --dir $RPM_BUILD_ROOT%{_datadir}/applications %{SOURCE2}
-
+desktop-file-install --dir $RPM_BUILD_ROOT%{_datadir}/applications %{SOURCE3}
-%post
-touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
-
-%postun
-if [ $1 -eq 0 ] ; then
- touch --no-create %{_datadir}/icons/hicolor &>/dev/null
- gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-fi
-
-%posttrans
-gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+mkdir -p $RPM_BUILD_ROOT%{_mandir}/man6
+install -p -m 0644 doc/abuse.6.in $RPM_BUILD_ROOT%{_mandir}/man6/abuse.6
+install -p -m 0644 doc/abuse-tool.6.in $RPM_BUILD_ROOT%{_mandir}/man6/abuse-tool.6
%files
-%doc AUTHORS COPYING* NEWS README
+%doc AUTHORS COPYING* NEWS README.md
%{_bindir}/%{name}*
-%{_datadir}/%{name}
+%{_datadir}/games/%{name}
%{_mandir}/man6/%{name}*.6*
%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
%{_datadir}/applications/%{name}.desktop
%changelog
+* Mon Feb 26 2018 Hans de Goede <j.w.r.degoede(a)gmail.com> - 0.9-1
+- Rebase to now github upstream, which calls itself version 0.9
+- 0.9 uses SDL2 instead of SDL-1.2
+- Fix abuse crashing at startup, making it playable again (rf#4276)
+- Modernize spec file a bit
+
* Thu Aug 31 2017 RPM Fusion Release Engineering <kwizart(a)rpmfusion.org> - 0.8-8
- Rebuilt for
https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
diff --git a/sources b/sources
index 4d520dc..9a937a6 100644
--- a/sources
+++ b/sources
@@ -1 +1,2 @@
ec678b8dc8d00e0382d8c805c6438489 abuse-0.8.tar.gz
+bbc431f386783b10fa39f2518f75970d abuse-3c674b1.tar.gz