From a76704eb855aa463c9689fbdc537fffcedf14ce4 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Mon, 5 Jan 2009 19:25:59 +0100 Subject: [PATCH] * Better Patch for Configfile handling * Remove creation of configfiles from launcher script * Done in python code now --- debian/changelog | 6 +++ debian/launcher | 6 --- debian/patches/configfile_move.patch | 59 +++++++++++++++++++++++++++++ debian/patches/local_config_goes_to_homedir | 21 ---------- debian/patches/series | 2 +- 5 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 debian/patches/configfile_move.patch delete mode 100644 debian/patches/local_config_goes_to_homedir diff --git a/debian/changelog b/debian/changelog index 6127fe2..1056bd3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +openanno (2008.1+svn1657-2) unstable; urgency=low + + * Improve Support for Configs in Homedir + + -- Christoph Egger Mon, 05 Jan 2009 19:28:23 +0100 + openanno (2008.1+svn1657-1) unstable; urgency=low * New Upstream Version diff --git a/debian/launcher b/debian/launcher index ccc7362..89abf0c 100644 --- a/debian/launcher +++ b/debian/launcher @@ -1,10 +1,4 @@ #!/bin/sh -if [ ! -e "$HOME"/.openanno/config.sqlite ] -then \ - mkdir "$HOME"/.openanno - cp /var/lib/python-support/python2.5/openanno/content/config.sqlite "$HOME"/.openanno/ -fi - cd /var/lib/python-support/python2.5/openanno/ && python openanno.pyc diff --git a/debian/patches/configfile_move.patch b/debian/patches/configfile_move.patch new file mode 100644 index 0000000..d767f85 --- /dev/null +++ b/debian/patches/configfile_move.patch @@ -0,0 +1,59 @@ +Index: a/game/settings.py +=================================================================== +--- a/game/settings.py (Revision 1648) ++++ b/game/settings.py (Arbeitskopie) +@@ -23,6 +23,7 @@ + import shutil + import os.path + import simplejson ++import user + + class Setting(object): + """ Class to store settings +@@ -114,8 +115,10 @@ + """ + @param config: + """ +- def __init__(self, config = 'config.sqlite'): ++ def __init__(self, config = '%s/.openanno/config.sqlite' % user.home): + if not os.path.exists(config): ++ if not os.path.exists(os.path.dirname(config)): ++ os.makedirs(os.path.dirname(config)) + shutil.copyfile('content/config.sqlite', config) + game.main.db("ATTACH ? AS config", config) + version = game.main.db("PRAGMA config.user_version")[0][0] +Index: a/game/savegamemanager.py +=================================================================== +--- a/game/savegamemanager.py (Revision 1648) ++++ b/game/savegamemanager.py (Arbeitskopie) +@@ -25,7 +25,7 @@ + import re + import glob + import time +- ++import user + import game.main + from dbreader import DbReader + +@@ -40,7 +40,7 @@ + The return values is usually a tuple: (list_of_savegame_files, list_of_savegame_names), + where savegame_names are meant for displaying to the user. + """ +- savegame_dir = "content/save" ++ savegame_dir = "%s/.openanno/content/save" % user.home + autosave_dir = savegame_dir+"/autosave" + quicksave_dir = savegame_dir+"/quicksave" + demo_dir = "content/demo" +@@ -60,6 +60,12 @@ + def __init__(self): + # share members across all instances + self.__dict__ = self._shared_state ++ ++ # create savegame directory if it does not exist ++ if not os.path.exists(self.autosave_dir): ++ os.makedirs(self.autosave_dir) ++ if not os.path.exists(self.quicksave_dir): ++ os.makedirs(self.quicksave_dir) + + def __get_displaynames(self, files): + """Returns list of names files, that should be displayed to the user. diff --git a/debian/patches/local_config_goes_to_homedir b/debian/patches/local_config_goes_to_homedir deleted file mode 100644 index 3bcea3b..0000000 --- a/debian/patches/local_config_goes_to_homedir +++ /dev/null @@ -1,21 +0,0 @@ -Index: openanno/game/settings.py -=================================================================== ---- openanno.orig/game/settings.py 2008-11-08 18:30:48.000000000 +0100 -+++ openanno/game/settings.py 2008-11-08 18:47:13.000000000 +0100 -@@ -23,6 +23,7 @@ - import shutil - import os.path - import simplejson -+import os - - class Setting(object): - """ Class to store settings -@@ -114,7 +115,7 @@ - """ - @param config: - """ -- def __init__(self, config = 'config.sqlite'): -+ def __init__(self, config = '%s/.openanno/config.sqlite' % os.getenv('HOME')): - if not os.path.exists(config): - shutil.copyfile('content/config.sqlite', config) - game.main.db("ATTACH ? AS config", config) diff --git a/debian/patches/series b/debian/patches/series index 24777ab..c744c4e 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1 @@ -local_config_goes_to_homedir +configfile_move.patch -- 2.11.4.GIT