Update for new OS versions

Reworked the script to support newer versions; now including:
- macOS Sierra
- OS X El Capitan
This commit is contained in:
Buster Collings
2016-10-26 23:23:58 -05:00
parent 46c271505a
commit d9cbe136c0
3 changed files with 45 additions and 38 deletions

View File

@@ -1,23 +1,30 @@
# OSX-ISO # OSX-ISO
Create a bootable ISO of OS X Yosemite or Mavericks, from the installation file.
Create a bootable ISO of OS X / macOS, from the installation app file.
## Prerequisites ## Prerequisites
The appropriate installation file must be located in `/Applications`
I.E. The appropriate installation file(s) must be located in `/Applications` i.e.
``` ```
/Applications/Install macOS Sierra.app
/Applications/Install OS X El Capitan.app
/Applications/Install OS X Yosemite.app /Applications/Install OS X Yosemite.app
/Applications/Install OS X Mavericks.app /Applications/Install OS X Mavericks.app
``` ```
Mac users can download theses files from the App Store. Mac users can download theses files from the App Store.
## Install with [bpkg](https://github.com/bpkg/bpkg) ## Install with [bpkg](https://github.com/bpkg/bpkg)
```sh ```sh
$ bpkg install busterc/osx-iso $ bpkg install busterc/osx-iso
``` ```
## Usage ## Usage
```sh ```sh
$ osxiso <Yosemite|Mavericks> $ osxiso <Sierra|"El Capitan"|Yosemite|Mavericks>
``` ```
## License ## License

66
osxiso
View File

