Skip to content

Have 'make uninstall' delete plugins which are no longer built#1312

Open
SteveErl wants to merge 2 commits intoMythTV:masterfrom
SteveErl:erlMerge38
Open

Have 'make uninstall' delete plugins which are no longer built#1312
SteveErl wants to merge 2 commits intoMythTV:masterfrom
SteveErl:erlMerge38

Conversation

@SteveErl
Copy link
Contributor

@SteveErl SteveErl commented Feb 26, 2026

This update modifies the uninstall rule in mythplugins/cleanup/Makefile to delete plugins which are not being built. If a builder reruns configuration to eliminate a plugin which was previously included, but fails to run uninstall before doing so, the old plugin may be left behind. Running make uninstall after the configuration changes wouldn't work. These changes will remove plugins which are no longer configured to be built.

Resolves #1174

Checklist

This update modifies the mythplugins/cleanup/Makefile
to delete plugins which are not being built. This helps
to prevent weird memory corruption problems caused by
trying to load an outdated plugin.

Resolves MythTV#1174
@linuxdude42
Copy link
Contributor

This does not belong in a "make install" command. I have no objection to it being part of a "make uninstall" command.

@kmdewaal
Copy link
Contributor

As I understand it this patch does remove the old plugins when there is a new plugin built.
But you can have an old build with more plugins than the new build and then there will be one or more old plugins still remaining, which can then cause a crash.
This is another reason to put this functionality in a "make uninstall" and I assume it can then uninstall everything that was previously installed.

@SteveErl
Copy link
Contributor Author

I could try moving it to make uninstall, but then it will only work if builders know that there is this sneaky hidden problem and that they need to run make uninstall to fix it. Do you always run make uninstall before running make install in the plugins directory? I haven't been doing that. I just tried it out to see how well it works. The output is a bit scary.

It tries, but luckily fails to remove /usr/bin/, /usr/share/mythtv/, /usr/share/mythtv/bindings, /usr/share/mythtv/fonts, /usr/share/mythtv/locales, /usr/share/mythtv/metadata, /usr/share/mythtv/mythconverg_backup.pl, /usr/share/mythtv/mythconverg_restore.pl, /usr/share/mythtv/sql, /usr/share/mythtv/themes. None of these are parts of the plugins. They are components of the mythbackend, mythfrontend, or the operating system.

I prefer to consider sudo make install a request to make sure the plugins currently being built are the only ones to be loaded by mythfrontend.

@kmdewaal
Copy link
Contributor

A few comments.

  • I think this is more a package management problem. It should be possible to build a package and then install that package. I think that some users do actually do this. This then solves the problem of removing the old package.
  • For my development I do use "make install" but I use dedicated target directories. Afte rmajor changes I just remove the complete target directory (e.g. /home/klaas/mythtv-master/usr/...) before doing the make install.
  • A proper solution would be that mythfrontend does do a better job of checking the version of the plugin before loading it. There some form of checking, as loading plugins sometimes fails with a version number mismatch message, but it also sometimes crashes. Maybe this check can be improved.

@SteveErl
Copy link
Contributor Author

The way the version check is currently implemented is that the plugin detects that its version does not match the libmythbase version. But this check is only done once the plugin is loaded, and by then, it's too late to avoid the memory corruption.

I looked into ways to implement your suggested "proper solution". The only way I found was

$ strings /usr/lib/mythtv/plugins/libmythmusic.so | grep libmythbase- | sed 's/^.*\.so\.//'
37
$ strings /usr/lib/mythtv/plugins/libmythweather.so | grep libmythbase- | sed 's/^.*\.so\.//'
34

This could work on Linux and MacOS, but Windows does not have a direct built-in equivalent that extracts strings from binary files in the same way the Linux strings command does. It also doesn't have a direct built-in equivalent to sed.

Implementing your "proper solution" would be quite complicated. The solution I came up with in this Pull Request is tremendously more simple. It will throw out libmythweather.so on my system since that plugin is expecting an old libmythbase version (34). As a result, it will never get loaded, and we avoid the memory corruption. The builder doesn't need to know about a new requirement that they run sudo make uninstall before sudo make install.

I grant that it's unusual to delete something during a make install command, but it's the simplest, most elegant solution to this problem.

@SteveErl SteveErl changed the title Have 'make install' delete plugins which are no longer built Have 'make uninstall' delete plugins which are no longer built Feb 28, 2026
The deletion of plugins which are no longer configured
to be built has been moved from the 'install' rule
to the 'uninstall' rule.

Resolves MythTV#1174
@SteveErl
Copy link
Contributor Author

I've moved the cleanup of old plugins from the install rule to the uninstall rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin with mismatched version causes crash

3 participants