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

installation_proxy: bytes package install #1266

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Abdullah-Albanna
Copy link
Contributor

@Abdullah-Albanna Abdullah-Albanna commented Oct 29, 2024

ability to install .ipa/.ipcc using bytes objects

why?

it's way nicer to directly install a package without dealing with paths.

someone could do something like so

import requests
from pymobiledevice3.lockdown import create_using_usbmux
from pymobiledevice3.services.installation_proxy import InstallationProxyService

file = requests.get(
    "https://raw.githubusercontent.com/Abdullah-Albanna/YemenIPCC/refs/heads/master/iPhone7Plus/iOS 15.8.2/Using Default Bundle/iPhone7Plus_iOS_15.8.2_CellularSouthLTE.ipcc",
)

lockdown = create_using_usbmux()

InstallationProxyService(lockdown).install(file.content)

without the need to save it to a file and then installing it and then deleting it !
too much work

this is also valid

from pathlib import Path

file = Path("file.ipa").read_bytes()

lockdown = create_using_usbmux()

InstallationProxyService(lockdown).install(file)

@doronz88
Copy link
Owner

I much rather it be explicitly done than implicit. I'm okay with the install_from_bytes(), but it should a different API instead of modifying the current

@Abdullah-Albanna
Copy link
Contributor Author

that makes sense, should be good now

pymobiledevice3/cli/apps.py Outdated Show resolved Hide resolved
pymobiledevice3/services/installation_proxy.py Outdated Show resolved Hide resolved
pymobiledevice3/services/installation_proxy.py Outdated Show resolved Hide resolved
dirs = zip_file.namelist()[1].split('/')

if dirs[0] != 'Payload':
raise AppInstallError('package does not have a payload')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise AppInstallError('package does not have a payload')
raise InvalidArgumentError('package does not have a payload')

raise AppInstallError('package does not have the appropriate folders structure')

except BadZipFile:
raise AppInstallError('invalid bytes package')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise AppInstallError('invalid bytes package')
raise InvalidArgumentError('invalid bytes package')

ipcc_mode = package_path.suffix == '.ipcc'

if options is None:
options = {}

if ipcc_mode:
options['PackageType'] = 'CarrierBundle'

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this diff


self._watch_completion(handler, ipcc_mode, args)

def upload_ipcc_as_folder(self, file: Path, afc_client: AfcService) -> None:
def upload_ipcc_as_folder(self, file: Union[Path, bytes], afc_client: AfcService) -> None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restore this function behavior to the old one. the bytes objects can already be convered to file in install_from_bytes()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants