r7107 - packages/trunk/biniax2/debian/patches

Miriam Ruiz miriam at alioth.debian.org
Mon May 19 15:35:20 UTC 2008


Author: miriam
Date: 2008-05-19 15:35:20 +0000 (Mon, 19 May 2008)
New Revision: 7107

Modified:
   packages/trunk/biniax2/debian/patches/fixes.patch
Log:
Fixed patch so that user directories are compliant with XDG Base Directory Specification
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html



Modified: packages/trunk/biniax2/debian/patches/fixes.patch
===================================================================
--- packages/trunk/biniax2/debian/patches/fixes.patch	2008-05-19 08:10:38 UTC (rev 7106)
+++ packages/trunk/biniax2/debian/patches/fixes.patch	2008-05-19 15:35:20 UTC (rev 7107)
@@ -1,10 +1,10 @@
 # Copyright (C) 2008 by Miriam Ruiz <little_miry at yahoo.es>
 # Distributed under the same license as the game. See debian/copyright
 
-Index: biniax2/biniax.c
+Index: biniax2-0.0.20080409/biniax.c
 ===================================================================
---- biniax2.orig/biniax.c	2008-04-18 13:40:19.000000000 +0000
-+++ biniax2/biniax.c	2008-04-18 13:45:00.000000000 +0000
+--- biniax2-0.0.20080409.orig/biniax.c	2008-05-19 14:32:53.000000000 +0000
++++ biniax2-0.0.20080409/biniax.c	2008-05-19 15:03:38.000000000 +0000
 @@ -51,6 +51,18 @@
  #include "lev.h"
  #include "inc.h"
@@ -53,35 +53,58 @@
  	
  	/******************************************************************
  	SHOW INITIAL WELCOME SCREEN                                                
-@@ -1161,11 +1187,43 @@
+@@ -1161,11 +1187,66 @@
  GAME AND HISCORE SAVE / RESTORE
  ******************************************************************************/
  
 +static const char *saveFileName()
 +{
 +#ifndef _WIN32
-+        static char filename[PATH_MAX] = "";
-+        char *home;
-+        struct passwd *passwd;
-+        if (*filename)
-+                return filename;
-+        if (!getuid() || !(home = getenv("HOME")))
-+        {
-+                passwd = getpwuid (getuid());
-+                home=passwd->pw_dir;
-+                if (!home)
-+                {
-+                        fprintf(stderr, "$HOME is not defined.n");
-+                        return "./autosave.bnx2";
-+                }
-+        }
-+        if (strlen(home) > PATH_MAX - sizeof("/.biniax2/autosave"))
-+        {
-+                fprintf(stderr, "$HOME is excessively long.n");
-+                return "./autosave.bnx2";
-+        }
-+        snprintf(filename, sizeof(filename), "%s/.biniax2", home);
-+        mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++	char filename[PATH_MAX];
++	char *home;	
++	struct passwd *passwd;
++	if (!getuid())
++	{
++				fprintf(stderr, "No access to data files for root.\n");
++				return BNX_FALSE;		
++	} else {
++		if ((home = getenv("XDG_DATA_HOME")))
++		{ /* See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */
++			if (strlen(home) > PATH_MAX - sizeof("/biniax2/hof"))
++			{
++				fprintf(stderr, "$XDG_DATA_HOME is excessively long.n");
++				return BNX_FALSE;
++			}
++			snprintf(filename, sizeof(filename), "%s/biniax2", home);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);			
++		}
++		else if ((home = getenv("HOME")))
++		{
++			passwd = getpwuid (getuid());
++			home=passwd->pw_dir;
++			if (!home)
++			{
++				fprintf(stderr, "$HOME is not defined.\n");
++				return BNX_FALSE;
++			}
++			if (strlen(home) > PATH_MAX - sizeof("/.local/share/biniax2/autosave"))
++			{
++				fprintf(stderr, "$HOME is excessively long.n");
++				return BNX_FALSE;
++			}
++			snprintf(filename, sizeof(filename), "%s/.local", home);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++			strncat(filename, "/share", sizeof(filename)-1);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++			strncat(filename, "/biniax2", sizeof(filename)-1);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++		}
++		else
++		{
++			fprintf(stderr, "Neither $XDG_DATA_HOME nor $HOME are defined.\n");
++			return BNX_FALSE;
++		}
++	}
 +        strncat(filename, "/autosave", sizeof(filename)-1);
 +        return filename;
 +#else
@@ -98,7 +121,7 @@
  
  	if ( file == (FILE *) NULL )
  		return BNX_FALSE;
