Posts by willhertz

    TL;DR You can skip the background info and go straight to ACTUAL PROCEDURE section.

    Some Background

    Problem:

    Cluttered addons list with unused languages making harder to navigate through addons collection.

    I'm not worried about free space since I do not host any media in system drive phisically. I simply want to be able to navigate through my addons list without scrolling 60+ languages and having to reread every line to get to my desired addon configuration.

    TL;DR You can skip the background info and go straight to ACTUAL PROCEDURE section.

    My setup:

    I have libreelec 9.2.2 (Generic.x86_64-9.2.2) running in an old Acer Revo3600

    It's an upgrade of upgrades that started in a very ancient version of OpenElec (2.0 or 3.x) and went to several upgrades and then upgraded to librelec 7.x and made it through 9.2.2 as of april 2020.

    I run it from a 4gb USB pen-drive and no local content, everything played here is through external optical drive, usb drives, sd card or samba shares and streaming services like youtube.

    What I have tried?

    Googling and searching forums.

    And found nothing, basically Kodi forums claiming its OpenElec's realm, and OpenElec forums claiming it's a Kodi's thing. but nothing clearly useful. Or perhaps I need to refine my googling skills.

    Since I don't currently have physical access to the box I can't connect a mouse and start uninsalling each one by one.

    • So I tried with Kore remote. Tiresome and error-prone since no tactile feedback makes a little hard to operate virtual remote watching only the screen.
    • TigerVNC and good ol' ok-corral. It's at least 5 clicks for each language also tiresome and error-prone due to video tearing (probably because of my very very old h/w).
    • Using the web interface. It lets me deactivate the addons somewhat easily but doesn't remove them.

    So i decided to make some hands-on research from command line via SSH

    Example: I want to remove estonian language. I know that stonian locale is "et_ee"

    I log to the box via SSH and do some:

    Revo3600:~ # find / -name "*.et_ee*"

    (Revo3600 is my hostname)

    and these are the results:

    Notice: There's a pattern here. the language related stuff is prepended by "resource.language"

    • Then I go to the Kodi GUI, and remove the language from the addons settings dialog.

    Right After uninstalling re-ran the same command

    Revo3600:~ # find / -name "*.et_ee*"

    It's exactly the same!

    So uninstalling a language addon doesn't remove it from disk.

    I don't care about the unused space. but makes me wonder if installing or uninstalling is made through some scripting that reads the presence of some files in certain locations with certain name conventions (just like system upgrade works) and alters the database to "install" the plugin.

    What if it works the same for uninstalling?

    What if when the system doesn't see those files in those places, alters the database and removes the non-existant plugins?

    There's just one way to find out: TRYING.

    I have nothing to lose but a libreelec install that in the worst case scenario might recquire a fresh install and some 20 minutes to reconfigure.

    ACTUAL PROCEDURE

    DISCLAIMER:

    DO IT AT YOUR OWN RISK

    Once you have read and understood the risks an implications let's go

    • SSH to your libreelec box

    And we assume that you are on root's "home" (/storage)

    let's find out which files are related to language.

    Remember that "resource.language" pattern we found before?

    Let's look for all the language resources and write them to a file:

    find / -name "resource.language.*" >languages.list

    Remember that you should not uninstall english language. So lets remove english language(s) from the deadpool and create a new file.

    sed -n '/en_/!p' languages.list > safe_languages.list

    If you want to keep another language besides of english

    use your locale identifier like this.

    For example I want to keep spanish. Spanish Mexico locale is "es_mx"

    Then i will use es_  as the pattern to exclude.

    sed -n '/es_/!p' safe_languages.list > final_languages.list

    Notice: This will keep all es_ variants such as "es_ar" and "es_es"

    (if you wish to keep more languages rinse and repeat with new files)

    By now my  final_languages.list contains all the languages that you want to remove.


    Let's send them to the oblivion

    This is your last chance to re assess that your final_languages.list is listing ONLY the files that you want to remove.

    Now run the following:

    Bash
    for f in $(cat final_languages.list) ; do
    rm -rf "$f"
    done


    You will see a lot of files will be deleted and will also see about 400 errors saying

    Quote from Results will throw this errors

    rm: can't remove '/usr/share/kodi/somefile': Read-only file system.

    Something completely expected as per FHS. Since /usr/share is supposed to be read only (and I think libreelec runs as much as possible from ramdisk)

    By now if you go to Kodi Addons menu you will see that all those languages are still there. Like we found before, changes of the filesystem do not trigger the install/uninstall scripts by themselves.

    Maybe refreshing plugins list might work here, but just for the sake of it

    Let's apply the good ol' IT swiss-knive: Reboot.

    And that's it.

    After reboot all the languages that you didn't decide to keep should be gone for good.

    Final thoughts:

    • How it works? Don't Really know
    • Does it affect my system if I want to reinstall one of those languages or future system updates/upgrades? Don't know at all.
    • Will this break something else in my system? Can't answer that. Please re-read the warning and disclaimer.
    • This might be a very risky overkill and perhaps the ony thing needed was to delete the language ZIPs from /storage/.kodi/addons/packages/ but this was made before testing that as stated before. You can try that and reboot.