From ed95764eb3ba73576c491e69bb8829350021fa1d Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Wed, 13 Jun 2012 00:50:05 +0200 Subject: [PATCH] Use ZEROINSTALL_PORTABLE_BASE environment variable to override normal XDG directory resolution --- 0install.1 | 7 +++++++ zeroinstall/support/basedir.py | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/0install.1 b/0install.1 index 012d7c6..4a47d3e 100644 --- a/0install.1 +++ b/0install.1 @@ -442,6 +442,13 @@ Downloaded cached implementations, indexed by manifest digest. .PP See the 0store(1) man page for more information. +.SH ENVIRONMENT VARIABLES + +The configuration and cache directories can be changed using \fBXDG_CONFIG_HOME\fP, +\fBXDG_CONFIG_DIRS\fP, \fBXDG_CACHE_HOME\fP and \fBXDG_CACHE_DIRS\fP, as usual. + +If \fBZEROINSTALL_PORTABLE_BASE\fP is set, then the XDG_ variables are ignored and the configuration and cache are stored in \fB$ZEROINSTALL_PORTABLE_BASE/config\fP and \fB$ZEROINSTALL_PORTABLE_BASE/cache\fP instead. + .SH LICENSE .PP Copyright (C) 2012 Thomas Leonard. diff --git a/zeroinstall/support/basedir.py b/zeroinstall/support/basedir.py index 9bab63a..53afea0 100644 --- a/zeroinstall/support/basedir.py +++ b/zeroinstall/support/basedir.py @@ -37,7 +37,15 @@ else: del old_home del home_owner -if os.name == "nt": +portable_base = os.environ.get('ZEROINSTALL_PORTABLE_BASE') +if portable_base: + xdg_data_home = os.path.join(portable_base, "data") + xdg_data_dirs = [xdg_data_home] + xdg_cache_home = os.path.join(portable_base, "cache") + xdg_cache_dirs = [xdg_cache_home] + xdg_config_home = os.path.join(portable_base, "config") + xdg_config_dirs = [xdg_config_home] +elif os.name == "nt": from win32com.shell import shell, shellcon appData = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) localAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, 0, 0) -- 2.11.4.GIT