Created
March 1, 2019 06:56
-
-
Save kavan-mevada/f65d33429b1087eb59a75dc97edb7f2f to your computer and use it in GitHub Desktop.
Create macOS Install app from apple cdn packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Root location of file | |
#-------------------------- | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
# Check for Source files exist or not. | |
#---------------------------------------- | |
if [ ! -f $DIR/src/BaseSystem.dmg ]; then # Check for BaseSystem.dmg | |
echo "File 'BaseSystem.dmg' not found in src!" | |
fi | |
if [ ! -f $DIR/src/BaseSystem.chunklist ]; then # Check for BaseSystem.chunklist | |
echo "File 'BaseSystem.chunklist' not found in src!" | |
fi | |
if [ ! -f $DIR/src/InstallInfo.plist ]; then # Check for InstallInfo.plist | |
echo "File 'InstallInfo.plist' not found in src!" | |
fi | |
if [ ! -f $DIR/src/InstallESDDmg.pkg ]; then # Check for InstallESDDmg.pkg | |
echo "File 'InstallESDDmg.pkg' not found in src!" | |
fi | |
if [ ! -f $DIR/src/AppleDiagnostics.dmg ]; then # Check for AppleDiagnostics.dmg | |
echo "File 'AppleDiagnostics.dmg' not found in src!" | |
fi | |
if [ ! -f $DIR/src/AppleDiagnostics.chunklist ]; then # Check for AppleDiagnostics.chunklist | |
echo "File 'AppleDiagnostics.chunklist' not found in src!" | |
fi | |
# Taking ownership of downloaded files | |
#------------------------------------------------- | |
chmod a+x $DIR/src/BaseSystem.dmg | |
chmod a+x $DIR/src/BaseSystem.chunklist | |
chmod a+x $DIR/src/InstallInfo.plist | |
chmod a+x $DIR/src/InstallESDDmg.pkg | |
chmod a+x $DIR/src/AppleDiagnostics.dmg | |
chmod a+x $DIR/src/AppleDiagnostics.chunklist | |
# Renaming 'InstallESDDmg.pkg' to 'InstallESD.dmg' | |
#------------------------------------------------- | |
mv -i $DIR/src/InstallESDDmg.pkg $DIR/src/InstallESD.dmg | |
# Replace <string>InstallESDDmg.pkg</string> to <string>InstallESD.dmg</string> in 'src/InstallInfo.plist' | |
#---------------------------------------------------------------------------------------------------------- | |
sed -i "" 's/<string>InstallESDDmg.pkg<\/string>/<string>InstallESD.dmg<\/string>/g' $DIR/src/InstallInfo.plist | |
# Remove these lines from 'src/InstallInfo.plist' | |
#------------------------------------------------ | |
# <key>chunklistURL</key> | |
# <string>InstallESDDmg.chunklist</string> | |
# <key>chunklistid</key> | |
# <string>com.apple.chunklist.InstallESDDmg</string> | |
sed -i "" '30,33d' $DIR/src/InstallInfo.plist | |
# Replace <string>com.apple.pkg.InstallESDDmg</string> to <string>com.apple.dmg.InstallESD</string> in 'src/InstallInfo.plist' | |
#---------------------------------------------------------------------------------------------------------- | |
sed -i "" 's/<string>com.apple.pkg.InstallESDDmg<\/string>/<string>com.apple.dmg.InstallESD<\/string>/g' $DIR/src/InstallInfo.plist | |
# Mount 'BaseSystem.dmg' | |
#------------------------- | |
hdiutil attach $DIR/src/BaseSystem.dmg | |
# Create Outout folder | |
#---------------------- | |
mkdir $DIR/out | |
# Pull 'Install macOS XXXX.app' from 'BaseSystem.dmg' | |
#----------------------------------------------------- | |
cp -R /Volumes/macOS\ Base\ System/Install\ macOS\ Mojave\ Beta.app $DIR/out/Install\ macOS\ Mojave\ Beta.app | |
# Create SharedSupport folder inside 'Install macOS XXXX.app/Contents' | |
#---------------------------------------------------------------------- | |
mkdir $DIR/out/Install\ macOS\ Mojave\ Beta.app/Contents/SharedSupport | |
# Copy All contents of src folder to 'Install macOS XXXX.app/Contents/SharedSupport' | |
#---------------------------------------------------------------------- | |
cp -R $DIR/src/* $DIR/out/Install\ macOS\ Mojave\ Beta.app/Contents/SharedSupport | |
# UnMount 'BaseSystem.dmg' | |
#------------------------- | |
hdiutil detach /Volumes/macOS\ Base\ System |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment