Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action workflow to patch SDKs #76

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
133 changes: 133 additions & 0 deletions .github/workflows/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Create SDK

on:
workflow_dispatch:
inputs:
ipsw_device:
description: 'The device ID to download the IPSW for, e.g. "iPhone11,2"'
required: true
type: string
ipsw_version:
description: 'The version to download the IPSW for, e.g. "16.5"'
required: true
type: string
dsc_basename:
description: 'The basename for the dyld_shared_cache in the IPSW'
required: true
type: string
default: 'dyld_shared_cache_arm64e'
xcode_version:
description: 'Xcode version, e.g. "14.4". Primarily used for the base SDK'
required: true
type: string
xcrun_sdk_name:
description: 'The value to pass to "xcrun --sdk", e.g. "iphoneos"'
required: true
type: string
default: 'iphoneos'
full_sdk_name:
description: 'The full name of the output SDK, e.g. "iPhoneOS16.5"'
required: true
type: string

jobs:
create:
# https://github.com/actions/runner-images/blob/main/images/macos
runs-on: macos-14
# needed to be able to push to the repo
permissions:
contents: write

steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Clone tbd
uses: actions/checkout@v4
with:
repository: leptos-null/tbd
ref: f0ae164d76b7bb802bbdf8ef758cc5637fac0fa1 # pinned, leptos/source-platform
path: tbd

- name: Build tbd
run: |
cd tbd
make bin/tbd

- name: Install blacktop/ipsw
run: brew install blacktop/tap/ipsw

- name: Install aria2
run: brew install aria2

- name: Patch SDK
id: patch-sdk
env:
DEVELOPER_DIR: /Applications/Xcode_${{ inputs.xcode_version }}.app
run: |
# use absolute path since we `cd` later
TBD_TOOL_PATH="$(pwd)/tbd/bin/tbd"
SDK_OUTPUT_PATH="$(pwd)/${{ inputs.full_sdk_name }}.sdk"

DSC_BASENAME="${{ inputs.dsc_basename }}"
XC_SDK_NAME="${{ inputs.xcrun_sdk_name }}"

cd tools/
PLATFORM_PATH="$(xcrun --sdk "${XC_SDK_NAME}" --show-sdk-platform-path)"
BASE_SDK_PATH="$(xcrun --sdk "${XC_SDK_NAME}" --show-sdk-path)"

SYMBOLS_DIR="$(mktemp -d -t symbols)"
IPSW_DOWNLOAD_DIR="$(mktemp -d -t ipsw)"
IPSW_EXTRACTION_DIR="$(mktemp -d -t ipsw)"

# `--dyld` is a convenient parameter for us, however it only supports iOS 16+
IPSW_DOWNLOAD_URL="$(ipsw download ipsw --urls --version "${{ inputs.ipsw_version }}" --device "${{ inputs.ipsw_device }}")"
echo "Downloading ${IPSW_DOWNLOAD_URL}"
aria2c --dir "${IPSW_DOWNLOAD_DIR}" "${IPSW_DOWNLOAD_URL}"

unzip -d "${IPSW_EXTRACTION_DIR}" "${IPSW_DOWNLOAD_DIR}"/*.ipsw "*.dmg"
# remove to save space
rm "${IPSW_DOWNLOAD_DIR}"/*.ipsw

for DMG_FILE in "${IPSW_EXTRACTION_DIR}"/*.dmg; do
# new mount root for each dmg so we don't have to
# worry about how we iterate over the mount root
DMG_MOUNT_ROOT="$(mktemp -d -t dmg)"
# some of the dmgs can't be mounted - not sure why
hdiutil attach "${DMG_FILE}" -mountroot "${DMG_MOUNT_ROOT}" || true
for MOUNT_VOL in "${DMG_MOUNT_ROOT}"/*; do
DYLD_CACHE_PATH="${MOUNT_VOL}/System/Library/Caches/com.apple.dyld/${DSC_BASENAME}"
if [ -e "${DYLD_CACHE_PATH}" ]; then
break 2 # break out of DMG_FILE loop
fi
# here becuase we didn't find the dyld shared cache (didn't break)
unset DYLD_CACHE_PATH
hdiutil detach "${MOUNT_VOL}" || true # this fails occasionally - just ignore
done
done

echo "Found dyld_shared_cache: ${DYLD_CACHE_PATH}"

if [ -z "${DYLD_CACHE_PATH}" ]; then
echo "Failed to find ${DSC_BASENAME} in IPSW"
exit 1
fi

./create_patched_sdk_image.sh "${DYLD_CACHE_PATH}" "${SDK_OUTPUT_PATH}" "${BASE_SDK_PATH}" "${PLATFORM_PATH}" "${TBD_TOOL_PATH}"

echo "sdk-path=${SDK_OUTPUT_PATH}" >> "${GITHUB_OUTPUT}"

- name: Create branch
run: |
# thanks to https://github.com/actions/checkout/discussions/479
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'

SDK_NAME="${{ inputs.full_sdk_name }}"
BRANCH_NAME="bot/${SDK_NAME}"

git switch -c "${BRANCH_NAME}"
git add "${{ steps.patch-sdk.outputs.sdk-path }}"

git commit -m "Add ${SDK_NAME} SDK"
git push --set-upstream origin "${BRANCH_NAME}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ This repository contains patched iOS SDKs containing private symbols. These were

To use with Theos, [download this repo](https://github.com/theos/sdks/archive/master.zip), extract, and copy whichever SDKs you desire into `$THEOS/sdks/`.

Generated using [create_patched_sdk.sh](create_patched_sdk.sh) and inoahdev’s [tbd v2.2](https://github.com/inoahdev/tbd/releases/tag/2.2) using binaries retrieved from iOS Device Support directory.
Generated using [create_patched_sdk.sh](tools/create_patched_sdk.sh) and inoahdev’s [tbd v2.2](https://github.com/inoahdev/tbd/releases/tag/2.2) using binaries retrieved from iOS Device Support directory or extracted from an IPSW.
62 changes: 0 additions & 62 deletions create_generic_symlinks.sh

This file was deleted.

Loading