The instructions for installing MacOS X and the Developer Tools have the unfortunate property of not being copy-pastable. Here is a “corrected” version
# hdiutil create -fs HFS+ -volname 10-4-chroot-hfs -verbose -size 4g 10-4-chroot # open 10-4-chroot.dmg
# export CM_BUILD=CM_BUILD # sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/System/Installation/Packages/BaseSystem.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/System/Installation/Packages/Essentials.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/System/Installation/Packages/BSD.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/System/Installation/Packages/X11User.pkg -target /Volumes/10-4-chroot-hfs
Assuming there were no errors you should have Mac OS X 10.4.x installed on the disk image Installing the Developers Tools
Install the Developer packages as described for the OS packages:
# sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/DeveloperTools.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/MacOSX10.4.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/gcc3.3.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/gcc4.0.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/DevSDK.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/X11SDK.pkg -target /Volumes/10-4-chroot-hfs # sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/BSDSDK.pkg -target /Volumes/10-4-chroot-hfs
There’s a number of useless Applications and bits of documentation you can clean up
this could stand to be fleshed out
# cd /Volumes/10-4-chroot-hfs # cd Applications # rm -rf iTunes.app
It might be useful to create a script like “prepare_osx_chroot.sh”
#!/bin/sh
CHROOT_NAME=10-4-chroot-hfs
mount -t devfs devfs /Volumes/${CHROOT_NAME}/dev
mount -t fdesc -o union stdin /Volumes/${CHROOT_NAME}/dev
mount_volfs /Volumes/${CHROOT_NAME}/.vol
After making the preparations above, enter the chroot environment by typing:
# sudo chroot /Volumes/10-4-chroot-hfs
While in chroot, download DarwinPorts sources, compile and install.
# cd tmp/ # curl -O http://www.darwinports.org/downloads/DarwinPorts-1.2.1.tar.bz2 # tar -xvjf DarwinPorts-1.2.1.tar.bz2 # cd DarwinPorts-1.2.1.tar.bz2 # ./configure && make && make install
Do the cleanup...
# cd .. # rm -rf DarwinPorts-1.2.1*
and selfupdate.
# port -d selfupdate
Everything is ready to go experimenting with DarwinPorts. Maybe now is the time one might want to make a backup of the diskimage in case of messing it all up :)
One of the convenient features of OS X images is the ability to make an image read-only. Changes to the image are written into so-called “shadow” files. To revert to the original disk image, one simply removes the “shadow” file.
To convert the disk image to a read-only image, do the following:
# mv 10-4-chroot.dmg 10-4-chroot-rw.dmg # hdiutil convert 10-4-chroot-rw.dmg -format UDRO -o 10-4-chroot-ro.dmg
Now, mounting the disk looks like:
# hdiutil attach 10-4-chroot-ro.dmg -shadow /tmp/10-4-chroot.shadow
You can revert back to the original version simply by executing rm /tmp/10-4-chroot.shadow.
If you find yourself wanting to make changes to the image, you have two options:
Use chroot to make whatever changes are needed
# hdiutil convert 10-4-chroot-ro.dmg -format UDRW -o 10-4-chroot-rw.dmg # hdiutil attach 10-4-chroot-rw.dmg # hdiutil detach /Volumes/10-4-chroot-hfs # hdiutil convert 10-4-chroot-rw.dmg -format UDRO -o 10-4-chroot-ro.dmg
Use chroot to make whatever changes are needed
# hdiutil attach 10-4-chroot-ro.dmg -shadow /tmp/10-4-chroot-ro.shadow # hdiutil detach /Volumes/10-4-chroot-hfs # hdiutil convert 10-4-chroot-ro.dmg -format UDRW -o 10-4-chroot-rw.dmg -shadow /tmp/10-4-chroot-ro.shadow # hdiutil convert 10-4-chroot-rw.dmg -format UDRO -o 10-4-chroot-ro.dmg
If you get an error like “C compiler could not create executable” during configure, try reinstalling DevSDK onto your chroot
# sudo installer -pkg /Volumes/Mac\ OS\ X\ Install\ DVD/Xcode\ Tools/Packages/DevSDK.pkg -target /Volumes/10-4-chroot-hfs/
If one of the installers hangs on the configure phase, try running a top in your regular terminal. If you see something like crashdump taking a large percent of CPU resources, try performing
# sudo killall crashdump
Your port should continue installing as normal.
I have no idea why this happens or how it works, but it seems to help! Somebody please clear this up! Note: it seems to happen when you install gmp; the configure script is stuck on configure:1282: checking build system type