Skip to content

Conversation

@torarnv
Copy link
Contributor

@torarnv torarnv commented Jan 10, 2025

Using <wait "string"> or <wait "(some|regex|here)"> allows installing macOS without having to specify hard-coded timeout waits such as <wait10s>.

@torarnv
Copy link
Contributor Author

torarnv commented Jan 10, 2025

Missing docs for new wait command, will add after initial feature review

@torarnv
Copy link
Contributor Author

torarnv commented Jan 10, 2025

This allows e.g:

diff --git a/macos/macos.pkrtpl.yaml b/macos/macos.pkrtpl.yaml
index bed5e73..305532e 100644
--- a/macos/macos.pkrtpl.yaml
+++ b/macos/macos.pkrtpl.yaml
@@ -1,14 +1,8 @@
-wait_for_boot:
-  # Wait for VM too boot
-  # FIXME: Ideally there would be some way to wait for the first
-  # non-black frame from the VNC server.
-  - <wait60s>
-
 install_macos:
-  # Hello, Hola, Bonjour, etc.
+  - <wait "Get Started">
   - <spacebar>
-  - <wait5s>
+  - <wait "Language">

@torarnv
Copy link
Contributor Author

torarnv commented Jan 10, 2025

Is the builder not a macOS machine?

@edigaryev
Copy link
Contributor

Hi @torarnv 👋

This is a pretty cool use of Apple's Vision framework.

Have you considered submitting this to packer or packer-plugin-sdk directly?

This way:

  1. Not just Packer Plugin for Tart could benefit from this, but literally all existing packer plugins, assuming that on non-macOS platforms something like github.com/otiai10/gosseract could be used

  2. <wait> syntax could be extended natively, without performing any hacks on Packer Plugin for Tart's side and yielding correct documentation

@torarnv
Copy link
Contributor Author

torarnv commented Jan 13, 2025

Thanks @edigaryev!

I did initially considered building this feature into packer-plugin-sdk's bootcommand package directly, but as this was a quick hackathon project, where my focus was to get something workable for packer-plugin-tart (scratching my own itch), I deferred that approach.

An upstream feature in packer-plugin-sdk would make sense, but one challenge there is that bootcommand has 3 different backends (VNC, USB, and PC-XT), and from what I can tell the boot commands are backend-agnostic. Adding the feature in the SDK would inevitably diverge the feature set, which I'm not sure is acceptable.

Using github.com/otiai10/gosseract would be an option, but would add more dependencies compared to the fairly straight forward use of the built in Vision.framework.

One possible upstream improvement would be to teach bootcommand to extend the grammar, so that we don't need regex-based logic to add new commands, but I sadly won't have time to dive into that.

I'm still testing this feature on my nightly builds, so we can hold on on merging for now. Let me know if you have other concerns though!

@torarnv torarnv force-pushed the vnc-text-recognition branch from d033baf to ecebf0f Compare February 25, 2025 12:26
@torarnv
Copy link
Contributor Author

torarnv commented Feb 25, 2025

I guess we need to move the lint and build to a macos_instance? Are there any predefined Cirrus images or rules that include the golang (lint) toolchain?

@torarnv
Copy link
Contributor Author

torarnv commented Feb 26, 2025

Missing docs for new wait command, will add after initial feature review

Done

@torarnv
Copy link
Contributor Author

torarnv commented Mar 5, 2025

@edigaryev @fkorotkov thoughts? 🙂

@edigaryev
Copy link
Contributor

I guess we need to move the lint and build to a macos_instance? Are there any predefined Cirrus images or rules that include the golang (lint) toolchain?

Something like this should do: d02016e.

@torarnv
Copy link
Contributor Author

torarnv commented Mar 13, 2025

Thanks for the reviews @edigaryev, will push an update soon. And thanks for fixing the CI bits to run on macOS :)

@edigaryev
Copy link
Contributor

And thanks for fixing the CI bits to run on macOS :)

You should probably rebase against main to get it working.

@hisaac
Copy link

hisaac commented May 21, 2025

Howdy @torarnv, @edigaryev. Where are things at with this PR? I'm very eager to use this functionality. Is there anything I can do to help move things along?

@torarnv
Copy link
Contributor Author

torarnv commented May 22, 2025

Hey hey @hisaac! I've been swamped, but picking this up now, will push a new PR soon!

@hisaac
Copy link

hisaac commented May 22, 2025

Sounds great. Let me know if you'd like any help testing or anything. I should have some time in the next couple weeks to help out if needed.

@torarnv torarnv force-pushed the vnc-text-recognition branch 2 times, most recently from ee43374 to 3219dfc Compare May 29, 2025 11:08
@torarnv
Copy link
Contributor Author

torarnv commented May 29, 2025

@hisaac Please test the latest version, thanks! 😄

@torarnv
Copy link
Contributor Author

torarnv commented May 29, 2025

@hisaac @edigaryev you may find hashicorp/packer-plugin-sdk#293 convenient as well. If it takes time to merge upstream, perhaps we can go replace the SDK with my fork?

@hisaac
Copy link

hisaac commented May 29, 2025

@hisaac @edigaryev you may find hashicorp/packer-plugin-sdk#293 convenient as well.

Love this!

@edigaryev edigaryev self-requested a review May 30, 2025 15:47
@edigaryev edigaryev requested a review from fkorotkov May 30, 2025 19:36
@edigaryev
Copy link
Contributor

@hisaac @edigaryev you may find hashicorp/packer-plugin-sdk#293 convenient as well. If it takes time to merge upstream, perhaps we can go replace the SDK with my fork?

Nice addition for Packer + macOS usability indeed!

Let's just see how fast it gets reviewed/merged and then go from there.

The functionality builds on the built in Vision framework on macOS,
and the existing VNC integration.

A custom VNC driver has been added that picks up changes to the
VNC framebuffer, and allows custom boot commands without changes
to the packer-sdk bootcommand grammar, by using a simple regex
replacement that uses two symbols from the Unicode Private Use
Area (PUA) as markers.
@torarnv torarnv force-pushed the vnc-text-recognition branch from 3219dfc to 730f770 Compare June 15, 2025 14:16
@hisaac
Copy link

hisaac commented Jun 23, 2025

ok I've tried to figure out how to test this but am not having any luck. How do I point to this branch in my Packer template so I can test the changes?

@edigaryev edigaryev merged commit 8e4cb37 into cirruslabs:main Jun 24, 2025
2 checks passed
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.

4 participants