Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imager breaks installation for Imager::File::PNG #498

Closed
KES777 opened this issue Jun 29, 2022 · 9 comments
Closed

Imager breaks installation for Imager::File::PNG #498

KES777 opened this issue Jun 29, 2022 · 9 comments

Comments

@KES777
Copy link

KES777 commented Jun 29, 2022

perl-carton/carton#282 (comment)

@tonycoz
Copy link
Owner

tonycoz commented Jun 30, 2022

cpan Imager::File::PNG installs successfully for me in a clean perl, including successfully installing Imager.

It's deliberate that installing Imager installs Imager::File::PNG if possible.

@tonycoz
Copy link
Owner

tonycoz commented Jun 30, 2022

You can prevent installation of the bundled modules by setting IM_ENABLE=none in the environment before trying to install Imager.

This will prevent any of the modules also on CPAN from being built, including FT2, GIF, JPEG, PNG, TIFF, Win32. FT1, T1.

@KES777
Copy link
Author

KES777 commented Jun 30, 2022

The problem is that Imager installs Imager::File::PNG directly and thus Carton did not notice that installation and does not include Imager::File::PNG modules into cpanfile.snapshot and archive for that modules into bundle.

@tonycoz
Copy link
Owner

tonycoz commented Jun 30, 2022

I don't know what you mean by "installs ... directly" - the sub directory modules are installed no differently to other sub-directory modules, such as in Encode or Tk. The only difference is that the Imager dist doesn't "provide" the modules, so that the separate dists will be installed as hard dependencies.

I've described a mechanism you can use to prevent installing Imager trying to install Imager::File::PNG. I won't be changing the default.

@tonycoz tonycoz closed this as completed Jun 30, 2022
@KES777
Copy link
Author

KES777 commented Jun 30, 2022

If Imager provides Imager::File::PNG it should describe that. Currently it installs that module silently:

  Imager-1.018
    pathname: T/TO/TONYC/Imager-1.018.tar.gz
    provides:
      Imager 1.018
      Imager::Color 1.015
      Imager::Color::Float 1.008
      Imager::Color::Table 1.004
      Imager::CountColor 0.03
      Imager::Expr 1.008
      Imager::Expr::Assem 1.004
      Imager::Expr::Infix 1.008
      Imager::Expr::Postfix 1.008
      Imager::ExtUtils 1.003
      Imager::FORMATS 1.018
      Imager::File::CUR 1.000
      Imager::File::ICO 0.08
      Imager::File::SGI 0.05
      Imager::Fill 1.013
      Imager::Filter::DynTest 0.03
      Imager::Filter::Flines 0.04
      Imager::Filter::Mandelbrot 0.05
      Imager::Font 1.039
      Imager::Font::BBox 1.007
      Imager::Font::FreeType2 1.021
      Imager::Font::Image 1.000
      Imager::Font::Test 1.002
      Imager::Font::Truetype 1.013
      Imager::Font::Type1 1.013
      Imager::Font::Wrap 1.005
      Imager::Fountain 1.009
      Imager::IO 1.018
      Imager::Matrix2d 1.013
      Imager::Preprocess 1.003
      Imager::Probe 1.008
      Imager::Regops 1.000
      Imager::Test 1.007
      Imager::Test::OverUtf8 1.007
      Imager::Transform 1.007
      Imager::TrimColorList 1.000
    requirements:
      Exporter 5.57
      ExtUtils::MakeMaker 0
      Scalar::Util 1.00
      Test::More 0.99
      XSLoader 0

Imager::File::PNG should be inside section provides:

@KES777
Copy link
Author

KES777 commented Jun 30, 2022

If Imager does not provide Imager::File::PNG why this alien module is inside this distribution? https://github.com/tonycoz/imager/blob/master/PNG/PNG.pm

@tonycoz
Copy link
Owner

tonycoz commented Jun 30, 2022

Imager::File::PNG and the other similar modules are part of the Imager distribution because they were historically part of the distribution and installed when you installed Imager if the appropriate libraries (libpng for PNG) were available. They continue to be bundled in the Imager distribution to maintain that behaviour.

The separate distributions were created so another module could reliably depend on them. The separate distributions only successfully install when the appropriate libraries available, so you can depend on them. Installing the Imager distribution itself may not install them, so they aren't provided.

@miyagawa
Copy link

miyagawa commented Jun 30, 2022

This is generally a problematic behavior when a distribution installs modules that belong to another distribution:

➜  curl -s www.cpan.org/modules/02packages.details.txt  | grep Imager::File::PNG
Imager::File::PNG                  0.98  T/TO/TONYC/Imager-File-PNG-0.98.tar.gz

if you install Imager first, Imager::File::PNG gets already installed as part of the process, and dependency managers like Carton/Carmel can't get the right information about the tarball you might otherwise need.

