zach-morris / plugin.program.iagl

The Internet Archive Game Launcher (IAGL) will launch Games from the Internet using Kodi
GNU General Public License v3.0
344 stars 49 forks source link

Question: Any way to install into kodi system folder? #231

Closed aanderse closed 2 years ago

aanderse commented 2 years ago

I noticed references to special://home throughout in the code. Unfortunately this means I can't install this plugin into my kodi system folder.

Is there any way around this so I could install this plugin into my kodi system folder? I would like to package this plugin for my Linux OS, so the plugin is located under the equivalent of /usr/share/kodi/addons/plugin.program.iagl.

zach-morris commented 2 years ago

Is there some sort of automatic way to install addons to that location? Just reading about that path, it's used for binary addons normally. Installing by zip or repository wouldn't automatically put it there somehow would it?

aanderse commented 2 years ago

That path is useful to Linux distributions which want to package software... like your wonderful plugin.

Then users can install your plugin via their OS package manager (just like they do with some binary add-ons).

Does kodi have an abstraction in code to access a plugins code, regardless of whether it is in the system or user path? It doesn't look like it...

zach-morris commented 2 years ago

Documented here.

From this documentation, I can't see a way for it to happen:

special://xbmc  ... Users should not modify files or install addons in this directory
special://home  ...   This path contains a writable version of the special://xbmc directories. Any addons should be installed here

The only other thing to keep in mind is I don't think the addon would auto update if it were in that directory.

aanderse commented 2 years ago

Plugins installed into the system directory can be updated via the OS package manager instead of kodi. If a repo has a newer version available the user can choose to "update" the plugin, but this just installs a new copy into the user directory.

Some Linux users prefer to have their OS manage kodi plugins instead of having kodi manage them. In my case I have multiple htpcs running Linux and I create images for them and deploy software that way. By using the OS to manage kodi packages I don't have to go through the kodi ui to install plugins, which can be time consuming.

zach-morris commented 2 years ago

Makes sense. Although I don't know of a way to do this. Are there other addons that are installable in this manner? I assume they'd have the same issue.

aanderse commented 2 years ago

I think most addons which are installable into the kodi system directory don't directly reference their own assets this way.

I'll do so research and report back.

Thanks!

aanderse commented 2 years ago

I found the way to access the path for an addon, regardless of where it is installed (system or user path): xbmcaddon.Addon().getAddonInfo('path')

I went through your addons code and unfortunately it isn't a simple search/replace to make this work. The kodi system path is read only, so determining which files are where is a little bit of challenge.

I did a simple search/replace to see how much of the addon still functioned and it wasn't great. You can see my work here: https://github.com/aanderse/plugin.program.iagl/commit/fc1de48cd8a6fa6553e5400a8a1fe5489d31266e

Does a change like this seem feasible?

zach-morris commented 2 years ago

Possibly. The one thing I'll have to look into is how i could pass the correct path to the InfoDialog for skin assets (example)This addon is a little different in that regard too, as there's a skin inside the addon for the Game Window.

Can you confirm this change wouldn't be used for some box/build that would be sold?

zach-morris commented 2 years ago

Looks like skins use relative paths anyway, so I didn't even need that whole path string. I've input changes that I think address this, but would need them to be tested

aanderse commented 2 years ago

Wow! Looking good!

I noticed one small import missing:

diff --git a/addon.py b/addon.py
index 8b6a13d..c6be6e1 100644
--- a/addon.py
+++ b/addon.py
@@ -10,7 +10,7 @@ from urllib.parse import unquote_plus as url_unquote
 from random import sample as random_sample
 from resources.lib.main import iagl_addon
 from resources.lib import paginate
-from resources.lib.utils import clear_mem_cache, get_mem_cache, set_mem_cache, get_next_page_listitem, get_setting_as, get_game_listitem, check_if_file_exists, check_if_dir_exists, clean_image_entry, clean_trailer_entry, loc_str, check_and_close_notification, get_history_listitem, get_netplay_listitem, update_listitem_title, get_post_dl_commands, add_game_to_favorites, clean_file_folder_name, get_uuid, generate_discord_announcement, get_blank_favorites_listitem, get_database_listitem, url_quote_query, delete_file_pathlib, remove_game_from_favorites, zachs_debug
+from resources.lib.utils import clear_mem_cache, get_mem_cache, set_mem_cache, get_next_page_listitem, get_setting_as, get_game_listitem, check_if_file_exists, check_if_dir_exists, clean_image_entry, clean_trailer_entry, loc_str, check_and_close_notification, get_history_listitem, get_netplay_listitem, update_listitem_title, get_post_dl_commands, add_game_to_favorites, clean_file_folder_name, get_uuid, generate_discord_announcement, get_blank_favorites_listitem, get_database_listitem, url_quote_query, delete_file_pathlib, remove_game_from_favorites, zachs_debug, ADDON_SPECIAL_PATH

After some light testing the plugin seems to work! :rocket:

I happened to notice some errors in the logs... but as mentioned, the plugin still works :thinking:

2021-11-05 15:15:08.188 T:206436   ERROR <general>: Delete - Error deleting file /usr/share/kodi/addons/plugin.program.iagl/resources/data/dat_files/Colecovision_ZachMorris.xml
2021-11-05 15:15:08.189 T:206436   ERROR <general>: Delete - Error deleting file /usr/share/kodi/addons/plugin.program.iagl/resources/data/dat_files/Master_System_Bestof_ZachMorris.xml
2021-11-05 15:15:08.189 T:206436   ERROR <general>: Rename - Error renaming file /usr/share/kodi/addons/plugin.program.iagl/resources/data/dat_files/Master_System_Bestof_ZachMorris.xml
2021-11-05 15:15:08.189 T:206436   ERROR <general>: Delete - Error deleting file /usr/share/kodi/addons/plugin.program.iagl/resources/data/dat_files/Master_System_Bestof_ZachMorris.xml
2021-11-05 15:15:08.189 T:206436   ERROR <general>: Delete - Error deleting file /usr/share/kodi/addons/plugin.program.iagl/resources/data/dat_files/CDI_ZachMorris.xml

Any thoughts?

Thank you SO much for your work on this! :heart:

zach-morris commented 2 years ago

Fixed the first part with the last commit. The errors are likely due to permissions in that new location?

Here's what the addon does: 1). Addon is installed, and contains the game xml/dat files 2). Addon runs, and if dat files are present in the addon directory, they're moved from the addon directory to the userdata directory so they can be modified 3). Later, if the addon is updated, the xml files in the newly installed addon folder are compared to existing files in the userdata folder. If the version of the dat file is updated, the user then has an option to update the files or ignore the update (delete the file from the addon folder). If the version is the same, the file is just deleted.

You could turn on DEBUG logging which would provide some more debug info on where the issue is, but thats likely the issue.

However, I don't think that'll really be an issue as far as functionality is concerned, since the addon also checks to see if the version of the dat file is new, and if it is the same version, then it just throws it away. The downside here is that the way kodi addons run is that it will do this check every time the addon is executed, so it could potentially seem to react slower since it's checking the contents of all these files every time.

The way these are installed, can the permissions of the folder be modified?

aanderse commented 2 years ago

Ah, thanks for the explanation. That makes sense.

The way these are installed, can the permissions of the folder be modified?

Unfortunately not. System level software can never be modified by a regular user. Your explanation makes me think this isn't critical and the addon will work.

Thank you very much for your work on this! I really appreciate it! :rocket: