mac: truncate homedir

This commit is contained in:
Richard Barber
2020-02-17 06:55:18 -08:00
parent 7a258d1a25
commit c9f887281e
2 changed files with 30 additions and 33 deletions

View File

@@ -2272,20 +2272,18 @@ void Options::load(bool lightweight)
#ifdef __APPLE__ #ifdef __APPLE__
// Build Application Support directory path for macOS. // Build Application Support directory path for macOS.
const gchar* homedir; const gchar* homedir = g_getenv("HOME"); // This returns the current container data dir in ~/Library
const gchar* configdir; const gchar* configdir = "/Application Support/RawTherapee/config";
homedir = g_getenv("HOME"); // This returns the current container data dir in ~/Library gchar* homebuf = g_strnfill(789, 'a');
configdir = "/../../../Application Support/RawTherapee/config"; // Back out of containers and into App. Support gsize homelength = strlen(homedir);
int bufferSize = strlen(homedir) + strlen(configdir) + 1; g_stpcpy(homebuf, homedir);
gchar* concatString = new gchar[ bufferSize ]; homebuf[homelength-45] = '\0';
strcpy( concatString, homedir ); configdir = "/Application Support/RawTherapee/config"; // Back out of containers and into App. Support
strcat( concatString, configdir ); const gchar* pathconcat = g_strconcat(homebuf, configdir);
path = concatString; path = pathconcat;
delete[] concatString;
#else #else
path = g_getenv("RT_SETTINGS"); path = g_getenv("RT_SETTINGS");
#endif #endif
if (path != nullptr) { if (path != nullptr) {
rtdir = Glib::ustring(path); rtdir = Glib::ustring(path);
@@ -2294,6 +2292,8 @@ void Options::load(bool lightweight)
throw Error(msg); throw Error(msg);
} }
} else { } else {
#ifdef WIN32 #ifdef WIN32
WCHAR pathW[MAX_PATH] = {0}; WCHAR pathW[MAX_PATH] = {0};
@@ -2329,17 +2329,12 @@ void Options::load(bool lightweight)
// Modify the path of the cache folder to the one provided in RT_CACHE environment variable. Build the cache folder name in macOS. // Modify the path of the cache folder to the one provided in RT_CACHE environment variable. Build the cache folder name in macOS.
#ifdef __APPLE__ #ifdef __APPLE__
const gchar* cachedir; const gchar* cachedir;
cachedir = "/../../../Application Support/RawTherapee/cache"; // Back out of containers and into App. Support cachedir = "/Application Support/RawTherapee/cache"; // Back out of containers and into App. Support
int bufferSize2 = strlen(homedir) + strlen(cachedir) + 1; //reuse homedir from above. const gchar* pathconcat2 = g_strconcat(homebuf, cachedir);
gchar* concatString2 = new gchar[ bufferSize2 ]; path = pathconcat2;
strcpy( concatString2, homedir );
strcat( concatString2, cachedir );
path = concatString2;
delete[] concatString2;
#else #else
path = g_getenv("RT_CACHE"); path = g_getenv("RT_CACHE");
#endif #endif
if (path != nullptr) { if (path != nullptr) {
cacheBaseDir = Glib::ustring(path); cacheBaseDir = Glib::ustring(path);
@@ -2348,6 +2343,8 @@ void Options::load(bool lightweight)
throw Error(msg); throw Error(msg);
} }
} }
// No environment variable provided, so falling back to the multi user mode, if enabled // No environment variable provided, so falling back to the multi user mode, if enabled
else if (options.multiUser) { else if (options.multiUser) {
#ifdef WIN32 #ifdef WIN32

View File

@@ -217,16 +217,16 @@ msg "Build GTK3 databases:"
sed -i "" -e "s|${PWD}/RawTherapee.app/Contents/|/Applications/RawTherapee.app/Contents/|" "${ETC}/gtk-3.0/gdk-pixbuf.loaders" "${ETC}/gtk-3.0/gtk.immodules" sed -i "" -e "s|${PWD}/RawTherapee.app/Contents/|/Applications/RawTherapee.app/Contents/|" "${ETC}/gtk-3.0/gdk-pixbuf.loaders" "${ETC}/gtk-3.0/gtk.immodules"
sed -i "" -e "s|/opt/local/|/Applications/RawTherapee.app/Contents/Frameworks/|" "${ETC}/gtk-3.0/gtk.immodules" sed -i "" -e "s|/opt/local/|/Applications/RawTherapee.app/Contents/Frameworks/|" "${ETC}/gtk-3.0/gtk.immodules"
# Install names
ModifyInstallNames
# Mime directory # Mime directory
msg "Copying shared files from ${GTK_PREFIX}:" msg "Copying shared files from ${GTK_PREFIX}:"
ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/mime ditto {"${LOCAL_PREFIX}/local","${RESOURCES}"}/share/mime
# Install names
ModifyInstallNames
msg "Installing required application bundle files:" msg "Installing required application bundle files:"
PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}/tools/osx" PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}/tools/osx"
ditto "${PROJECT_SOURCE_DIR}/build/Resources" "${RESOURCES}" ditto "${CMAKE_BUILD_TYPE}/Resources" "${RESOURCES}"
ditto "${PROJECT_SOURCE_DIR}/rtdata/fonts" "${ETC}/fonts" ditto "${PROJECT_SOURCE_DIR}/rtdata/fonts" "${ETC}/fonts"
# App bundle resources # App bundle resources
@@ -260,19 +260,19 @@ echo " install_name_tool -add_rpath /Applications/RawTherapee.app/Contents/Fra
done done
# Sign the app # Sign the app
msg "Codesigning:"
CODESIGNID="$(cmake .. -LA -N | grep "CODESIGNID" | cut -d "=" -f2)" CODESIGNID="$(cmake .. -LA -N | grep "CODESIGNID" | cut -d "=" -f2)"
if ! test -z "$CODESIGNID" ; then if ! test -z "${CODESIGNID}" ; then
msg "Codesigning:"
install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/rt.entitlements" "${CONTENTS}/rt.entitlements" install -m 0644 "${PROJECT_SOURCE_DATA_DIR}/rt.entitlements" "${CONTENTS}/rt.entitlements"
plutil -convert binary1 "${CONTENTS}/rt.entitlements" plutil -convert binary1 "${CONTENTS}/rt.entitlements"
codesign -v -s "${CODESIGNID}" -i "com.rawtherapee.RawTherapee" -o runtime --timestamp --entitlements "${CONTENTS}/rt.entitlements" "${CONTENTS}/rt.entitlements" codesign -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --timestamp --entitlements '${CONTENTS}/rt.entitlements' '${CONTENTS}/rt.entitlements'
codesign -v -s "${CODESIGNID}" -i "com.rawtherapee.RawTherapee" -o runtime --timestamp --entitlements "${CONTENTS}/rt.entitlements" "${EXECUTABLE}" codesign -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --timestamp --entitlements '${CONTENTS}/rt.entitlements' '${EXECUTABLE}'
codesign -v -s "${CODESIGNID}" -i "com.rawtherapee.RawTherapee" -o runtime --timestamp --entitlements "${CONTENTS}/rt.entitlements" "${EXECUTABLE}-cli" codesign -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --timestamp --entitlements '${CONTENTS}/rt.entitlements' '${EXECUTABLE}-cli'
for frameworklibs in ${CONTENTS}/Frameworks/* ; do for frameworklibs in ${CONTENTS}/Frameworks/* ; do
codesign -v -s "${CODESIGNID}" -i "com.rawtherapee.RawTherapee" -o runtime --timestamp "${frameworklibs}" codesign -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --timestamp '${frameworklibs}'
done done
codesign --deep --preserve-metadata=identifier,entitlements,runtime --timestamp --strict -v -s "${CODESIGNID}" -i "com.rawtherapee.RawTherapee" -o runtime --entitlements "${CONTENTS}/rt.entitlements" "${APP}" codesign --deep --preserve-metadata=identifier,entitlements,runtime --timestamp --strict -v -s "${CODESIGNID}" -i com.rawtherapee.RawTherapee -o runtime --entitlements '${CONTENTS}/rt.entitlements' '${APP}'
spctl -a -vvvv "${APP}" spctl -a -vvvv ${APP}
fi fi
# Notarize the app # Notarize the app
@@ -331,7 +331,7 @@ hdiutil create -format UDBZ -fs HFS+ -srcdir "${srcDir}" -volname "${PROJECT_NAM
# Sign disk image # Sign disk image
if ! test -z "$CODESIGNID" ; then if ! test -z "$CODESIGNID" ; then
codesign --deep --force -v -s "${CODESIGNID}" --timestamp "${dmg_name}.dmg" codesign --deep --force -v -s ""${CODESIGNID}"" --timestamp "${dmg_name}.dmg"
fi fi
# Notarize the dmg # Notarize the dmg