mikespub-org / seblucas-cops

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)
http://blog.slucas.fr/en/oss/calibre-opds-php-server
GNU General Public License v2.0
65 stars 7 forks source link

Updates after `cops 2.0.1` on openwrt with `php=8.1` #78

Closed wikiped closed 5 months ago

wikiped commented 5 months ago

I had version 2.0.1 installed on an openwrt device.

checkconfig.php showed the following:

``` COPS Configuration Check Check if PHP version is correct OK (8.1.27) Check if GD is properly installed and loaded OK Check if Sqlite is properly installed and loaded OK Check if libxml is properly installed and loaded OK Check if DOM is properly installed and loaded OK Check if XMLWriter is properly installed and loaded OK Check if Json is properly installed and loaded OK Check if mbstring is properly installed and loaded OK Check if intl is properly installed and loaded OK Check if Normalizer class is properly installed and loaded OK Check if zlib is properly installed and loaded OK Check if the rendering will be done on client side or server side Client side rendering Check if Calibre database path is not an URL OK Check if Calibre database file exists and is readable OK Check if Calibre database file can be opened with PHP OK Check if Calibre database file contains at least some of the needed tables OK ```

Then I tried to install version 2.1.4 and the following was displayed on checkconfig.php:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a 64-bit build of PHP. in /srv/www/books/vendor/composer/platform_check.php on line 28

Unless I missed it, nothing in changelogs or the prerequisites indicates that 64-bit platform is required to run cops.

And this seems like a breaking change worth mentioning somewhere.

If there is anything that could be done to keep cops as portable as it used to be - that would be greatly appreciated!

Thank you for keeping cops alive.

dunxd commented 5 months ago

This came up with my implementation of COPS as a Home Assistant add-on. It's the same issue discussed at https://github.com/dunxd/HomeAssistantAddons/issues/45#issuecomment-1968766683

mikespub commented 5 months ago

Hi @wikiped I'm sorry about that.

As mentioned in the comment @dunxd referred to, COPS and mikespub/php-epub-meta are now using the maennchen/zipstream-php package to update .epub files, and that package requires a 64-bit platform since its version 3.x

If you don't configure COPS to update metadata and you don't re-generate the cover for Kobo devices, you do not need it at all, so you could remove it from the dependencies and continue working on 32-bit platforms.

wikiped commented 5 months ago

Thank you @mikespub for the feedback.

Your suggestion sounds like a very acceptable workaround for the issue. The only thing is that it would be great if you (or someone who knows how to actually do that) add literal steps to take to implement it.

  1. don't configure COPS to update metadata
  2. don't re-generate the cover for Kobo devices

Does it involve editing config_local.php or other file to remove those dependencies?

mikespub commented 5 months ago

Good guess ;-)

Both options are already disabled by default in config_default.php, but in case you customized your config_local.php make sure you have the following values set to 0:

$config['cops_update_epub-metadata'] = '0';
$config['cops_provide_kepub'] = '0';

Removing (or downgrading) the requirement of the mikespub/php-epub-meta package is a bit more tricky, and depends on how you installed COPS:

The cops-2.x.x.zip release packages already include it, and they don't allow you to (easily) override the dependencies, so you'll need to use the source code installation instead - see README.md option 2.

You'll need the PHP composer tool to install the dependencies. From what I've read for openwrt the command-line installation seems like the best option there.

Then before you run the composer install --no-dev -o or phar composer.phar install --no-dev -o command, you need to update the composer.json file to remove (or downgrade) the mikespub/php-epub-meta package:

https://github.com/mikespub-org/seblucas-cops/blob/fd9480e159eae8b642e24e81c7e7f04154f009d6/composer.json#L31

In your case, you could simply remove that line if you don't use the epub reader either, or change it to

        "mikespub/php-epub-meta": "^1.5",

And the same for the mikespub/epub-loader package which depends on it:

https://github.com/mikespub-org/seblucas-cops/blob/fd9480e159eae8b642e24e81c7e7f04154f009d6/composer.json#L52

It can also be removed or replaced with:

        "mikespub/epub-loader": "^1.5",
wikiped commented 5 months ago

Thank you for taking time to look into this and outlining the steps - very helpful.

Perhaps, it should also be mentioned that composer.lock file needs to be renamed/removed to avoid version confilicts with composer.json.

Assuming that this is as far as the solution will go we can close the issue.

Thank you again for helping this.

wikiped commented 5 months ago

Here is a little bash script that patches cops source directory as outlined above by @mikespub.