ProjectOSX

Welcome Guest!

Returning User? Login here.

Want membership privileges? Register here.

 
Start a new topic Add Reply
> Manage Extra On Efi Or Usb Sticks, Mount/Umount EFI, fix permissions, create mkexts
zhell
post Sep 16 2009, 12:40 PM
Post #1
Manage Extra on EFI or USB sticks


Managing KEXTs, creating mkext caches and dealing with permissions can be a pain.
Whenever you download the latest KEXTs, you need to fix their permissions before you can create an mkext.
If you have Chameleon in the EFI volume, you have to mount and umount it for every small change you want to make.

The script below should help with these issues.
Note: Script requires Chameleon 2.0RC3

Use at your own risk.

If you do not understand what this script does, or how to adapt it for your needs, then it is not a script that you should use.

Attached File  UpdateExtra.sh.zip ( 4.76K ) Number of downloads: 104

CODE
#!/usr/bin/env zsh
# Prerequisites:
# The Chameleon 2.0RC[45] boot loader needs to be installed
# on the boot volume
#
# If installing to an EFI partition (partition 1 on GUID partition
# table-formatted disks), then the EFI partition must be FAT32 formatted
#
# The script takes a volume root folder and copies its contents to the boot
# volume. This root folder must contain the `boot' file and the Extra folder
#
# The Extra folder needs to contain at least one subfolder with KEXTs
# (./Extensions, ./10.5/Extensions, or ./10.6/Extensions)
#
# The entire contents of the root folder will be copied to the boot volume
# and will REPLACE any existing `boot' file or Extra folder therein
#
# Permissions of KEXTs do not matter, i.e. they may be owned by you
# to allow copying around KEXTs in Finder


# Setup: The script needs two values as input: the boot volume and root folder
#
# You may specify them on the command line as arguments 1 and 2
# or hard-code them below
#
# Command line arguments override hard-coded values

# root folder to copy onto the boot volume
ROOT_FOLDER="/Library/Chameleon/Root/Default"

# Device ID of the boot volume into which to copy the root folder contents.
# WARNING: This will overwrite the boot file and the Extra folder on this
# volume without asking
BOOT_DEVICE="/dev/disk0s1"

# If you have separate themes for your USB sticks or other boot volumes,
# this script can preserve them.
# Make sure the theme is already present in the Extra folder on the boot volume
# and it is called $DEVICE_THEME
# And make sure it is selected in your com.apple.Boot.plist (key 'Theme')
DEVICE_THEME="DeviceTheme"

# Set to 0 for silent operation
#VERBOSE=0
VERBOSE=${VERBOSE:-1}

# # # # # # # # # #
# # # # # Nothing to modify below this line # # # # #
# # # # # # # # # #

# No unset variables
set -u
# Exit on error
set -e
# Inherit error signal trap
set -E
SCRNAME="$(basename "$0")"
scr_p="$0"; [ -z "$scr_p" ] && exit 2
while ([ -h "${scr_p}" ]); do scr_p="`readlink "${scr_p}"`"; done
SCRPATH="$(cd "$(dirname "${scr_p}")" > /dev/null && pwd)"; unset scr_p
SCRFILE="$SCRPATH/$SCRNAME"
[ -f "$SCRFILE" ] || echo "Fatal error: Unable to determine path to script file\n\"$0\""

[[ "$USER" = "root" ]] || { echo "$SCRNAME: Must be run as root" >&2; exit 1; }

# List of temporary directories to erase at exit
declare -a TEMPDIRS

