34
CI WITH HACKINTOSH Increasing build performance locally

Continuous Integration with Hackintosh

Embed Size (px)

Citation preview

CI WITH HACKINTOSH Increasing build performance locally

ABOUT ME

➤ Previously developed music games in Japan ➤ Joined Propellerhead 2013 ➤ Worked on ReBirth, Thor, Figure, Take, ??? ➤ Manager of Mobile at Allihoopa (Propellerhead spinoff) ➤ Amateur photographer and musician ➤ 💓 creative tools

DISCLAIMER

➤ Installing macOS on non-Apple hardware is a violation of their EULA

➤ Apple will not support any such scenario ➤ It could stop working with any version of macOS ➤ Don’t do this for mission-critical systems

➤ We have a Mac Mini slave as backup

MOTIVATION

➤ Why build a Hackintosh? ➤ It can be faster than anything Apple makes ➤ It’s much cheaper than anything Apple makes ➤ It’s fun to build things few* other people do

COMMUNITY

➤ Lots of people do this ➤ There are multiple sites chock full of users and info ➤ I use tonymacx86.com

Building the rig

HARDWARE

BUILDING A PC IS MORE FUN WITH OTHERS

BUILDING A PC IS MORE FUN WITH OTHERS

BUILDING A PC IS MORE FUN WITH OTHERS

BUILDING A PC IS MORE FUN WITH OTHERS

THINGS I RAN INTO

➤ Insertion order is important, especially when troubleshooting ➤ Didn’t pass POST (power on self test)

➤ Take out components one by one to find the culprit ➤ 1 / 8 sticks of RAM was bad, apparently

Setting up macOS

SOFTWARE INVOLVED

➤ UEFI: newer firmware replacement for BIOS that can run programs like the Clover bootloader

➤ Unibeast: Application for building a bootable USB stick that runs the macOS installer and also may be used as a recovery disk

➤ Multibeast: Application that runs a wizard configuring a Clover config.plist to patch default macOS so we can run with hardware support for our Hackinstosh

➤ Clover: bootloader we use to patch parts of macOS so it works on the Hackintosh. Has lots of options for adding commandline arguments, configurations, and restoring previous setups

➤ Clover Configurator: Utility app to generate Clover config files, mount EFI partition, and update Clover itself

➤ kext: Kernel Extension, basically the mac equivalent of a Windows driver

UNIBEAST

MULTIBEAST

CLOVER

OS SETUP FLOW

1. Create bootable USB stick of macOS installer with Unibeast.

2. Boot stick, install macOS to SSD

3. Run Multibeast to build Clover bootloader with patches

4. Get Nvidia drivers and use them via the Nvidia web installer

Setting up Jenkins

WHAT IS JENKINS?

➤ Open source continuous integration (CI) solution in Java ➤ Does almost anything based on source changes ➤ Activities are called jobs, comprised of steps ➤ Jobs are xml files administered from a webpage ➤ Common jobs

➤ Build all configs/schemes ➤ Run unit, integration, and UI tests ➤ Build and distribute binaries

➤ Compares to Travis (hosted CI on a virtual machine)

GETTING JENKINS TO RUN (OVERALL FLOW)

➤ Add Jenkins with the installer (creates shared account, startup) ➤ Install Xcode ➤ Install your VCS client ➤ Install Jenkins plugins ➤ Copy jobs from another build machine (optional) ➤ Lots of little tweaks

➤ Environment variables ➤ Permissions ➤ Keychain/credentials

➤ Run Xcode once and sign to get past all the dialog pop-ups

GETTING JENKINS TO RUN (THE DETAILS)1. Install Jenkins 2.7.4

2. Install Xcode

3. Install P4V

4. Install Xcode / VCS plugins

5. Set up buildmaster VCS user in Jenkins credentials config for each job

6. Add access to the login keychain as part of Jenkins credentials so the Xcode phases can access the private keys to sign

7. Copy jobs over from OLD BUILD MACHINE

8. Chown jenkins:jenkins on each directory so Jenkins can modify them

9. Fix lots of little things that may be due to new Jenkins or plugin versions

10. Add the Source Tree environment variables to each Xcode step as a custom option, since they are not loaded automatically

11. Modify Jenkins job VCS workspace views to include the auto-generated paths

12. Enable the "unlock keychain" option in the code signing section of each Xcode step that attempts to sign a build, and choose the "Login" credentials which have been added to the Jenkins installation

13. Move the keys for signing from the login to system keychain

1. This is because Jenkins 2.7.4 is running as itself, not as build machine user 2. Alternative to install the keys on login for jenkins user own keychain?

14. Log in to build machine as jenkins and open Xcode with the GUI once and download all provisioning profiles, then do an archive of a target for device once to trigger the UI popups asking about keychain access. Choose "Always Allow" for each time

