[aquaria] Linux packaging
Andrew Church
achurch+aquaria at achurch.org
Mon Jun 14 07:48:40 EDT 2010
(I'm new on the list -- hello to all!)
>I was getting enthusiastic about packaging this for Debian (and hence
>Ubuntu), which is kinda the first reason I signed to this mailing
>list, but now I'm not sure how to do it without game data. Since the
>data isn't even redistributable, how would a packaging work? Do you
>have something in mind? From what I can tell in the source, the game
>data has to be in the same directory as the binary, so it could create
>an awkward packaging.
How about the patch below, to let an environment variable override the
default of the executable's directory? I haven't tested it deeply, but
it looks like initialization is the only time chdir() is called, so it
should be safe.
--Andrew Church
achurch at achurch.org
http://achurch.org/
------------------------------------------------------------------------
# HG changeset patch
# User achurch
# Date 1276469231 -32400
# Branch data-path-from-env-var
# Node ID fa4df25f635ea03c93293742377a23d17b4fb212
# Parent 4d71e196dae6b46109a1238f33b371275a7d19b8
Take the data file path from ${AQUARIA_DATA_PATH}, if present.
This patch allows the environment variable ${AQUARIA_DATA_PATH} to be used
to override the default path for data files (the executable's directory).
By running Aquaria as e.g.
AQUARIA_DATA_PATH=/usr/games/lib/aquaria /usr/games/bin/aquaria
Aquaria will look in the specified directory for all its data files, so
the executable can be installed in a different place.
This currently only works on Linux (i.e., when BBGE_BUILD_UNIX is set),
but it could work for other systems as well with appropriate code in
Aquaria/Main.cpp (to get the environment variable or other system setting)
and Core::initPlatform() (to set the directory appropriately).
diff -r 4d71e196dae6 -r fa4df25f635e Aquaria/Main.cpp
--- a/Aquaria/Main.cpp Tue Jun 08 03:28:50 2010 +0900
+++ b/Aquaria/Main.cpp Mon Jun 14 07:47:11 2010 +0900
@@ -209,7 +209,15 @@
remove("ran");
#endif
- DSQ core("");
+ std::string fileSystem = "";
+
+#ifdef BBGE_BUILD_UNIX
+ const char *envPath = getenv("AQUARIA_DATA_PATH");
+ if (envPath != NULL)
+ fileSystem = envPath;
+#endif
+
+ DSQ core(fileSystem);
#endif
{
core.init();
diff -r 4d71e196dae6 -r fa4df25f635e BBGE/Core.cpp
--- a/BBGE/Core.cpp Tue Jun 08 03:28:50 2010 +0900
+++ b/BBGE/Core.cpp Mon Jun 14 07:47:11 2010 +0900
@@ -981,12 +981,13 @@
initRenderObjectLayers(numRenderLayers);
- initPlatform();
+ initPlatform(filesystem);
}
-void Core::initPlatform()
+void Core::initPlatform(const std::string &filesystem)
{
#if defined(BBGE_BUILD_MACOSX) && !defined(BBGE_BUILD_MACOSX_NOBUNDLEPATH)
+ // FIXME: filesystem not handled
CFBundleRef mainBundle = CFBundleGetMainBundle();
//CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle);
@@ -1000,6 +1001,13 @@
debugLog(path);
chdir(path);
#elif defined(BBGE_BUILD_UNIX)
+ if (!filesystem.empty())
+ {
+ if (chdir(filesystem.c_str()) == 0)
+ return;
+ else
+ debugLog("Failed to chdir to filesystem path" + filesystem);
+ }
char path[PATH_MAX];
// always a symlink to this process's binary, on modern Linux systems.
const ssize_t rc = readlink("/proc/self/exe", path, sizeof (path));
@@ -1021,6 +1029,7 @@
}
#endif
#ifdef BBGE_BUILD_WINDOWS
+ // FIXME: filesystem not handled
#endif
}
diff -r 4d71e196dae6 -r fa4df25f635e BBGE/Core.h
--- a/BBGE/Core.h Tue Jun 08 03:28:50 2010 +0900
+++ b/BBGE/Core.h Mon Jun 14 07:47:11 2010 +0900
@@ -888,8 +888,8 @@
NO_DESTROY
};
// init
- Core(const std::string &fileystem, int numRenderLayers, const std::string &appName="BBGE", int particleSize=1024, std::string userDataSubFolder="");
- void initPlatform();
+ Core(const std::string &filesystem, int numRenderLayers, const std::string &appName="BBGE", int particleSize=1024, std::string userDataSubFolder="");
+ void initPlatform(const std::string &filesystem);
~Core();
virtual void init();
More information about the aquaria
mailing list