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

scripting: add export command #6716

Merged
merged 1 commit into from
Nov 20, 2024
Merged

scripting: add export command #6716

merged 1 commit into from
Nov 20, 2024

Conversation

naveenrajm7
Copy link
Contributor

Fixes #6553

  • Exposed VM export via Apple Scripting and CLI
  • Turned on sandbox for unsigned utmctl binary to be consistent with unsigned UTM. So we can test the same data across unsigned products.

Example:

Usage in AppleScript

tell application "/Users/***/UTM.app"
  set vm to virtual machine named "ubuntu"
  set output to POSIX file "/Users/***/ubuntuExport.utm"
  export vm to output
end tell

Usage in cli (path must be writable by utmctl)

utmctl export ubuntu --path /Users/***/ubuntuExport.utm

@osy osy added this to the v4.6 milestone Nov 20, 2024
@osy osy merged commit 28a14b9 into utmapp:main Nov 20, 2024
27 checks passed
@osy
Copy link
Contributor

osy commented Nov 21, 2024

I'm curious how to document the fact that utmctl can only specify paths inside the sandbox. Any ideas?

@osy
Copy link
Contributor

osy commented Nov 21, 2024

Maybe it would be better to not allow passing absolute paths but only relative paths?

@osy
Copy link
Contributor

osy commented Nov 21, 2024

Can you explain what the use case for utmctl to only export (and import) to paths that are in the sandbox? I'm wondering if this should be in utmctl at all now... I do recall explicitly not adding this functionality for this reason.

@naveenrajm7
Copy link
Contributor Author

Thanks for your comments, with these and the previous discussion on file URLs now I understand the problem.

When I did this pull request, I did not realize that utmctl command would not work for all paths.
This is because of the wrong test that I did. As shown in example, I first tried export in applescript and then used the same file path after deleting the previous export file to test in utmctl , it worked. But now I see any other file path tried directly via utmctl will not work.

We have two options,

  1. Try to get access to path inside utmctl. Similar to what POSIX file in applescript does for us to use that file.
  2. Remove support for export command from utmctl only. ( import is not in utmctl)

From your comments, I get a sense that option 1 is not feasible or desirable.
I will remove export from UTMCtl file, please acknowledge if you agree.

Note: Using these commands via apple script will still work, because the POSIX file of applescript takes care of permissions for us.

@osy
Copy link
Contributor

osy commented Nov 21, 2024

Yeah I remember now I looked extensively into 1 before and found it's just a limitation of Apple's sandbox system. Basically any path accessed by the app must be passed as a bookmark initially. AppleScript does this correctly but there's no way to do this from the terminal. And yes, it still works from AppleScript.

I will go ahead and remove it from utmctl and mention in the release notes that it's only accessible through the AppleScript interface.

@naveenrajm7
Copy link
Contributor Author

Thanks for agreeing to remove it by yourself.

The Xcode build from main branch fails for me with below error.

ld: framework 'phodav-3.0.0' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@osy
Copy link
Contributor

osy commented Nov 21, 2024

Yes you need to download the latest dependencies from the actions

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.

Add utmctl export command
2 participants