Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved userdata to XDG_DATA_HOME #5895

Merged
merged 4 commits into from Jan 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions tools/Linux/kodi.sh.in
Expand Up @@ -26,7 +26,7 @@ exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
LIBDIR="@libdir@"
CRASHLOG_DIR=${CRASHLOG_DIR:-$HOME}
USERDATA_DIR="${HOME}/.${bin_name}"
USERDATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/${bin_name}"


# Check for some options used by this script
Expand All @@ -50,7 +50,13 @@ migrate_home()
#check if data migration is needed
if [ -d "${HOME}/.xbmc" ] && [ ! -d "${USERDATA_DIR}" ]; then
echo "INFO: migrating userdata folder. Renaming ${HOME}/.xbmc to $USERDATA_DIR"
mv ${HOME}/.xbmc $USERDATA_DIR
mv ${HOME}/.xbmc ${USERDATA_DIR}
ln -s $USERDATA_DIR ${HOME}/.xbmc
touch ${USERDATA_DIR}/.kodi_data_was_migrated
elif [ -d "${HOME}/.kodi" ] && [ ! -d "${USERDATA_DIR}" ]; then
echo "INFO: migrating userdata folder. Renaming ${HOME}/.kodi to $USERDATA_DIR"
mv ${HOME}/.kodi ${USERDATA_DIR}
ln -s $USERDATA_DIR ${HOME}/.kodi
touch ${USERDATA_DIR}/.kodi_data_was_migrated
fi
}
Expand Down
37 changes: 24 additions & 13 deletions xbmc/Application.cpp
Expand Up @@ -647,7 +647,7 @@ bool CApplication::Create()
{
std::string lcAppName = CCompileInfo::GetAppName();
StringUtils::ToLower(lcAppName);
fprintf(stderr,"Could not init logging classes. Permission errors on ~/.%s (%s)\n", lcAppName.c_str(),
fprintf(stderr,"Could not init logging classes. Permission errors on $XDG_CACHE_HOME/%s (%s)\n", lcAppName.c_str(),
CSpecialProtocol::TranslatePath(g_advancedSettings.m_logFolder).c_str());
return false;
}
Expand Down Expand Up @@ -1056,10 +1056,10 @@ bool CApplication::InitDirectoriesLinux()
special://xbmc/ => [read-only] system directory (/usr/share/kodi)
special://home/ => [read-write] user's directory that will override special://kodi/ system-wide
installations like skins, screensavers, etc.
($HOME/.kodi)
($XDG_DATA_HOME/kodi)
NOTE: XBMC will look in both special://xbmc/addons and special://home/addons for addons.
special://masterprofile/ => [read-write] userdata of master profile. It will by default be
mapped to special://home/userdata ($HOME/.kodi/userdata)
mapped to special://home/userdata ($XDG_DATA_HOME/kodi/userdata)
special://profile/ => [read-write] current profile's userdata directory.
Generally special://masterprofile for the master profile or
special://masterprofile/profiles/<profile_name> for other profiles.
Expand All @@ -1081,14 +1081,15 @@ bool CApplication::InitDirectoriesLinux()
else
userHome = "/root";

std::string appBinPath, appPath;
std::string appBinPath, appPath, xdgDataPath, xdgCachePath;
std::string appName = CCompileInfo::GetAppName();
std::string dotLowerAppName = "." + appName;
StringUtils::ToLower(dotLowerAppName);
std::string lowerAppName = appName;
StringUtils::ToLower(lowerAppName);
const char* envAppHome = "KODI_HOME";
const char* envAppBinHome = "KODI_BIN_HOME";
const char* envAppTemp = "KODI_TEMP";

const char* xdgDataHome = "XDG_DATA_HOME";
const char* xdgCacheHome = "XDG_CACHE_HOME";

CUtil::GetHomePath(appBinPath, envAppBinHome);
if (getenv(envAppHome))
Expand All @@ -1110,20 +1111,31 @@ bool CApplication::InitDirectoriesLinux()
}
}

if (getenv(xdgDataHome))
xdgDataPath = getenv(xdgDataHome);
else
xdgDataPath = userHome + "/.local/share/";

if (getenv(xdgCacheHome))
xdgCachePath = getenv(xdgCacheHome);
else
xdgCachePath = userHome + "/.cache/";

/* Set some environment variables */
setenv(envAppBinHome, appBinPath.c_str(), 0);
setenv(envAppHome, appPath.c_str(), 0);

if (m_bPlatformDirectories)
{
// map our special drives
/* map our special drives */
CSpecialProtocol::SetXBMCBinPath(appBinPath);
CSpecialProtocol::SetXBMCPath(appPath);
CSpecialProtocol::SetHomePath(userHome + "/" + dotLowerAppName);
CSpecialProtocol::SetMasterProfilePath(userHome + "/" + dotLowerAppName + "/userdata");
CSpecialProtocol::SetHomePath(xdgDataPath + lowerAppName);
CSpecialProtocol::SetMasterProfilePath(xdgDataPath + lowerAppName + "/userdata");

CStdString strTempPath = userHome;
strTempPath = URIUtils::AddFileToFolder(strTempPath, dotLowerAppName + "/temp");
CStdString strTempPath = URIUtils::AddFileToFolder(xdgCachePath, lowerAppName + "/");
CDirectory::Create(strTempPath);
strTempPath = URIUtils::AddFileToFolder(xdgCachePath, lowerAppName + "/temp");
if (getenv(envAppTemp))
strTempPath = getenv(envAppTemp);
CSpecialProtocol::SetTempPath(strTempPath);
Expand All @@ -1132,7 +1144,6 @@ bool CApplication::InitDirectoriesLinux()
g_advancedSettings.m_logFolder = strTempPath;

CreateUserDirs();

}
else
{
Expand Down
11 changes: 6 additions & 5 deletions xbmc/filesystem/SpecialProtocol.h
Expand Up @@ -28,23 +28,24 @@

special://xbmc/ - the main XBMC folder (i.e. where the app resides).
special://home/ - a writeable version of the main XBMC folder
Linux: ~/.kodi/
Linux: $XDG_DATA_HOME/kodi/ (defaults to ~/.local/share)
OS X: ~/Library/Application Support/Kodi/
Win32: ~/Application Data/XBMC/
special://userhome/ - a writable version of the user home directory
Linux, OS X: ~/.kodi
Linux: $XDG_DATA_HOME/kodi/ (defaults to ~/.local/share)
OS X: ~/.kodi
Win32: home directory of user
special://masterprofile/ - the master users userdata folder - usually special://home/userdata
Linux: ~/.kodi/userdata/
Linux: $XDG_DATA_HOME/kodi/userdata/ (defaults to ~/.local/share)
OS X: ~/Library/Application Support/Kodi/UserData/
Win32: ~/Application Data/XBMC/UserData/
special://profile/ - the current users userdata folder - usually special://masterprofile/profiles/<current_profile>
Linux: ~/.kodi/userdata/profiles/<current_profile>
Linux: $XDG_DATA_HOME/kodi/userdata/profiles/<current_profile> (defaults to ~/.local/share)
OS X: ~/Library/Application Support/Kodi/UserData/profiles/<current_profile>
Win32: ~/Application Data/XBMC/UserData/profiles/<current_profile>

special://temp/ - the temporary directory.
Linux: ~/.kodi/temp
Linux: $XDG_CACHE_HOME/kodi/temp (defaults to ~/.cache)
OS X: ~/
Win32: ~/Application Data/XBMC/cache
*/
Expand Down