1. This fixes the problem where codesign claims "user interaction is not allowed" and cannot resign frameworks

Performance

PERFORMANCE: SINGLE ARCHIVE & DISTRIBUTION

Mac Mini 3m 20s Hackintosh 1m 50s

PERFORMANCE: MULTIPLE JOBS AT ONCE

➤ Xcode has limits on parallel compiling due to target dependencies, but multiple concurrent jobs are possible

➤ This requires ensuring a unique DerivedData path for each job

Updating things

UPDATING MACOS

➤ Requires new Nvidia driver every time the macOS # changes ➤ Major updates will break things related to permissions

➤ Jenkins may no longer be able to run/write to its logs ➤ VNC may be broken ➤ Hostname may be reset

UPDATING MACOS (GENERAL FLOW)

➤ Download macOS installer, update Clover ➤ Copy kexts to EFI mount so new macOS version appears ➤ Run macOS installer, reboot ➤ Choose the new OS mount to continue installation ➤ Check for minor version updates in App Store ➤ Update Nvidia drivers ➤ Fix sharing/permissions/power/host etc. that gets hosed

often on upgrades

UPDATING MACOS (EXAMPLE DETAILED FLOW)1. Download the macOS installer from the Mac App Store

2. Download Clover Configurator (CC).

3. Run CC, mount the EFI partition, and update Clover installation to latest.

4. Run this in the terminal: defaults write com.apple.finder AppleShowAllFiles YES; killall Finder (allows you to see kexts in Finder)

5. Copy kexts from Main Drive\Library\Extensions to EFI\Clover\kexts\other

6. Ensure "No Caches" was checked in CC and generate a new config file (config-generate)

7. Run this in the terminal: defaults write com.apple.finder AppleShowAllFiles NO; killall Finder (returns Finder to its normal state)

8. Run the macOS installer

9. Reboot the machine, choose the new Clover configuration with No Caches enabled

10. Choose the newly present "Boot from macOS Install" option to continue the installation with the newly discoverable macOS 10.x partition the installer had created

11. Log in again with the Apple account to get Mac App Store and other things running. Do NOT use iCloud features on the build machine.

12. Go to Mac App Store and check for updates, which triggers the 10.12.3 download/update boot cycle

13. Made sure to choose "Not Now" when macOS asked if we wanted to auto-update macOS versions (this is a bad idea due to the patchwork system of a Hackintosh)

14. Updated the Nvidia drivers to the version verified supported in the tonymacx86 forum your graphics card

15. Updated the boot method of Nvidia drivers as described here: https://www.tonymacx86.com/threads/new-method-for-enabling-nvidia-web-drivers-in-clover.202341/

16. Had to go into sharing System Preferences panel and change the hostname back to YOUR_HOST, somehow it had reset itself to imac

17. Had to go into Energy saver and turn off sleep for hard disks and monitors, which had been reset

18. Had to re-enable permissions for Jenkins being able to read and write stuff due to security resets from Sierra: http://stackoverflow.com/questions/39794811/jenkins-does-not-start-on-macos-10-12-sierra

UPDATING XCODE

➤ Xcode may require certain versions of macOS ➤ This happens often, for example Xcode 8 requires 10.11.5 ➤ You will probably need to update your build machine

every 18 months ➤ Xcode may also occasionally break Jenkins

➤ Jenkins plugins and xcodebuild will get out of sync with requirements for packaging and signing, for example

➤ Pay attention to the detailed Jenkins log for warnings about tools, deprecation (PackageApplication, etc.)

UPDATING NVIDIA DRIVERS

➤ Nvidia will try to update drivers, but these may not work ➤ Always consult the forum before updating

➤ Links to approved drivers are usually posted rather quickly

GOTCHAS / TIPS

➤ Important parameters to keep in mind when setting up Multibeast or Clover Configurator ➤ Use iMac14,2 (27" 2013) as the hardware model ➤ Inject Intel video driver for when Nvidia doesn't work

➤ Be careful where you set DerivedData to if you want more than one executor

➤ Make remote-hosted backups ➤ Of Jenkins’ jobs ➤ Of your SSD (though this still requires some effort to use) ➤ Of your build artifacts (dSYM, xcarchive, etc.)

REFERENCES

➤ https://www.tonymacx86.com/threads/im-new-to-everything-where-do-i-start.104542/

➤ https://www.tonymacx86.com/threads/clover-basics-and-switching-advice.171680/

➤ https://sourceforge.net/projects/cloverefiboot/?source=typ_redirect

➤ http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html

THANK YOU FOR LISTENING

Contact me anytime:

➤ @gamedeventura

➤ perfectforwarding.tumblr.com

➤ david @ allihoopa.com

➤ http://allihoopa.com/pango