-@@ -1181,7 +1239,7 @@
+@@ -1181,7 +1262,7 @@
  {
  	FILE		*file;
  
@@ -107,10 +130,10 @@
  
  	if ( file == (FILE *) NULL )
  		return BNX_FALSE;
-Index: biniax2/desktop/cfg.c
+Index: biniax2-0.0.20080409/desktop/cfg.c
 ===================================================================
---- biniax2.orig/desktop/cfg.c	2008-04-18 13:40:19.000000000 +0000
-+++ biniax2/desktop/cfg.c	2008-04-18 13:40:20.000000000 +0000
+--- biniax2-0.0.20080409.orig/desktop/cfg.c	2008-05-19 14:32:53.000000000 +0000
++++ biniax2-0.0.20080409/desktop/cfg.c	2008-05-19 15:03:30.000000000 +0000
 @@ -30,6 +30,17 @@
  
  #include "inc.h"
@@ -129,7 +152,7 @@
  
  /******************************************************************************
  FUNCTIONS
-@@ -52,13 +63,40 @@
+@@ -52,13 +63,63 @@
  	char	buffer[ _Cfg_Buffer ];
  	int		nTemp;
  
@@ -137,23 +160,46 @@
 +	char filename[PATH_MAX];
 +	char *home;	
 +	struct passwd *passwd;
-+	if (!getuid() || !(home = getenv("HOME")))
++	if (!getuid())
 +	{
-+		passwd = getpwuid (getuid());
-+		home=passwd->pw_dir;
-+		if (!home)
++				fprintf(stderr, "No access to config files for root.\n");
++				return BNX_FALSE;		
++	} else {
++		if ((home = getenv("XDG_CONFIG_HOME")))
++		{ /* See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */
++			if (strlen(home) > PATH_MAX - sizeof("/biniax2/config"))
++			{
++				fprintf(stderr, "$XDG_CONFIG_HOME is excessively long.n");
++				return BNX_FALSE;
++			}
++			snprintf(filename, sizeof(filename), "%s/biniax2", home);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);			
++		}
++		else if ((home = getenv("HOME")))
 +		{
-+			fprintf(stderr, "$HOME is not defined.n");
++			passwd = getpwuid (getuid());
++			home=passwd->pw_dir;
++			if (!home)
++			{
++				fprintf(stderr, "$HOME is not defined.\n");
++				return BNX_FALSE;
++			}
++			if (strlen(home) > PATH_MAX - sizeof("/.config/biniax2/config"))
++			{
++				fprintf(stderr, "$HOME is excessively long.n");
++				return BNX_FALSE;
++			}
++			snprintf(filename, sizeof(filename), "%s/.config", home);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++			strncat(filename, "/biniax2", sizeof(filename)-1);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++		}
++		else
++		{
++			fprintf(stderr, "Neither $XDG_CONFIG_HOME nor $HOME are defined.\n");
 +			return BNX_FALSE;
 +		}
 +	}
-+	if (strlen(home) > PATH_MAX - sizeof("/.biniax2/config"))
-+	{
-+		fprintf(stderr, "$HOME is excessively long.n");
-+		return BNX_FALSE;
-+	}
-+	snprintf(filename, sizeof(filename), "%s/.biniax2", home);
-+	mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
 +	strncat(filename, "/config", sizeof(filename)-1);
 +#else
 +	char filename[] = "./config.bnx2";
@@ -171,7 +217,7 @@
  		return BNX_FALSE;
  	}
  
-@@ -76,6 +114,10 @@
+@@ -76,6 +137,10 @@
  
  	fclose( f );
  
@@ -182,7 +228,7 @@
  	return BNX_TRUE;
  }
  
-@@ -84,12 +126,28 @@
+@@ -84,12 +149,28 @@
  	return _Cfg.sound;
  }
  
@@ -211,10 +257,10 @@
 +{
 +	_Cfg.fullscreen = b;
 +}
-Index: biniax2/desktop/cfg.h
+Index: biniax2-0.0.20080409/desktop/cfg.h
 ===================================================================
---- biniax2.orig/desktop/cfg.h	2008-04-18 13:40:19.000000000 +0000
-+++ biniax2/desktop/cfg.h	2008-04-18 13:40:20.000000000 +0000
+--- biniax2-0.0.20080409.orig/desktop/cfg.h	2008-05-19 14:32:53.000000000 +0000
++++ biniax2-0.0.20080409/desktop/cfg.h	2008-05-19 14:32:59.000000000 +0000
 @@ -43,4 +43,8 @@
  BNX_BOOL cfgGetMusic();
  BNX_BOOL cfgGetFullscreen();
