Question with Addon paths

  • Hi all,

    I'm trying to create a Kodi Addon which is an application which binaries have some direct references to files located on the /usr folder, for example:

    -The original application wants to play a wav file which on an Ubuntu distribution is located at "/usr/share/appname/myfile.wav".

    -Looking into the app's code, I can see something like audio.play(DATADIR + "/myfile.wav") and the DATADIR variable can be customized when configuring the build (default value is "/usr/local/appname").

    And there's the question: I want to add this myfile.wav to the addon, for example on a folder called audio, so the final location would be "$ADDON_FOLDER_PATH/audio/myfile.wav".

    I supose the only way to make this work is by telling the configure command "DATADIR=/storage/.kodi/addons/appname". However, this seems wrong. If I make this, the addon would only run on LibreELEC and if it's located at ~/.kodi/addons (it won't work, for example, if I decided to make a LibreELEC build with this addon added to the base image).

    Is there any way to solve this issue, or I have to work with these limitations?

    Thanks in advance!

  • Have a look at how inputstream.adaptive depends upon widevine CDM files being installed to the OS in a known location. If the files are not present, the add-on initiates a download of a ChromeOS update file which contains them, and then the update file is unpacked and the needed files are moved to a consistent location where inputstream.adaptive can find them. This keeps the core add-on size small (and avoids the legal issues involved with pre-bundling the widevine files).

    In your case you can detect distro by looking in /etc/os-release and if LE, initiate a download of the needed (bulky) files to a cache location under /storage/.kodi or somewhere else on /storage, and if not LE, check for the package being installed in the known location. Then set the media file paths to either the cache location or the /usr location as needed. On other distros you'll need to gracefully handle the dependency on the app binaries being installed anyway.

  • Yes, I though on this solution. However, the problem here is that the media file's path is hardcoded into the main program pointing to "/usr/share/appname/myfile.wav" or whatever DATADIR is specified when running the ./configure command. As I understand this, hardcoding paths like that is a bad practice. However, the source code has at least 50 files and not playing this media file is the smaller problem we'll find related to hardcoded paths.

    I supose the best option here is look for an alternative or create a custom LibreELEC build with this application added into the image.

  • I wouldn’t create it as a custom image. As an addon, with a little bit of patching or sed. The addon can be made to work right. It is all done by the build scripts.

    One I have been looking at recently is net-snmp (so DATADIR would be replaced as below)

    LibreELEC.tv/package.mk at 9670b47b41c8c5bdada28ed21474af33e2d2bdf3 · LibreELEC/LibreELEC.tv
    Just enough OS for KODI. Contribute to LibreELEC/LibreELEC.tv development by creating an account on GitHub.
    github.com
  • I wouldn’t create it as a custom image. As an addon, with a little bit of patching or sed. The addon can be made to work right. It is all done by the build scripts.

    One I have been looking at recently is net-snmp (so DATADIR would be replaced as below)

    https://github.com/LibreELEC/Libr…/package.mk#L42

    Yes, my case is exactly the same as this. Configuring the package like that will solve the problem. What I didn't know was if this was right for a LibreELEC addon or if there was a better way to create it.

    Thanks for the answers and the example.