The package rpms/powdertoy.git has added or updated architecture specific content in its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/powdertoy.git/commit/?id=57bce8e5....
Change:
+%ifarch %{ix86} x86_64
Thanks.
Full change:
============
commit 57bce8e55f0b82f66157c8fa5556662e8d5a587a
Author: Artur Iwicki <fedora(a)svgames.pl>
Date: Wed Sep 25 23:40:25 2019 +0200
Import from SRPM (RHBZ1747996)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..78c1137
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/The-Powder-Toy-v94.1.tar.gz
diff --git a/powdertoy--add-the-noinstallprompt-option-to-Sconscript.patch
b/powdertoy--add-the-noinstallprompt-option-to-Sconscript.patch
new file mode 100644
index 0000000..d059d12
--- /dev/null
+++ b/powdertoy--add-the-noinstallprompt-option-to-Sconscript.patch
@@ -0,0 +1,21 @@
+diff --git a/SConscript b/SConscript
+index d7893db7..310050ff 100644
+--- a/SConscript
++++ b/SConscript
+@@ -45,6 +45,7 @@ AddSconsOption('msvc', False, False, "Use the Microsoft
Visual Studio compiler."
+ AddSconsOption("tool", False, True, "Tool prefix appended before
gcc/g++.")
+
+ AddSconsOption('beta', False, False, "Beta build.")
++AddSconsOption('no-install-prompt', False, False, "Disable the \"do
you want to install Powder Toy?\" prompt.")
+ AddSconsOption('save-version', False, True, "Save version.")
+ AddSconsOption('minor-version', False, True, "Minor version.")
+ AddSconsOption('build-number', False, True, "Build number.")
+@@ -536,6 +537,8 @@ elif GetOption('snapshot'):
+
+ if GetOption('beta'):
+ env.Append(CPPDEFINES=['BETA'])
++if GetOption('no-install-prompt'):
++ env.Append(CPPDEFINES=['NO_INSTALL_CHECK'])
+
+
+ #Generate list of sources to compile
diff --git a/powdertoy--store-powder.pref-in-user-directory.patch
b/powdertoy--store-powder.pref-in-user-directory.patch
new file mode 100644
index 0000000..b227efc
--- /dev/null
+++ b/powdertoy--store-powder.pref-in-user-directory.patch
@@ -0,0 +1,311 @@
+diff --git a/SConscript b/SConscript
+index d7893db7..8efe7780 100644
+--- a/SConscript
++++ b/SConscript
+@@ -69,6 +69,8 @@ AddSconsOption('opengl-renderer', False, False, "Build
with OpenGL renderer supp
+ AddSconsOption('renderer', False, False, "Build the save renderer.")
+ AddSconsOption('font', False, False, "Build the font editor.")
+
++AddSconsOption('data-in-homedir', False, False, "Store preferences and
savegames inside the user home directory.")
++
+ AddSconsOption('wall', False, False, "Error on all warnings.")
+ AddSconsOption('no-warnings', False, False, "Disable all compiler
warnings.")
+ AddSconsOption('nolua', False, False, "Disable Lua.")
+@@ -507,6 +509,9 @@ if GetOption('renderer'):
+ if GetOption('font'):
+ env.Append(CPPDEFINES=['FONTEDITOR'])
+
++if GetOption('data-in-homedir'):
++ env.Append(CPPDEFINES=['DATA_IN_HOMEDIR'])
++
+ if GetOption("wall"):
+ if msvc:
+ env.Append(CCFLAGS=['/WX'])
+diff --git a/src/Platform.cpp b/src/Platform.cpp
+index 62939f4f..b5a5e5e3 100644
+--- a/src/Platform.cpp
++++ b/src/Platform.cpp
+@@ -8,8 +8,10 @@
+ #include <shlwapi.h>
+ #include <windows.h>
+ #else
+-#include <unistd.h>
+ #include <ctime>
++#include <errno.h>
++#include <unistd.h>
++#include <sys/stat.h>
+ #include <sys/time.h>
+ #endif
+ #ifdef MACOSX
+@@ -21,6 +23,40 @@
+ namespace Platform
+ {
+
++ByteString PrefFileDirectory()
++{
++#if defined(WIN)
++ char *appdata = getenv("APPDATA");
++ if(appdata != nullptr) return std::string(appdata) + "\\The Powder Toy\\";
++
++ char *homedrive = getenv("HOMEDRIVE");
++ char *homepath = getenv("HOMEPATH");
++ if(homedrive != nullptr && homepath != nullptr) return std::string(homedrive) +
std::string(homepath) + "\\AppData\\Roaming\\The Powder Toy\\";
++#elif defined(LIN)
++ char *xdg_data = getenv("XDG_DATA_HOME");
++ if(xdg_data != nullptr) return std::string(xdg_data) + "/powdertoy/";
++
++ char *home = getenv("HOME");
++ if(home != nullptr) return std::string(home) + "/.local/share/powdertoy/";
++
++ char *username = getlogin();
++ if(username != nullptr) return "/home/" + std::string(username) +
"/.local/share/powdertoy/";
++#elif defined(MACOSX)
++ FSRef ref;
++ OSType folderType = kApplicationSupportFolderType;
++ char path[PATH_MAX];
++
++ FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
++
++ FSRefMakePath( &ref, (UInt8*)&path, PATH_MAX );
++
++ std::string tptPath = std::string(path) + "/The Powder Toy";
++ return tptPath;
++#endif
++
++ return ""; // give up
++}
++
+ ByteString ExecutableName()
+ {
+ ByteString ret;
+@@ -144,4 +180,51 @@ void LoadFileInResource(int name, int type, unsigned int& size,
const char*& dat
+ #endif
+ }
+
++int MakeDirectory(const char * dirName)
++{
++#ifdef WIN
++ return _mkdir(dirName);
++#else
++ return mkdir(dirName, 0755);
++#endif
++}
++
++int MakeDirectory(const ByteString &dirName)
++{
++ return MakeDirectory(dirName.c_str());
++}
++
++int MakeDirectoryChain(const char * dirName)
++{
++ ByteString dirStr = dirName;
++ return MakeDirectoryChain(dirStr);
++}
++
++int MakeDirectoryChain(ByteString dirName)
++{
++ int success = MakeDirectory(dirName);
++ if(success == 0) return 0;
++
++ // If the directory already exists, consider it a success
++ if(errno == EEXIST) return 0;
++
++ // ENOENT signifies that an element of the path does not exist, i.e. a parent directory
is missing.
++ // If the error is ENOENT, descend in path and try to create parent directories.
++ // If it's something else, bail out and return failure.
++ if(errno != ENOENT) return -1;
++
++#ifdef WIN
++ unsigned long slashPos = dirName.find_last_of('\\', 0);
++#else
++ unsigned long slashPos = dirName.find_last_of('/', 0);
++#endif
++
++ // No slash, means we can't descent further in path
++ if(slashPos == std::string::npos) return -1;
++
++ // Descend in path and try again
++ dirName = dirName.Erase(slashPos, dirName.length());
++ return MakeDirectoryChain(dirName);
++}
++
+ }
+diff --git a/src/Platform.h b/src/Platform.h
+index 9a2ad8ab..f5cdffc2 100644
+--- a/src/Platform.h
++++ b/src/Platform.h
+@@ -5,6 +5,7 @@
+
+ namespace Platform
+ {
++ ByteString PrefFileDirectory();
+ ByteString ExecutableName();
+ void DoRestart();
+
+@@ -14,6 +15,11 @@ namespace Platform
+ long unsigned int GetTime();
+
+ void LoadFileInResource(int name, int type, unsigned int& size, const char*&
data);
++
++ int MakeDirectory(const char * dirname);
++ int MakeDirectory(const ByteString &dirname);
++ int MakeDirectoryChain(const char * dirname);
++ int MakeDirectoryChain(ByteString dirname);
+ }
+
+ #endif
+diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp
+index 47843a36..11026980 100644
+--- a/src/PowderToySDL.cpp
++++ b/src/PowderToySDL.cpp
+@@ -57,6 +57,7 @@ using namespace std;
+
+ #define INCLUDE_SYSWM
+ #include "SDLCompat.h"
++#include "Platform.h"
+
+ int desktopWidth = 1280, desktopHeight = 1024;
+
+@@ -598,18 +599,10 @@ void SigHandler(int signal)
+
+ void ChdirToDataDirectory()
+ {
+-#ifdef MACOSX
+- FSRef ref;
+- OSType folderType = kApplicationSupportFolderType;
+- char path[PATH_MAX];
+-
+- FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
+-
+- FSRefMakePath( &ref, (UInt8*)&path, PATH_MAX );
+-
+- std::string tptPath = std::string(path) + "/The Powder Toy";
+- mkdir(tptPath.c_str(), 0755);
+- chdir(tptPath.c_str());
++#if defined(DATA_IN_HOMEDIR) || defined(MACOSX)
++ ByteString path = Platform::PrefFileDirectory();
++ Platform::MakeDirectoryChain(path);
++ chdir(path.c_str());
+ #endif
+ }
+
+diff --git a/src/client/Client.cpp b/src/client/Client.cpp
+index 22f1b4d4..e63312dc 100644
+--- a/src/client/Client.cpp
++++ b/src/client/Client.cpp
+@@ -533,15 +533,6 @@ std::vector<ByteString> Client::DirectorySearch(ByteString
directory, ByteString
+ return searchResults;
+ }
+
+-int Client::MakeDirectory(const char * dirName)
+-{
+-#ifdef WIN
+- return _mkdir(dirName);
+-#else
+- return mkdir(dirName, 0755);
+-#endif
+-}
+-
+ bool Client::WriteFile(std::vector<unsigned char> fileData, ByteString filename)
+ {
+ bool saveError = false;
+@@ -1102,7 +1093,7 @@ ByteString Client::AddStamp(GameSave * saveData)
+ ByteString saveID = ByteString::Build(Format::Hex(Format::Width(lastStampTime, 8)),
Format::Hex(Format::Width(lastStampName, 2)));
+ ByteString filename = STAMPS_DIR PATH_SEP + saveID + ".stm";
+
+- MakeDirectory(STAMPS_DIR);
++ Platform::MakeDirectory(STAMPS_DIR);
+
+ Json::Value stampInfo;
+ stampInfo["type"] = "stamp";
+@@ -1137,7 +1128,7 @@ ByteString Client::AddStamp(GameSave * saveData)
+
+ void Client::updateStamps()
+ {
+- MakeDirectory(STAMPS_DIR);
++ Platform::MakeDirectory(STAMPS_DIR);
+
+ std::ofstream stampsStream;
+ stampsStream.open(ByteString(STAMPS_DIR PATH_SEP "stamps.def").c_str(),
std::ios::binary);
+diff --git a/src/client/Client.h b/src/client/Client.h
+index 27f98feb..4c444505 100644
+--- a/src/client/Client.h
++++ b/src/client/Client.h
+@@ -120,7 +120,6 @@ public:
+ void SetProxy(ByteString proxy);
+ bool IsFirstRun();
+
+- int MakeDirectory(const char * dirname);
+ bool WriteFile(std::vector<unsigned char> fileData, ByteString filename);
+ bool WriteFile(std::vector<char> fileData, ByteString filename);
+ bool FileExists(ByteString filename);
+diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp
+index 5a994297..defe726d 100644
+--- a/src/gui/game/GameController.cpp
++++ b/src/gui/game/GameController.cpp
+@@ -1265,7 +1265,7 @@ void GameController::OpenLocalSaveWindow(bool asCurrent)
+ gameSave->authors = localSaveInfo;
+
+ gameModel->SetSaveFile(&tempSave);
+- Client::Ref().MakeDirectory(LOCAL_SAVE_DIR);
++ Platform::MakeDirectory(LOCAL_SAVE_DIR);
+ std::vector<char> saveData = gameSave->Serialise();
+ if (saveData.size() == 0)
+ new ErrorMessage("Error", "Unable to serialize game data.");
+diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp
+index dde7f722..530631b7 100644
+--- a/src/gui/game/GameView.cpp
++++ b/src/gui/game/GameView.cpp
+@@ -21,6 +21,7 @@
+ #include "gui/interface/Window.h"
+ #include "simulation/SaveRenderer.h"
+ #include "simulation/SimulationData.h"
++#include "Platform.h"
+
+
+ class SplitButton;
+@@ -1064,8 +1065,8 @@ int GameView::Record(bool record)
+ {
+ time_t startTime = time(NULL);
+ recordingFolder = startTime;
+- Client::Ref().MakeDirectory("recordings");
+- Client::Ref().MakeDirectory(ByteString::Build("recordings", PATH_SEP,
recordingFolder).c_str());
++ Platform::MakeDirectory("recordings");
++ Platform::MakeDirectory(ByteString::Build("recordings", PATH_SEP,
recordingFolder));
+ recording = true;
+ recordingIndex = 0;
+ }
+diff --git a/src/gui/save/LocalSaveActivity.cpp b/src/gui/save/LocalSaveActivity.cpp
+index e7418416..551851d8 100644
+--- a/src/gui/save/LocalSaveActivity.cpp
++++ b/src/gui/save/LocalSaveActivity.cpp
+@@ -12,6 +12,7 @@
+ #include "gui/interface/Button.h"
+ #include "gui/interface/Label.h"
+ #include "gui/interface/Textbox.h"
++#include "Platform.h"
+
+
+ class LocalSaveActivity::CancelAction: public ui::ButtonAction
+@@ -116,7 +117,7 @@ void LocalSaveActivity::Save()
+
+ void LocalSaveActivity::saveWrite(ByteString finalFilename)
+ {
+- Client::Ref().MakeDirectory(LOCAL_SAVE_DIR);
++ Platform::MakeDirectory(LOCAL_SAVE_DIR);
+ GameSave *gameSave = save.GetGameSave();
+ Json::Value localSaveInfo;
+ localSaveInfo["type"] = "localsave";
+diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp
+index 14361751..1cf05851 100644
+--- a/src/lua/LuaScriptInterface.cpp
++++ b/src/lua/LuaScriptInterface.cpp
+@@ -3138,7 +3138,7 @@ int LuaScriptInterface::fileSystem_makeDirectory(lua_State * l)
+ const char * dirname = luaL_checkstring(l, 1);
+
+ int ret = 0;
+- ret = Client::Ref().MakeDirectory(dirname);
++ ret = Platform::MakeDirectory(dirname);
+ lua_pushboolean(l, ret == 0);
+ return 1;
+ }
diff --git a/powdertoy.spec b/powdertoy.spec
new file mode 100644
index 0000000..ca9a0b9
--- /dev/null
+++ b/powdertoy.spec
@@ -0,0 +1,137 @@
+Name: powdertoy
+Summary: Physics sandbox game
+URL:
https://powdertoy.co.uk
+
+# Powder Toy itself is GPLv3
+# src/bson/ is Apache v.2.0
+# src/json/ and src/lua/ are MIT
+License: GPLv3 and MIT and ASL 2.0
+
+Version: 94.1
+Release: 4%{?dist}
+
+%global repo_owner The-Powder-Toy
+%global repo_name The-Powder-Toy
+Source0:
https://github.com/%{repo_owner}/%{repo_name}/archive/v%{version}/%{repo_...
+
+# By default, the program stores its preferences file in current working dir
+Patch0: %{name}--store-powder.pref-in-user-directory.patch
+# The program has a built-in "install me" prompt, we don't want that
+Patch1: %{name}--add-the-noinstallprompt-option-to-Sconscript.patch
+
+BuildRequires: bzip2-devel
+BuildRequires: fftw-devel
+BuildRequires: gcc-c++
+BuildRequires: lua-devel
+BuildRequires: luajit-devel
+BuildRequires: libcurl-devel
+BuildRequires: mesa-libGL-devel
+BuildRequires: python3-scons
+BuildRequires: SDL2-devel
+BuildRequires: zlib-devel
+
+BuildRequires: desktop-file-utils
+BuildRequires: libappstream-glib
+
+Requires: hicolor-icon-theme
+
+
+%description
+The Powder Toy is a free physics sandbox game, which simulates air pressure
+and velocity, heat, gravity and a countless number of interactions between
+different substances! The game provides you with various building materials,
+liquids, gases and electronic components which can be used to construct complex
+machines, guns, bombs, realistic terrains and almost anything else.
+You can then mine them and watch cool explosions, add intricate wirings,
+play with little stickmen or operate your machine. You can also browse and play
+thousands of different saves made by the community or upload your own!
+
+
+%prep
+%autosetup -p1 -n %{repo_name}-%{version}
+
+# We're gonna use "powdertoy" instead of just "powder"
+# for the executable name and icon names
+sed -e 's/=powder$/=%{name}/' -i resources/powder.desktop
+mv resources/powder.desktop resources/%{name}.desktop
+
+sed -e 's/powder.desktop/%{name}.desktop/' -i resources/powder.appdata.xml
+mv resources/powder.appdata.xml resources/%{name}.appdata.xml
+
+
+%build
+%global noarch_scons_flags --builddir=build --data-in-homedir --luajit
--no-install-prompt --release --symbols --output=%{name}
+
+# The game assumes x86 and passes "--sse --sse2" to the compiler by default,
+# so we have to manually set the SSE flags based on the architecture
+%ifarch %{ix86} x86_64
+ %global scons_flags %{noarch_scons_flags} --sse --sse2 --sse3
+%else
+ %global scons_flags %{noarch_scons_flags} --no-sse
+%endif
+
+%set_build_flags
+scons-3 %{scons_flags} %{?_smp_mflags} ./
+
+
+%install
+install -m 755 -d %{buildroot}%{_bindir}
+install -m 755 build/%{name} %{buildroot}%{_bindir}/
+
+# -- png icons
+for ICONSIZE in 128 256; do
+ ICONDIR="%{buildroot}%{_datadir}/icons/hicolor/${ICONSIZE}x${ICONSIZE}/apps"
+ install -m 755 -d "${ICONDIR}"
+ install -m 644 -p "resources/icon/new-unused/icon_${ICONSIZE}.png"
"$ICONDIR/%{name}.png"
+done
+
+# -- svg icon
+ICONDIR="%{buildroot}%{_datadir}/icons/hicolor/scalable/apps"
+install -m 755 -d "${ICONDIR}"
+install -m 644 -p "resources/icon/new-unused/icon.svg"
"$ICONDIR/%{name}.svg"
+
+# -- .desktop and .appdata.xml file
+install -m 755 -d %{buildroot}%{_datadir}/applications
+install -m 755 -d %{buildroot}%{_metainfodir}/
+
+desktop-file-install \
+ --dir %{buildroot}/%{_datadir}/applications/ \
+ resources/%{name}.desktop
+
+install -m 644 -p resources/%{name}.appdata.xml %{buildroot}%{_metainfodir}/
+
+# -- savefile mimetype
+install -m 755 -d %{buildroot}%{_datadir}/mime/packages/
+install -m 644 resources/powdertoy-save.xml %{buildroot}%{_datadir}/mime/packages/
+
+
+%check
+desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop
+appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/%{name}.appdata.xml
+
+
+%files
+%{_bindir}/%{name}
+%{_datadir}/applications/%{name}.desktop
+%{_metainfodir}/%{name}.appdata.xml
+%{_datadir}/icons/hicolor/**/apps/%{name}.png
+%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
+%{_datadir}/mime/packages/%{name}*
+
+
+%changelog
+* Wed Sep 25 2019 Artur Iwicki <fedora(a)svgames.pl> - 94.1-4
+- Fix the License: tag and include %%{dist} in the Release: tag
+- Edit the "store data in HOME" patch
+
+* Fri Sep 06 2019 Artur Iwicki <fedora(a)svgames.pl> - 94.1-3
+- Add Patch0: store the preference file in XDG_CONFIG_DIR
+- Add Patch1: disable the "install me" in-game prompt
+
+* Mon Sep 02 2019 Artur Iwicki <fedora(a)svgames.pl> - 94.1-2
+- Set the build flags properly
+- Install the savegame MIME info file
+- Fix build failures on non-x86 arches (due to auto-enabled SSE code)
+
+* Wed Aug 28 2019 Artur Iwicki <fedora(a)svgames.pl> - 94.1-1
+- Initial packaging
diff --git a/sources b/sources
new file mode 100644
index 0000000..365649e
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+SHA512 (The-Powder-Toy-v94.1.tar.gz) =
ecda20d206298ff605a3a361255a0766caceece4d268355e4dbf1d56ef78bd7c43e54560d1ad71f29a8c3572d66eca875d5539e1006b260e029561ab91bf34d4