-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note: The system automatically migrates Vienna's library files to a sandbox container on launching Vienna with sandboxing enabled. This can be reversed by using the provided shell script, e.g. for development purposes or for downgrading to an earlier version of Vienna. The container-migration.plist file specifies the old and new locations for the migration. It should cover all of Vienna's directories and files, so that the user ideally ends up with a complete sandbox container. Some system-defined locations have to be changed to avoid duplication. For example, Apple moved the cookies storage from ~/Library/Cookies to ~/Library/HTTPStorages starting with macOS 11/Safari 14. Within sandbox containers however, ~/Library/Cookies is used. The automatic migration does not overwrite files. Therefore, a migration of ~/Library/HTTPStorages is attempted first. If that attempt is successful then the migration of ~/Library/Cookies should (silently) fail; otherwise ~/Library/Cookies is migrated instead. User preferences in ~/Library/Preferences are migrated automatically. User scripts are migrated from ~/Library/Scripts/Applications/Vienna to ~/Library/Application Scripts/<bundle ID> and a symlink is left at the former location; this also happens automatically. The shell script uses ditto to copy the directories. Ditto will merge directories rather than overwrite them, if the destination directory exists. It will, however, overwrite individual files.
- Loading branch information
Showing
10 changed files
with
243 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>MigrateScriptsForApplication</key> | ||
<string>Vienna</string> | ||
<key>Move</key> | ||
<array> | ||
<array> | ||
<string>${Caches}/${BundleId}/WebKit</string> | ||
<string>${Caches}/WebKit</string> | ||
</array> | ||
<string>${Caches}/${BundleId}</string> | ||
<array> | ||
<string>${ApplicationSupport}/Vienna/Sources</string> | ||
<string>${Caches}/${BundleId}/Sources</string> | ||
</array> | ||
<string>${ApplicationSupport}/Vienna</string> | ||
<string>${Library}/HTTPStorages/${BundleId}</string> | ||
<array> | ||
<string>${Library}/HTTPStorages/${BundleId}.binarycookies</string> | ||
<string>${Library}/Cookies/Cookies.binarycookies</string> | ||
</array> | ||
<array> | ||
<string>${Library}/Cookies/${BundleId}.binarycookies</string> | ||
<string>${Library}/Cookies/Cookies.binarycookies</string> | ||
</array> | ||
<string>${Library}/Saved Application State/${BundleId}.savedState</string> | ||
<array> | ||
<string>${Library}/WebKit/${BundleId}</string> | ||
<string>${Library}/WebKit</string> | ||
</array> | ||
<array> | ||
<string>${Library}/WebKit/Databases/___IndexedDB/${BundleId}</string> | ||
<string>${Library}/WebKit/Databases/___IndexedDB</string> | ||
</array> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/bin/sh | ||
# | ||
# undo-container-migration.sh | ||
# Vienna | ||
# | ||
# Copyright 2021-2022 Eitot | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
LIBRARY="$HOME/Library" | ||
BUNDLE_ID='uk.co.opencommunity.vienna2' | ||
CONTAINER="$LIBRARY/Containers/$BUNDLE_ID" | ||
CONTAINER_LIBRARY="$CONTAINER/Data/Library" | ||
|
||
set -e | ||
|
||
if [ ! -d "$CONTAINER" ] | ||
then | ||
printf 'No sandbox container found for Vienna\n' >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ -n "$(killall -s Vienna 2>/dev/null)" ] | ||
then | ||
printf 'Please quit Vienna and try again\n' >&2 | ||
exit 1 | ||
fi | ||
|
||
printf 'This script attempts to undo the container migration. Use this only to ' | ||
printf 'revert to an older version of Vienna that does not support sandboxing. ' | ||
printf 'Please make sure that Vienna is not opened during this process.\n' | ||
|
||
tput bold | ||
printf 'Are you sure you want to do this? [y/N] ' | ||
tput sgr0 | ||
read -r | ||
if ! printf '%s' "$REPLY" | grep -q -E '^[Yy]$' | ||
then | ||
exit 1 | ||
fi | ||
|
||
# Configure ditto to use verbose mode and abort if encountering a fatal error. | ||
alias ditto='ditto -v' | ||
export DITTOABORT=1 | ||
|
||
# User scripts are located in ~/Library/Application Scripts/<bundle ID> instead | ||
# of the sandbox container when sandboxing is enabled. Without sandboxing, they | ||
# are located in ~/Library/Scripts/Applications/<app name>. A symlink was added | ||
# at that location as a result of the automatic migration. | ||
if [ -L "$LIBRARY/Scripts/Applications/Vienna" ] | ||
then | ||
unlink "$LIBRARY/Scripts/Applications/Vienna" \ | ||
&& printf 'Cleared %s\n' "$LIBRARY/Scripts/Applications/Vienna" | ||
fi | ||
|
||
if [ -d "$LIBRARY/Application Scripts/$BUNDLE_ID" ] | ||
then | ||
ditto "$LIBRARY/Application Scripts/$BUNDLE_ID" \ | ||
"$LIBRARY/Scripts/Applications/Vienna" | ||
rm -r "$LIBRARY/Application Scripts/$BUNDLE_ID" \ | ||
&& printf 'Deleted %s\n' "$LIBRARY/Application Scripts/$BUNDLE_ID" | ||
fi | ||
|
||
if [ -d "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB" \ | ||
"$LIBRARY/WebKit/Databases/___IndexedDB/$BUNDLE_ID" | ||
rm -r "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB" \ | ||
&& printf 'Deleted %s\n' "$CONTAINER_LIBRARY/WebKit/Databases/___IndexedDB" | ||
fi | ||
|
||
if [ -d "$CONTAINER_LIBRARY/WebKit" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/WebKit" "$LIBRARY/WebKit/$BUNDLE_ID" | ||
fi | ||
|
||
if [ -d "$CONTAINER_LIBRARY/Saved Application State/$BUNDLE_ID.savedState" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Saved Application State/$BUNDLE_ID.savedState" \ | ||
"$LIBRARY/Saved Application State/$BUNDLE_ID.savedState" | ||
fi | ||
|
||
# Preferences are not explicitely declared in the migration manifest file; the | ||
# behaviour is implicit. | ||
if [ -f "$CONTAINER_LIBRARY/Preferences/$BUNDLE_ID.plist" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Preferences/$BUNDLE_ID.plist" \ | ||
"$LIBRARY/Preferences/$BUNDLE_ID.plist" | ||
fi | ||
|
||
# The location of cookies files of non-sandboxed applications changed from | ||
# ~/Library/Cookies to ~/Library/HTTPStorages as of macOS 11 (and probably | ||
# Safari 14). | ||
MACOS_VERSION="$(sw_vers -productVersion)" | ||
MACOS_MAJOR_VERSION="${MACOS_VERSION%%.*}" | ||
|
||
if [ "$MACOS_MAJOR_VERSION" -ge 11 ] || [ -d "$LIBRARY/HTTPStorages" ] | ||
then | ||
if [ -f "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" \ | ||
"$LIBRARY/HTTPStorages/$BUNDLE_ID.binarycookies" | ||
fi | ||
else | ||
if [ -f "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Cookies/Cookies.binarycookies" \ | ||
"$LIBRARY/Cookies/$BUNDLE_ID.binarycookies" | ||
fi | ||
fi | ||
|
||
if [ -d "$CONTAINER_LIBRARY/HTTPStorages/$BUNDLE_ID" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/HTTPStorages/$BUNDLE_ID" \ | ||
"$LIBRARY/HTTPStorages/$BUNDLE_ID" | ||
fi | ||
|
||
if [ -d "$CONTAINER_LIBRARY/Application Support/Vienna" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Application Support/Vienna" \ | ||
"$LIBRARY/Application Support/Vienna" | ||
fi | ||
|
||
# The Sources subdirectory was moved from Library/Application Support to | ||
# Library/Caches. | ||
if [ -d "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources" \ | ||
"$LIBRARY/Application Support/Vienna/Sources" | ||
rm -r "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources" \ | ||
&& printf 'Deleted %s\n' "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID/Sources" | ||
fi | ||
|
||
# The WebKit subdirectory in Library/Caches used to be located within the app's | ||
# caches directory (Library/Caches/<bundle ID>/WebKit). | ||
if [ -d "$CONTAINER_LIBRARY/Caches/WebKit" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Caches/WebKit" \ | ||
"$LIBRARY/Caches/$BUNDLE_ID/WebKit" | ||
rm -r "$CONTAINER_LIBRARY/Caches/WebKit" \ | ||
&& printf 'Deleted %s\n' "$CONTAINER_LIBRARY/Caches/WebKit" | ||
fi | ||
|
||
if [ -d "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID" ] | ||
then | ||
ditto "$CONTAINER_LIBRARY/Caches/$BUNDLE_ID" "$LIBRARY/Caches/$BUNDLE_ID" | ||
fi | ||
|
||
osascript -e "tell application \"Finder\" to delete POSIX file \"$CONTAINER\"" \ | ||
1>/dev/null && printf 'Trashed %s\n' "$CONTAINER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.