Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Device/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ the steps, what we depend on and what to do when something changed.

### Amethyst (iOS 12 and 13)

On iOS 12.2 to 13.7 the app is the official [Amethyst](https://github.com/staturnzz/amethyst)
On iOS 12.0 to 13.7 the app is the official [Amethyst](https://github.com/staturnzz/amethyst)
release (1.1, pinned in `scripts/tools.py` like Dopamine) with Resize APFS in it, installed the
same way (`scripts/amethyst_route.py`; xtool always signs, as Xcode builds nothing for iOS 12
and 13). The differences:
Expand Down Expand Up @@ -224,8 +224,10 @@ and 13). The differences:
opened again the app starts from its first page. Afterwards iOS runs from the live volume,
so the app's existing "Remove snapshot" frees orig-fs before a shrink (Amethyst's own
restore-rootfs needs orig-fs and stops working then).
- **iOS 12.2 and later only:** the library needs the Swift runtime that iOS 12.0 and 12.1 lack,
and Amethyst's executable brings none. The checkra1n route covers those versions.
- **The Swift runtime comes along.** Amethyst's executable brings none, so the payload carries
the app's back-deployment runtime in `Resources/Frameworks`, which lands in the app's
`Frameworks` next to the library. iOS 12.0 and 12.1 load it from there; 12.2 and later take
their own from `/usr/lib/swift`, searched first.

Moving to a newer Amethyst: [docs/updating-amethyst.md](../docs/updating-amethyst.md).

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open Terminal in the `ResizeAPFS-v…` folder. Then pick the method for your dev
| **DFU** (checkra1n) | A7 to A11 | 12 to 14 |
| **Dopamine**, no DFU | A8 to A13 | 15.0 to 18.7.1, 26.0 to 26.0.1 |
| | A14 and later | 15.0 to 17.3.1 |
| **Amethyst**, no DFU | every device | 12.2 to 13.7 |
| **Amethyst**, no DFU | every device | 12.0 to 13.7 |

### Via DFU (checkra1n / palera1n)

Expand Down Expand Up @@ -57,7 +57,7 @@ app carries inside.

### Via Amethyst

For iOS 12.2 to 13.7, the iPhone 5s, iPad Air and iPad mini 2 and 3 included.
For iOS 12.0 to 13.7, the iPhone 5s, iPad Air and iPad mini 2 and 3 included.

1. Connect the device, unlock it and trust the computer.
2. Run `./resize-apfs boot --amethyst`.
Expand Down
3 changes: 2 additions & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

The iOS 12-14 app (`out/device-ios12`) contains the Swift runtime and system
overlay libraries in `ResizeAPFS.app/Frameworks`, copied at build time from the
overlay libraries in `ResizeAPFS.app/Frameworks` (and the Amethyst payload's
`access/Resources/Frameworks`), copied at build time from the
Xcode toolchain's back-deployment runtime (`usr/lib/swift-5.0/iphoneos`), because
iOS 12.0 and 12.1 have no Swift runtime. They are part of the Swift project,
licensed under the Apache License 2.0 with the Runtime Library Exception, which
Expand Down
9 changes: 9 additions & 0 deletions Tests/ReleaseTests/test_amethyst_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ def test_the_executable_built_from_source_takes_the_official_ones_place(self):
self.assertEqual(archive.read(app + 'Base.lproj/LaunchScreen.storyboardc/Info.plist'), b'ours')
self.assertNotIn(app + embed.HOST + '/Amethyst', archive.namelist())

def test_the_swift_runtime_lands_next_to_the_library(self):
# Amethyst brings no Swift runtime: iOS 12.0 and 12.1 load the payload's.
(self.payload / 'Resources/Frameworks').mkdir(parents=True)
(self.payload / 'Resources/Frameworks/libswiftCore.dylib').write_bytes(b'runtime')
with self.prepared() as archive:
app = 'Payload/Amethyst.app/Frameworks/'
self.assertEqual(archive.read(app + 'libswiftCore.dylib'), b'runtime')
self.assertEqual(archive.read(app + 'ResizeAccess.dylib'), b'\xcf\xfa\xed\xfe library')