@@ -7,10 +7,11 @@ function osxiso() {
function usage() { function usage() {
cat <<EOF cat <<EOF
Usage: ${0##*/} <Yosemite|Mavericks> Create a bootable ISO of OS X / macOS, from the installation app file.
Description: Usage:
Create a bootable ISO of OS X, from the installation file.
$ ${0##*/} <Sierra|"El Capitan"|Yosemite|Mavericks>
EOF EOF
exit 1 exit 1
@@ -20,25 +21,22 @@ EOF
local temp="$PWD/temp" local temp="$PWD/temp"
local dist="$PWD/dist" local dist="$PWD/dist"
local iso="$dist/$1.iso" local iso="$dist/$1.iso"
local mpapp="/Volumes/install_app" local app_mount="/Volumes/install_app"
local mpbuild="/Volumes/install_build" local build_mount="/Volumes/install_build"
local base_mount="/Volumes/OS X Base System"
function detachmps() { function detach_mounts() {
echo "Attempting to detach mountpoints" echo "Attempting to detach mounts"
# Unmount the installer image # Unmount the installer image
[[ ! -d "$mpapp" ]] || hdiutil detach "/Volumes/install_app" [[ ! -d "$app_mount" ]] || hdiutil detach "$app_mount"
# Unmount the sparse bundle # Unmount the sparse bundle
[[ ! -d "$mpbuild" ]] || hdiutil detach "/Volumes/install_build" [[ ! -d "$base_mount" ]] || hdiutil detach "$base_mount"
} }
function cleanup() { function cleanup() {
# Unmount the installer image detach_mounts
[[ ! -d "$mpapp" ]] || hdiutil detach "/Volumes/install_app"
# Unmount the sparse bundle
[[ ! -d "$mpbuild" ]] || hdiutil detach "/Volumes/install_build"
# Remove temp directory # Remove temp directory
rm -rf "$temp" rm -rf "$temp"
@@ -53,7 +51,6 @@ EOF
trap abort ERR trap abort ERR
# Attempt cleanup of any previous attempts # Attempt cleanup of any previous attempts
# detachmps
cleanup cleanup
# Prepare to do work # Prepare to do work
@@ -61,36 +58,33 @@ EOF
mkdir -p "$dist" mkdir -p "$dist"
# Mount the installer image # Mount the installer image
hdiutil attach "$app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint "/Volumes/install_app" hdiutil attach "$app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint "$app_mount"
# Convert the boot image to a sparse bundle # Create a blank ISO of 7316MB with a Single Partition
hdiutil convert "/Volumes/install_app/BaseSystem.dmg" -format UDSP -o "$temp/$1" hdiutil create -o "$temp/$1.cdr" -size 7316m -layout SPUD -fs HFS+J
# Increase the sparse bundle capacity to accommodate the packages # Mount the blank ISO
hdiutil resize -size 8g "$temp/$1.sparseimage" hdiutil attach "$temp/$1.cdr.dmg" -noverify -nobrowse -mountpoint "$build_mount"
# Mount the sparse bundle for package addition # Restore the Base System into the blank ISO
hdiutil attach "$temp/$1.sparseimage" -noverify -nobrowse -mountpoint "/Volumes/install_build" asr restore -source "$app_mount/BaseSystem.dmg" -target "$build_mount" -noprompt -noverify -erase
# Remove Package link and replace with actual files # Remove Package link and replace with actual files
rm "/Volumes/install_build/System/Installation/Packages" rm "$base_mount/System/Installation/Packages"
cp -rp "/Volumes/install_app/Packages" "/Volumes/install_build/System/Installation/" cp -rp "$app_mount/Packages" "$base_mount/System/Installation/"
# Copy "$1" installer dependencies # Copy "$1" installer dependencies
cp -rp "/Volumes/install_app/BaseSystem.chunklist" "/Volumes/install_build/BaseSystem.chunklist" cp -rp "$app_mount/BaseSystem.chunklist" "$base_mount/BaseSystem.chunklist"
cp -rp "/Volumes/install_app/BaseSystem.dmg" "/Volumes/install_build/BaseSystem.dmg" cp -rp "$app_mount/BaseSystem.dmg" "$base_mount/BaseSystem.dmg"
# Detach mounts # Detach mounts
detachmps detach_mounts
# Resize the partition in the sparse bundle to remove any free space
hdiutil resize -size "$(hdiutil resize -limits $temp/$1.sparseimage | tail -n 1 | awk '{ print $1 }')b" "$temp/$1.sparseimage"
# Convert the sparse bundle to ISO/CD master # Convert the sparse bundle to ISO/CD master
hdiutil convert "$temp/$1.sparseimage" -format UDTO -o "$temp/$1" hdiutil convert "$temp/$1.cdr.dmg" -format UDTO -o "$temp/$1.iso"
# Rename the ISO and move it to the distribution "dist" dir # Rename the ISO and move it to the distribution "dist" dir
mv "$temp/$1.cdr" "$iso" mv "$temp/$1.iso.cdr" "$iso"
cleanup cleanup
@@ -103,10 +97,16 @@ EOF
local versions=( local versions=(
Yosemite Yosemite
Mavericks Mavericks
"El Capitan"
Sierra
) )
for version in "${versions[@]}"; do for version in "${versions[@]}"; do
if [[ "$1" = "$version" ]]; then if [[ "$1" = "$version" ]]; then
app="/Applications/Install OS X $1.app" if [[ "$1" = "Sierra" ]]; then
app="/Applications/Install macOS $1.app"
else
app="/Applications/Install OS X $1.app"
fi
if [[ ! -e "$app" ]]; then if [[ ! -e "$app" ]]; then
cat <<EOF cat <<EOF

View File

@@ -1,7 +1,7 @@
{ {
"name": "osxiso", "name": "osxiso",
"version": "1.0.0", "version": "1.0.0",
"description": "Create a bootable ISO of OS X Yosemite or Mavericks, from the installation file.", "description": "Create a bootable ISO of OS X / macOS, from the installation app file.",
"global": "1", "global": "1",
"install": "install -c osxiso ${PREFIX:-/usr/local}/bin", "install": "install -c osxiso ${PREFIX:-/usr/local}/bin",
"repository": { "repository": {