An ideal way to handle this is to split the distributions one step further, so Imager distribution would depend on Imager::File::PNG, like LWP distribution was split into multiple dists, and the core libwww-perl depends on bunch of sub distributions. I can anticipate that it would introduce circular dependencies, unless you make a new Imager-Core distribution, which then Imager would depend on i.e.

Imager
-> Imager::Core
-> Imager::File::PNG
-> Imager::File::JPEG
...

Imager::File::PNG
-> Imager::Core

Imager::File::JPEG
-> Imager::Core

All that being said, it seems you can avoid this behavior with IM_ENABLE=none though - so I suppose you can set that while running carton @KES777

@tonycoz
Copy link
Owner

tonycoz commented Jul 4, 2022

Imager doesn't require Imager::File::PNG to successfully install, but the intent is other modules (or non module users) can depend on successful installation of Imager::File::PNG.

mtremer pushed a commit to ipfire/ipfire-2.x that referenced this issue Dec 12, 2024
- Update from version 1.012 (2020) to 1.024
- Update of rootfile
- Addition of patch to fix inclusion of t1tables.h for FT_Has_PS_Glyph_Names which is
   no longer pulled in by ftmm.h since FreeType 2.13.3
- Changelog
    1.024
	 - TIFF: improve reporting from a test on failure.
	 - TIFF: support back to libtiff 4.0.8, for compatibility with RHEL
	   and its clones.
	   tonycoz/imager#527
    1.023
	 - TIFF: don't read after free when looking up a compression codec
	   by the libtiff defined name,
	   tonycoz/imager#524
    1.022
	 - TIFF: We can no longer be lazy in implementing the size callback.
	   tonycoz/imager#522
	   https://bugs.debian.org/1057270
    1.021
	Several TIFF changes:
	 - require libtiff 4.1.0 or later
	 - add buildversion, builddate and libversion methods
	 - add the codecs method which fetches a list of available TIFF
	   compression codes
	 - avoid deprecation warnings from libtiff about using the old
	   libtiff defined integer types
	 - require vsnprintf() (C99)
	 - remove my adaption of TIFFReadRGBATile() since libtiff now provides
	   TIFFReadRGBATileExt() which can do the same thing
	 - use pkg-config to find libtiff if possible
	 - for sufficiently modern libtiff (4.5.0) use TIFFClientOptions to
	   specify the warning and error handlers, this means we no longer
	   need a mutex for 4.5.0 and later.
	 - collect warnings using a buffer chain instead of custom allocation
	   code.
	 - include the "module" name (typically a libtiff function name) when
	   recording libtiff warnings.
	 - add CI to test Imager::File::TIFF against libtiff 4.1.0 through 4.6.0
	 - other minor fixes
	Other changes:
	 - prevent CodeQL from complaining about an implicit conversion to
	   unsigned char
    1.020
	 - masked(): disallow negative width/height masked images
	 - masked(): adjust source corners as bottom right relative if they
	   are negative.
	 - masked(): reject image source corners where either co-ordinate is
	   negative after the above adjustment.
	 - Imager::Files: update external image file support modules list
	 - internal test: don't fail on Imager::File::APNG link
	 - disable Imager::Font::T1 and Freetype 1.x fonts by default.
	   Unpatched t1lib simply doesn't work on 64 bit systems, and no-one
	   ships the patched version anymore.
	   tonycoz/imager#510
    1.019
	 - fix palette/transparency table generation when writing paletted PNG
	   images with tranparency.  This happened to work for the test case,
	   but the mechanism used to generate the palette order preserved most
	   palette index positions, which hid the problem with actually
	   generating the PLTE and tRNS chunks.
	   tonycoz/imager#499
	 - added lowish-level read() and write() class methods to
	   Imager::File::PNG, these are mostly intended for
	   Imager::File::APNG, but are documented and usable elsewhere.
	 - document in Imager::Install how to install Imager without any of
	   the bundled-but-also-on-CPAN modules being installed.
	   tonycoz/imager#498
    1.018
	 - skip trying to produce deprecation warnings before perl 5.14, since
	   that doesn't support custom warning categories within a package.
	   This prevents pointless failures on these old versions of perl.
    1.017
	Bug fix:
	 - fix a one bytes underallocation for Imager::TrimColorList.  On
	   older perls this could lead to writing a zero byte one past the end
	   of the allocated block.
	Documentation:
	 - expand on why you might want to call Imager->preload() and that you
	   probably don't need to.
    1.016
	Upcoming backward incompatible changes:
	 - deprecate setting/deleting tags by code.  If this causes you a
	   problem please open an issue.  You can disable the warning produced
	   with:
	    no warnings 'Imager::tagcodes';
	 - deprecate image channel masks.  If this causes you a problem please
	   open an issue.  You can disable the warning produced with:
	    no warnings 'Imager::channelmask';
	If you use either of these features please let me know.
	Minor features:
	 - add magic/extension support for AVIF files, see Imager::File::AVIF
	   on CPAN.
	 - treat an unknown extension of two or more characters as a potential
	   file type on write.
	Bug fixes:
	 - prevent a possible undefined value warning from t/t10jpeg.t
	 - update MANIFEST.SKIPs, update MANIFESTs and improve MANIFEST testing.
	 - TGA: failing to read in the palette of a paletted TGA file would
	   leak memory.
	 - JPEG: supplying invalid values for the new JPEG write tags could
	   leak memory.
	 - PNG: fix validation of Latin1 only tags when writing PNGs.
	   (detected by clang)
	 - matrix_transform: correctly use fabs() instead of abs() on floating
	   point values when deciding whether to divide for a perspective
	   transform. (detected by clang)
	 - fix the i_poly_aa_cfill_m() API macro
	Cage cleaning:
	 - eliminate IO::File usage from the Imager code base
	 - fix a type error harmlessly ignored by gcc but found by clang
	 - eliminate memory leaks in sub-module Makefile.PL probe test code to
	   allow the probes to succeed under LeakSanitizer.
	 - BMP: fix some otherwise harmless clang warnings
	 - remove some code meant to work around some unspecified old Solaris
	   linker bug.
	 - i_noise: prevent a harmless conversion warning from clang
	 - fountain fill/filter: limit ssample_param to 1000 to simplify code.
    1.015
	 - rename the "virtual" member of i_img to "isvirtual" to allow the
	   API to be used from C++, this may break source compatibility, using
	   the i_img_virtual() accessor is backward compatible.
	 - add cookbook entry to populating an image from raw RGB samples
	   tonycoz/imager#471
	 - Imager::Probe now puts the existing value of PKG_CONFIG_PATH at the
	   front of the PKG_CONFIG_PATH used when it calls pkg-config.
	 - setup CodeQL workflow and fix detected warnings
	JPEG updates:
	 - detect libjpeg (of whichever variety) via pkg-config if possible
	 - add specific support for mozjpeg (turn its optimization off by
	   default so tests pass.)
	 - add libjpeg_version(), is_mozjpeg(), is_turbojpeg() and
	   has_arith_coding() methods
	 - add jpeg_compress_profile output tag, which only matters for
	   mozjpeg
	 - the libjpeg_version() method replaces the old
	   Imager::File::JPEG::i_libjpeg_version() function, and the format
	   has changed.
	 - various obscure jpeg output controls:
	   - add support for JPEG arithmetic coding when the supplied libjpeg
	     supports it.  Note that not all JPEG decoders can handle arithmetic
	     coded JPEGs.
	   - add support for disabling the JFIF header for JPEG files using the
	     jpeg_jfif tag.
	   - add support for smoothing to eliminate dithering noise (like cjpeg
	     -smooth) using the jpeg_smooth tag.
	   - add support for producing JPEG restart markers (like cjpeg -restart
	     N), using the jpeg_restart tag.
	   - add control over subsample for JPEG (like the cjpeg -sample
	     parameter) using the jpeg_sample tag
	   - added tags for the rest of the MozJPEG API parameters.
	   - add jpeg_tune tag, corresponding to the MozJPEG cjpeg -tune-*
	     options.
    1.014
	Bug fixes:
	 - fix failed to build on non-threaded perls.
	   tonycoz/imager#472
	 - when writing a paletted image with an alpha channel to PNG only
	   set the tRNS chunk if the image has transparent colours.  With
	   older libpng this could add an erroneous tRNS chunk (or possibly
	   undefined behaviour if I understand the libpng code).
	   tonycoz/imager#459
	Features:
	 - Imager::Color and Imager::Color::Float objects can now be created
	   from CSS style rgb(...) strings.
	   tonycoz/imager#463
	 - added the as_css_rgb() method to both Imager::Color and
	   Imager::Color::Float to format the supplied color as a CSS style
	   rgb() string.
	   tonycoz/imager#463
	 - Imager::Color and Imager::Color::Float objects can now be created
	   (copied) or set from other Imager::Color or Imager::Color::Float
	   objects.
    1.013
	 - added rgb_difference() method
	   Thanks to Andreas König
	   tonycoz/imager#462
	 - update ppport.h to prevent a redefinition diagnostic
	 - update bug tracker URLs to point at github
	   tonycoz/imager#466
	 - update some other bug tracker URLs too.
	 - add the trim() and trim_rect() methods, to trim borders off an
	   image.
	 - add the as_float() method to Imager::Color and the as_8bit() method
	   to Imager::Color::Float to convert between the two types.
	 - update ppport.h to avoid a diagnostic in more modern perls.
	 - add detection for HEIF, JPEG XL and QOI image formats

Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
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

No branches or pull requests

3 participants