Building OpenWRT on macOS
I've previously posted a rough guide to building OpenWRT on macOS, but I'd like to consolidate the relevant information here before it is polished for public use. I plan on providing a shell script that will do the below, without much interference from the user.
The standard Mac OS X installation has a few limitations that prevent OpenWRT trunk from being built:
Continue on with installing the necessary packages to build OpenWRT...
The standard Mac OS X installation has a few limitations that prevent OpenWRT trunk from being built:
- Apple formatted HFS+ disks' namespace is case-insensitive
- Developer tools are not included in the default system
- Absence of GNU tools and other development files in Apple/Xcode's provided environment
- Certain versions of tools and packages will refuse to build without modifying the source
It's a very simple problem to tackle, but was incredibly tedious and frustrating to troubleshoot. In
retrospect, building in a Debian chroot would have made the process easier, but that's no fun. Coincidentally, I had
to resort to such a setup when building on Ubuntu experimental; which I chalked up to my system being an esoteric
case. If that option seems enticing, using debootstrap to
set up a minimal Debian or Ubuntu environment to build OpenWRT has a better chance of getting the job done quickly.
Before checking out trunk via subversion, a target disk needs to be prepared that will fulfill the expectations of
the OpenWRT build scripts. One way of doing this is to format separate drive as case-sensitive HFS+ and proceeding
with the installation on the disk. Another is to create a loopback image through the Disk Utility. I
will just copy and paste from my earlier guide for the next steps:
Which can be done in one simple command as a regular user:The OpenWRT source is case-sensitive, unfortunately HFS+ drives formatted by Apple are not set to be case-sensitive; so we're going to create a .sparseimage workspace by opening Disk Utility in the /Applications/Utilities directory.Click File -> New -> Blank Disk Image...
On the top of the dialog that just came up fill in "OpenWRT" without the quotes in the Save As: field and in the lower Name: field.Choose a size larger than 3GB. My disk image is ~8G and will reach it's limit after compiling the packages and firmware images more than a few times.
IMPORTANT: In the Format: drop down, select Mac OS Extended (case-sensitive)In the Image Format: drop down select "sparse disk image". Then click Create. The newly created disk image will be on the left panel of the Disk Utility, double clicking it will mount it on /Volumes/OpenWRT
hdiutil create -size 15g -fs "Case-sensitive HFS+" \
-volname OpenWRT ~/OpenWRT.sparsebundleThat will create a 15GB file in your home directory and can be mounted by issuing:
hdiutil attach OpenWRT.sparsebundle
Continue on with installing the necessary packages to build OpenWRT...