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 on Mac OS X 10.11.6 fails #14

Closed
uho opened this issue Mar 5, 2017 · 7 comments
Closed

Installation on Mac OS X 10.11.6 fails #14

uho opened this issue Mar 5, 2017 · 7 comments

Comments

@uho
Copy link

uho commented Mar 5, 2017

Following the proposed installation procedure, the installation fails:

  1. System
    $ uname -a
    Darwin computer.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64
    $ sw_vers -productVersion
    10.11.6

  2. Checking for correct Go version 1.8:

    $ go version
    go version go1.8 darwin/amd64

  3. Installing gokrazy:

    $ go get -u github.com/gokrazy/tools/cmd/gokr-packer
    # github.com/gokrazy/gokrazy/internal/iface
    go/src/github.com/gokrazy/gokrazy/internal/iface/iface.go:108: undefined: syscall.SIOCADDRT
    go/src/github.com/gokrazy/gokrazy/internal/iface/iface.go:122: undefined: syscall.SIOCDELRT

The correct behavior would be to install without errors.

@stapelberg
Copy link
Contributor

Thanks for the report. The code in question should only be compiled for the target (linux arm64), but is currently compiled for the host due to the way we pull in code. I’ll push a commit in a second which should fix this. Please reopen if you still encounter issues afterwards.

stapelberg added a commit that referenced this issue Mar 5, 2017
@uho
Copy link
Author

uho commented Mar 6, 2017

Fix changes behavior to

`$ go get -u github.com/gokrazy/tools/cmd/gokr-packer`
`# github.com/gokrazy/tools/cmd/gokr-packer`
`go/src/github.com/gokrazy/tools/cmd/gokr-packer/parttable.go:81: undefined: unix.BLKGETSIZE64`
`go/src/github.com/gokrazy/tools/cmd/gokr-packer/parttable.go:93: undefined: unix.BLKRRPART`

still not able to install without errors. Reopening this issue.

@stapelberg stapelberg reopened this Mar 7, 2017
@stapelberg
Copy link
Contributor

Thanks. I’ll need to make that code conditional, then.

Given that I don’t have a macOS machine handy, any fix would be blind. I might be able to actually test gokrazy (and not just have it compile) on macOS next week. If you want to race me to it, contributions are very welcome :).

@uho
Copy link
Author

uho commented Mar 7, 2017

It looks like the constants

unix.BLKGETSIZE64
unix.BLKRRPART

are not available with darwin/amd64 as Darwin lacks these requests for IOCTL.

A substitute for Darwin has to be identified in order to
determine the device size and re-read partition table.

Maybe The discusscion How do I get the partition offset in OS X with C/C++? on Stackoverflow gives some hints.

stapelberg added a commit to gokrazy/tools that referenced this issue Mar 18, 2017
stapelberg added a commit to gokrazy/tools that referenced this issue Mar 18, 2017
stapelberg added a commit to gokrazy/tools that referenced this issue Mar 18, 2017
stapelberg added a commit to gokrazy/tools that referenced this issue Mar 18, 2017
@stapelberg
Copy link
Contributor

The commits I just pushed should allow you to install gokr-packer on macOS.

Prep work

Before you’ll be able to create an image, you’ll need to dump the system root certificates:

mkdir -p ~/.config/gokrazy
security find-certificate -a \
  -p /System/Library/Keychains/SystemCACertificates.keychain \
  > ~/.config/gokrazy/cacert.pem

Test cross-compilation

Check whether GOOS=linux GOARCH=arm64 go get -u github.com/gokrazy/hello fails. If it fails due to a permission error (common if you have used the Go installer), you have 3 options:

  1. Run gokrazy as root, thereby gaining write permission to /usr/local/go
  2. Copy /usr/local/go to a temporary directory and set the GOROOT environment variable to that directory
  3. Re-install Go from source into a directory where you have write permission.

Creating an image

I’d recommend to follow https://github.com/gokrazy/tools#alternative-creating-an-sd-card-image and use whichever tool you feel comfortable with to write the image to an SD card.

Creating an image (the harder(?) way)

In case you want to use gokr-packer to directly write to the SD card, a couple more steps are necessary. Notably, you’ll need to repeat all of these steps whenever you want to directly write to your SD card.

Locate your SD card in diskutil list. On my machine, it shows up as /dev/disk2.

In case the SD card contained any partitions with a file system, use umount to unmount the file systems (otherwise you’ll get a “device busy” error on the next command).

Overwrite the SD card with zeros to remove all partitions and file systems, preventing macOS from mounting the file systems after we overwrite the partition table:

dd if=/dev/zero of=/dev/rdisk2 bs=1m count=1024

Afterwards, the following worked for me:

gokr-packer -overwrite=/dev/disk2 github.com/gokrazy/hello

macOS prompts you halfway through the process about not being able to read any file systems (which aren’t written at that point). Dismiss the dialog by clicking its “ignore” button.

@stapelberg
Copy link
Contributor

I’m closing this issue. We can discuss/track individual remaining issues/improvements to the experience in separate issues, if desired.

@uho
Copy link
Author

uho commented Mar 20, 2017 via email

bradfitz pushed a commit to bradfitz/gokrazy that referenced this issue Apr 4, 2023
The new `-tls` parameter is empty by default, retaining the current behavior (no change).

If `-tls=self-signed` is specified, the packer generates and signs a RSA4096 certificate, stored in the host-specific config directory, e.g. typically `~/.config/gokrazy/<hostname>/{cert,key}.pem` on Linux.

If `-tls=<certpath>[,<keypath>]` is specified, the packer uses the specified certificate and key.

When TLS is used, the certificate/key is included in the gokrazy root file system at  `/etc/ssl/{web,web_key}.pem`.

To switch an unencrypted (HTTP) installation to HTTPS, use the `-insecure` flag for the first update, e.g.:
`gokr-packer -tls=self-signed -insecure …`
…then remove it for all subsequent updates, which will now be done via HTTPS:
`gokr-packer -tls=self-signed …`
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

No branches or pull requests

2 participants