timsutton / osx-vm-templates

macOS templates for Packer and VeeWee.
MIT License
1.12k stars 248 forks source link

Add High Sierra support to prepare_iso.sh #97

Closed americanhanko closed 3 years ago

americanhanko commented 6 years ago

This PR

Why

clburlison commented 6 years ago

For what it's worth I used this PR yesterday to build an iso with High Sierra 👍 . Might be nice to verify against an older OS version.

tzeejay commented 6 years ago

@americanhanko Do I get it right that this is just "make this script understand the changes in the High Sierra" installer but outputs a non-bootable iso, because of the signing mess?

tzeejay commented 6 years ago

If yes, I just got a little excited.

Thanks for you work anyways. Would like to see this merged

camilamacedo86 commented 6 years ago

Following the test performed.

** prepare_iso = Worked OK

cmacedo@camilas-MBP ~/Desktop/osx-vm-templates (pr) $ sudo prepare_iso/prepare_iso.sh /Applications/Install\ macOS\ High\ Sierra.app/ out
-- Destination dir out doesn't exist, creating..
-- Attaching input OS X installer image with shadow file..
expected   CRC32 $0954E321
/dev/disk3              GUID_partition_scheme           
/dev/disk3s1            EFI                             
/dev/disk3s2            Apple_HFS                       /private/tmp/veewee-osx-esd.V2kM
-- Mounting BaseSystem..
Checksumming Protective Master Boot Record (MBR : 0)…
Protective Master Boot Record (MBR :: verified   CRC32 $FDC76543
Checksumming GPT Header (Primary GPT Header : 1)…
 GPT Header (Primary GPT Header : 1): verified   CRC32 $84AC1518
Checksumming GPT Partition Data (Primary GPT Table : 2)…
GPT Partition Data (Primary GPT Tabl: verified   CRC32 $EDA37B3F
Checksumming  (Apple_Free : 3)…
                    (Apple_Free : 3): verified   CRC32 $00000000
Checksumming disk image (Apple_HFS : 4)…
..........................................................................................................................................
          disk image (Apple_HFS : 4): verified   CRC32 $42F71E59
Checksumming  (Apple_Free : 5)…
...................................................................................................................................................
                    (Apple_Free : 5): verified   CRC32 $00000000
Checksumming GPT Partition Data (Backup GPT Table : 6)…
GPT Partition Data (Backup GPT Table: verified   CRC32 $EDA37B3F
Checksumming GPT Header (Backup GPT Header : 7)…
  GPT Header (Backup GPT Header : 7): verified   CRC32 $C66FDEB8
verified   CRC32 $C694E6B5
/dev/disk4              GUID_partition_scheme           
/dev/disk4s1            Apple_HFS                       /private/tmp/veewee-osx-basesystem.ut2J
-- OS X version detected: 10.13.4, build 17E199
-- Making firstboot installer pkg..
No log handling enabled - using stderr logging
Created directory: /var/db/net-snmp
Created directory: /var/db/net-snmp/mib_indexes
productbuild: Wrote product to /Users/cmacedo/Desktop/osx-vm-templates/prepare_iso/support/tmp/veewee-config.pkg
"disk4" unmounted.
"disk4" ejected.
-- Creating empty read-write DMG located at /tmp/veewee-osx-basesystem-rw.UIpI.dmg..
created: /tmp/veewee-osx-basesystem-rw.UIpI.dmg
/dev/disk4              Apple_partition_scheme          
/dev/disk4s1            Apple_partition_map             
/dev/disk4s2            Apple_HFS                       /private/tmp/veewee-osx-basesystem.ut2J
-- Restoring ('asr restore') the BaseSystem to the read-write DMG..
    Validating target...done
    Validating source...done
    Retrieving scan information...done
    Validating sizes...done
    Restoring  ....10....20....30....40....50....60....70....80....90....100
    Remounting target volume...done
-- Moving 'Packages' directory from the ESD to BaseSystem..
/tmp/veewee-osx-esd.V2kM/Packages -> /Volumes/OS X Base System/System/Installation/Packages
/tmp/veewee-osx-esd.V2kM/Packages/Core.pkg -> /Volumes/OS X Base System/System/Installation/Packages/Core.pkg
/tmp/veewee-osx-esd.V2kM/Packages/EmbeddedOSFirmware.pkg -> /Volumes/OS X Base System/System/Installation/Packages/EmbeddedOSFirmware.pkg
/tmp/veewee-osx-esd.V2kM/Packages/FirmwareUpdate.pkg -> /Volumes/OS X Base System/System/Installation/Packages/FirmwareUpdate.pkg
/tmp/veewee-osx-esd.V2kM/Packages/OSInstall.mpkg -> /Volumes/OS X Base System/System/Installation/Packages/OSInstall.mpkg
/tmp/veewee-osx-esd.V2kM/Packages/SecureBoot.pkg -> /Volumes/OS X Base System/System/Installation/Packages/SecureBoot.pkg
-- Copying in original BaseSystem dmg and chunklist..
-- Adding automated components..
-- Unmounting BaseSystem..
"disk4" unmounted.
"disk4" ejected.
-- Unmounting ESD..
"disk3" unmounted.
"disk3" ejected.
-- On Mavericks and later, the entire modified BaseSystem is our output dmg.
Preparing imaging engine…
Reading Driver Descriptor Map (DDM : 0)…
   (CRC32 $651204F3: Driver Descriptor Map (DDM : 0))
Reading Apple (Apple_partition_map : 1)…
   (CRC32 $D01936FD: Apple (Apple_partition_map : 1))
Reading disk image (Apple_HFS : 2)…
....................................................................................................................................................
   (CRC32 $B9E691B5: disk image (Apple_HFS : 2))
Adding resources…
....................................................................................................................................................
Elapsed Time: 44.270s
File size: 5725371873 bytes, Checksum: CRC32 $13B6715F
Sectors processed: 20971520, 13026129 compressed
Speed: 143.7Mbytes/sec
Savings: 46.7%
created: /Users/cmacedo/Desktop/osx-vm-templates/out/OSX_InstallESD_10.13.4_17E199.dmg
-- Fixing permissions..
-- Checksumming output image..
-- MD5: b4643fab138a5f4641b82c040aefd268
-- Done. Built image is located at out/OSX_InstallESD_10.13.4_17E199.dmg. Add this iso and its checksum to your template.
cmacedo@camilas-MBP ~/Desktop/osx-vm-templates (pr) $ 

** Using packer to build the image: ( errors were found in the template )

cmacedo@camilas-MBP ~/Desktop/bento (master) $ packer validate ../osx-vm-templates/packer/template.json 
Template validation failed. Errors are shown below.

Errors validating build 'parallels-iso'. 1 error(s) occurred:

* Bad source '../scripts/support/set_kcpassword.py': stat ../scripts/support/set_kcpassword.py: no such file or directory

Errors validating build 'virtualbox-iso'. 1 error(s) occurred:

* Bad source '../scripts/support/set_kcpassword.py': stat ../scripts/support/set_kcpassword.py: no such file or directory

Errors validating build 'virtualbox-ovf'. 1 error(s) occurred:

* source_path is required

Errors validating build 'vmware-iso'. 1 error(s) occurred:

* Bad source '../scripts/support/set_kcpassword.py': stat ../scripts/support/set_kcpassword.py: no such file or directory
cmacedo@camilas-MBP ~/Desktop/bento (master) $ 

After change the relative's paths to the places where the scripts are it is working, however, it stops in the ssh script.


cmacedo@camilas-MBP ~/Desktop/bento (master) $ packer build -only=virtualbox-iso -var 'iso_checksum=b4643fab138a5f4641b82c040aefd268' -var 'iso_url=/Users/cmacedo/Desktop/osx-vm-templates/out/OSX_InstallESD_10.13.4_17E199.dmg' macosx-10.13.json 
virtualbox-iso output will be in this color.

Warnings for build 'virtualbox-iso':

* A checksum type of 'none' was specified. Since ISO files are so big,
a checksum is highly recommended.

==> virtualbox-iso: Downloading or copying ISO
    virtualbox-iso: Downloading or copying: file:///Users/cmacedo/Desktop/osx-vm-templates/out/OSX_InstallESD_10.13.4_17E199.dmg
==> virtualbox-iso: Creating virtual machine...
==> virtualbox-iso: Creating hard drive...
==> virtualbox-iso: Creating forwarded port mapping for communicator (SSH, WinRM, etc) (host port 2308)
==> virtualbox-iso: Executing custom VBoxManage commands...
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --audiocontroller hda
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --boot1 dvd
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --boot2 disk
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --chipset ich9
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --firmware efi
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --hpet on
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --keyboard usb
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --memory 2048
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --mouse usbtablet
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1531211334 --vram 128
    virtualbox-iso: Executing: storagectl packer-virtualbox-iso-1531211334 --name IDE Controller --remove
==> virtualbox-iso: Starting the virtual machine...
==> virtualbox-iso: Waiting 2s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Waiting for SSH to become available...
pietrocaselani commented 5 years ago

Hi everyone! Any updates here? Do you consider merging this PR?

egandro commented 5 years ago

Following the test performed. ==> virtualbox-iso: Waiting for SSH to become available...

Same issue here with 10.14.2.

No Idea how to fix this.

I played with the USB -> xhci and the mouse to be USB.

itstehkman commented 5 years ago

@timsutton @americanhanko @tzeejay any updates on this PR? I am glad to help and review or make some PRs! think this is also a necessary patch in order to support Mojave as well (https://github.com/timsutton/osx-vm-templates/issues/99)

Can confirm that I am running into the same issue of waiting for SSH that @camilamacedo86 ran into, looking at the code to think about why that could be. Maybe the prepare_iso/support/pkg-postinstalll script doesnt setup sshd correctly for High Sierra, and maybe it is related to this comment about shadowhash not being interpreted correctly in High Sierra https://github.com/timsutton/osx-vm-templates/pull/82#discussion_r135430187

jfpanisset commented 5 years ago

Starting with 10.14/Mojave BaseSystem.dmg mounts as /Volumes/macOS Base System rather than /Volumes/OS X Base System