@@ -224,10 +270,10 @@
 +void cfgSetFullscreen(BNX_BOOL);
 +                                             
  #endif
-Index: biniax2/hof.c
+Index: biniax2-0.0.20080409/hof.c
 ===================================================================
---- biniax2.orig/hof.c	2008-04-18 13:40:19.000000000 +0000
-+++ biniax2/hof.c	2008-04-18 13:45:00.000000000 +0000
+--- biniax2-0.0.20080409.orig/hof.c	2008-05-19 14:32:53.000000000 +0000
++++ biniax2-0.0.20080409/hof.c	2008-05-19 15:03:34.000000000 +0000
 @@ -31,6 +31,18 @@
  
  #include "inc.h"
@@ -247,36 +293,59 @@
  #define chCursor '_'
  #define chSpace ' '
  
-@@ -82,6 +94,37 @@
+@@ -82,6 +94,60 @@
  	}
  }
  
 +static const char *hofFileName()
 +{
 +#ifndef _WIN32
-+	static char filename[PATH_MAX] = "";
-+	char *home;
++	char filename[PATH_MAX];
++	char *home;	
 +	struct passwd *passwd;
-+	if (*filename)
-+		return filename;
-+	if (!getuid() || !(home = getenv("HOME")))
++	if (!getuid())
 +	{
-+		passwd = getpwuid (getuid());
-+		home=passwd->pw_dir;
-+		if (!home)
++				fprintf(stderr, "No access to data files for root.\n");
++				return BNX_FALSE;		
++	} else {
++		if ((home = getenv("XDG_DATA_HOME")))
++		{ /* See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */
++			if (strlen(home) > PATH_MAX - sizeof("/biniax2/hof"))
++			{
++				fprintf(stderr, "$XDG_DATA_HOME is excessively long.n");
++				return BNX_FALSE;
++			}
++			snprintf(filename, sizeof(filename), "%s/biniax2", home);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);			
++		}
++		else if ((home = getenv("HOME")))
 +		{
-+			fprintf(stderr, "$HOME is not defined.n");
-+			return "./hof.bnx2";
++			passwd = getpwuid (getuid());
++			home=passwd->pw_dir;
++			if (!home)
++			{
++				fprintf(stderr, "$HOME is not defined.\n");
++				return BNX_FALSE;
++			}
++			if (strlen(home) > PATH_MAX - sizeof("/.local/share/biniax2/hof"))
++			{
++				fprintf(stderr, "$HOME is excessively long.n");
++				return BNX_FALSE;
++			}
++			snprintf(filename, sizeof(filename), "%s/.local", home);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++			strncat(filename, "/share", sizeof(filename)-1);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++			strncat(filename, "/biniax2", sizeof(filename)-1);
++			mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
 +		}
++		else
++		{
++			fprintf(stderr, "Neither $XDG_DATA_HOME nor $HOME are defined.\n");
++			return BNX_FALSE;
++		}
 +	}
-+	if (strlen(home) > PATH_MAX - sizeof("/.biniax2/hof"))
-+	{
-+		fprintf(stderr, "$HOME is excessively long.n");
-+		return "./hof.bnx2";
-+	}
-+	snprintf(filename, sizeof(filename), "%s/.biniax2", home);
-+	mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
-+	strncat(filename, "/hof", sizeof(filename)-1);
++	strncat(filename, "/config", sizeof(filename)-1);
 +	return filename;
 +#else
 +	return "./hof.bnx2";
@@ -285,7 +354,7 @@
  
  BNX_BOOL hofInit()
  {
-@@ -98,7 +141,7 @@
+@@ -98,7 +164,7 @@
  		Hof.tactic[ i ].score = (cHofEntries - i) * cHofInitScore;
  	}
  
@@ -294,7 +363,7 @@
  
  	if ( file == (FILE *) NULL )
  		return BNX_FALSE;
-@@ -114,7 +157,7 @@
+@@ -114,7 +180,7 @@
  {
  	FILE		*file;
  
@@ -303,7 +372,7 @@
  
  	if ( file == (FILE *) NULL )
  		return BNX_FALSE;
-@@ -246,4 +289,4 @@
+@@ -246,4 +312,4 @@
  BNX_HALL *hofGet()
  {
  	return (BNX_HALL *) &Hof;




More information about the Pkg-games-commits mailing list