Index: trunk/package/Distribution =================================================================== --- trunk/package/Distribution (revision 2568) +++ trunk/package/Distribution (revision 2569) @@ -17,7 +17,7 @@ var bootPlist = null; if (my.target) { - var boot_plist_filenames = new Array( 'org.chameleon.Boot.plist', 'com.apple.Boot.plist' ); + var boot_plist_filenames = new Array( 'org.chameleon.Boot.plist', 'com.apple.Boot.plist', 'com.apple.boot.plist'); for ( var i = 0; i < boot_plist_filenames.length; i++ ) { bootPlist = system.files.plistAtPath( my.target.mountpoint + '/Extra/' + boot_plist_filenames[i] ); if (bootPlist) Index: trunk/package/slimpkg.sh =================================================================== --- trunk/package/slimpkg.sh (revision 2568) +++ trunk/package/slimpkg.sh (revision 2569) @@ -62,7 +62,6 @@ ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Pre/Scripts/Resources/revision ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Pre/Scripts/Resources/version cp -f ${pkgroot}/Scripts/Main/preinstall ${1}/Pre/Scripts - cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/Pre/Scripts echo " [BUILD] Pre " buildpackage "${1}/Pre" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1 # End build pre install package @@ -123,7 +122,6 @@ mkdir -p ${1}/Standard/Root mkdir -p ${1}/Standard/Scripts/Resources cp -f ${pkgroot}/Scripts/Main/Standardpostinstall ${1}/Standard/Scripts/postinstall - cp -f ${pkgroot}/Scripts/Sub/* ${1}/Standard/Scripts ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Resources/SetFile ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Standard/Scripts/Resources/revision ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Standard/Scripts/Resources/version @@ -135,7 +133,6 @@ mkdir -p ${1}/EFI/Root mkdir -p ${1}/EFI/Scripts/Resources cp -f ${pkgroot}/Scripts/Main/ESPpostinstall ${1}/EFI/Scripts/postinstall - cp -f ${pkgroot}/Scripts/Sub/* ${1}/EFI/Scripts ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Resources/SetFile ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/EFI/Scripts/Resources/revision ditto --noextattr --noqtn ${1%/*/*}/version ${1}/EFI/Scripts/Resources/version @@ -223,8 +220,6 @@ mkdir -p ${1}/Post/Root mkdir -p ${1}/Post/Scripts cp -f ${pkgroot}/Scripts/Main/postinstall ${1}/Post/Scripts - cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/Post/Scripts - cp -f ${pkgroot}/Scripts/Sub/UnMountEFIvolumes.sh ${1}/Post/Scripts ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Post/Scripts/Resources/revision ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Post/Scripts/Resources/version echo " [BUILD] Post " Index: trunk/package/Scripts.templates/AddOption/postinstall =================================================================== --- trunk/package/Scripts.templates/AddOption/postinstall (revision 2568) +++ trunk/package/Scripts.templates/AddOption/postinstall (revision 2569) @@ -2,28 +2,34 @@ set -u -targetVolume="$3" +configFile='/private/tmp/InstallConfig.plist' +v_mntptDev=$( /usr/libexec/plistbuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//' ) key="@optionKey@" value="@optionValue@" type="@optionType@" logName="@LOG_FILENAME@" -logFile="${targetVolume}/$logName" # Check if target volume exists -if [[ ! -d "$targetVolume" ]]; then - echo "$targetVolume volume does not exist!" >&2 +if [[ ! -d "$v_mntpt" ]]; then + echo "$v_mntpt volume does not exist!" >&2 exit 1 fi -exec >>"${logFile}" 2>&1 +mainLine="==============================================================================" +subLine="------------------------------------------------------------------------------" -echo "Added boot option: ${key}=${value}" +exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 +echo "$mainLine" +echo "Writing boot option: ${key}=${value}" + key="${key// /\\ }" # Escape spaces value="${value// /\\ }" # Escape spaces -bootPListFile="${targetVolume}/Extra/org.chameleon.Boot.plist" +bootPListFile="${v_mntpt}/Extra/org.chameleon.Boot.plist" case "$type" in bool|text) @@ -54,4 +60,5 @@ ;; esac +echo "$subLine" exit 0 Index: trunk/package/Scripts.templates/Post/postinstall =================================================================== --- trunk/package/Scripts.templates/Post/postinstall (revision 2568) +++ trunk/package/Scripts.templates/Post/postinstall (revision 2569) @@ -5,53 +5,93 @@ # $3 = Installation volume (mountpoint) to receive the payload # $4 = Root directory for the system +mainLine="==============================================================================" +subLine="------------------------------------------------------------------------------" + +if [ "$3" == "/" ] +then + targetVolume="/Volumes/"$( ls -1F /Volumes | sed -n 's:@$::p' ) + # really need to do that?? Unix "component" path assume are between "/" + # ie current volume can be also /// or ///Volumes///MyVolume w/o problem! +else + targetVolume="$3" +fi + +configFile='/private/tmp/InstallConfig.plist' +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//' ) + +targetDevice=$( /usr/libexec/PlistBuddy -c "Print :targetdev" ${configFile} ) +choicedVolume=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//' ) +backupRootDir="${targetVolume}/Chameleon.Backups" +backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} ) + # Check target exists -if [ ! -d "$3" ]; then - echo "$3 volume does not exist !" >&2 +if [ ! -d "${targetVolume}" ]; then + echo "Target volume does not exist !" >&2 exit 1 fi - -# If target volume is root of current system then replace -# / with volume name. -if [ "$3" == "/" ]; then - dest_vol="/Volumes/"$( ls -1F /Volumes | sed -n 's:@$::p' ) -else - dest_vol="$3" +if [ ! -d "${v_mntpt}" ]; then + echo "Ram disk volume does not exist !" >&2 + exit 1 fi +if [ ! -d "${choicedVolume}" ]; then + echo "${choicedVolume} volume does not exist !" >&2 + exit 1 +fi logName="@LOG_FILENAME@" -logFile="${dest_vol}/$logName" -exec >>"${logFile}" 2>&1 +exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 -# Find script location so to find the Install Log script. -MYLOCATION="${PWD}/${BASH_ARGV[0]}" -export MYLOCATION="${MYLOCATION%/*}" -scriptDir=$MYLOCATION - -# Write some information to the Install Log -echo "======================================================" +echo "$mainLine" echo "Running Post postinstall script" -echo "Target volume = ${dest_vol}" +echo "Target volume = ${choicedVolume}" +echo "$subLine" -# --------------------------------------------- +# Replace/Copying the Extra folder +echo "Moving Extra folder to ${choicedVolume}" +cp -R "${v_mntpt}/Extra" "${choicedVolume}"/ + +echo "NOTE: any Themes or modules you have must be there since this now is the boot partition," +echo " ACPI tables, SMBios.plist and the org.chameleon.Boot.plist (with custom settings" +echo " for the target OSX must be in each partition that contanin it.)" + +echo "$subLine" +echo "Post postinstall script complete" +echo "$mainLine" + # Update Rights -# --------------------------------------------- -chmod 777 ${dest_vol}/Extra 2>/dev/null -chmod 666 ${dest_vol}/Extra/*.plist 2>/dev/null +chmod 777 "${choicedVolume}"/Extra 2>/dev/null +chmod 666 "${choicedVolume}"/Extra/*.plist 2>/dev/null +chmod 666 "${choicedVolume}/Extra/${logName}" 2>/dev/null +# if an Extra/Extensions exist... we can repair the permission??? -# --------------------------------------------- -# Cleanup -# --------------------------------------------- +# Check Backup folder (is always on the target Volume) -# Unmount ALL mounted volumes named EFI -"$scriptDir"UnMountEFIvolumes.sh "${dest_vol}" "${scriptDir}" +if [ -d "${backupRootDir}/${backupDir}" ]; then + # Remove empty directories + find "${backupRootDir}" -type d -depth -empty -exec rmdir {} \; +fi -# remove any temporary boot sector files if they exist -rm -f /tmp/newbs /tmp/origbs /tmp/originalBootSector /tmp/newBootSector +# copying the installer log inside the Extra folder +if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then + # if we have installed the bootloader, this is a new log + cat "${v_mntpt}/${logName}" > "${choicedVolume}/Extra/${logName}" +else + # ..otherwise adding the new log to the existing one (if exist) + cat "${v_mntpt}/${logName}" >> "${choicedVolume}/Extra/${logName}" +fi -# Remove /.ChameleonEFI file -rm -f "${dest_vol}/.ChameleonEFI" -echo "======================================================" -echo "Post postinstall script complete" +# Umount the Ram Disk & cleaning +rm -f /private/tmp/InstallConfig.plist +rm -f "${targetVolume}/EXTRAROOTDIR" +exec 1<&- # Restore stdout and close file descriptor #1 before umount the Ram Disk +umount -f $v_mntptDev > /dev/null +hdiutil detach $v_mntptDev + + + Index: trunk/package/Scripts.templates/Pre/clean_bootplist.pl =================================================================== --- trunk/package/Scripts.templates/Pre/clean_bootplist.pl (revision 2568) +++ trunk/package/Scripts.templates/Pre/clean_bootplist.pl (revision 2569) @@ -1,95 +0,0 @@ -#!/usr/bin/perl - -use strict; -use YAML::Syck; - -our $target_volume; -our $boot_plist_filepath; - -our $yaml_file="@YAML_FILE@"; - -if ($#ARGV < 0) { - print stderr "A target volume is needed\n"; -} else { - $target_volume=$ARGV[0]; -} - -$boot_plist_filepath = "${target_volume}/Extra/org.chameleon.Boot.plist"; -if ( -f "$boot_plist_filepath" ) { - main("$yaml_file"); -} - -sub _do_cmd { - my ($cmd, $key, $value) = @_; - my $out; - - $key =~ s/([\s])/\\$1/g; # Escape characters in key - $value =~ s/([\s"])/\\$1/g; # Escape characters in value (space & ") - my $plistbuddy_command="$cmd :$key $value"; - - open ( OUTPUT, "-|", '/usr/libexec/plistbuddy', "-c", "$plistbuddy_command", "$boot_plist_filepath" ); - my $exit_code = $?; - chomp($out = ); - close OUTPUT; - return $out; -} - -sub get_boot_plist_option { - my ($option) = @_; - return _do_cmd( "Print", "$option"); -} - -sub delete_boot_plist_option { - my ($option) = @_; - return _do_cmd( "Delete", "$option"); -} - -sub delete_boot_plist_text_option { - my ($option, $values) = @_; - my $current_value = get_boot_plist_option "$option"; - if ( $current_value ne "") { - foreach my $recognized_value (@{$values}) { - if ($recognized_value eq $current_value) { - return _do_cmd( "Delete", "$option"); - } - } - } - return ""; -} - -sub delete_boot_plist_list_option { - my ($option, $values) = @_; - my $current_value = get_boot_plist_option "$option"; - if ( $current_value ne "") { - my %count; - my @new_list; - foreach my $value (@{$values}) { - $count{$value} = 1; - } - foreach my $value (split(/\s+/,$current_value)) { - if ( not exists $count{$value} ) { - push @new_list, $value; - } - } - return _do_cmd( "Set", $option, join(' ',@new_list) ); - } - return ""; -} - -sub main() { - # Remove all options that installer can managed - my ($yaml_file) = @_; - my $hash_ref = LoadFile($yaml_file) or die "Can't open yaml file\n"; - foreach my $option ( keys %{$hash_ref} ) { - my $type = $hash_ref->{$option}->{type}; - if ( $type =~ /^bool$/i ) { - delete_boot_plist_option($option); - } elsif ( $type =~ /^text$/i ) { - delete_boot_plist_text_option( $option, - $hash_ref->{$option}->{values} ); - } elsif ( $type =~ /^list$/i ) { - delete_boot_plist_list_option( $option, - $hash_ref->{$option}->{values} ); - } - } -} Index: trunk/package/Scripts.templates/Pre/preinstall =================================================================== --- trunk/package/Scripts.templates/Pre/preinstall (revision 2568) +++ trunk/package/Scripts.templates/Pre/preinstall (revision 2569) @@ -1,30 +1,15 @@ #!/bin/bash -echo "===============================================" -echo "Pre-Install Script" -echo "*********************************" -echo "-----------------------------------------------" -echo "" - # Creates text file named '@LOG_FILENAME@' # at the root of the target volume. This is to give the user # a record of the installation process and also to show why # possibly the installation process failed (even though the # package installer ends reading 'Installation Successful'). -# This script also prepares, then backs up any previous -# stage2 boot file, /Extra folder and install log if they exist. +# This script also prepares the Ram Disk and the InstallConfig.plist +mainLine="==============================================================================" +subLine="------------------------------------------------------------------------------" -# Find location of this script in the package installer -# so we know where all the other scripts are located. - -MYLOCATION="${PWD}/${BASH_ARGV[0]}" -export MYLOCATION="${MYLOCATION%/*}" -scriptDir=$MYLOCATION - - -# If target volume root of current system then replace -# / with volume name. if [ "$3" == "/" ] then targetVolume="/Volumes/"$( ls -1F /Volumes | sed -n 's:@$::p' ) @@ -32,68 +17,75 @@ targetVolume="$3" fi +v_mntpt="/Volumes/BOOTRAMDISK" +size='409600' # is the size of a standard EFI partition logName="@LOG_FILENAME@" -logFile="${targetVolume}/$logName" +configFile="/private/tmp/InstallConfig.plist" -# --------------------------------------------- -# Preparing Backing up of Chameleon files -# --------------------------------------------- -backupRootDir="${targetVolume}/Chameleon.Backups" -backupDir="${backupRootDir}/"$( date -j "+%F-%Hh%M" ) +# Functions to create/umount the RAM DISK +UMOUNT_VDISK() { + umount -f "${1}" + hdiutil detach "${1}" +} -# Create the backup directory -mkdir -p "$backupDir" +RAM_DISK() { + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ + grep -x "${v_mntpt}" ) ]; then + devToUmount=$( LC_ALL=C diskutil info "${v_mntpt}" | grep -i 'Device Node:' | awk '{print $3}' ) + UMOUNT_VDISK $devToUmount + fi + echo "CREATING RAM DISK" +# mkdir -p $v_mntpt -[[ -f "$logFile" ]] && mv "$logFile" "${backupDir}/${logName}" # Backup old log file + dev=$(hdiutil attach -nomount ram://${size}) + if [ $? -eq 0 ] ; then + diskutil erasevolume FAT32 "BOOTRAMDISK" ${dev} + else + echo "Failed to create the Ram Disk, installation aborted!" + exit 1 + fi -# Setup Chameleon Log file -# by writing header and diskutil list + rm -f $configFile + # adding the Ram disk device to InstallConfig.plist to be shared with other packages + /usr/libexec/PlistBuddy -c "Add :ramdisk string ${dev}" $configFile +} -echo "Chameleon installer log - $( date ) -Installer version: %CHAMELEONVERSION% %CHAMELEONREVISION% -======================================================" >"${logFile}" +RAM_DISK -diskutil list >>"${logFile}" -echo "======================================================" >>"${logFile}" - -# --------------------------------------------- -# Backup Chameleon files -# --------------------------------------------- -echo "Backup Chameleon files" >>"${logFile}" -# Backup stage2 -if [[ -f "${targetVolume}/boot" ]];then - echo "Backup stage2 file ${targetVolume}/boot to ${backupDir}/boot" >>"${logFile}" - cp -p "${targetVolume}/boot" "${backupDir}/boot" +# ensure that ram disk has "/Volumes/BOOTRAMDISK" mount point +v_mntpt=$( LC_ALL=C diskutil info ${dev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//' ) +if [ ! -d "${v_mntpt}" ]; then + echo "Ram Disk not found!" + exit fi -# Backup /Extra directory -if [[ -d "${targetVolume}/Extra" ]];then - echo "Backing up ${targetVolume}/Extra folder to ${backupDir}/Extra" >>"${logFile}" - cp -pR "${targetVolume}/Extra" "${backupDir}/Extra" -fi -chflags -R nohidden "$backupDir" # Remove the invisible flag of files in the backups +touch "${v_mntpt}/${logName}" +exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 -find "${backupRootDir}" -type d -depth -empty -exec rmdir {} \; # Remove empty directories +echo "$mainLine" +echo "Pre-Install Script" +echo "$subLine" -echo "======================================================" >>"${logFile}" +# creating a symlink (from Clover) +echo "Creating ${targetVolume}/EXTRAROOTDIR symlink targeting ${v_mntpt}" +ln -sf "${v_mntpt}" "${targetVolume}/EXTRAROOTDIR" -# Check existing plist name for old naming convention and change to new convention. -if [[ -f "${targetVolume}/Extra/com.apple.Boot.plist" ]]; then - echo "Renaming existing com.apple.Boot.plist to org.chameleon.Boot.plist" >>"${logFile}" - mv "${targetVolume}/Extra/com.apple.Boot.plist" "${targetVolume}/Extra/org.chameleon.Boot.plist" -fi +# Preparing Backing up of Chameleon files +backupRootDir="${targetVolume}/Chameleon.Backups" +backupDir=$( date -j "+%F-%Hh%M" ) -# --------------------------------------------- -# Clearing options that Chameleon can managed -# --------------------------------------------- -echo "Clearing options..." >>"${logFile}" -"${PWD}/clean_bootplist.pl" "${targetVolume}" 2>&1 | grep -v 'Does Not Exist' >>"${logFile}" -echo "======================================================" >>"${logFile}" +# Create the backup directory +mkdir -p "${backupRootDir}/${backupDir}" -echo "===============================================" +# Remove the invisible flag of files in the backups +chflags -R nohidden "${backupRootDir}" + +# adding the backupdir name to InstallConfig.plist to be shared with other packages +/usr/libexec/PlistBuddy -c "Add :backupDir string ${backupDir}" $configFile >/dev/null + +diskutil list >> "${v_mntpt}/${logName}" +echo "$subLine" echo "END - Pre-Install Script" -echo "*********************************" -echo "-----------------------------------------------" -echo "" exit 0 Index: trunk/package/Scripts.templates/InstallTheme/postinstall =================================================================== --- trunk/package/Scripts.templates/InstallTheme/postinstall (revision 2568) +++ trunk/package/Scripts.templates/InstallTheme/postinstall (revision 2569) @@ -2,21 +2,35 @@ set -u -targetVolume="$3" +configFile='/private/tmp/InstallConfig.plist' +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//' ) themeName="@themeName@" themeDir="@themeDir@" logName="@LOG_FILENAME@" -logFile="${targetVolume}/$logName" # Check if target volume exists -if [[ ! -d "$targetVolume" ]]; then - echo "$targetVolume volume does not exist!" >&2 +if [[ ! -d "${v_mntpt}" ]]; then + echo "$v_mntpt volume does not exist!" >&2 exit 1 fi -exec >>"${logFile}" 2>&1 +mainLine="==============================================================================" +subLine="------------------------------------------------------------------------------" -[[ -d "${targetVolume}/Extra/Themes/$themeDir" ]] && echo "Theme $themeName installed" +exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 +echo "$mainLine" +echo "Installing Theme $themeName" +echo "$subLine" + +if [[ -d "${v_mntpt}/Extra/Themes/$themeDir" ]]; then + echo "Theme $themeName installed" +else + echo "*** ERROR:$themeName not installed" +fi + +echo "$subLine" exit 0 Index: trunk/package/Scripts.templates/InstallModule/postinstall =================================================================== --- trunk/package/Scripts.templates/InstallModule/postinstall (revision 2568) +++ trunk/package/Scripts.templates/InstallModule/postinstall (revision 2569) @@ -2,21 +2,36 @@ set -u -targetVolume="$3" +configFile='/private/tmp/InstallConfig.plist' +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//' ) moduleName="@moduleName@" moduleFile="@moduleFile@" logName="@LOG_FILENAME@" -logFile="${targetVolume}/$logName" # Check if target volume exists -if [[ ! -d "$targetVolume" ]]; then - echo "$targetVolume volume does not exist!" >&2 - exit 1 +if [[ ! -d "${v_mntpt}" ]]; then + echo "Ram Disk not found volume does not exist!" >&2 +# exit 1 fi -exec >>"${logFile}" 2>&1 +mainLine="==============================================================================" +subLine="------------------------------------------------------------------------------" -[[ -f "${targetVolume}/Extra/modules/$moduleFile" ]] && echo "Module $moduleName installed" +exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 +echo "$mainLine" +echo "Installing $moduleFile" +echo "$subLine" + +if [[ -f "${v_mntpt}/Extra/modules/$moduleFile" ]]; then + echo "$moduleName installed to Ram disk" +else + echo "*** ERROR:$moduleName not installed" +fi + +echo "$subLine" + exit 0 Index: trunk/package/Scripts.templates/CleanOptions/clean_bootplist.pl =================================================================== --- trunk/package/Scripts.templates/CleanOptions/clean_bootplist.pl (revision 0) +++ trunk/package/Scripts.templates/CleanOptions/clean_bootplist.pl (revision 2569) @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +use strict; +use YAML::Syck; + +our $target_volume; +our $boot_plist_filepath; + +our $yaml_file="@YAML_FILE@"; + +if ($#ARGV < 0) { + print stderr "A target volume is needed\n"; +} else { + $target_volume=$ARGV[0]; +} + +$boot_plist_filepath = "${target_volume}/Extra/org.chameleon.Boot.plist"; +if ( -f "$boot_plist_filepath" ) { + main("$yaml_file"); +} + +sub _do_cmd { + my ($cmd, $key, $value) = @_; + my $out; + + $key =~ s/([\s])/\\$1/g; # Escape characters in key + $value =~ s/([\s"])/\\$1/g; # Escape characters in value (space & ") + my $plistbuddy_command="$cmd :$key $value"; + + open ( OUTPUT, "-|", '/usr/libexec/PlistBuddy', "-c", "$plistbuddy_command", "$boot_plist_filepath" ); + my $exit_code = $?; + chomp($out = ); + close OUTPUT; + return $out; +} + +sub get_boot_plist_option { + my ($option) = @_; + return _do_cmd( "Print", "$option"); +} + +sub delete_boot_plist_option { + my ($option) = @_; + return _do_cmd( "Delete", "$option"); +} + +sub delete_boot_plist_text_option { + my ($option, $values) = @_; + my $current_value = get_boot_plist_option "$option"; + if ( $current_value ne "") { + foreach my $recognized_value (@{$values}) { + if ($recognized_value eq $current_value) { + return _do_cmd( "Delete", "$option"); + } + } + } + return ""; +} + +sub delete_boot_plist_list_option { + my ($option, $values) = @_; + my $current_value = get_boot_plist_option "$option"; + if ( $current_value ne "") { + my %count; + my @new_list; + foreach my $value (@{$values}) { + $count{$value} = 1; + } + foreach my $value (split(/\s+/,$current_value)) { + if ( not exists $count{$value} ) { + push @new_list, $value; + } + } + return _do_cmd( "Set", $option, join(' ',@new_list) ); + } + return ""; +} + +sub main() { + # Remove all options that installer can managed + my ($yaml_file) = @_; + my $hash_ref = LoadFile($yaml_file) or die "Can't open yaml file\n"; + foreach my $option ( keys %{$hash_ref} ) { + my $type = $hash_ref->{$option}->{type}; + if ( $type =~ /^bool$/i ) { + delete_boot_plist_option($option); + } elsif ( $type =~ /^text$/i ) { + delete_boot_plist_text_option( $option, + $hash_ref->{$option}->{values} ); + } elsif ( $type =~ /^list$/i ) { + delete_boot_plist_list_option( $option, + $hash_ref->{$option}->{values} ); + } + } +} Property changes on: trunk/package/Scripts.templates/CleanOptions/clean_bootplist.pl ___________________________________________________________________ Added: svn:executable + * Index: trunk/package/Changes.txt =================================================================== --- trunk/package/Changes.txt (revision 2568) +++ trunk/package/Changes.txt (revision 2569) @@ -1,3 +1,5 @@ +- Micky1979 - Update Chameleon pkg Installer (Allow install on ESP). + - Micky1979 - Add sectorsize is a tiny command line made to detect the Physical and logical sector size of your hard disk. - JrCs - boot1-install can show ntfs volume. Index: trunk/package/Scripts/Main/BootNO =================================================================== --- trunk/package/Scripts/Main/BootNO (revision 0) +++ trunk/package/Scripts/Main/BootNO (revision 2569) @@ -0,0 +1,8 @@ +#!/bin/bash + +configFile="/private/tmp/InstallConfig.plist" + +# adding option to declare that we are NOT installing the binary of the bootloader +# to the InstallConfig.plist +/usr/libexec/PlistBuddy -c "Add :bootloader bool false" ${configFile} + Property changes on: trunk/package/Scripts/Main/BootNO ___________________________________________________________________ Added: svn:executable + * Index: trunk/package/Scripts/Main/BootYES =================================================================== --- trunk/package/Scripts/Main/BootYES (revision 0) +++ trunk/package/Scripts/Main/BootYES (revision 2569) @@ -0,0 +1,8 @@ +#!/bin/bash + +configFile="/private/tmp/InstallConfig.plist" + +# adding option to declare that we are NOT installing the binary of the bootloader +# to the InstallConfig.plist +/usr/libexec/PlistBuddy -c "Add :bootloader bool true" ${configFile} + Property changes on: trunk/package/Scripts/Main/BootYES ___________________________________________________________________ Added: svn:executable + * Index: trunk/package/Scripts/Main/ESPpostinstall =================================================================== --- trunk/package/Scripts/Main/ESPpostinstall (revision 2568) +++ trunk/package/Scripts/Main/ESPpostinstall (revision 2569) @@ -1,203 +1,418 @@ #!/bin/bash -echo "===============================================" -echo "Main EFI System Partition Post-Install Script" -echo "*********************************************" -echo "-----------------------------------------------" -echo "" +# -------------------------------------------------------------------------------------------------------- +# Install.sh v1.3, script to install Chameleon +# Created by Miky1979 on December 8th, 2014 +# -------------------------------------------------------------------------------------------------------- +targetVolume="${3}" +InstallToESP="1" +InstallBootloader="0" +configFile="/private/tmp/InstallConfig.plist" -# Find location of this script in the package installer -# so we know where all the other scripts are located. - -MYLOCATION="${PWD}/${BASH_ARGV[0]}" -export MYLOCATION="${MYLOCATION%/*}" -scriptDir=$MYLOCATION - - -#echo "===============================================" -#echo "Apple Installer Package Variables" -#echo "*********************************" -#echo "DEBUG: $ 1 = Full path to the installation package the installer app is processing: " $1 -#echo "DEBUG: $ 2 = Full path to the installation destination: " $2 -#echo "DEBUG: $ 3 = Installation volume (mountpoint) to receive the payload: " $3 -#echo "DEBUG: $ 4 = Root directory for the system: " $4 -#echo "DEBUG: Script Name: " $SCRIPT_NAME -#echo "DEBUG: Package Path: " $PACKAGE_PATH -#echo "DEBUG: Installer Temp: " $INSTALLER_TEMP -#echo "DEBUG: Full path to the temp directory containing the operation executable: " $RECEIPT_PATH -#echo "-----------------------------------------------" -#echo "" - -# Initialise Script Globals - +if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then + # installing stage 0, 1 and 2 only if user want this: + # ie only if have no selected noboot choice + InstallBootloader="1" +fi +# -------------------------------------------------------------------------------------------------------- +if [ ! -d "${targetVolume}" ]; then echo "target Volume not found, aborting!"; exit 1; fi +# -------------------------------------------------------------------------------------------------------- +i386Dir="${targetVolume}/usr/standalone/i386" +usrLocalBin="${targetVolume}/usr/local/bin" +# -------------------------------------------------------------------------------------------------------- +choicedVolume="${targetVolume}" +ESP_MOUNTED="0" +# -------------------------------------------------------------------------------------------------------- +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//') +backupRootDir="${targetVolume}/Chameleon.Backups" +backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} ) +logName="Chameleon_Installer_Log.txt" +logFile="${v_mntpt}/${logName}" +# -------------------------------------------------------------------------------------------------------- stage0Loader="boot0" stage0LoaderDualBoot="boot0md" stage1LoaderHFS="boot1h" stage1LoaderFAT="boot1f32" +stage1LoaderExFAT="boot1x" stage2Loader="boot" +versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' ) +# -------------------------------------------------------------------------------------------------------- +localdd="/bin/dd" +SS="${usrLocalBin}/sectorsize" +# -------------------------------------------------------------------------------------------------------- +# Scanning all Variables. We are switching to the target Volume or its ESP. +# This function is usefull to rescan the new target "at need" +SCAN() { + targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' ) + targetDeviceRaw=${targetDevice/disk/rdisk} + targetDisk=${targetDevice%s*} + targetDiskRaw=${targetDisk/disk/rdisk} + targetSlice=${targetDevice#*disk*s} + IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' ) + FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \ + awk '{print $NF}' | awk '{print tolower($0)}' ) + disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \ + perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) -# If target volume root of current system then replace -# / with volume name. -if [ "$3" == "/" ] -then - targetVolumeChosenByUser="/Volumes/"$( ls -1F /Volumes | sed -n 's:@$::p' ) -else - targetVolumeChosenByUser="$3" -fi + if [ $InstallBootloader = "1" ];then + blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' ) + fi +} +# -------------------------------------------------------------------------------------------------------- +# lines +mainLine="==============================================================================" +subLine="------------------------------------------------------------------------------" +# -------------------------------------------------------------------------------------------------------- +# Debug for Chameleon. +# Create a folder inside the Desktop called "DebugChameleon", and the log will be full +DEBUG() { + echo "$mainLine" + echo "DEBUG: display script variables (ESPpostinstall)" + echo "$mainLine" + echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)" + echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)" + echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}" + echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}" + echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}" + echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}" + echo "DEBUG: targetVolume: Volume is ${targetVolume}" + echo "DEBUG: targetDevice: Volume device is ${targetDevice}" + echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}" + echo "DEBUG: targetDisk: Disk device is ${targetDisk}" + echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}" + echo "DEBUG: targetSlice: Volume slice is ${targetSlice}" + echo "DEBUG: versionToInstall: version to install is ${versionToInstall}" + echo "DEBUG: IOContent: partition scheme is ${IOContent}" + echo "DEBUG: FS: file System is ${FS}" + if [ $InstallBootloader = "1" ];then + echo "DEBUG: blocksize: block size detected = ${blocksize}-bytes" + fi +} +# -------------------------------------------------------------------------------------------------------- +# Checking for unsupported FAT16 filesystem +CHECK_FAT16() { + pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \ + | awk '{print $NF}' | awk '{print tolower($0)}' ) -targetDeviceChosenByUser=$( df "${targetVolumeChosenByUser}" | sed -n '2p' | awk '{print $1}' ) + case $pers in + fat16) + echo "** ERROR: Can't Install to a device using FAT16!" + exit 1 + ;; + *) + echo "First Check Passed!" + ;; + esac +} +# -------------------------------------------------------------------------------------------------------- +# Mount or umount the ESP..or leave as is if already mounted.. +UMOUNT_ESP_DISK() { + # umount the ESP by its dev + umount -f $espDisk +} -targetVolume="/Volumes/EFI" -targetDevice=${targetDeviceChosenByUser%s*}s1 -targetDeviceRaw=${targetDevice/disk/rdisk} -targetDisk=${targetDevice%s*} -targetDiskRaw=${targetDisk/disk/rdisk} -targetSlice=${targetDevice#*disk*s} +CHECK_ESP_MOUNTPOINT() { + # umount the ESP by its Mount Point + # and checking it if is busy by another ESP + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ + grep -x '/Volumes/ESP' ) ]; then + umount -f /Volumes/ESP + ESP_MOUNTED="0" + fi +} -targetResources="${targetVolumeChosenByUser}/usr/local/bin/" +MOUNT_ESP() { + ESP_MOUNTED="1" # ..assuming that the ESP can be already mounted.. + if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then + # ESP is already mounted, so now we aquire the Mount Point + espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^[ \t]*//' ) + if [ -d "${espmtp}" ];then + echo "ESP Mount Point is:${espmtp}, using that as target Volume!" + choicedVolume="${espmtp}" + SCAN + else + echo "The mount point was not found, try to umount it to get the standard one.." + UMOUNT_ESP_DISK + CHECK_ESP_MOUNTPOINT + fi + else + # ESP is not mounted.. + ESP_MOUNTED="0" + fi -efiPartitionExist=0 # target volume does not have EFI system partition. + if [ $ESP_MOUNTED = "0" ];then + mkdir -p /Volumes/ESP + case $( fstyp $espDisk ) in + hfs) + mount -t hfs $espDisk /Volumes/ESP + ;; + msdos) + mount -t msdos $espDisk /Volumes/ESP + ;; + *) + echo "ESP fileSystem unsupported, Installing to ${targetVolume}!" + choicedVolume="${targetVolume}" + ;; + esac + sleep 0.3 -echo "===============================================" -echo "DEBUG: display script variables" -echo "***************************" + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ + grep -x '/Volumes/ESP' ) ]; then + ESP_MOUNTED="1" + choicedVolume="/Volumes/ESP" + SCAN + else + echo "ESP can't be mounted, Installing to ${targetVolume}!" + choicedVolume="${targetVolume}" + fi + fi +} +# -------------------------------------------------------------------------------------------------------- +PARTITION_ACTIVE_IF() { + echo -e "${mainLine}\nSET PARTITION ACTIVE:" + # if Windows was detected, don't activate the partition.. + # if the stage 0 loader is boo0hfs, don't activate the partition + if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then + partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}') + if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then + echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it." + else + echo "Setting ${choicedVolume} partition active." + # BadAxe requires EFI partition to be flagged active. + # but it doesn't' hurt to do it for any non-windows partition. -echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}" -echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot}" -echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}" -echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}" -echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}" -echo "DEBUG: targetVolumeChosenByUser: Volume is ${targetVolumeChosenByUser}" -echo "DEBUG: targetDeviceChosenByUser: Volume device is ${targetDeviceChosenByUser}" -echo "DEBUG: targetVolume: Volume is ${targetVolume}" -echo "DEBUG: targetDevice: Volume device is ${targetDevice}" -echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}" -echo "DEBUG: targetDisk: Disk device is ${targetDisk}" -echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}" -echo "DEBUG: targetSlice: Volume slice is ${targetSlice}" -echo "DEBUG: targetResources: Boot Resources is ${targetResources}" -echo "-----------------------------------------------" -echo "" +# leave left aligned the follow code: +fdisk -e ${targetDiskRaw} <<-MAKEACTIVE +print +flag ${targetSlice} +write +y +quit +MAKEACTIVE + fi + else + echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs" + fi + echo "" + echo "$mainLine" +} +# -------------------------------------------------------------------------------------------------------- +# Writing stage 0 +CHECK_WINDOWS() { + WINDOWS_EXIST="0" + if [ "${disksignature}" = "00000000" ]; then + echo "Windows installation not found on ${targetDisk}." + else + echo "Windows installation found on ${targetDisk}." + WINDOWS_EXIST="1" + fi +} +WRITE_STAGE0() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 0:" + CHECK_WINDOWS + case "$1" in + hfs) + if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi + ;; + msdos) + if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi + ;; + exfat) + stage0Loader="boot0" + ;; + esac -# Write some information to the Install Log -"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Running EFI postinstall script" -"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Target selected by user = ${targetVolumeChosenByUser} on ${targetDeviceChosenByUser}" -"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Target volume = ${targetVolume} on ${targetDevice}" + "${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk} + echo "${stage0Loader} writed to ${targetDisk}" + fi +} -# Check to see if the selected disk uses a GPT +# -------------------------------------------------------------------------------------------------------- +# Writing stage 1 on different filesystems +WRITE_STAGE1_HFS() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 1 HFS:" + $localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw} + echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}." + fi +} -bootuuid=$( diskutil info "$targetDeviceChosenByUser" | grep Volume\ UUID | awk {'print $3'} ) -partitiontable=$( diskutil list ${targetDeviceChosenByUser%s*} | sed -n '3p' | awk '{print $2}' ) +WRITE_STAGE1_EXFAT() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:" + cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/ + cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/ + "${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw} + echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}." + fi +} -if [ ${partitiontable} = "GUID_partition_scheme" ]; then - echo "Confirm this is a GPT partitioned disk." +WRITE_STAGE1_FAT32() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 1 FAT32:" + $localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs" + cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs" + $localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc + $localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512 - # Double check we can see the selected partition and it's of the right type. - # The following script returns either 0 or 1 to proceed, or 2 to indicate failure. + echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}." + fi +} +# -------------------------------------------------------------------------------------------------------- +# Writing stage 2 +WRITE_STAGE2() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 2:" + cp -R "${i386Dir}/${stage2Loader}" "${choicedVolume}/" + chflags hidden "${choicedVolume}/${stage2Loader}" + echo "Stage 2 (boot) writed to ${choicedVolume}." + fi +} +# -------------------------------------------------------------------------------------------------------- +# Waiting for targhet Volume was re-mounted before proceeding.. +# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..) +WAIT_REMOUNT() { + if [ $InstallBootloader = "1" ];then + if [ ! -d "${choicedVolume}" ]; then + echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:" + until [ -d "${choicedVolume}" ]; do + sleep 0.3 + done + echo "${choicedVolume} is mounted!" + fi + fi +} +# -------------------------------------------------------------------------------------------------------- +# Extra folder... +EXTRA() { + echo -e "${mainLine}\nEXTRA FOLDER:" + if [ ! -d "${choicedVolume}/Extra" ]; then + echo "Extra not found on ${choicedVolume}, creating.." + mkdir -p "${v_mntpt}/Extra" + /usr/libexec/PlistBuddy -c "Add :'Kernel Flags' string -v" "${v_mntpt}/Extra/org.chameleon.Boot.plist" + else + echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.." + cp -R "${choicedVolume}/Extra" "${v_mntpt}"/ + ./clean_bootplist.pl "${v_mntpt}" >/dev/null + fi +} +# -------------------------------------------------------------------------------------------------------- +# Preparing Backing up of Chameleon files +BACKUP() { + echo -e "${mainLine}\nBACKUP CHAMELEON FILES:" + # Backup Stage 2 + if [ $InstallBootloader = "1" ];then + if [ -f "${choicedVolume}/boot" ]; then + echo "Backup stage2 file ${choicedVolume}/boot to ${backupRootDir}/${backupDir}/boot" + cp "${choicedVolume}/boot" "${backupRootDir}/${backupDir}/boot" + else + echo "No stage 2 (boot) was found, nothing to be saved." + fi + fi + # Backup /Extra directory + if [[ -d "${choicedVolume}/Extra" ]];then + echo "Backing up ${choicedVolume}/Extra folder to ${backupRootDir}/${backupDir}/Extra" + cp -pR "${choicedVolume}/Extra" "${backupRootDir}/${backupDir}"/ + else + echo "No Extra folder was found, nothing to be saved." + fi +} +# -------------------------------------------------------------------------------------------------------- +if [ ! -d "${v_mntpt}" ]; then + echo "Ram Disk not found!" + exit +fi - "$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}" - returnValue=$? - if [ ${returnValue} -ne 2 ]; then - # OK to proceed +exec > >(tee -a "${logFile}") 2>&1 - # Remember if the target volume has an EFI system partition. - if [ ${returnValue} -ne 1 ]; then - efiPartitionExist=1 - fi +echo "$mainLine" +echo "Main ESP Post-Install Script" +echo "Chameleon installer log - $( date )" +if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi +echo "" - # Does a GRUB or Linux loader already exist in the disk's MBR? - # The script returns 1 if yes, 0 if no. +SCAN - "$scriptDir"CheckGRUBLinuxLoader.sh "${targetDisk}" "${targetVolumeChosenByUser}" "${scriptDir}" - returnValue=$? - if [ ${returnValue} = 0 ]; then - # OK to proceed +# (adjusted from Clover) +if [ ! "${targetDevice#*disk*s}" ]; then + echo + echo "*** ERROR: Volume does not use slices!" + echo + exit 1 +fi +if [ "${InstallToESP}" == "1" ]; then + echo "$mainLine" + echo "SEARCHING ESP PARTITION:" + case "$IOContent" in + GUID_partition_scheme) + echo "GPT partition Scheme detected.." + espDisk="${targetDisk}s1" + if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \ + awk '{print $NF}' ) = "EFI" ]; then + echo "EFI partition found is ${espDisk}, try to mount it.." + MOUNT_ESP + else + echo "EFI was not fount, continue installing to ${targetVolume}" + choicedVolume="${targetVolume}" + fi + ;; + *) + echo "Can't install on the ESP, because does not exist.." + echo "..continue installing to ${targetVolume}" + ;; + esac +else + SCAN +fi - # check for a 4-byte Windows disk signature in the disk's MBR. - # the following script returns 1 if a Windows disk signature exists, and 0 if not. - "$scriptDir"CheckWindowsDiskSignature.sh "${targetDisk}" "${targetVolumeChosenByUser}" "${scriptDir}" - diskSigCheck=$? +if [ -d "${HOME}/Desktop/DebugChameleon" ]; then + DEBUG +fi +# adding the chosen Volume dev id to the InstallConfig.plist +/usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile - # check for existing bootloaders in the disk's MBR - # and find out if we can write the Chameleon boot files. - # the following script returns 0 if we can proceed - # with writing the boot files, and 1 for not. +BACKUP +EXTRA - "$scriptDir"CheckDiskMicrocode.sh "${targetDisk}" "${diskSigCheck}" "${targetVolumeChosenByUser}" "${scriptDir}" - diskupdate=$? +echo "${mainLine}" +CHECK_FAT16 +case "$FS" in + hfs) + echo "${targetDevice} is HFS formatted" + WRITE_STAGE0 hfs + WRITE_STAGE1_HFS + ;; + msdos) + echo "${targetDevice} is FAT32 formatted" + WRITE_STAGE0 msdos + WRITE_STAGE1_FAT32 + ;; + exfat) + echo "${targetDevice} is ExFAT formatted" + WRITE_STAGE0 exfat + WRITE_STAGE1_EXFAT + WAIT_REMOUNT + ;; + *) + echo "FileSystem unsupported, aborting!" + exit 0 + ;; +esac +WRITE_STAGE2 +PARTITION_ACTIVE_IF - # check the format of the selected partition. - # result should be either hfs or msdos - # Should really check to make sure! +echo "$mainLine" +echo "END - ESP Post-Install Script" +# -------------------------------------------------------------------------------------------------------- - targetFormat=$( fstyp "$targetDevice" ) - - - # Append a LineBreak to the installer log - "$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "LineBreak" - - if [ ${diskupdate} = "0" ]; then - - # Write the stage 0 loader to the MBR - "$scriptDir"WriteChameleonStage0.sh "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetResources}" "${targetVolumeChosenByUser}" "${scriptDir}" - else - "$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Stage 0 loader not written to ${targetDisk}." - fi - - # Write the stage 1 loader to the partition boot sector - "$scriptDir"WriteChameleonStage1.sh "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${targetVolumeChosenByUser}" "${targetDeviceRaw}" "${targetVolumeChosenByUser}" "${scriptDir}" - - - # Unmount ALL mounted volumes named EFI. - # Returns 0=success, 1=fail - - "$scriptDir"UnMountEFIvolumes.sh "${targetVolumeChosenByUser}" "${scriptDir}" - returnValue=$? - if [ ${returnValue} = 0 ]; then - # OK to proceed - - # Mount the EFI system partition - "$scriptDir"MountESP.sh "${targetDisk}" "${targetVolumeChosenByUser}" "${efiPartitionExist}" "${scriptDir}" - - # Write the stage 2 loader to the root of the selected partition - "$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${targetVolume}" "${targetDevice}" "${targetVolumeChosenByUser}" "${scriptDir}" - - # Check for another existing Chameleon installation on the same disk - "$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak" - "$scriptDir"InstallLog.sh "${targetVolume}" "Preparing to check target disk for previous installations." - "$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolumeChosenByUser}" "${scriptDir}" - fi - - # Append a LineBreak to the installer log - "$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "LineBreak" - - # Set the active partition ONLY if Windows is not installed - "$scriptDir"SetActivePartition.sh "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolumeChosenByUser}" "${scriptDir}" - - fi - fi -else - #echo "ERROR Volume is not on a GPT partitioned disc." - "$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "ERROR Volume is not on a GPT partitioned disc." -fi - -# Create temporary file on target volume to notify Postinstall -# script, boot option code, that EFI (ESP) option was chosen -echo "EFI" >"${targetVolumeChosenByUser}"/.ChameleonEFI - -"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "LineBreak" -"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "EFI script complete" - -echo "===============================================" -echo "END - Main EFI System Partition Post-Install Script" -echo "*********************************************" -echo "-----------------------------------------------" -echo "" - exit 0 Index: trunk/package/Scripts/Main/Standardpostinstall =================================================================== --- trunk/package/Scripts/Main/Standardpostinstall (revision 2568) +++ trunk/package/Scripts/Main/Standardpostinstall (revision 2569) @@ -1,205 +1,417 @@ #!/bin/bash -echo "===============================================" -echo "Main Standard Post-Install Script" -echo "*********************************" -echo "-----------------------------------------------" -echo "" +# -------------------------------------------------------------------------------------------------------- +# Install.sh v1.3, script to install Chameleon +# Created by Miky1979 on December 8th, 2014 +# -------------------------------------------------------------------------------------------------------- +targetVolume="${3}" +InstallToESP="0" +InstallBootloader="0" +configFile="/private/tmp/InstallConfig.plist" -# Find location of this script in the package installer -# so we know where all the other scripts are located. - -MYLOCATION="${PWD}/${BASH_ARGV[0]}" -export MYLOCATION="${MYLOCATION%/*}" -scriptDir=$MYLOCATION - - -#echo "===============================================" -#echo "Apple Installer Package Variables" -#echo "*********************************" -#echo "DEBUG: $ 1 = Full path to the installation package the installer app is processing: " $1 -#echo "DEBUG: $ 2 = Full path to the installation destination: " $2 -#echo "DEBUG: $ 3 = Installation volume (mountpoint) to receive the payload: " $3 -#echo "DEBUG: $ 4 = Root directory for the system: " $4 -#echo "DEBUG: Script Name: " $SCRIPT_NAME -#echo "DEBUG: Package Path: " $PACKAGE_PATH -#echo "DEBUG: Installer Temp: " $INSTALLER_TEMP -#echo "DEBUG: Full path to the temp directory containing the operation executable: " $RECEIPT_PATH -#echo "-----------------------------------------------" -#echo "" - - -# Initialise Script Globals - +if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then + # installing stage 0, 1 and 2 only if user want this: + # ie only if have no selected noboot choice + InstallBootloader="1" +fi +# -------------------------------------------------------------------------------------------------------- +if [ ! -d "${targetVolume}" ]; then echo "target Volume not found, aborting!"; exit 1; fi +# -------------------------------------------------------------------------------------------------------- +i386Dir="${targetVolume}/usr/standalone/i386" +usrLocalBin="${targetVolume}/usr/local/bin" +# -------------------------------------------------------------------------------------------------------- +choicedVolume="${targetVolume}" +ESP_MOUNTED="0" +# -------------------------------------------------------------------------------------------------------- +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ + | sed -e 's/^[ \t]*//') +backupRootDir="${targetVolume}/Chameleon.Backups" +backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} ) +logName="Chameleon_Installer_Log.txt" +logFile="${v_mntpt}/${logName}" +# -------------------------------------------------------------------------------------------------------- stage0Loader="boot0" stage0LoaderDualBoot="boot0md" stage1LoaderHFS="boot1h" stage1LoaderFAT="boot1f32" +stage1LoaderExFAT="boot1x" stage2Loader="boot" +versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' ) +# -------------------------------------------------------------------------------------------------------- +localdd="/bin/dd" +SS="${usrLocalBin}/sectorsize" +# -------------------------------------------------------------------------------------------------------- +# Scanning all Variables. We are switching to the target Volume or its ESP. +# This function is usefull to rescan the new target "at need" +SCAN() { + targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' ) + targetDeviceRaw=${targetDevice/disk/rdisk} + targetDisk=${targetDevice%s*} + targetDiskRaw=${targetDisk/disk/rdisk} + targetSlice=${targetDevice#*disk*s} + IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' ) + FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \ + awk '{print $NF}' | awk '{print tolower($0)}' ) + disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \ + perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) -# If target volume root of current system then replace -# / with volume name. -if [ "$3" == "/" ] -then - targetVolume="/Volumes/"$( ls -1F /Volumes | sed -n 's:@$::p' ) -else - targetVolume="$3" -fi + if [ $InstallBootloader = "1" ];then + blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' ) + fi +} +# -------------------------------------------------------------------------------------------------------- +# lines +mainLine="==============================================================================" +subLine="------------------------------------------------------------------------------" +# -------------------------------------------------------------------------------------------------------- +# Debug for Chameleon. +# Create a folder inside the Desktop called "DebugChameleon", and the log will be full +DEBUG() { + echo "$mainLine" + echo "DEBUG: display script variables (Standardpostinstall)" + echo "$mainLine" + echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)" + echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)" + echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}" + echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}" + echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}" + echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}" + echo "DEBUG: targetVolume: Volume is ${targetVolume}" + echo "DEBUG: targetDevice: Volume device is ${targetDevice}" + echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}" + echo "DEBUG: targetDisk: Disk device is ${targetDisk}" + echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}" + echo "DEBUG: targetSlice: Volume slice is ${targetSlice}" + echo "DEBUG: versionToInstall: version to install is ${versionToInstall}" + echo "DEBUG: IOContent: partition scheme is ${IOContent}" + echo "DEBUG: FS: file System is ${FS}" + if [ $InstallBootloader = "1" ];then + echo "DEBUG: blocksize: block size detected = ${blocksize}-bytes" + fi +} +# -------------------------------------------------------------------------------------------------------- +# Checking for unsupported FAT16 filesystem +CHECK_FAT16() { + pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \ + | awk '{print $NF}' | awk '{print tolower($0)}' ) + case $pers in + fat16) + echo "** ERROR: Can't Install to a device using FAT16!" + exit 1 + ;; + *) + echo "First Check Passed!" + ;; + esac +} +# -------------------------------------------------------------------------------------------------------- +# Mount or umount the ESP..or leave as is if already mounted.. +UMOUNT_ESP_DISK() { + # umount the ESP by its dev + umount -f $espDisk +} -targetDevice=$( df "${targetVolume}" | sed -n '2p' | awk '{print $1}' ) -targetDeviceRaw=${targetDevice/disk/rdisk} -targetDisk=${targetDevice%s*} -targetDiskRaw=${targetDisk/disk/rdisk} -targetSlice=${targetDevice#*disk*s} +CHECK_ESP_MOUNTPOINT() { + # umount the ESP by its Mount Point + # and checking it if is busy by another ESP + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ + grep -x '/Volumes/ESP' ) ]; then + umount -f /Volumes/ESP + ESP_MOUNTED="0" + fi +} -targetResources="${targetVolume}/usr/local/bin/" +MOUNT_ESP() { + ESP_MOUNTED="1" # ..assuming that the ESP can be already mounted.. + if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then + # ESP is already mounted, so now we aquire the Mount Point + espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^[ \t]*//' ) + if [ -d "${espmtp}" ];then + echo "ESP Mount Point is:${espmtp}, using that as target Volume!" + choicedVolume="${espmtp}" + SCAN + else + echo "The mount point was not found, try to umount it to get the standard one.." + UMOUNT_ESP_DISK + CHECK_ESP_MOUNTPOINT + fi + else + # ESP is not mounted.. + ESP_MOUNTED="0" + fi -updateStage1=1 # by default update partition boot sector -efiPartitionExist=0 # target volume does not have EFI system partition. + if [ $ESP_MOUNTED = "0" ];then + mkdir -p /Volumes/ESP + case $( fstyp $espDisk ) in + hfs) + mount -t hfs $espDisk /Volumes/ESP + ;; + msdos) + mount -t msdos $espDisk /Volumes/ESP + ;; + *) + echo "ESP fileSystem unsupported, Installing to ${targetVolume}!" + choicedVolume="${targetVolume}" + ;; + esac + sleep 0.3 -echo "===============================================" -echo "DEBUG: display script variables" -echo "*******************************" + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ + grep -x '/Volumes/ESP' ) ]; then + ESP_MOUNTED="1" + choicedVolume="/Volumes/ESP" + SCAN + else + echo "ESP can't be mounted, Installing to ${targetVolume}!" + choicedVolume="${targetVolume}" + fi + fi +} +# -------------------------------------------------------------------------------------------------------- +PARTITION_ACTIVE_IF() { + echo -e "${mainLine}\nSET PARTITION ACTIVE:" + # if Windows was detected, don't activate the partition.. + # if the stage 0 loader is boo0hfs, don't activate the partition + if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then + partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}') + if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then + echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it." + else + echo "Setting ${choicedVolume} partition active." + # BadAxe requires EFI partition to be flagged active. + # but it doesn't' hurt to do it for any non-windows partition. -echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}" -echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot}" -echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}" -echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}" -echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}" -echo "DEBUG: targetVolume: Volume is ${targetVolume}" -echo "DEBUG: targetDevice: Volume device is ${targetDevice}" -echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}" -echo "DEBUG: targetDisk: Disk device is ${targetDisk}" -echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}" -echo "DEBUG: targetSlice: Volume slice is ${targetSlice}" -echo "DEBUG: targetResources: Boot Resources is ${targetResources}" -echo "-----------------------------------------------" -echo "" +# leave left aligned the follow code: +fdisk -e ${targetDiskRaw} <<-MAKEACTIVE +print +flag ${targetSlice} +write +y +quit +MAKEACTIVE + fi + else + echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs" + fi + echo "" + echo "$mainLine" +} +# -------------------------------------------------------------------------------------------------------- +# Writing stage 0 +CHECK_WINDOWS() { + WINDOWS_EXIST="0" + if [ "${disksignature}" = "00000000" ]; then + echo "Windows installation not found on ${targetDisk}." + else + echo "Windows installation found on ${targetDisk}." + WINDOWS_EXIST="1" + fi +} +WRITE_STAGE0() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 0:" + CHECK_WINDOWS + case "$1" in + hfs) + if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi + ;; + msdos) + if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi + ;; + exfat) + stage0Loader="boot0" + ;; + esac -# Write some information to the Install Log -"$scriptDir"InstallLog.sh "${targetVolume}" "Running Standard postinstall script" -"$scriptDir"InstallLog.sh "${targetVolume}" "Target volume = ${targetVolume} on ${targetDevice}" + "${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk} + echo "${stage0Loader} writed to ${targetDisk}" + fi +} +# -------------------------------------------------------------------------------------------------------- +# Writing stage 1 on different filesystems +WRITE_STAGE1_HFS() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 1 HFS:" + $localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw} + echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}." + fi +} -# Double check we can see the selected partition and it's of the right type. -# The following script returns either 0 or 1 to proceed, or 2 to indicate failure. +WRITE_STAGE1_EXFAT() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:" + cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/ + cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/ + "${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw} + echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}." + fi +} -"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDevice}" "${targetVolume}" "${scriptDir}" -returnValue=$? -if [ ${returnValue} -ne 2 ]; then - # OK to proceed - - # Remember if the target volume has an EFI system partition. - if [ ${returnValue} -ne 1 ]; then - efiPartitionExist=1 - fi +WRITE_STAGE1_FAT32() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 1 FAT32:" + $localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs" + cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs" + $localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc + $localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512 - # Does a GRUB or Linux loader already exist in the disk's MBR? - # The script returns 1 if yes, 0 if no. - "$scriptDir"CheckGRUBLinuxLoader.sh "${targetDisk}" "${targetVolume}" "${scriptDir}" - diskupdate=$? - if [ ${diskupdate} -ne 0 ]; then - "$scriptDir"InstallLog.sh "${targetVolume}" "Found an existing GRUB/LILO bootloader in the MBR." - "$scriptDir"InstallLog.sh "${targetVolume}" "MBR and partition boot sector will not be modified." - updateStage1=0 - else - # check for existing bootloaders in the disk's MBR - # and find out if we can write the Chameleon boot files. - # the following script returns 0 if we can proceed - # with writing the boot files, and 1 for not. - "$scriptDir"CheckDiskMicrocode.sh "${targetDisk}" "${diskSigCheck}" "${targetVolume}" "${scriptDir}" - diskupdate=$? - fi + echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}." + fi +} +# -------------------------------------------------------------------------------------------------------- +# Writing stage 2 +WRITE_STAGE2() { + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nWRITING STAGE 2:" + cp -R "${i386Dir}/${stage2Loader}" "${choicedVolume}/" + chflags hidden "${choicedVolume}/${stage2Loader}" + echo "Stage 2 (boot) writed to ${choicedVolume}." + fi +} +# -------------------------------------------------------------------------------------------------------- +# Waiting for targhet Volume was re-mounted before proceeding.. +# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..) +WAIT_REMOUNT() { + if [ $InstallBootloader = "1" ];then + if [ ! -d "${choicedVolume}" ]; then + echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:" + until [ -d "${choicedVolume}" ]; do + sleep 0.3 + done + echo "${choicedVolume} is mounted!" + fi + fi +} +# -------------------------------------------------------------------------------------------------------- +# Extra folder... +EXTRA() { + echo -e "${mainLine}\nEXTRA FOLDER:" + if [ ! -d "${choicedVolume}/Extra" ]; then + echo "Extra not found on ${choicedVolume}, creating.." + mkdir -p "${v_mntpt}/Extra" + /usr/libexec/PlistBuddy -c "Add :'Kernel Flags' string -v" "${v_mntpt}/Extra/org.chameleon.Boot.plist" + else + echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.." + cp -R "${choicedVolume}/Extra" "${v_mntpt}"/ + ./clean_bootplist.pl "${v_mntpt}" >/dev/null + fi +} +# -------------------------------------------------------------------------------------------------------- +# Preparing Backing up of Chameleon files +BACKUP() { + echo -e "${mainLine}\nBACKUP CHAMELEON FILES:" + # Backup Stage 2 + if [ $InstallBootloader = "1" ];then + if [ -f "${choicedVolume}/boot" ]; then + echo "Backup stage2 file ${choicedVolume}/boot to ${backupRootDir}/${backupDir}/boot" + cp "${choicedVolume}/boot" "${backupRootDir}/${backupDir}/boot" + else + echo "No stage 2 (boot) was found, nothing to be saved." + fi + fi + # Backup /Extra directory + if [[ -d "${choicedVolume}/Extra" ]];then + echo "Backing up ${choicedVolume}/Extra folder to ${backupRootDir}/${backupDir}/Extra" + cp -pR "${choicedVolume}/Extra" "${backupRootDir}/${backupDir}"/ + else + echo "No Extra folder was found, nothing to be saved." + fi +} +# -------------------------------------------------------------------------------------------------------- +if [ ! -d "${v_mntpt}" ]; then + echo "Ram Disk not found!" + exit +fi - # check for a 4-byte Windows disk signature in the disk's MBR. - # the following script returns 1 if a Windows disk signature exists, and 0 if not. - "$scriptDir"CheckWindowsDiskSignature.sh "${targetDisk}" "${targetVolume}" "${scriptDir}" - diskSigCheck=$? +exec > >(tee -a "${logFile}") 2>&1 +echo "$mainLine" +echo "Main Standard Post-Install Script" +echo "Chameleon installer log - $( date )" +if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi +echo "" - # check the format of the selected partition. - # result should be either hfs or msdos - # Should really check to make sure! - targetFormat=$( fstyp "$targetDevice" ) +SCAN +# (adjusted from Clover) +if [ ! "${targetDevice#*disk*s}" ]; then + echo + echo "*** ERROR: Volume does not use slices!" + echo + exit 1 +fi - # check the partition scheme used for the selected disk. - # the following script returns 1 if GPT - # the following script returns 2 if GPT/MBR - # the following script returns 3 if MBR - # the following script returns 0 if nothing - "$scriptDir"CheckPartitionScheme.sh "${targetDisk}" "${targetVolume}" "${scriptDir}" - partitionScheme=$? - if [ ${partitionScheme} = 3 ]; then - # If MBR partition scheme then check for FAT16 or FAT32 +if [ "${InstallToESP}" == "1" ]; then + echo "$mainLine" + echo "SEARCHING ESP PARTITION:" + case "$IOContent" in + GUID_partition_scheme) + echo "GPT partition Scheme detected.." + espDisk="${targetDisk}s1" + if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \ + awk '{print $NF}' ) = "EFI" ]; then + echo "EFI partition found is ${espDisk}, try to mount it.." + MOUNT_ESP + else + echo "EFI was not fount, continue installing to ${targetVolume}" + choicedVolume="${targetVolume}" + fi + ;; + *) + echo "Can't install on the ESP, because does not exist.." + echo "..continue installing to ${targetVolume}" + ;; + esac +else + SCAN +fi - # the following script returns 1 if FAT16 - # the following script returns 2 if FAT32 - # the following script returns 0 if nothing - "$scriptDir"CheckFatType.sh "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}" - fatType=$? - fi - if [ "${fatType}" = 1 ] && [ "${partitionScheme}" = 3 ]; then - # Write error to Chameleon_Error_Log file - "$scriptDir"InstallLog.sh "${targetVolume}" "FAIL: Cannot install to a device using FAT16" - else - # Continue if the selected device is not a FAT16 format device +if [ -d "${HOME}/Desktop/DebugChameleon" ]; then + DEBUG +fi - # Append a line break to the installer log - "$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak" +# adding the chosen Volume dev id to the InstallConfig.plist +/usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile - if [ ${diskupdate} -eq 0 ]; then - # Write the stage 0 loader to the MBR - "$scriptDir"WriteChameleonStage0.sh "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetResources}" "${targetVolume}" "${scriptDir}" - else - "$scriptDir"InstallLog.sh "${targetVolume}" "Stage 0 loader not written to ${targetDisk}." - fi +BACKUP +EXTRA - if [ ${updateStage1} -eq 1 ]; then - # Write the stage 1 loader to the partition boot sector - "$scriptDir"WriteChameleonStage1.sh "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}" - else - "$scriptDir"InstallLog.sh "${targetVolume}" "Partition boot sector not written to ${targetDevice}." - fi +echo "${mainLine}" +CHECK_FAT16 +case "$FS" in + hfs) + echo "${targetDevice} is HFS formatted" + WRITE_STAGE0 hfs + WRITE_STAGE1_HFS + ;; + msdos) + echo "${targetDevice} is FAT32 formatted" + WRITE_STAGE0 msdos + WRITE_STAGE1_FAT32 + ;; + exfat) + echo "${targetDevice} is ExFAT formatted" + WRITE_STAGE0 exfat + WRITE_STAGE1_EXFAT + WAIT_REMOUNT + ;; + *) + echo "FileSystem unsupported, aborting!" + exit 0 + ;; +esac - # Write the stage 2 loader to the root of the selected partition - "$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}" "${scriptDir}" +WRITE_STAGE2 +PARTITION_ACTIVE_IF - # Next we look to check for existing Chameleon installations. - "$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak" - "$scriptDir"InstallLog.sh "${targetVolume}" "Preparing to check target disk for previous installations." - if [ ${efiPartitionExist} -ne 0 ]; then # volume has an EFI system partition - "$scriptDir"InstallLog.sh "${targetVolume}" "Going to check the EFI system partition also." - # Unmount ALL mounted volumes named EFI. Returns 0=success, 1=fail - "$scriptDir"UnMountEFIvolumes.sh "${targetVolume}" "${scriptDir}" - returnValue=$? - if [ ${returnValue} = 0 ]; then - # Mount the EFI system partition - "$scriptDir"MountESP.sh "${targetDisk}" "${targetVolume}" "${efiPartitionExist}" "${scriptDir}" - fi - fi - # Check for another existing Chameleon installation on the same disk - "$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolume}" "${scriptDir}" - - # Append a line break to the installer log - "$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak" - - # Set the active partition ONLY if Windows is not installed - "$scriptDir"SetActivePartition.sh "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}" "${scriptDir}" - fi -fi - -"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak" -"$scriptDir"InstallLog.sh "${targetVolume}" "Standard script complete" -"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak" - -echo "===============================================" +echo "$mainLine" echo "END - Standard Post-Install Script" -echo "*********************************" -echo "-----------------------------------------------" -echo "" +# -------------------------------------------------------------------------------------------------------- exit 0 Index: trunk/package/buildpkg.sh =================================================================== --- trunk/package/buildpkg.sh (revision 2568) +++ trunk/package/buildpkg.sh (revision 2569) @@ -274,6 +274,10 @@ case "$option" in --group=*) shift; groupChoice=${option#*=} ;; + --selected=*) + shift; choiceOptions="$choiceOptions selected=\"${option#*=}\"" ;; + --enabled=*) + shift; choiceOptions="$choiceOptions enabled=\"${option#*=}\"" ;; --start-selected=*) shift; choiceOptions="$choiceOptions start_selected=\"${option#*=}\"" ;; --start-enabled=*) @@ -467,69 +471,53 @@ choiceId="Core" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot1x ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot1he ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/boot1hp ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/cdboot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/chain0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 - ditto --noextattr --noqtn ${SYMROOT}/i386/fdisk440 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin + ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot1x ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot1he ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot1hp ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/cdboot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/chain0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/fdisk440 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin + ditto --noextattr --noqtn ${SYMROOT}/i386/sectorsize ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin ditto --noextattr --noqtn ${SYMROOT}/i386/boot1-install ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin ditto --noextattr --noqtn ${SYMROOT}/i386/bdmesg ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" - addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}" + addChoice --start-visible="false" --selected="choices['boot'].selected" --pkg-refs="$packageRefId" "${choiceId}" # End build core package -# build Chameleon package - echo "================= Chameleon =================" - addGroupChoices --exclusive_one_choice "Chameleon" - - # build standard package - choiceId="Standard" +# build boot choice package + choiceId="boot" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root - mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources - addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" InstallerLog - cp -f ${PKGROOT}/Scripts/Main/${choiceId}postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall - cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts - ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts + cp -f ${PKGROOT}/Scripts/Main/BootYES ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" - addChoice --group="Chameleon" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}" - # End build standard package + addChoice --start-visible="false" --selected="!choices['noboot'].selected" \ + --pkg-refs="$packageRefId" "${choiceId}" +# End build boot choice package - # build efi package -if [[ 1 -eq 0 ]];then - # Only standard installation is currently supported - # We need to update the script to be able to install - # Chameleon on EFI partition - choiceId="EFI" - mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root - mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources - addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" InstallerLog - cp -f ${PKGROOT}/Scripts/Main/ESPpostinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall - cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts - ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile +# build Chameleon package + echo "================= Chameleon =================" + addGroupChoices "Chameleon" - packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" - addChoice --group="Chameleon" --start-visible="systemHasGPT()" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" - # End build efi package -fi - # build no bootloader choice package + # build noboot choice package choiceId="noboot" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts + cp -f ${PKGROOT}/Scripts/Main/BootNO ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" - addChoice --group="Chameleon" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" - # End build no bootloader choice package + addChoice --group="Chameleon" --selected="!choices['boot'].selected" \ + --pkg-refs="$packageRefId" "${choiceId}" +# End build noboot choice package # End build Chameleon package @@ -573,7 +561,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build ACPICodec package module } @@ -592,7 +580,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build NvidiaGraphicsEnabler package module } @@ -611,7 +599,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build AMDGraphicsEnabler package module } @@ -630,7 +618,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build IntelGraphicsEnabler package module } @@ -649,7 +637,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build KernelPatcher package module } @@ -668,7 +656,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build KextPatcher package module } @@ -680,18 +668,18 @@ # Start build Keylayout package module choiceId="Keylayout" moduleFile="${choiceId}.dylib" - mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/{modules,Keymaps} + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/{modules,Keymaps} mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src" if [ -d "$layout_src_dir" ];then # Create a tar.gz from layout sources (cd "$layout_src_dir"; \ - tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt) + tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/Keymaps/layouts-src.tar.gz" README *.slt) fi # Adding module - ditto --noextattr --noqtn ${SYMROOT}/i386/modules/$moduleFile ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/modules + ditto --noextattr --noqtn ${SYMROOT}/i386/modules/$moduleFile ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/modules # Adding Keymaps - ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps + ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/Keymaps # Adding tools ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin # Adding scripts @@ -722,7 +710,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build klibc package module } @@ -741,7 +729,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build Resolution package module } @@ -760,7 +748,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build HDAEnabler package module } @@ -779,7 +767,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build FileNVRAM package module } @@ -798,7 +786,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}" # End build Sata package module } @@ -822,7 +810,7 @@ InstallModule packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}") - buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules" + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules" # Add the klibc package because the uClibc module is dependent of klibc module addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId $klibcPackageRefId" "${choiceId}" # End build uClibc package module @@ -978,24 +966,59 @@ InstallTheme packageRefId=$(getPackageRefId "${packagesidentity}" "${themeName}") - buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "/Extra/Themes" + buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "/EXTRAROOTDIR/Extra/Themes" addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${themeName}" done # End build theme packages# End build Extras package -# build pre install package - echo "================= Pre =================" +# build standard package +echo "================ standard ================" packagesidentity="${chameleon_package_identity}" - choiceId="Pre" + choiceId="Standard" + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources + local yamlFile="Resources/chameleon_options.yaml" + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ + --subst="YAML_FILE=${yamlFile}" CleanOptions + generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile" + cp -f ${PKGROOT}/Scripts/Main/${choiceId}postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall + ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" + addChoice --group="Chameleon" --start-selected="true" --selected="!choices['EFI'].selected" \ + --pkg-refs="$packageRefId" "${choiceId}" +# End build standard package + +# build efi package +echo "================== EFI ==================" + packagesidentity="${chameleon_package_identity}" + choiceId="EFI" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources local yamlFile="Resources/chameleon_options.yaml" addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \ - --subst="YAML_FILE=${yamlFile}" ${choiceId} + --subst="YAML_FILE=${yamlFile}" CleanOptions generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile" + cp -f ${PKGROOT}/Scripts/Main/ESPpostinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall + ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile + + packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" + addChoice --group="Chameleon" --enabled="systemHasGPT()" --start-selected="false" \ + --selected="!choices['Standard'].selected" \ + --pkg-refs="$packageRefId" "${choiceId}" +# End build efi package + +# build pre install package + echo "================= Pre =================" + packagesidentity="${chameleon_package_identity}" + choiceId="Pre" + + packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") + mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root + addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId} + buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" # End build pre install package # build post install package @@ -1004,7 +1027,6 @@ choiceId="Post" mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId} - cp -f ${PKGROOT}/Scripts/Sub/UnMountEFIvolumes.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}") buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/" @@ -1107,6 +1129,7 @@ } generateChoices() { + for (( idx=1; idx < ${#choice_key[*]} ; idx++)); do local choiceId=${choice_key[$idx]} local choiceOptions=${choice_options[$idx]} @@ -1172,6 +1195,7 @@ local start_indent_level=2 echo -e "\n\t" >> "${PKG_BUILD_DIR}/${packagename}/Distribution" + for main_choice in ${choice_group_items[0]};do generateOutlineChoices $main_choice $start_indent_level >> "${PKG_BUILD_DIR}/${packagename}/Distribution" done Index: trunk/package/po/mk.po =================================================================== --- trunk/package/po/mk.po (revision 2568) +++ trunk/package/po/mk.po (revision 2569) @@ -609,7 +609,7 @@ #: Resources/templates/Localizable.strings:126 #, no-wrap msgid "PrivateData=No" -msgstr "" +msgstr "PrivateData=No" #. type: "PrivateData_description" #: Resources/templates/Localizable.strings:127 @@ -621,7 +621,7 @@ #: Resources/templates/Localizable.strings:131 #, no-wrap msgid "USBBusFix=Yes" -msgstr "" +msgstr "USBBusFix=Yes" #. type: "USBBusFix_description" #: Resources/templates/Localizable.strings:132 @@ -631,10 +631,9 @@ #. type: "USBLegacyOff_title" #: Resources/templates/Localizable.strings:134 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "USBLegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "USBLegacyOff=Yes" #. type: "USBLegacyOff_description" #: Resources/templates/Localizable.strings:135 @@ -644,10 +643,9 @@ #. type: "XHCILegacyOff_title" #: Resources/templates/Localizable.strings:137 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "XHCILegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "XHCILegacyOff=Yes" #. type: "XHCILegacyOff_description" #: Resources/templates/Localizable.strings:138 Index: trunk/package/po/nl.po =================================================================== --- trunk/package/po/nl.po (revision 2568) +++ trunk/package/po/nl.po (revision 2569) @@ -628,7 +628,7 @@ #: Resources/templates/Localizable.strings:126 #, no-wrap msgid "PrivateData=No" -msgstr "" +msgstr "PrivateData=No" #. type: "PrivateData_description" #: Resources/templates/Localizable.strings:127 @@ -640,7 +640,7 @@ #: Resources/templates/Localizable.strings:131 #, no-wrap msgid "USBBusFix=Yes" -msgstr "" +msgstr "USBBusFix=Yes" #. type: "USBBusFix_description" #: Resources/templates/Localizable.strings:132 @@ -650,10 +650,9 @@ #. type: "USBLegacyOff_title" #: Resources/templates/Localizable.strings:134 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "USBLegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "USBLegacyOff=Yes" #. type: "USBLegacyOff_description" #: Resources/templates/Localizable.strings:135 @@ -663,10 +662,9 @@ #. type: "XHCILegacyOff_title" #: Resources/templates/Localizable.strings:137 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "XHCILegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "XHCILegacyOff=Yes" #. type: "XHCILegacyOff_description" #: Resources/templates/Localizable.strings:138 Index: trunk/package/po/hr.po =================================================================== --- trunk/package/po/hr.po (revision 2568) +++ trunk/package/po/hr.po (revision 2569) @@ -610,7 +610,7 @@ #: Resources/templates/Localizable.strings:126 #, no-wrap msgid "PrivateData=No" -msgstr "" +msgstr "PrivateData=No" #. type: "PrivateData_description" #: Resources/templates/Localizable.strings:127 @@ -622,7 +622,7 @@ #: Resources/templates/Localizable.strings:131 #, no-wrap msgid "USBBusFix=Yes" -msgstr "" +msgstr "USBBusFix=Yes" #. type: "USBBusFix_description" #: Resources/templates/Localizable.strings:132 @@ -632,10 +632,9 @@ #. type: "USBLegacyOff_title" #: Resources/templates/Localizable.strings:134 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "USBLegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "USBLegacyOff=Yes" #. type: "USBLegacyOff_description" #: Resources/templates/Localizable.strings:135 @@ -645,10 +644,9 @@ #. type: "XHCILegacyOff_title" #: Resources/templates/Localizable.strings:137 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "XHCILegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "XHCILegacyOff=Yes" #. type: "XHCILegacyOff_description" #: Resources/templates/Localizable.strings:138 Index: trunk/package/po/pl.po =================================================================== --- trunk/package/po/pl.po (revision 2568) +++ trunk/package/po/pl.po (revision 2569) @@ -614,7 +614,7 @@ #: Resources/templates/Localizable.strings:126 #, no-wrap msgid "PrivateData=No" -msgstr "" +msgstr "PrivateData=No" #. type: "PrivateData_description" #: Resources/templates/Localizable.strings:127 @@ -626,7 +626,7 @@ #: Resources/templates/Localizable.strings:131 #, no-wrap msgid "USBBusFix=Yes" -msgstr "" +msgstr "USBBusFix=Yes" #. type: "USBBusFix_description" #: Resources/templates/Localizable.strings:132 @@ -636,10 +636,9 @@ #. type: "USBLegacyOff_title" #: Resources/templates/Localizable.strings:134 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "USBLegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "USBLegacyOff=Yes" #. type: "USBLegacyOff_description" #: Resources/templates/Localizable.strings:135 @@ -649,10 +648,9 @@ #. type: "XHCILegacyOff_title" #: Resources/templates/Localizable.strings:137 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "XHCILegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "XHCILegacyOff=Yes" #. type: "XHCILegacyOff_description" #: Resources/templates/Localizable.strings:138 Index: trunk/package/po/hu.po =================================================================== --- trunk/package/po/hu.po (revision 2568) +++ trunk/package/po/hu.po (revision 2569) @@ -603,7 +603,7 @@ #: Resources/templates/Localizable.strings:126 #, no-wrap msgid "PrivateData=No" -msgstr "" +msgstr "PrivateData=No" #. type: "PrivateData_description" #: Resources/templates/Localizable.strings:127 @@ -615,7 +615,7 @@ #: Resources/templates/Localizable.strings:131 #, no-wrap msgid "USBBusFix=Yes" -msgstr "" +msgstr "USBBusFix=Yes" #. type: "USBBusFix_description" #: Resources/templates/Localizable.strings:132 @@ -625,10 +625,9 @@ #. type: "USBLegacyOff_title" #: Resources/templates/Localizable.strings:134 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "USBLegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "USBLegacyOff=Yes" #. type: "USBLegacyOff_description" #: Resources/templates/Localizable.strings:135 @@ -638,10 +637,9 @@ #. type: "XHCILegacyOff_title" #: Resources/templates/Localizable.strings:137 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "XHCILegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "XHCILegacyOff=Yes" #. type: "XHCILegacyOff_description" #: Resources/templates/Localizable.strings:138 Index: trunk/package/po/ca.po =================================================================== --- trunk/package/po/ca.po (revision 2568) +++ trunk/package/po/ca.po (revision 2569) @@ -612,7 +612,7 @@ #: Resources/templates/Localizable.strings:126 #, no-wrap msgid "PrivateData=No" -msgstr "" +msgstr "PrivateData=No" #. type: "PrivateData_description" #: Resources/templates/Localizable.strings:127 @@ -624,7 +624,7 @@ #: Resources/templates/Localizable.strings:131 #, no-wrap msgid "USBBusFix=Yes" -msgstr "" +msgstr "USBBusFix=Yes" #. type: "USBBusFix_description" #: Resources/templates/Localizable.strings:132 @@ -634,10 +634,9 @@ #. type: "USBLegacyOff_title" #: Resources/templates/Localizable.strings:134 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "USBLegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "USBLegacyOff=Yes" #. type: "USBLegacyOff_description" #: Resources/templates/Localizable.strings:135 @@ -647,10 +646,9 @@ #. type: "XHCILegacyOff_title" #: Resources/templates/Localizable.strings:137 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "XHCILegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "XHCILegacyOff=Yes" #. type: "XHCILegacyOff_description" #: Resources/templates/Localizable.strings:138 Index: trunk/package/po/sr.po =================================================================== --- trunk/package/po/sr.po (revision 2568) +++ trunk/package/po/sr.po (revision 2569) @@ -608,7 +608,7 @@ #: Resources/templates/Localizable.strings:126 #, no-wrap msgid "PrivateData=No" -msgstr "" +msgstr "PrivateData=No" #. type: "PrivateData_description" #: Resources/templates/Localizable.strings:127 @@ -620,7 +620,7 @@ #: Resources/templates/Localizable.strings:131 #, no-wrap msgid "USBBusFix=Yes" -msgstr "" +msgstr "USBBusFix=Yes" #. type: "USBBusFix_description" #: Resources/templates/Localizable.strings:132 @@ -630,10 +630,9 @@ #. type: "USBLegacyOff_title" #: Resources/templates/Localizable.strings:134 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "USBLegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "USBLegacyOff=Yes" #. type: "USBLegacyOff_description" #: Resources/templates/Localizable.strings:135 @@ -643,10 +642,9 @@ #. type: "XHCILegacyOff_title" #: Resources/templates/Localizable.strings:137 -#, fuzzy, no-wrap -#| msgid "LegacyLogo=Yes" +#, no-wrap msgid "XHCILegacyOff=Yes" -msgstr "LegacyLogo=Yes" +msgstr "XHCILegacyOff=Yes" #. type: "XHCILegacyOff_description" #: Resources/templates/Localizable.strings:138