From 1a02eb904a9db010aa9ad7d9217f9e8f5c399ed75267477b073edef344897eaf Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 21 Sep 2023 13:35:08 +0000 Subject: [PATCH 1/6] add skcms/gtk pieces from rq 1111631 wrap blocks in with(out)_bcond OBS-URL: https://build.opensuse.org/package/show/graphics/libjxl?expand=0&rev=26 --- .gitattributes | 2 + 0001-Remove-LCMS-mutex.patch | 117 ----------------------------------- _service | 11 ++++ libjxl.changes | 20 ++++++ libjxl.spec | 73 +++++++++++++++++----- skcms.tar | 3 + 6 files changed, 94 insertions(+), 132 deletions(-) delete mode 100644 0001-Remove-LCMS-mutex.patch create mode 100644 _service create mode 100644 skcms.tar diff --git a/.gitattributes b/.gitattributes index 9b03811..d9861d7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,3 +21,5 @@ *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text +## Specific LFS patterns +skcms.tar filter=lfs diff=lfs merge=lfs -text diff --git a/0001-Remove-LCMS-mutex.patch b/0001-Remove-LCMS-mutex.patch deleted file mode 100644 index 3657b96..0000000 --- a/0001-Remove-LCMS-mutex.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 057cd06c19875bcf8b5d34d41d92a8abdb856b7c Mon Sep 17 00:00:00 2001 -From: Kleis Auke Wolthuizen -Date: Fri, 11 Mar 2022 21:11:24 +0100 -Subject: [PATCH] Remove LCMS mutex (#112) - -* Remove LCMS mutex - -Requires mm2/Little-CMS@a35bacd, which is released in LCMS v2.11. - -* Use a threadsafe alternative of gmtime in LCMS - -Requires mm2/Little-CMS@68ee2ff, which is released in LCMS v2.13. - -LCMS submodule was updated to version 2.13.1 instead. ---- - lib/jxl/enc_color_management.cc | 15 +++++++++++++++ - third_party/CMakeLists.txt | 2 +- - third_party/lcms2.cmake | 14 -------------- - 3 files changed, 16 insertions(+), 15 deletions(-) - -Index: libjxl-0.8.1/lib/jxl/enc_color_management.cc -=================================================================== ---- libjxl-0.8.1.orig/lib/jxl/enc_color_management.cc -+++ libjxl-0.8.1/lib/jxl/enc_color_management.cc -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -308,6 +309,14 @@ int DoColorSpaceTransform(void* t, size_ - // Define to 1 on OS X as a workaround for older LCMS lacking MD5. - #define JXL_CMS_OLD_VERSION 0 - -+// cms functions (even *THR) are not thread-safe, except cmsDoTransform. -+// To ensure all functions are covered without frequent lock-taking nor risk of -+// recursive lock, we lock in the top-level APIs. -+static std::mutex& LcmsMutex() { -+ static std::mutex m; -+ return m; -+} -+ - #if JPEGXL_ENABLE_SKCMS - - JXL_MUST_USE_RESULT CIExy CIExyFromXYZ(const float XYZ[3]) { -@@ -871,6 +880,9 @@ bool ApplyCICP(const uint8_t color_prima - - } // namespace - -+// All functions that call lcms directly (except ColorSpaceTransform::Run) must -+// lock LcmsMutex(). -+ - Status ColorEncoding::SetFieldsFromICC() { - // In case parsing fails, mark the ColorEncoding as invalid. - SetColorSpace(ColorSpace::kUnknown); -@@ -917,6 +929,7 @@ Status ColorEncoding::SetFieldsFromICC() - DetectTransferFunction(profile, this); - #else // JPEGXL_ENABLE_SKCMS - -+ std::lock_guard guard(LcmsMutex()); - const cmsContext context = GetContext(); - - Profile profile; -@@ -984,6 +997,7 @@ void JxlCmsDestroy(void* cms_data) { - if (cms_data == nullptr) return; - JxlCms* t = reinterpret_cast(cms_data); - #if !JPEGXL_ENABLE_SKCMS -+ std::lock_guard guard(LcmsMutex()); - TransformDeleter()(t->lcms_transform); - #endif - delete t; -@@ -1020,6 +1034,7 @@ void* JxlCmsInit(void* init_data, size_t - return nullptr; - } - #else // JPEGXL_ENABLE_SKCMS -+ std::lock_guard guard(LcmsMutex()); - const cmsContext context = GetContext(); - Profile profile_src, profile_dst; - if (!DecodeProfile(context, c_src.ICC(), &profile_src)) { -Index: libjxl-0.8.1/third_party/CMakeLists.txt -=================================================================== ---- libjxl-0.8.1.orig/third_party/CMakeLists.txt -+++ libjxl-0.8.1/third_party/CMakeLists.txt -@@ -111,7 +111,7 @@ if (JPEGXL_ENABLE_SKCMS OR JPEGXL_ENABLE - endif () - if (JPEGXL_ENABLE_VIEWERS OR NOT JPEGXL_ENABLE_SKCMS) - if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lcms/.git" OR JPEGXL_FORCE_SYSTEM_LCMS2 ) -- find_package(LCMS2 2.13) -+ find_package(LCMS2 2.10) - if ( NOT LCMS2_FOUND ) - message(FATAL_ERROR "Please install lcms2 or run git submodule update --init") - endif () -Index: libjxl-0.8.1/third_party/lcms2.cmake -=================================================================== ---- libjxl-0.8.1.orig/third_party/lcms2.cmake -+++ libjxl-0.8.1/third_party/lcms2.cmake -@@ -60,18 +60,4 @@ target_compile_definitions(lcms2 - target_compile_definitions(lcms2 - PUBLIC "-DCMS_NO_REGISTER_KEYWORD=1") - --# Ensure that a thread safe alternative of gmtime is used in LCMS --include(CheckSymbolExists) --check_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R) --if (HAVE_GMTIME_R) -- target_compile_definitions(lcms2 -- PUBLIC "-DHAVE_GMTIME_R=1") --else() -- check_symbol_exists(gmtime_s "time.h" HAVE_GMTIME_S) -- if (HAVE_GMTIME_S) -- target_compile_definitions(lcms2 -- PUBLIC "-DHAVE_GMTIME_S=1") -- endif() --endif() -- - set_property(TARGET lcms2 PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/_service b/_service new file mode 100644 index 0000000..f0d2976 --- /dev/null +++ b/_service @@ -0,0 +1,11 @@ + + + git + https://github.com/libjxl/libjxl.git/ + enable + third_party/skcms + v0.8.2 + skcms + _none_ + + diff --git a/libjxl.changes b/libjxl.changes index f044cfe..0e07870 100644 --- a/libjxl.changes +++ b/libjxl.changes @@ -1,3 +1,23 @@ +------------------------------------------------------------------- +Thu Sep 21 13:34:05 UTC 2023 - Jan Engelhardt + +- Switch from LCMS to SKCMS; delete 0001-Remove-LCMS-mutex.patch + +------------------------------------------------------------------- +Sat Sep 16 06:58:55 UTC 2023 - Atri Bhattacharya + +- Build plugins: + * Add _service file to generate skcms tarball (needed to build + plugins). + * Add skcms tarball as source and copy extracted dir to + ./third_party/ so cmake can find it. + * Split out new packages: + * gdk-pixbuf-loader-jxl: Pixbuf loader for supported apps. + * gimp-plugin-jxl: Plugin to allow gimp to work with JPEG XL + files. + * jxl-thumbnailer: Thumbnailer and mime files to allow + generating thumbnails for JPEG XL files. + ------------------------------------------------------------------- Wed Jun 14 13:00:09 UTC 2023 - Jan Engelhardt diff --git a/libjxl.spec b/libjxl.spec index add6d4e..f4c8ee3 100644 --- a/libjxl.spec +++ b/libjxl.spec @@ -18,6 +18,7 @@ Name: libjxl %define lname libjxl0_8 +%bcond_without gtk Version: 0.8.2 Release: 0 Summary: JPEG XL reference implementation @@ -26,11 +27,15 @@ URL: https://jpegxl.info/ #Git-Clone: https://github.com/libjxl/libjxl Source: https://github.com/libjxl/libjxl/archive/refs/tags/v%version.tar.gz Source1: baselibs.conf -Patch0: 0001-Remove-LCMS-mutex.patch +Source2: skcms.tar BuildRequires: c++_compiler BuildRequires: cmake BuildRequires: pkg-config -BuildRequires: pkgconfig(lcms2) >= 2.10 +%if %{with gtk} +BuildRequires: pkgconfig(gdk-pixbuf-2.0) >= 2.36 +BuildRequires: pkgconfig(gimp-2.0) >= 2.10 +BuildRequires: pkgconfig(gimpui-2.0) >= 2.10 +%endif BuildRequires: pkgconfig(libbrotlicommon) BuildRequires: pkgconfig(libbrotlidec) BuildRequires: pkgconfig(libbrotlienc) @@ -38,6 +43,9 @@ BuildRequires: pkgconfig(libhwy) >= 1.0 BuildRequires: pkgconfig(libjpeg) BuildRequires: pkgconfig(libpng) %{?suse_build_hwcaps_libs} +%if %{with gtk} +Provides: bundled(skcms) = 0 +%endif %description JPEG XL is a raster-graphics file format that supports both lossy and @@ -68,23 +76,39 @@ Summary: Command-line utilities to convert from/to JPEG XL %description tools Command-line utilities to convert from/to JPEG XL. -%prep -%setup -q +%package -n gdk-pixbuf-loader-jxl +Summary: A gdk-pixbuf loader for JPEG-XL using libjxl +Supplements: (%lname and gdk-pixbuf) +%gdk_pixbuf_loader_requires -%if %{pkg_vcmp liblcms2-2 < 2.13} -# libjxl 0.7.0 requires lcms2 >= 2.13, so if we have an older version -# (as in SLE15/Leap) just reverse the patch that adds that dependency -%patch0 -p1 -%else -# Make sure patch at least applies -%patch0 -p1 -%patch0 -p1 -R -%endif +%description -n gdk-pixbuf-loader-jxl +This package provides a libjxl-based gdk-pixbuf loader for JPEG XL files. + +%package -n gimp-plugin-jxl +Summary: Plugin for GIMP to enable working with JPEG XL files +Supplements: (%lname and gimp) + +%description -n gimp-plugin-jxl +This package provides a plugin for GIMP 2.0 to enable it to work with JPEG XL files. + +%package -n jxl-thumbnailer +Summary: Generate thumbnails for JPEG XL files +BuildArch: noarch + +%description -n jxl-thumbnailer +This package provides a thumbnailer to render for JPEG XL file thumbnails, +for example, on file-browsers. + +%prep +%setup -a2 +mv skcms third_party/ %build %cmake -DJPEGXL_FORCE_SYSTEM_HWY=ON -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ - -DJPEGXL_FORCE_SYSTEM_LCMS2=ON -DBUILD_TESTING=OFF \ - -DJPEGXL_ENABLE_PLUGINS=OFF -DJPEGXL_ENABLE_SKCMS=OFF \ + -DJPEGXL_FORCE_SYSTEM_LCMS2=OFF -DBUILD_TESTING=OFF \ +%if %{with gtk} + -DJPEGXL_ENABLE_PLUGINS=ON -DJPEGXL_ENABLE_SKCMS=ON \ +%endif -DJPEGXL_ENABLE_SJPEG=OFF %cmake_build @@ -94,6 +118,12 @@ rm -fv %buildroot/%_libdir/*.a %ldconfig_scriptlets -n %lname +%post -n gdk-pixbuf-loader-jxl +%gdk_pixbuf_loader_post + +%postun -n gdk-pixbuf-loader-jxl +%gdk_pixbuf_loader_postun + %files -n %lname %license LICENSE %_libdir/libjxl*.so.* @@ -108,4 +138,17 @@ rm -fv %buildroot/%_libdir/*.a %_libdir/libjxl_threads.so %_libdir/pkgconfig/*.pc +%if %{with gtk} +%files -n gdk-pixbuf-loader-jxl +%_libdir/gdk-pixbuf-2.0/*/loaders/libpixbufloader-jxl.so + +%files -n gimp-plugin-jxl +%_libdir/gimp/2.0/plug-ins/file-jxl/ + +%files -n jxl-thumbnailer +%dir %_datadir/thumbnailers +%_datadir/thumbnailers/*.thumbnailer +%_datadir/mime/packages/*.xml +%endif + %changelog diff --git a/skcms.tar b/skcms.tar new file mode 100644 index 0000000..e4cc563 --- /dev/null +++ b/skcms.tar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8335d994cd09b5a8456e6cd9f3ac94933337925aa918d525d91ee0ef4b732212 +size 14899200 From 2fc88990fe8d6294a4cc0255dcfb5cea7f1647335c53d00cb88efe7856a13458 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 21 Sep 2023 14:07:16 +0000 Subject: [PATCH 2/6] add _multibuild description OBS-URL: https://build.opensuse.org/package/show/graphics/libjxl?expand=0&rev=27 --- _multibuild | 4 ++++ libjxl.spec | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 _multibuild diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..0ab1057 --- /dev/null +++ b/_multibuild @@ -0,0 +1,4 @@ + + standard + gtk + diff --git a/libjxl.spec b/libjxl.spec index f4c8ee3..36f4506 100644 --- a/libjxl.spec +++ b/libjxl.spec @@ -18,7 +18,11 @@ Name: libjxl %define lname libjxl0_8 -%bcond_without gtk +%if "@BUILD_FLAVOR@" == "gtk" +%bcond_without gtk +%else +%bcond_with gtk +%endif Version: 0.8.2 Release: 0 Summary: JPEG XL reference implementation @@ -79,7 +83,9 @@ Command-line utilities to convert from/to JPEG XL. %package -n gdk-pixbuf-loader-jxl Summary: A gdk-pixbuf loader for JPEG-XL using libjxl Supplements: (%lname and gdk-pixbuf) +%if %{with gtk} %gdk_pixbuf_loader_requires +%endif %description -n gdk-pixbuf-loader-jxl This package provides a libjxl-based gdk-pixbuf loader for JPEG XL files. From 9238b960b4eef378db50ab9599325f5d60a23fa15507945b58de5b428dc32bfe Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 21 Sep 2023 14:38:36 +0000 Subject: [PATCH 3/6] OBS-URL: https://build.opensuse.org/package/show/graphics/libjxl?expand=0&rev=28 --- _multibuild | 1 - 1 file changed, 1 deletion(-) diff --git a/_multibuild b/_multibuild index 0ab1057..6bf7c9f 100644 --- a/_multibuild +++ b/_multibuild @@ -1,4 +1,3 @@ - standard gtk From f98e5949a921bac8d03174508c1186f2f28b9827666ffb3fa886f93f40d78800 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 22 Sep 2023 01:29:22 +0000 Subject: [PATCH 4/6] strip nongtk files from gtk build run OBS-URL: https://build.opensuse.org/package/show/graphics/libjxl?expand=0&rev=29 --- libjxl.spec | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libjxl.spec b/libjxl.spec index 36f4506..f6fa457 100644 --- a/libjxl.spec +++ b/libjxl.spec @@ -120,7 +120,11 @@ mv skcms third_party/ %install %cmake_install -rm -fv %buildroot/%_libdir/*.a +b="%buildroot" +rm -fv "$b/%_libdir"/*.a +%if %{with gtk} +rm -Rf "$b/%_libdir"/libjxl* "$b/%_bindir" "$b/%_includedir" "$b/%_libdir/pkgconfig" +%endif %ldconfig_scriptlets -n %lname @@ -130,6 +134,8 @@ rm -fv %buildroot/%_libdir/*.a %postun -n gdk-pixbuf-loader-jxl %gdk_pixbuf_loader_postun +%if %{without gtk} + %files -n %lname %license LICENSE %_libdir/libjxl*.so.* @@ -144,7 +150,8 @@ rm -fv %buildroot/%_libdir/*.a %_libdir/libjxl_threads.so %_libdir/pkgconfig/*.pc -%if %{with gtk} +%else + %files -n gdk-pixbuf-loader-jxl %_libdir/gdk-pixbuf-2.0/*/loaders/libpixbufloader-jxl.so @@ -155,6 +162,7 @@ rm -fv %buildroot/%_libdir/*.a %dir %_datadir/thumbnailers %_datadir/thumbnailers/*.thumbnailer %_datadir/mime/packages/*.xml + %endif %changelog From 51cf0d88875e7ce6ef7331eaf2777d68f02ecfa63c57ef3db60bdd64da56ee77 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 22 Sep 2023 11:04:08 +0000 Subject: [PATCH 5/6] OBS-URL: https://build.opensuse.org/package/show/graphics/libjxl?expand=0&rev=30 --- libjxl.changes | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libjxl.changes b/libjxl.changes index 0e07870..74873b2 100644 --- a/libjxl.changes +++ b/libjxl.changes @@ -1,7 +1,9 @@ ------------------------------------------------------------------- Thu Sep 21 13:34:05 UTC 2023 - Jan Engelhardt -- Switch from LCMS to SKCMS; delete 0001-Remove-LCMS-mutex.patch +- Switch from LCMS to SKCMS: libjxl core can use either, but + plugins can only use SKCMS. Exercising two CMS simultaneously + also is silly. Delete 0001-Remove-LCMS-mutex.patch . ------------------------------------------------------------------- Sat Sep 16 06:58:55 UTC 2023 - Atri Bhattacharya From cdd77ad4aae03b0c1c43116d3c54c8866c26822f8b6ca537239ce5bd6ac9d06d Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sat, 23 Sep 2023 20:21:21 +0000 Subject: [PATCH 6/6] Separate %name per @FLAVOR@ OBS-URL: https://build.opensuse.org/package/show/graphics/libjxl?expand=0&rev=31 --- libjxl.spec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libjxl.spec b/libjxl.spec index f6fa457..ee414f8 100644 --- a/libjxl.spec +++ b/libjxl.spec @@ -1,5 +1,5 @@ # -# spec file for package libjxl +# spec file for package libjxl-gtk # # Copyright (c) 2023 SUSE LLC # @@ -16,11 +16,12 @@ # -Name: libjxl %define lname libjxl0_8 %if "@BUILD_FLAVOR@" == "gtk" +Name: libjxl-gtk %bcond_without gtk %else +Name: libjxl %bcond_with gtk %endif Version: 0.8.2 @@ -106,7 +107,7 @@ This package provides a thumbnailer to render for JPEG XL file thumbnails, for example, on file-browsers. %prep -%setup -a2 +%setup -n libjxl-%version -a2 mv skcms third_party/ %build