From cec79084296570fb5b4a076d3f9a3c1fbad3ed04 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 3 May 2020 17:06:16 +0300 Subject: [PATCH 1/2] rtexif: Fix conversion from RATIONAL to int, double or string RATIONAL tags are defined as a ratio of two LONG, themselves defined as 32-bit unsigned integers. The value is misinterpreted when converting to an int, double or string, as the numerator and the denominator are interpreted as signed values. The problem has been noticed with the ExposureTime tag generated by libtiff, which sets the denominator to 0xffffffff for exposure times lower than 1. Fix it. Signed-off-by: Laurent Pinchart --- rtexif/rtexif.cc | 26 ++++++++++++++++++-------- rtexif/rtexif.h | 22 +++++++++++++++------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/rtexif/rtexif.cc b/rtexif/rtexif.cc index 06604ade5..95b46c2b9 100644 --- a/rtexif/rtexif.cc +++ b/rtexif/rtexif.cc @@ -1510,8 +1510,6 @@ int Tag::toInt (int ofs, TagType astype) const return attrib->interpreter->toInt (this, ofs, astype); } - int a; - if (astype == INVALID) { astype = type; } @@ -1537,10 +1535,15 @@ int Tag::toInt (int ofs, TagType astype) const case LONG: return (int)sget4 (value + ofs, getOrder()); - case SRATIONAL: - case RATIONAL: - a = (int)sget4 (value + ofs + 4, getOrder()); + case SRATIONAL: { + int a = (int)sget4 (value + ofs + 4, getOrder()); return a == 0 ? 0 : (int)sget4 (value + ofs, getOrder()) / a; + } + + case RATIONAL: { + uint32_t a = (uint32_t)sget4 (value + ofs + 4, getOrder()); + return a == 0 ? 0 : (uint32_t)sget4 (value + ofs, getOrder()) / a; + } case FLOAT: return (int)toDouble (ofs); @@ -1589,10 +1592,14 @@ double Tag::toDouble (int ofs) const return (double) ((int)sget4 (value + ofs, getOrder())); case SRATIONAL: - case RATIONAL: ud = (int)sget4 (value + ofs, getOrder()); dd = (int)sget4 (value + ofs + 4, getOrder()); - return dd == 0. ? 0. : (double)ud / (double)dd; + return dd == 0. ? 0. : ud / dd; + + case RATIONAL: + ud = (uint32_t)sget4 (value + ofs, getOrder()); + dd = (uint32_t)sget4 (value + ofs + 4, getOrder()); + return dd == 0. ? 0. : ud / dd; case FLOAT: conv.i = sget4 (value + ofs, getOrder()); @@ -1735,10 +1742,13 @@ void Tag::toString (char* buffer, int ofs) const break; case SRATIONAL: - case RATIONAL: sprintf (b, "%d/%d", (int)sget4 (value + 8 * i + ofs, getOrder()), (int)sget4 (value + 8 * i + ofs + 4, getOrder())); break; + case RATIONAL: + sprintf (b, "%u/%u", (uint32_t)sget4 (value + 8 * i + ofs, getOrder()), (uint32_t)sget4 (value + 8 * i + ofs + 4, getOrder())); + break; + case FLOAT: sprintf (b, "%g", toDouble (8 * i + ofs)); break; diff --git a/rtexif/rtexif.h b/rtexif/rtexif.h index 1a956a4a5..5084f70de 100644 --- a/rtexif/rtexif.h +++ b/rtexif/rtexif.h @@ -434,13 +434,18 @@ public: case LONG: return (double) ((int)sget4 (t->getValue() + ofs, t->getOrder())); - case SRATIONAL: - case RATIONAL: { + case SRATIONAL: { const double dividend = (int)sget4 (t->getValue() + ofs, t->getOrder()); const double divisor = (int)sget4 (t->getValue() + ofs + 4, t->getOrder()); return divisor == 0. ? 0. : dividend / divisor; } + case RATIONAL: { + const double dividend = (uint32_t)sget4 (t->getValue() + ofs, t->getOrder()); + const double divisor = (uint32_t)sget4 (t->getValue() + ofs + 4, t->getOrder()); + return divisor == 0. ? 0. : dividend / divisor; + } + case FLOAT: return double (sget4 (t->getValue() + ofs, t->getOrder())); @@ -454,8 +459,6 @@ public: // Get the value as an int virtual int toInt (const Tag* t, int ofs = 0, TagType astype = INVALID) { - int a; - if (astype == INVALID || astype == AUTO) { astype = t->getType(); } @@ -480,10 +483,15 @@ public: case LONG: return (int)sget4 (t->getValue() + ofs, t->getOrder()); - case SRATIONAL: - case RATIONAL: - a = (int)sget4 (t->getValue() + ofs + 4, t->getOrder()); + case SRATIONAL: { + int a = (int)sget4 (t->getValue() + ofs + 4, t->getOrder()); return a == 0 ? 0 : (int)sget4 (t->getValue() + ofs, t->getOrder()) / a; + } + + case RATIONAL: { + uint32_t a = (uint32_t)sget4 (t->getValue() + ofs + 4, t->getOrder()); + return a == 0 ? 0 : (uint32_t)sget4 (t->getValue() + ofs, t->getOrder()) / a; + } case FLOAT: return (int)toDouble (t, ofs); From 65f1b4c3d9a976d90f41853b915f79bf98ac2864 Mon Sep 17 00:00:00 2001 From: Benitoite Date: Tue, 12 May 2020 05:17:53 -0700 Subject: [PATCH 2/2] Update macOS packaging for 10.15.4 Several smaller fixes to provide an improved handling of installing/using RT on macOS. * mac: update entitlements for 10.15.4 * mac: fix the CLI. Provides an un-codesigned rawtherapee-cli outside the app bundle for use on the terminal command line, using the app bundle's 3rd-party libraries. * How to install RawTherapee.app and rawtherapee-cli for macOS --- CMakeLists.txt | 9 ++++++++- tools/INSTALL.readme | 3 +++ tools/osx/macosx_bundle.sh | 36 +++++++++++++++++++++++------------- tools/osx/rt.entitlements | 31 ++++++++++++++----------------- 4 files changed, 48 insertions(+), 31 deletions(-) create mode 100644 tools/INSTALL.readme diff --git a/CMakeLists.txt b/CMakeLists.txt index cbddde251..7d66109e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -669,7 +669,14 @@ if(WIN32) elseif(APPLE) set( ABOUT_COMMAND_WITH_ARGS - cmake -DPROJECT_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/UpdateInfo.cmake -DSYSTEM:STRING=Apple -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} -DCOMPILER_INFO:STRING=${COMPILER_INFO} -DCACHE_NAME_SUFFIX:STRING=${CACHE_NAME_SUFFIX}) + cmake + -DPROJECT_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} + -DCACHE_NAME_SUFFIX:STRING=${CACHE_NAME_SUFFIX} + -P ${PROJECT_SOURCE_DIR}/UpdateInfo.cmake + -DSYSTEM:STRING=Apple + -DCXX_FLAGS:STRING=${CXX_FLAGS} + -DLFLAGS:STRING=${LFLAGS} + -DCOMPILER_INFO:STRING=${COMPILER_INFO}) else() list(APPEND ABOUT_COMMAND_WITH_ARGS -DSYSTEM:STRING=Linux -DCXX_FLAGS:STRING=${CXX_FLAGS} -DLFLAGS:STRING=${LFLAGS} diff --git a/tools/INSTALL.readme b/tools/INSTALL.readme new file mode 100644 index 000000000..a4f19ec3c --- /dev/null +++ b/tools/INSTALL.readme @@ -0,0 +1,3 @@ +To install the RawTherapee application, open the .dmg and drag the RawTherapee app onto the /Applications folder. + +To use the optional rawtherapee-cli command line interface, move rawtherapee-cli into a folder in your $PATH and install the RawTherapee app as above. diff --git a/tools/osx/macosx_bundle.sh b/tools/osx/macosx_bundle.sh index 9258810c0..bc1a2dc3b 100644 --- a/tools/osx/macosx_bundle.sh +++ b/tools/osx/macosx_bundle.sh @@ -236,6 +236,11 @@ ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/icons/Adwaita/index.theme "${LOCAL_PREFIX}/local/bin/gtk-update-icon-cache" "${RESOURCES}/share/icons/Adwaita" ditto "${LOCAL_PREFIX}/local/share/icons/hicolor" "${RESOURCES}/share/icons/hicolor" +# fix libfreetype install name +for lib in "${LIB}"/*; do + install_name_tool -change libfreetype.6.dylib "${LIB}"/libfreetype.6.dylib "${lib}" +done + # pixbuf loaders & immodules msg "Build GTK3 databases:" "${LOCAL_PREFIX}"/local/bin/gdk-pixbuf-query-loaders "${LIB}"/libpix*.so > "${ETC}"/gtk-3.0/gdk-pixbuf.loaders @@ -259,11 +264,11 @@ ditto "${PROJECT_SOURCE_DIR}/rtdata/fonts" "${ETC}/fonts" ditto "${PROJECT_SOURCE_DATA_DIR}/"{rawtherapee,profile}.icns "${RESOURCES}" ditto "${PROJECT_SOURCE_DATA_DIR}/PkgInfo" "${CONTENTS}" install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/Info.plist.in" "${CONTENTS}/Info.plist" +install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/cliInfo.plist.in" "${LIB}/Info.plist" sed -i "" -e "s|@version@|${PROJECT_FULL_VERSION}| s|@shortVersion@|${PROJECT_VERSION}| s|@arch@|${arch}|" \ "${CONTENTS}/Info.plist" -plutil -convert binary1 "${CONTENTS}/Info.plist" update-mime-database -V "${RESOURCES}/share/mime" msg "Build glib database:" @@ -279,23 +284,25 @@ ModifyInstallNames # fix @rpath in Frameworks msg "Registering @rpath in Frameworks folder." -for frameworklibs in "${LIB}"/*{dylib,so}; do +for frameworklibs in "${LIB}"/*{dylib,so,cli}; do install_name_tool -delete_rpath ${LOCAL_PREFIX}/local/lib "${frameworklibs}" install_name_tool -add_rpath /Applications/"${LIB}" "${frameworklibs}" done install_name_tool -delete_rpath RawTherapee.app/Contents/Frameworks "${EXECUTABLE}"-cli -install_name_tool -add_rpath @executable_path "${EXECUTABLE}"-cli +install_name_tool -add_rpath /Applications/"${LIB}" "${EXECUTABLE}"-cli +ditto "${EXECUTABLE}"-cli "${APP}"/.. # Codesign the app if [[ -n $CODESIGNID ]]; then msg "Codesigning Application." - install -m 0644 "${PROJECT_SOURCE_DATA_DIR}"/rt.entitlements "${CMAKE_BUILD_TYPE}"/rt.entitlements - plutil -convert binary1 "${CMAKE_BUILD_TYPE}"/rt.entitlements + iconv -f UTF-8 -t ASCII "${PROJECT_SOURCE_DATA_DIR}"/rt.entitlements > "${CMAKE_BUILD_TYPE}"/rt.entitlements + iconv -f UTF-8 -t ASCII "${PROJECT_SOURCE_DATA_DIR}"/rt-cli.entitlements > "${CMAKE_BUILD_TYPE}"/rt-cli.entitlements mv "${EXECUTABLE}"-cli "${LIB}" - for frameworklibs in "${LIB}"/*; do - codesign -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee --force --verbose -o runtime --timestamp "${frameworklibs}" + for frameworklibs in "${LIB}"/*{dylib,so}; do + codesign -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee --force --verbose -o runtime --timestamp --entitlements "${CMAKE_BUILD_TYPE}"/rt.entitlements "${frameworklibs}" done - codesign --timestamp --strict -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --entitlements "${CMAKE_BUILD_TYPE}"/rt.entitlements "${APP}" + codesign --force -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --entitlements "${CMAKE_BUILD_TYPE}"/rt-cli.entitlements "${LIB}"/rawtherapee-cli + codesign --deep --timestamp --strict -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --entitlements "${CMAKE_BUILD_TYPE}"/rt.entitlements "${APP}" spctl -a -vvvv "${APP}" fi @@ -345,7 +352,7 @@ function CreateDmg { CreateWebloc 'Report Bug' 'https://github.com/Beep6581/RawTherapee/issues/new' # Disk image name - dmg_name="${PROJECT_NAME// /_}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}" + dmg_name="${PROJECT_NAME}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}" lower_build_type="$(tr '[:upper:]' '[:lower:]' <<< "$CMAKE_BUILD_TYPE")" if [[ $lower_build_type != release ]]; then dmg_name="${dmg_name}_${lower_build_type}" @@ -390,6 +397,7 @@ function CreateDmg { xcrun stapler staple "${dmg_name}.dmg" # staple the ticket xcrun stapler validate -v "${dmg_name}.dmg" echo "dmg Notarization success" + rm *dmg.zip break elif [[ $status1 = "in" ]]; then echo "dmg Notarization still in progress, sleeping for 15 seconds and trying again" @@ -404,10 +412,12 @@ function CreateDmg { # Zip disk image for redistribution msg "Zipping disk image for redistribution:" - zip "${dmg_name}.zip" "${dmg_name}.dmg" - rm "${dmg_name}.dmg" - msg "Removing disk image caches:" - rm -rf "${srcDir}" + mkdir "${PROJECT_NAME}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}_folder" + ditto {"${PROJECT_NAME}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}.dmg","rawtherapee-cli","${PROJECT_SOURCE_DATA_DIR}/INSTALL.readme.rtf"} "${PROJECT_NAME}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}_folder" + zip -r "${PROJECT_NAME}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}.zip" "${PROJECT_NAME}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_FULL_VERSION}_folder/" + # rm "${dmg_name}.dmg" + # msg "Removing disk image caches:" + # rm -rf "${srcDir}" } CreateDmg msg "Finishing build:" diff --git a/tools/osx/rt.entitlements b/tools/osx/rt.entitlements index c571f1f41..8fc97c7da 100644 --- a/tools/osx/rt.entitlements +++ b/tools/osx/rt.entitlements @@ -1,19 +1,16 @@ + - - application-identifier - com.rawtherapee.RawTherapee - com.apple.security.temporary-exception.files.absolute-path.read-write - - / - - com.apple.security.cs.allow-dyld-environment-variables - - com.apple.security.files.user-selected.read-write - - com.apple.security.app-sandbox - - com.apple.security.files.downloads.read-write - - - \ No newline at end of file + + com.apple.application-identifier + com.rawtherapee.RawTherapee + com.apple.security.app-sandbox + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.temporary-exception.files.absolute-path.read-write + + / + + +