# Output to where terminal is connected
puts () {
[[ $# -ne 1 ]] && { echo "Usage: puts <string>"; return 1; }
[[ -t 1 ]] && printf "${1}" >&1 || printf "${1}" >&2
return 0
}
putl () {
puts "$1\n"
}

# Output only if VERBOSE=1
vrb () {
[[ $# -ne 1 ]] && { echo "Usage: vrb <string>"; return 1; }
[[ $VERBOSE -eq 1 ]] && printf "$1\n" >&2 || return 0
}

# Output only if VERBOSE=1; prefix "***"
ifmc () {
vrb "$(echo "$1" | sed -E 's/^/*** /')"
}

# Output only if VERBOSE=1; prefix "***" and newline before and after
ifm () {
ifmc "
$1"
}

# Output only if VERBOSE=1; prefix "***"
wrnc () {
vrb "$(echo "$1" | sed -E 's/^/##### /')"
}

# Output only if VERBOSE=1; prefix "***" and newline before and after
wrn () {
wrnc "
$1"
}

# Output error with line number and exit
erx () {
cleanup
# Commented next line for zsh --sh 20100511
#set +e; set +u
trap - EXIT INT TERM KILL
[[ ! -z "$3" ]] && line=$3
if [[ $1 -gt 1 ]]; then
wrn "$2\n$( if [[ ! -z $line ]]; then echo Line: $line)\nExit $1\n"
else
puts "$2\n$( if [[ ! -z $line ]]; then echo Line: $line; fi)\nExit $1\n"
fi
exit $ret
}

cleanup () {
set +e; set +u
ifm "Cleaning up temporary directories $(echo "${TEMPDIRS[@]/#/
}")"
for dir in "${TEMPDIRS[@]}"; do
if [[ -d "$dir" ]]; then
if mount | egrep "$dir"; then
putl "cleanup: umount \"$dir\""
umount "$dir"
sleep 1
if mount | egrep "$dir"; then
putl "cleanup: umount -f \"$dir\""
umount -f "$dir"
sleep 1
fi
fi
if mount | egrep "$dir"; then
putl "cleanup: Failed to umount \"$dir\""
else
putl "cleanup: erasing \"$dir\""
rm -rf "$dir"
fi
fi
done
}

trap cleanup EXIT INT TERM
# Print only date and name of `ls' output
ls_relative_date_name () {
if [[ $# -eq 1 ]]; then
ls -dnoprtT "$1" | sed -En 's,^(.{11}) +[^ ]+ +[^ ]+ +[^ ]+ +(.{6}) (.{8}) (.{4}) (.+),\3 \2 \5,p'
(cd "$1" && ls -noprtT | sed -En 's,^(.{11}) +[^ ]+ +[^ ]+ +[^ ]+ +(.{6}) (.{8}) (.{4}) (.+),\3 \2 ::/\5,p')
elif [[ $# -eq 2 ]]; then
for item in "$1/$2"*; do
if [[ -d "$item" ]]; then
(cd "$1" && ls -dnoprtT "${item#$1/}" | sed -En 's,^(.{11}) +[^ ]+ +[^ ]+ +[^ ]+ +(.{6}) (.{8}) (.{4}) (.+),\3 \2 \5,p')
(cd "$1" && ls -noprtT "${item#$1/}" | sed -En 's,^(.{11}) +[^ ]+ +[^ ]+ +[^ ]+ +(.{6}) (.{8}) (.{4}) (.+),\3 \2 ::/\5,p')
else
(cd "$1" && ls -noprtT "${item#$1/}" | sed -En 's,^(/.*)|(.{11}) +[^ ]+ +[^ ]+ +[^ ]+ +(.{6}) (.{8}) (.{4}) (.+),\1\4 \3 \6,p')
fi
done
else
return 1
fi
}

# Check Darwin release
DARWINREL="$(uname -r)"
if ! [[ "$DARWINREL" =~ ^(9|10)\.[0-9]\.[0-9] ]]; then
erx 2 "Support for Mac OS X Darwin release \"$DARWINREL\" not implemented yet"
fi

# Set up user-adjustable variables

VERBOSE=${VERBOSE:-1}

DEVTHEME="${DEVICE_THEME:-DeviceTheme}"

BOOTDEV="${BOOT_DEVICE:-/dev/disk0s1}"
SRCROOTBASEDIR="/Library/Chameleon/Root"
SRCROOTDIR="${ROOT_FOLDER:-.}"

# Parse command line arguments
declare o_theme o_help o_verbose
zparseopts -D -E -K -- t=o_theme h=o_help v=o_verbose

declare uptheme=0
if [[ "$o_theme" != "" ]]; then
uptheme=1
fi

ifm "Number of arguments: $#"

declare tmpvol tmpsrc
if [[ -d "$SRCROOTDIR" ]]; then
tmpsrc="$SRCROOTDIR"
fi

if [[ $# -eq 1 ]]; then
if [[ $1 =~ ^(/dev/)?disk[0-9]+(s[0-9]+)?$ ]]; then
ifm "Using single argument as boot device ID: \"$1\""
BOOTDEV="$1"
else
ifm "Using single argument as root folder: \"$1\""
tmpsrc="$1"
fi
elif [[ $# -eq 2 ]]; then
if [[ $1 =~ ^(/dev/)?disk[0-9]+(s[0-9]+)?$ ]]; then
ifm "Using first argument as boot device ID: \"$1\""
BOOTDEV="$1"
tmpsrc="$2"
elif [[ $2 =~ ^(/dev/)?disk[0-9]+(s[0-9]+)?$ ]]; then
ifm "Using second argument as boot device ID: \"$1\""
BOOTDEV="$2"
tmpsrc="$1"
else
ifm "Guessing argument order..."
if [[ -d "/Volumes/${1#/Volumes/}" ]]; then
tmpvol="${1#/Volumes}"
tmpsrc="$2"
ifm "Interpreting first argument \"$1\" as boot volume name: \"$tmpvol\""
else
tmpvol="${2#/Volumes/}"
tmpsrc="$1"
ifm "Interpreting second argument \"$2\" as boot volume name: \"$tmpvol\""
fi
BOOTDEV=$( mount | sed -nE 's#^(/dev/disk[0-9]+(s[0-9]+)?) on /Volumes/'$tmpvol'.*#\1#p' )
if [[ ! $BOOTDEV =~ ^(/dev/)?disk[0-9]+(s[0-9]+)?$ ]]; then
erx 1 "Cannot determine boot device from volume name \"$tmpvol\"" $LINENO
else
ifm "Got boot device: \"$BOOTDEV\""
fi
fi
fi

if [[ -z "$tmpsrc" ]]; then
erx 1 "Cannot determine source folder" $LINENO
fi
if [[ -d "$tmpsrc" ]]; then
SRCROOTDIR="$tmpsrc"
else
SRCROOTDIR="$SRCROOTBASEDIR/$tmpsrc"
fi

#
# Setup up rest of variables
#

# Chameleon
# Note: don't modify unless you know what you are doing
# Version
CHAMVERSSTRRE='Darwin/x86 boot v5.0.132 - Chameleon v2.0-RC[45]'
# Supported locations of KEXTs and MKEXTs
SRCKEXTDIRLIST=( "Extensions" "10.5/Extensions" "10.6/Extensions" )

# Boot volume
# Type of partition table
BOOTTABLETYPE=
# Type of partition
BOOTPARTTYPE=

#
# Sanity checks
#

# Check root folder
if [[ -z "$SRCROOTDIR" ]]; then
erx 1 "Source root folder SRCROOTDIR undefined" $LINENO
fi
if ls "$SRCROOTDIR" &>/dev/null && $(cd "$SRCROOTDIR" &>/dev/null); then
SRCROOTDIR="$(cd "$SRCROOTDIR" && pwd)"
else
erx 1 "Source root folder \"$SRCROOTDIR\" not found" $LINENO
fi
SRCBOOTER="$SRCROOTDIR/boot"
SRCEXTRADIR="$SRCROOTDIR/Extra"
# Check /boot file and version
if [[ -f "$SRCBOOTER" ]]; then
strings "$SRCBOOTER" | egrep "$CHAMVERSSTRRE" &>/dev/null \
|| erx 1 "Version of boot file \"$SRCBOOTER\" does not match \"$CHAMVERSSTRRE\"" $LINENO
else
erx 1 "Could not find boot file \"$SRCBOOTER\"" $LINENO
fi

if [[ -d "$SRCEXTRADIR" ]]; then
kextfound=0
for kextdir in "${SRCKEXTDIRLIST[@]}"; do
unsetopt nomatch
if ls "$SRCEXTRADIR/$kextdir"/*.kext &>/dev/null; then
kextfound=1
break
fi
setopt nomatch
done
[[ $kextfound -eq 1 ]] || erx 1 "No KEXTs found in \"$SRCEXTRADIR\".
Check sub directories $(echo ${SRCKEXTDIRLIST[@]})" $LINENO
fi

# Check boot volume
BOOTDEV=${BOOTDEV/*disk/\/dev\/disk}
if [[ $BOOTDEV =~ ^/dev/disk[0-9]+(s[0-9]+)? ]]; then
if ! ls "$BOOTDEV" &>/dev/null; then
erx 1 "Device \"$BOOTDEV\" of boot volume does not exist " $LINENO
fi
if BOOTTABLETYPE="$(diskutil info "${BOOTDEV%s[0-9]*}" \
| sed -nE 's/^ *Partition Type: *(.+)/\1/p')" \
&& [[ ! -z "$BOOTTABLETYPE" ]]; then
ifm "Partition table type of boot volume is \"$BOOTTABLETYPE\""
else
erx 1 "Cannot determine partition table type of boot volume \"$BOOTDEV\"" $LINENO
fi
if [[ "$BOOTTABLETYPE" = "GUID_partition_scheme" ]]; then
if BOOTPARTTYPE="$(diskutil info "$BOOTDEV" \
| sed -nE 's/^ *Partition Type: *(.+)/\1/p')"; then
ifm "Partition type of boot volume is \"$BOOTPARTTYPE\""
if ! [[ "$BOOTPARTTYPE" = "EFI" || "$BOOTPARTTYPE" = "Apple_HFS" ]]; then
erx 1 "Support for partition type \"$BOOTPARTTYPE\" not implemented yet" $LINENO
fi
fi
elif [[ "$BOOTTABLETYPE" = "FDisk_partition_scheme" ]]; then
if ! [[ "$BOOTPARTTYPE" = "Apple_HFS" ]]; then
erx 1 "Support for partition type \"$BOOTPARTTYPE\" on partition table type \"$BOOTTABLETYPE\" not implemented yet" $LINENO
fi
else
erx 1 "Support for partition table type \"$BOOTTABLETYPE\" not implemented yet" $LINENO
fi
else
erx 1 "Invalid boot volume device identifier: \"$BOOTDEV\"" $LINENO
fi

# Mount boot volume
DSTROOTDIR=
DSTEXTRADIR=
DSTTHEMEDIR=
DSTEXTRAOLDDIR=
DSTEXTRANEWDIR=

if [[ "$BOOTTABLETYPE" = "GUID_partition_scheme" \
|| "$BOOTTABLETYPE" = "FDisk_partition_scheme" ]]; then

if DSTROOTDIR="$(mount | sed -nE "s:^$BOOTDEV on (.+) \([^)]+\)$:\1:p")" \
&& [[ ! -z "$DSTROOTDIR" ]]; then
ifm "Boot volume \"$BOOTDEV\" is mounted at \"$DSTROOTDIR\""
if ! mount | egrep "$BOOTDEV on $DSTROOTDIR" &>/dev/null; then
erx 2 "Boot volume \"BOOTDEV\" not mounted at \"$DSTROOTDIR\"" $LINENO
fi
else
if [[ "$BOOTPARTTYPE" = "EFI" ]]; then
DSTROOTDIR="$(mktemp -d "/private/tmp/$SCRNAME.BootVolume.XXXX")"
TEMPDIRS+=("$DSTROOTDIR")
mount_msdos "$BOOTDEV" "$DSTROOTDIR"
elif [[ "$BOOTPARTTYPE" = "Apple_HFS" ]]; then
diskutil quiet mount "$BOOTDEV" && \
DSTROOTDIR="$(mount | sed -nE "s:^$BOOTDEV on (.+) \([^)]+\)$:\1:p")"
else
erx 1 "Support for partition type \"$BOOTPARTTYPE\" not implemented yet" $LINENO
fi

if ! mount | egrep "$BOOTDEV on $DSTROOTDIR" &>/dev/null; then
erx 2 "Boot volume \"BOOTDEV\" not mounted at \"$DSTROOTDIR\"" $LINENO
fi
ifm "Mounted boot volume $BOOTDEV at \"$DSTROOTDIR\""
fi
else
erx 1 "Support for partition table type \"$BOOTTABLETYPE\" not implemented yet" $LINENO
fi

if [[ "$BOOTPARTTYPE" = "EFI" \
|| "$BOOTPARTTYPE" = "Apple_HFS"
|| "$BOOTPARTTYPE" = "DOS_FAT_32" ]]; then
DSTBOOTER="$DSTROOTDIR/boot"
DSTEXTRADIR="$DSTROOTDIR/Extra"
DSTBOOTPLIST="$DSTEXTRADIR/com.apple.Boot.plist"
DSTTHEMEDIR="$DSTEXTRADIR/Themes"
DSTEXTRAOLDDIR="$DSTROOTDIR/Extra.UpdateEFIold"
DSTEXTRANEWDIR="$DSTROOTDIR/Extra.UpdateEFInew"
else
erx 1 "Support for partition type \"$BOOTPARTTYPE\" on partition table type \"$BOOTTABLETYPE\" not implemented yet" $LINENO
fi

ifm "Contents of source root folder:
$(ls -x "$SRCROOTDIR")"

ifm "Contents of source Extra folder:
$(ls -x "$SRCEXTRADIR")"

# Copy source root folder to temp. dir to fix ownership and permissions
SRCROOTDIRTMP="$( mktemp -d "/private/tmp/$SCRNAME.Extra.XXXX" )"
TEMPDIRS+=("$SRCROOTDIRTMP")
SRCEXTRADIRTMP="$SRCROOTDIRTMP/Extra"
SRCTHEMEDIRTMP="$SRCEXTRADIRTMP/Themes"

ifm "Copying \"$SRCROOTDIR\"
to temporary location
\"$SRCROOTDIRTMP\""
rsync -a --exclude='.DS_Store' "$SRCROOTDIR/" "$SRCROOTDIRTMP"

# Preserve existing theme called $DEVTHEME if exists
if [[ -d "$DSTTHEMEDIR/$DEVTHEME" ]]; then
if [[ $uptheme -eq 1 ]]; then
# Update device theme
ifm "Not preserving existing device theme"
else
ifm "Preserving existing device theme at
\"$DSTTHEMEDIR/$DEVTHEME\""
rm -rf "$SRCTHEMEDIRTMP/$DEVTHEME"
rsync -a --exclude='.DS_Store' \
"$DSTTHEMEDIR/$DEVTHEME/" \
"$SRCTHEMEDIRTMP/$DEVTHEME/"
fi
else
ifm "Note: No device theme found at
\"$DSTTHEMEDIR/$DEVTHEME\"
Themes:
$(ls -x "$DSTTHEMEDIR")"
fi

ifm "Set ownership and permissions of \"$SRCROOTDIRTMP\""
chown -R 0:0 "$SRCROOTDIRTMP"
chmod -R 644 "$SRCROOTDIRTMP"
find "$SRCROOTDIRTMP" -type d -exec chmod 755 {} \;

ifm "Creating KEXT caches"
for kextdir in "${SRCKEXTDIRLIST[@]}"; do
kextdirtmp="$SRCEXTRADIRTMP/$kextdir"
mkexttmp="$kextdirtmp.mkext"
#ifm "Check if KEXT sub directory \"$kextdirtmp\" exists"
[[ -d "$kextdirtmp" ]] || continue

mktype=
if [[ $DARWINREL =~ ^9\.[0-9]\.[0-9] ]]; then
mktype='-m'
else
if [[ $kextdir =~ 10.5 ]]; then
mktype='-mkext1'
elif [[ $kextdir =~ 10.6 ]]; then
mktype='-mkext2'
fi
fi
ifmc " Create KEXT cache \"$mkexttmp\"
of type \"${mktype#-}\" from KEXTs in \"$kextdir\""
{ kextcache -a i386 -a x86_64 -l "$mktype" "$mkexttmp" "$kextdirtmp" \
2>&1; } | egrep -v 'dependenc(y|ies)' || true
done

ifm "Copy /boot file to \"$DSTROOTDIR\""

rsync -a "$SRCROOTDIR/boot" "$DSTROOTDIR/"

ifm "Copy Extra folder to \"$DSTROOTDIR\""

[[ -d "$DSTEXTRANEWDIR" ]] && rm -rf "$DSTEXTRANEWDIR"

rsync -a --exclude='.DS_Store' "$SRCEXTRADIRTMP/" "$DSTEXTRANEWDIR/"

rm -rf "$SRCROOTDIRTMP"
[[ -d "$DSTEXTRAOLDDIR" ]] && rm -rf "$DSTEXTRAOLDDIR"
if [[ -d "$DSTEXTRADIR" ]]; then
mv "$DSTEXTRADIR" "$DSTEXTRAOLDDIR"
fi
mv "$DSTEXTRANEWDIR" "$DSTEXTRADIR"
[[ -d "$DSTEXTRAOLDDIR" ]] && rm -rf "$DSTEXTRAOLDDIR"

if [[ -f "$DSTBOOTER" ]]; then
ifm "


Installed Chameleon to boot volume \"$BOOTDEV\"
Revision: $(strings "$DSTBOOTER" | egrep "$CHAMVERSSTRRE")"
else
erx 1 "Could not find boot file \"$DSTBOOTER\"" $LINENO
fi
ifm "
Contents of \"$DSTEXTRADIR\":
$(ls_relative_date_name "$DSTEXTRADIR")"

ifm "
Themes in \"$DSTTHEMEDIR\":
$(ls -x "$DSTTHEMEDIR")"

ifm "
Selected theme in \"$DSTBOOTPLIST\": $(defaults read "${DSTBOOTPLIST%.plist}" Theme)"

ifm "
KEXT directories and caches in \"$DSTEXTRADIR\":"
for kextdir in "${SRCKEXTDIRLIST[@]}"; do
[[ -d "$DSTEXTRADIR/$kextdir" ]] \
&& ifm "$(ls_relative_date_name "$DSTEXTRADIR" "$kextdir")"
done

sync

if [[ "$BOOTPARTTYPE" = "EFI" ]]; then
ifm "Umount EFI volume"
umount "$DSTROOTDIR"
sleep 1
rmdir "$DSTROOTDIR" || umount -f "$DSTROOTDIR"
fi

# vim: et ts=4 sw=4 sts=4


Usage

CODE
admin@blue ~$ sudo ~/.scripts/UpdateExtra.sh


For example, this is what it looks like on my machine:
CODE
admin@blue ~$ time sudo ~/.scripts/UpdateExtra.sh
***
*** Partition table type of boot volume is "GUID_partition_scheme"
***
*** Partition type of boot volume is "EFI"
***
*** Mounted boot volume /dev/disk0s1 at "/private/tmp/UpdateExtra.sh.BootVolume.fhOu"
***
*** Contents of source root folder:
*** Extra boot
***
*** Contents of source Extra folder:
*** 10.5 10.6 DSDT.aml
*** Themes com.apple.Boot.plist smbios.plist
***
*** Copying "/Library/Chameleon/Root/Default"
*** to temporary location
*** "/private/tmp/UpdateExtra.sh.Extra.nyOG"
***
*** Preserving existing device theme at
*** "/private/tmp/UpdateExtra.sh.BootVolume.fhOu/Extra/Themes/DeviceTheme"
***
*** Set ownership and permissions of "/private/tmp/UpdateExtra.sh.Extra.nyOG"
***
*** Creating KEXT caches
*** Create KEXT cache "/private/tmp/UpdateExtra.sh.Extra.nyOG/Extra/10.5/Extensions.mkext"
*** of type "mkext1" from KEXTs in "10.5/Extensions"
*** Create KEXT cache "/private/tmp/UpdateExtra.sh.Extra.nyOG/Extra/10.6/Extensions.mkext"
*** of type "mkext2" from KEXTs in "10.6/Extensions"
***
*** Copy /boot file to "/private/tmp/UpdateExtra.sh.BootVolume.fhOu"
***
*** Copy Extra folder to "/private/tmp/UpdateExtra.sh.BootVolume.fhOu"
***
***
***
***
*** Installed Chameleon to boot volume "/dev/disk0s1"
*** Revision: Darwin/x86 boot v5.0.132 - Chameleon v2.0-RC3 r659
***
***
*** Contents of "/private/tmp/UpdateExtra.sh.BootVolume.fhOu/Extra":
*** 14:23:50 Sep 15 /private/tmp/UpdateExtra.sh.BootVolume.fhOu/Extra/
*** 22:48:24 Jul 13 ::/smbios.plist
*** 23:10:58 Aug 4 ::/DSDT.aml
*** 14:23:50 Sep 15 ::/com.apple.Boot.plist
*** 15:28:02 Sep 16 ::/Themes/
*** 15:28:02 Sep 16 ::/10.6/
*** 15:28:02 Sep 16 ::/10.5/
***
***
*** Themes in "/private/tmp/UpdateExtra.sh.BootVolume.fhOu/Extra/Themes":
*** BootCamp BootCamp-EMTECEFI BootCamp-Transcend
*** BootCamp-WDCEFI DeviceTheme
***
***
*** Selected theme in "/private/tmp/UpdateExtra.sh.BootVolume.fhOu/Extra/com.apple.Boot.plist": DeviceTheme
***
***
*** KEXT directories and caches in "/private/tmp/UpdateExtra.sh.BootVolume.fhOu/Extra":
***
*** 22:35:40 Aug 23 10.5/Extensions/
*** 11:43:18 Nov 1 ::/OpenHaltRestart.kext/
*** 15:21:54 Apr 5 ::/DisableUpstreamUserClientLeo.kext/
*** 19:42:30 Jun 30 ::/LegacyAppleHDASTAC9271D.kext/
*** 12:17:40 Aug 22 ::/FakeSMCv2Leo.kext/
*** 22:35:40 Aug 23 10.5/Extensions.mkext
***
*** 14:05:18 Sep 15 10.6/Extensions/
*** 05:37:48 Jun 28 ::/OpenHaltRestart.kext/
*** 19:42:30 Jun 30 ::/LegacyAppleHDASTAC9271D.kext/
*** 22:46:06 Jul 20 ::/AppleVIAATA.kext/
*** 12:32:32 Aug 1 ::/DisableUpstreamUserClient3264.kext/
*** 16:09:22 Sep 12 ::/FakeSMCv2Snow.kext/
*** 14:05:18 Sep 15 10.6/Extensions.mkext
***
*** Umount EFI volume
***
*** Cleaning up temporary directories
*** /private/tmp/UpdateExtra.sh.BootVolume.fhOu
*** /private/tmp/UpdateExtra.sh.Extra.nyOG

real 0m2.869s
user 0m0.339s
sys 0m0.681s


How to Set This Up

Note: if you do something differently, then you need to adapt the script accordingly.
First, create a folder that will hold all your Chameleon configurations; by default, the script uses '/Library/Chameleon/Root/'. So let's create this directory and make us the owner:
CODE
sudo mkdir -p /Library/Chameleon/Root
sudo chown -R $USER /Library/Chameleon/

Next, we create a backup of your existing "known good" configuration of Chameleon on your <BOOT VOLUME> and store it as "Default".
If you use the EFI partition, you need to mount it first (change disk0s1 to disk{1,2,3,...}s1 accordingly if you have multiple disks):
CODE
sudo mkdir /Volumes/EFI && sudo mount_msdos /dev/disk0s1 /Volumes/EFI

Now let's copy the existing Chameleon configuration from your <BOOT VOLUME> to the previously created Chameleon root folder:
CODE
mkdir /Library/Chameleon/Root/Default
sudo cp -pR /Volumes/<BOOT VOLUME>/boot /Volumes/<BOOT VOLUME>/Extra /Library/Chameleon/Root/Default

So far so good. Now let's adapt the script to make sure it operates on the proper device ID. Find out the device ID of your <BOOT VOLUME> by running
CODE
mount | egrep '<BOOT VOLUME>'

The device should be of the form "/dev/diskXsY", where X and Y are numbers. This is what you need to set variable BOOT_DEVICE to:
BOOT_DEVICE="/dev/disk0s1"

Now, before we do any experiments, let's set up a USB stick with identical Chameleon configuration as your main boot volume. Pop in a stick and install Chameleon 2.0RC3 on it (either in its EFI volume or in a dedicated HFS+ volume). Then find out its device ID as shown above. Now we can run the script (where <DEVICE ID> is the device ID of your USB stick)
CODE
sudo ./UpdateExtra.sh <DEVICE ID>

Reboot and see if this USB stick allows you to boot your machine. If this succeeds, you may want to run the script without arguments and it should set up your main boot volume identically as it was before.
Once that works, you can copy the existing "Default" root folder, call it "Test" (you can do this in Finder) and modify it (e.g. add a new version of some KEXT). Then to install the new "Test" configuration to the USB stick, you need to find the device ID of the USB stick again, then run
CODE
sudo ./UpdateExtra.sh <DEVICE ID> Test

and it will install the "Test" configuration to your USB stick.
Note 1: Instead of just "Test", you may also specify an absolute path to the configuration folder that you want to use, e.g. "/Library/Chameleon/Root/Test" would have the same effect.
Note 2: The order of the arguments does not really matter as the script will identify the partition ID first and take the other argument as the name of your configuration.

Once this works with the USB stick, restore the "Default" configuration to the USB stick and check if it still boots your machine.
Now, at last, you can run the script to install the "Test" configuration to your main <BOOT VOLUME>:
CODE
sudo ./UpdateExtra.sh Test

Once that works. you may want to rename the previous "Default" folder to "Default-previous" and rename "Test" to "Default".

My Setup

I have multiple root folders for testing and for various USB sticks that I use to boot other machines. "Default" is a symbolic link that points at the latest known good configuration.
CODE
admin@blue ~$ ls /Library/Chameleon/Root/
ChameleonRc3_FakeSMCv2                  FakeSMC1_OpenHaltRestart_OK
Default                                 FakeSMC2_OpenHaltRestart_Disabler3264
Dsmos_OK                                FakeSMC2_OpenHaltRestart_OK
EmtecUSB                                diosTranscendUSB
FakeSMC1

These are the contents of my current "Default" root folder:
CODE
admin@blue ~$ ls /Library/Chameleon/Root/Default/*
/Library/Chameleon/Root/Default/boot
/Library/Chameleon/Root/Default/Extra:
10.5                    DSDT.aml                com.apple.Boot.plist
10.6                    Themes                  smbios.plist

Should one of my experiments go wrong, I just boot from a USB stick with a known good configuration, then run the script without arguments and it will quickly restore the "Default" configuration to my EFI volume and I'm back in business.

This post has been edited by zhell: Jun 19 2010, 02:14 PM
GA-Z68MX-UD2H-B3-U1c | Core i7 2600 | 16GB DDR3-1600
Intel SSD 520 240GB + WDC WD-20EARX 2TB Fusion drive
Sapphire Radeon HD 6850 1024MB PEG | Atheros AR9380 Mini PCIe | Intel 82574L PCIe
OS X 10.8.2 | Chameleon 2.1svn | Clover EFI r897
youminbuluo
post Oct 3 2009, 03:14 PM
Post #2
Thanks for your tutorial!


This post has been edited by youminbuluo: Oct 3 2009, 03:14 PM
zhell
post Oct 18 2009, 07:30 PM
Post #3
QUOTE (youminbuluo @ Oct 3 2009, 05:14 PM) *
Thanks for your tutorial!

Your're very welcome. Thanks for your feedback. So far, quite a few people have downloaded the script but apparently it has either worked or they did not use it...
GA-Z68MX-UD2H-B3-U1c | Core i7 2600 | 16GB DDR3-1600
Intel SSD 520 240GB + WDC WD-20EARX 2TB Fusion drive
Sapphire Radeon HD 6850 1024MB PEG | Atheros AR9380 Mini PCIe | Intel 82574L PCIe
OS X 10.8.2 | Chameleon 2.1svn | Clover EFI r897

Add Reply Start a new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: