Kodi Community Forum

Full Version: Development with several Kodi versions and userdata directories
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Now that Kodi Matrix alpha is close to be released, I would like to port my addons from Python 2 to Python 3. The purpose of this thread is to know your opinion about how development of an addon in Linux can be done, having both Kodi Leia and Kodi Matrix installed.

I want to create separate branches for my addons, one for Python 2 and Leia and a new branch for Pyhton 3 and Matrix onward. Currently, Kodi on Linux uses ~/.kodi/ as the user writable directory and there is no way to change this. On Windows, users can use the -p parameter to tell Kodi to run in portable mode, however this feature is not available on Linux.

Currently, I use my compilation scripts to compile the Kodi version I want, including all Retroplayer binary addons, and installing them on the regular user account in directory /home/kodi/bin-kodi/. This is fine and it uses ~/.kodi/ for user writable directory (includes the user installed addons directory, the temp directory, the userdata directory, etc.). I can modify my compilation scripts to compile Matrix Alpha and place in directory /home/kodi/bin-kodi-matrix/, for example, while keeping Kodi Leia installed.

The main problem I see is that if I run Kodi Matrix then it will overwrite the user writable storage /home/kodi/.kodi/. In some other thread I cannot locate now, @wsnipex suggested to create several user writable directories, for example, ~/.kodi-leia/ and ~/.kodi-matrix/ and then create a symlink ~/.kodi/ pointing to the corresponding directory. However, this may lead to errors if you accidentally execute the wrong version of Kodi when the link points to the incorrect userdata folder. Note that I use Kodi Leia not only for development but also as IPTV, in other words, it is not a test installation but rather a "production" installation I do not want to destroy for development.

Other users/developers that may have this or a similar problem, what is your approach to solve this?

As a feature request, does it make sense to add a command line parameter in Linux, for example -uwd ~/.kodi-matrix/, to override the default user writable directory ~/.kodi/?
Could you spin up a development Kodi in a VM within your production machine?
(2020-07-31, 07:59)Wintermute0110 Wrote: [ -> ]however this feature is not available on Linux.

Yes, it is.  When you have built Kodi, simply run it from the build directory with ./kodi-x11 -p (assuming the X11 version) and it will create a portable_data directory in your CWD with all the necessary stuff inside it.

/kodi-19/kodi-build$ ls
addons                      CMakeFiles             kodi-x11     media
advancedsettings.xml.old    cmake_install.cmake    kodi-xrandr  portable_data
build                       compile_commands.json  launch-c     system
CMakeCache.txt              core                   launch-cxx   Testing
CMakeDoxyfile.in            CTestTestfile.cmake    libkodi.a    userdata
CMakeDoxygenDefaults.cmake  kodi-test              Makefile     xbmc

I do this all the time, plus it's trivial to switch to a new out-of-tree build directory and build and run another instance in that, again in portable mode.


NOTE:  DO NOT install Kodi anywhere, just run it in the build directory with the -p parameter.
(2020-07-31, 09:02)littlejeem Wrote: [ -> ]Could you spin up a development Kodi in a VM within your production machine?

That's something definitely doable, yes. However, it requires installing the OS in the VM, Kodi, the emulators, etc. I think is a bit cracking a nut with a sledgehammer.
Fair point in the overkill...

I'm really not up to speed on this yet, but would a docker instance be less overkill but still separate from the main system.
if you take a look at the kodi wrapper script, you'll find:
KODI_DATA=${KODI_DATA:-"${HOME}/.${bin_name}"} # mapped to special://home/

this env var allows you to override your profile dir.
Even simpler
Thanks everybody for your answers. I think I will use @wsnipex approach. I will keep Kodi Leia installed in /home/kodi/bin-kodi/ with special://home/ in the default ~/.kodi/. Then, I will compile and install Kodi Matrix in /home/kodi/bin-kodi-matrix/. I then will create the kodi-matrix script and put it in ~/bin/


# Set custom special://home/

OK, so I made a nasty discovery. If I use this script:


# Mapped to special://home/, default is ~/.kodi

# Execute Kodi

The usual home directory ~/.kodi is used.

This version of the script works as expected (notice the export keyword):


# Mapped to special://home/, default is ~/.kodi
export KODI_DATA=/home/kodi/.kodi-matrix

# Execute Kodi
KISS. Just add another user, switch back and forth between them with su