From d391c4d5f5d7007af99cda89da8f22b30bed1704 Mon Sep 17 00:00:00 2001 From: Toshaan Bharvani Date: Tue, 18 Oct 2022 14:06:45 +0200 Subject: [PATCH] initial package creation Signed-off-by: Toshaan Bharvani --- SOURCES/README | 43 +++++++++ SOURCES/opengl-game-functions.sh | 26 ++++++ SOURCES/opengl-game-wrapper.sh | 9 ++ SPECS/opengl-games-utils.spec | 146 +++++++++++++++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 SOURCES/README create mode 100644 SOURCES/opengl-game-functions.sh create mode 100644 SOURCES/opengl-game-wrapper.sh create mode 100644 SPECS/opengl-games-utils.spec diff --git a/SOURCES/README b/SOURCES/README new file mode 100644 index 0000000..64691ed --- /dev/null +++ b/SOURCES/README @@ -0,0 +1,43 @@ +This package contains various shell scripts which are intented for use by +3D games packages. These shell scripts can be used to check if direct rendering +is available before launching an OpenGL game. This package is intended for use +by other packages and is not intended for direct end user use! + + +Currently this package contains one utility script: +opengl-game-wrapper.sh + +To use this script create a link in /usr/bin gamename-wrapper[.sh] to +opengl-game-wrapper.sh, and put gamename-wrapper[.sh] in your desktop file +instead of gamename. The wrapper script will use $0 to determine gamename, +if direct rendering is available the wrapper script will execute gamename +with any parameters passed to the script, if direct rendering is not +available a userfriendly error dialog will be shown explaining that gamename +cannot run without hardware accelerated 3d, and that this is probably due to +missing Free Software support for the users card. + +The utility script uses 2 functions defined in +/usr/share/opengl-games-utils/opengl-game-functions.sh +You can also use these 2 functions directly from your own scripts by +including the above file from your own shell script. + +The 2 included functions are: + +hasDri: +This function will return true if hardware accellerated OpenGL is available +and false if it is not. This does not say anything about the OpenGL +capabilities (nor the quality of the driver). + +checkDriOK: +This functino calls hasDri, if hardware accellerated OpenGL is available +it does nothing, if it is not available it will show an error dialog and +then call exit. This is the function around which opengl-game-wrapper.sh is +build. It is provided as a "library" function so that if your game needs a +wrapper script anyways, you don't need to wrap the wrapper but instead can +call it directly from the wrapper. + + +Last but not least before I forget, to avoid any licensing issues I hereby +declare that all files in this package are in the Public Domain. + +Hans de Goede 15 September 2011. diff --git a/SOURCES/opengl-game-functions.sh b/SOURCES/opengl-game-functions.sh new file mode 100644 index 0000000..d188728 --- /dev/null +++ b/SOURCES/opengl-game-functions.sh @@ -0,0 +1,26 @@ +# check if DRI is available, true if it is, false otherwise + +function hasDri () +{ + if [ "`glxinfo | grep "direct rendering: " | head -n 1 | cut -d " " -f 3`" != Yes ] || + glxinfo | grep -qE "OpenGL renderer string: Software Rasterizer|OpenGL renderer string: Gallium .* on llvmpipe"; then + return 1 + else + return 0 + fi +} + +# check if DRI is available, show an error and exit if it isn't + +function checkDriOK () +{ + if ! hasDri; then + zenity --error --text="Your system currently is not capable of hardware \ +accelerated 3D. Therefore $1 cannot run. + +Usually the cause of this error is that there are no Free Software drivers \ +for your graphics card, please contact your graphics card manufacturer and \ +kindly ask them to provide Free Software support for your card." + exit 1; + fi +} diff --git a/SOURCES/opengl-game-wrapper.sh b/SOURCES/opengl-game-wrapper.sh new file mode 100644 index 0000000..52c6803 --- /dev/null +++ b/SOURCES/opengl-game-wrapper.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +. /usr/share/opengl-games-utils/opengl-game-functions.sh + +GAME=`basename $0 | sed 's/-wrapper.*//'` + +checkDriOK $GAME + +exec $GAME "$@" diff --git a/SPECS/opengl-games-utils.spec b/SPECS/opengl-games-utils.spec new file mode 100644 index 0000000..0bb0d18 --- /dev/null +++ b/SPECS/opengl-games-utils.spec @@ -0,0 +1,146 @@ +Name: opengl-games-utils +Version: 0.2 +Release: 22%{?dist} +Summary: Utilities to check proper 3d support before launching 3d games +License: Public Domain +URL: http://fedoraproject.org/wiki/SIGs/Games +Source0: opengl-game-wrapper.sh +Source1: opengl-game-functions.sh +Source2: README +BuildArch: noarch +Requires: zenity glx-utils + +%description +This package contains various shell scripts which are intented for use by +3D games packages. These shell scripts can be used to check if direct rendering +is available before launching an OpenGL game. This package is intended for use +by other packages and is not intended for direct end user use! + + +%prep +%setup -c -T +cp %{SOURCE2} . + + +%build +# nothing to build + + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT%{_bindir} +mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name} +install -p -m 755 %{SOURCE0} $RPM_BUILD_ROOT%{_bindir} +install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/%{name} + +if [ "%{_prefix}" != "/usr" ]; then + sed -i "s/\/usr/\%{_prefix}/g" $RPM_BUILD_ROOT%{_bindir}/opengl-game-wrapper.sh +fi + + +%files +%doc README +%{_bindir}/opengl-game-wrapper.sh +%{_datadir}/%{name} + + +%changelog +* Fri Jul 22 2022 Fedora Release Engineering - 0.2-22 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Thu Jan 20 2022 Fedora Release Engineering - 0.2-21 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Jul 22 2021 Fedora Release Engineering - 0.2-20 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Tue Jan 26 2021 Fedora Release Engineering - 0.2-19 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Tue Jul 28 2020 Fedora Release Engineering - 0.2-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Wed Jan 29 2020 Fedora Release Engineering - 0.2-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Fri Aug 09 2019 Gwyn Ciesla - 0.2-16 +- Fix path. + +* Fri Aug 09 2019 Gwyn Ciesla - 0.2-15 +- Adapt to flatpak. + +* Thu Jul 25 2019 Fedora Release Engineering - 0.2-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Fri Feb 01 2019 Fedora Release Engineering - 0.2-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jul 13 2018 Fedora Release Engineering - 0.2-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Thu Feb 08 2018 Fedora Release Engineering - 0.2-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 0.2-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Fedora Release Engineering - 0.2-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Feb 04 2016 Fedora Release Engineering - 0.2-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 0.2-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 0.2-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Aug 03 2013 Fedora Release Engineering - 0.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Thu Feb 14 2013 Fedora Release Engineering - 0.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Fri Jul 20 2012 Fedora Release Engineering - 0.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Jan 13 2012 Fedora Release Engineering - 0.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Thu Sep 15 2011 Hans de Goede 0.2-1 +- Recognize software rendering as such now that it is done with gallium + llvmpipe, rather then the classic software renderer +- Add a new hasDri function to opengl-game-functions.sh + +* Tue Feb 08 2011 Fedora Release Engineering - 0.1-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Sat Jul 25 2009 Fedora Release Engineering - 0.1-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Fri Apr 10 2009 Hans de Goede 0.1-8 +- Recognize software rendering as such with new Mesa which always says + DRI = Yes (rh 494174) + +* Thu Feb 26 2009 Fedora Release Engineering - 0.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Nov 13 2008 Hans de Goede 0.1-6 +- Handle glxinfo output not containing any dri info at all (rh 471374) + +* Fri Jan 11 2008 Hans de Goede 0.1-5 +- Fix DRI detection to work with dual head configurations + +* Tue Oct 16 2007 Hans de Goede 0.1-4 +- Fix a minor spelling error in the dialog shown when DRI is not available + +* Mon Sep 24 2007 Hans de Goede 0.1-3 +- Put DRI checking functionality in a checkDriOK bash function in + opengl-game-functions.sh, for usage from existing wrapper scripts + +* Sun Sep 16 2007 Hans de Goede 0.1-2 +- Various spelling fixes thanks to Rahul Sundaram + +* Sun Sep 16 2007 Hans de Goede 0.1-1 +- Initial Fedora package