def test_the_official_stripped_executable_is_refused(self):
with self.assertRaisesRegex(ValueError, 'run_jailbreak.*built from its source'):
embed.check_amethyst(amethyst_executable(stripped=True))
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
4 changes: 2 additions & 2 deletions scripts/amethyst_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
Access/AmethystBridge.m). On a device's first run the whole device restarts once, while
Amethyst sets iOS's system snapshot aside; the user opens the app again afterwards.

iOS 12.0 and 12.1 are not served: the app's library needs the Swift runtime that iOS has from
12.2 on, and Amethyst's executable brings none (the checkra1n route covers them).
Amethyst's executable brings no Swift runtime, so the payload brings the app's back-deployment
runtime (scripts/build-device-ios12.sh): iOS 12.0 and 12.1 load it from the app's Frameworks.

xtool signs the app with the user's Apple ID and installs it, after one confirmation
(sideload.py); where xtool has no release, the prepared app is left for the user to sign and
Expand Down
25 changes: 22 additions & 3 deletions scripts/build-device-ios12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# also makes the compiler reject any API newer than iOS 12.
#
# Swift runtime: iOS 12.2 and later have it in /usr/lib/swift; iOS 12.0 and 12.1 do
# not. As Xcode does for apps, the app bundles Apple's back-deployment runtime
# not. As Xcode does for apps, the app (and the Amethyst payload) bundles Apple's back-deployment runtime
# (toolchain usr/lib/swift-5.0/iphoneos) in ResizeAPFS.app/Frameworks, searched after
# /usr/lib/swift, so the system copy wins wherever it exists. The checkra1n route
# copies only the helper file; it always installs the app first and removes it last,
Expand Down Expand Up @@ -98,8 +98,10 @@ for binary in "$app/ResizeAPFS" "$out/resize-helper"; do
done
# The app without DFU on iOS 12 and 13 (scripts/embed.py puts this into the pinned Amethyst app
# on the user's computer): the interface as a library, the resources it needs, the helper, and
# Amethyst's executable built from its source (scripts/build-amethyst.sh). The library needs
# Swift in iOS (12.2 and later): it is loaded by Amethyst's executable, which brings no runtime.
# Amethyst's executable built from its source (scripts/build-amethyst.sh). Amethyst brings no
# Swift runtime, so the payload brings the app's back-deployment runtime in Resources/Frameworks,
# which lands in the host app's Frameworks next to the library: iOS 12.0 and 12.1 load it from
# there, iOS 12.2 and later take their own from /usr/lib/swift, searched first.
access="$out/access"
mkdir -p "$access/Resources" "$access/host"
xcrun --sdk iphoneos clang -target "$target" -isysroot "$sdk" -Os -fobjc-arc -fmodules \
Expand All @@ -108,9 +110,26 @@ xcrun --sdk iphoneos clang -target "$target" -isysroot "$sdk" -Os -fobjc-arc -fm
swiftc -parse-as-library -emit-library -module-name ResizeAccess -I "$build" -L "$build" -lResizeCore \
$(ls App/*.swift | grep -v '^App/AppDelegate.swift$') Access/StorageAccess.swift "$build/AmethystBridge.o" \
-Xlinker -install_name -Xlinker @executable_path/Frameworks/ResizeAccess.dylib \
-Xlinker -rpath -Xlinker @executable_path/Frameworks \
-o "$access/ResizeAccess.dylib"
first=$(xcrun otool -l "$access/ResizeAccess.dylib" | awk '/cmd LC_RPATH/ {getline; getline; print $2; exit}')
[[ "$first" == /usr/lib/swift ]] || { echo "ResizeAccess.dylib must search /usr/lib/swift first, not $first." >&2; exit 1; }
mkdir -p "$access/Resources/Frameworks"
pending=$(rpath_libs "$access/ResizeAccess.dylib")
while [[ -n "$pending" ]]; do
next=""
for lib in $pending; do
[[ -f "$access/Resources/Frameworks/$lib" || ! -f "$app/Frameworks/$lib" ]] && continue
cp "$app/Frameworks/$lib" "$access/Resources/Frameworks/$lib"
next+=" $(rpath_libs "$app/Frameworks/$lib")"
done
pending=$(echo $next | tr ' ' '\n' | sort -u)
done
for binary in "$access/ResizeAccess.dylib" "$access"/Resources/Frameworks/*.dylib; do
for lib in $(strong_libs "$binary"); do
[[ -f "$access/Resources/Frameworks/$lib" ]] || { echo "$binary needs $lib, which iOS 12.0 lacks and which is not bundled." >&2; exit 1; }
done
done
xcrun --sdk iphoneos strip -x "$access/ResizeAccess.dylib"
codesign --force --sign - --timestamp=none "$access/ResizeAccess.dylib"
cp "$app/Info.plist" "$access/Info.plist"
Expand Down
8 changes: 4 additions & 4 deletions scripts/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def route(given, dopamine=False, amethyst=False):
require(given is None or given >= 15, 'The Dopamine route needs iOS/iPadOS 15 or later.')
return 'dopamine'
if amethyst:
require(given is None or given in (12, 13), 'The Amethyst route needs iOS/iPadOS 12.2 to 13.7.')
require(given is None or given in (12, 13), 'The Amethyst route needs iOS/iPadOS 12.0 to 13.7.')
return 'amethyst'
if given is None:
print('iOS/iPadOS version on the device (Settings > General > About):\n'
' 1) 15 or later\n'
' 2) 12, 13 or 14\n'
' 3) 15 or later, without DFU: Dopamine (also iPhone XS, XR, 11 and other A12/A13 devices)\n'
' 4) 12.2 to 13.7, without DFU: Amethyst (also iPhone 5s, iPad Air, iPad mini 2 and 3)')
' 4) 12.0 to 13.7, without DFU: Amethyst (also iPhone 5s, iPad Air, iPad mini 2 and 3)')
answer = input('> ').strip()
require(answer in ('1', '2', '3', '4'), 'Please answer 1, 2, 3 or 4.')
return {'1': 'palera1n', '2': 'checkra1n', '3': 'dopamine', '4': 'amethyst'}[answer]
Expand All @@ -63,14 +63,14 @@ def route(given, dopamine=False, amethyst=False):

def main():
parser = argparse.ArgumentParser(description='Prepare and boot Resize APFS: palera1n for iOS 15+, checkra1n for iOS 12-14, '
'Dopamine for iOS 15+ and Amethyst for iOS 12.2-13.7 without DFU.')
'Dopamine for iOS 15+ and Amethyst for iOS 12.0-13.7 without DFU.')
parser.add_argument('action', choices=['prepare', 'boot'])
parser.add_argument('--ios', type=int, metavar='VERSION',
help='the installed iOS major version (e.g. 15 or 12); skips the question')
parser.add_argument('--dopamine', action='store_true',
help='use Dopamine instead of DFU: the app installed with your Apple ID (iOS 15 or later); skips the question')
parser.add_argument('--amethyst', action='store_true',
help='use Amethyst instead of DFU: the app installed with your Apple ID (iOS 12.2 to 13.7); skips the question')
help='use Amethyst instead of DFU: the app installed with your Apple ID (iOS 12.0 to 13.7); skips the question')
parser.add_argument('--ssh', action='store_true',
help='for developers, with Dopamine: also install an SSH server for root, reachable over USB '
'only and only with your SSH public key (~/.ssh/id_ed25519.pub)')
Expand Down
Loading