Index: branches/iFabio/trunk/package/buildpkg =================================================================== --- branches/iFabio/trunk/package/buildpkg (revision 185) +++ branches/iFabio/trunk/package/buildpkg (revision 186) @@ -42,22 +42,23 @@ ((xmlindent++)) # build core package - mkdir -p ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/boot ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/i386 - cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/i386 - fixperms "${1}/Core/Root/i386" - cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/i386 - cp -f ${pkgroot}/fdisk ${1}/Core/Root/i386 - local coresize=$( du -hkc "${1}/Core/Root/i386" | tail -n1 | awk {'print $1'} ) + mkdir -p ${1}/Core/Root/usr/sbin + mkdir -p ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386 + cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386 + fixperms "${1}/Core/Root/" + cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/usr/sbin + cp -f ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin + local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} ) echo "Building core package" - buildpackage "${1}/Core" "/binaries" "0" "start_visible=\"false\" start_selected=\"true\"" + buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" # End build core package # build standard package @@ -66,7 +67,7 @@ cp -f ${pkgroot}/Scripts/Standard/postinstall ${1}/Standard/Scripts ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile echo "Building boot0 package" - buildpackage "${1}/Standard" "/binaries" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['noboot'])\"" + buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['noboot'])\"" # End build standard package # build standard package with boot0hfs @@ -75,7 +76,7 @@ cp -f ${pkgroot}/Scripts/Standardhfs/postinstall ${1}/Standardhfs/Scripts ditto --arch i386 `which SetFile` ${1}/Standardhfs/Scripts/Tools/SetFile echo "Building boot0hfs package" - buildpackage "${1}/Standardhfs" "/binaries" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['EnhancedHFS']) && exclusive(choices['Standard']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['noboot'])\"" + buildpackage "${1}/Standardhfs" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['EnhancedHFS']) && exclusive(choices['Standard']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['noboot'])\"" # End build standard package with boot0hfs # build efi fat32 package @@ -84,7 +85,7 @@ cp -f ${pkgroot}/Scripts/FAT/* ${1}/EnhancedFAT/Scripts ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile echo "Building efi fat32 package" - buildpackage "${1}/EnhancedFAT" "/binaries" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedHFS']) && exclusive(choices['noboot'])\"" + buildpackage "${1}/EnhancedFAT" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedHFS']) && exclusive(choices['noboot'])\"" # End build efi fat32 package # build efi hfs package @@ -93,13 +94,13 @@ cp -f ${pkgroot}/Scripts/HFS/* ${1}/EnhancedHFS/Scripts ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile echo "Building efi hfs package" - buildpackage "${1}/EnhancedHFS" "/binaries" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['noboot'])\"" + buildpackage "${1}/EnhancedHFS" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['noboot'])\"" # End build efi hfs package # build reset choice package mkdir -p ${1}/noboot/Root # echo "Building reset choice package" - buildpackage "${1}/noboot" "/binaries" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['EnhancedHFS'])\"" + buildpackage "${1}/noboot" "/" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['Standardhfs']) && exclusive(choices['EnhancedFAT']) && exclusive(choices['EnhancedHFS'])\"" # End build reset choice package ((xmlindent--)) @@ -123,7 +124,7 @@ buildpackage "${1}/${theme}" "/Extra/Themes" "" "start_selected=\"false\"" rm -R -f "${1}/${i##*/}" done - echo "Building themes package" + echo "Building themes package" ((xmlindent--)) outline[$((outlinecount++))]="${indent[$xmlindent]}\t" # End build theme packages @@ -140,7 +141,7 @@ mkdir -p "${1}/${options[$i]##*/}/Scripts" ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall" echo "Building ${options[$i]##*/} package" - buildpackage "${1}/${options[$i]##*/}" "/binaries" "" "start_selected=\"false\"" + buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\"" rm -R -f "${1}/${i##*/}" done # build resolution packages @@ -154,7 +155,7 @@ mkdir -p "${1}/${resolutions[$y]##*/}/Root" mkdir -p "${1}/${resolutions[$y]##*/}/Scripts" ditto --noextattr --noqtn "${resolutions[$y]}/postinstall" "${1}/${resolutions[$y]##*/}/Scripts/postinstall" - buildpackage "${1}/${resolutions[$y]##*/}" "/binaries" "" "start_selected=\"false\"" + buildpackage "${1}/${resolutions[$y]##*/}" "/" "" "start_selected=\"false\"" rm -R -f "${1}/${y##*/}" done echo "Building Resolution package" @@ -244,7 +245,7 @@ mkdir -p ${1}/Post/Scripts cp -f ${pkgroot}/Scripts/Post/postinstall ${1}/Post/Scripts ditto --arch i386 `which SetFile` ${1}/Post/Scripts/Tools/SetFile - buildpackage "${1}/Post" "/binaries" "" "start_visible=\"false\" start_selected=\"true\"" + buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" echo "Building post package" # End post install package @@ -349,6 +350,7 @@ popd >/dev/null done + ditto --noextattr --noqtn "${pkgroot}/Icon.icns" "${1%/*}/${packagename// /}-${version}-r${revision}-Standard.pkg" ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution" ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources" @@ -370,7 +372,7 @@ perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f` perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f` -# place for info about the kind of pkg standard or advanced +# place for info about the kind of pkg standard or advanced or dummy(language test) perl -i -p -e "s/%PKGTYPE%/Standard pkg installer/g" `find "${1}/${packagename}/Resources" -type f` # end place for info @@ -392,9 +394,8 @@ # cp -R -f "${1}/${packagename}/Resources" ${1%/*}/Resources # End place for copy Resouces + echo "Finish! $packagename Install Package (Standard) v${version%%-*} $stage r$revision was created" + } main "${1}" "${2}" "${3}" "${4}" "${5}" -# Building Icon - -echo "Finish! $packagename Install Package (Standard) v${version%%-*} $stage r$revision was created" \ No newline at end of file Index: branches/iFabio/trunk/package/Scripts/HFS/postinstall =================================================================== --- branches/iFabio/trunk/package/Scripts/HFS/postinstall (revision 185) +++ branches/iFabio/trunk/package/Scripts/HFS/postinstall (revision 186) @@ -1,8 +1,8 @@ #!/bin/bash -diskloader="/i386/boot0" -partitionloader="/i386/boot1h" -filesystemloader="/i386/boot" +diskloader="/usr/standalone/i386/boot0" +partitionloader="/usr/standalone/i386/boot1h" +filesystemloader="/usr/standalone/i386/boot" bootervolumename="EFI" booterextensions="Extra/Extensions" Index: branches/iFabio/trunk/package/Scripts/Standard/postinstall =================================================================== --- branches/iFabio/trunk/package/Scripts/Standard/postinstall (revision 185) +++ branches/iFabio/trunk/package/Scripts/Standard/postinstall (revision 186) @@ -1,32 +1,230 @@ -#!/usr/bin/perl +#!/bin/bash -$destino = $ARGV[1]; -$destino =~ s/ /\\ /g; -$volume = $ARGV[2]; -my %mapa; -open (MOUNT, "mount|"); -while () { - chomp; - $line = $_; - if ($line =~ /^([^ ]+) on ([^(]+) \([^)]*\)$/) { - $mapa{$2}=$1; - } +diskloader="boot0" +partitionloader="boot1h" +filesystemloader="boot" + +diskmicrocodetype[1]="GRUB,47525542" +diskmicrocodetype[2]="LILO,4c494c4f" + +start () +{ +# 1 volume + +bootvolume="${@}" +echo "Volume is $bootvolume" +bootresources="${0%/*}" +echo "$bootresources" + +if [ -z "${bootvolume}" ]; then + echo + echo "Cannot find the volume. Exiting." + echo + exit +fi + +bootdev=$( df "${bootvolume}" | sed -n '2p' | awk '{print $1}' ) +bootrdev=${bootdev/disk/rdisk} + +if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then + echo + echo "ERROR Volume does not use slices." + echo + exit +fi + +bootdisk=${bootdev%s*} +bootrdisk=${bootdisk/disk/rdisk} +bootslice=${bootdev#*disk*s} + +echo "Volume is ${bootvolume}" +echo "Volume device is ${bootdev}" +echo "Volume raw device is ${bootrdev}" +echo "Volume slice is ${bootslice}" +echo "Disk device is ${bootdisk}" +echo "Disk raw device is ${bootrdisk}" +echo "Disk loader is ${diskloader}" +echo "Partition loader is ${partitionloader}" +echo "Filesystem loader is ${filesystemloader}" +echo "Boot Resources is ${bootresources}" + } -close (MOUNT); -if ($mapa{$volume}) { - if ($mapa{$volume} =~ /^\/dev\/(disk\d)s(\d)$/) { - $disk = $1; - $partition = $2; - $volume =~ s/ /\\ /g; - system ($destino."/i386/fdisk -f ".$destino."/i386/boot0 -u -y /dev/r".$disk); - system ("dd if=".$destino."/i386/boot1h of=/dev/r".$disk."s".$partition); - system ("cp ".$destino."/i386/boot ".$volume); - open (PIPE, "|fdisk -e /dev/".$disk."|"); - print PIPE "f ".$partition."\n"; - print PIPE "write\n"; - print PIPE "y\n"; - print PIPE "exit\n"; - } -} \ No newline at end of file +checkdiskmicrocodetype () +{ +diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + +diskmicrocodetypecounter=0 +while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do + diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 )) + diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,} + if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then + echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found." + fi +done +} + +checkdiskmicrocode () +{ +# 1 action ( check or set ) + +diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) +diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 ) + +if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then + if [ "${1}" = "set" ]; then + echo "No disk microcode found. Updating." + diskupdate=true + else + echo "No disk microcode found." + fi +else + if [ ${1} = set ]; then + echo "Disk microcode found. Preserving." + else + echo "Disk microcode found." + fi + echo "Disk microcode MD5 is ${diskmicrocodemd5}" +fi +} + +checkdisksignature () +{ +disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + +if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then + echo "No disk signature found." +else + echo "Disk signature found." + echo "Disk signature is 0x${disksignature}" +fi +} + +checkpartitionbootcode () +{ +# 1 action ( check or set ) + +partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) +partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + +if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then + if [ "${1}" = "set" ]; then + echo "No partition bootcode found. Updating." + else + echo "No partition bootcode found." + fi +else + if [ "${1}" = "set" ]; then + echo "Partition bootcode found. Overwriting." + else + echo "Partition bootcode found." + fi + if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then + partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 ) + else + partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 ) + echo "Partition bootcode is dual sector." + fi + echo "Partition bootcode MD5 is ${partitionbootcodemd5}" +fi +} + +checkpartitionactive () +{ +partitionactive=$( fdisk440 -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}') + +if [ -n "${partitionactive}" ]; then + echo "Partition flagged active is ${partitionactive}" +else + echo "No partition flagged active." +fi + +} + +start ${3} + +#partitiontable=$( diskutil list ${bootdisk} | sed -n '3p' | awk '{print $2}' ) +#[ "${partitiontable}" = "GUID_partition_scheme" ] && echo "GPT found." +#[ "${partitiontable}" = "FDisk_partition_scheme" ] && echo "MBR found." +#[ "${partitiontable}" = "Apple_partition_scheme" ] && echo "APT found." && exit + +partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) +if [ "${partitiontable:0:16}" == "4546492050415254" ]; then + partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + if [ "${partitiontable:8:2}" == "ee" ]; then + if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then + partitiontable="GPT" + else + partitiontable="GPT/MBR" + fi + fi +else + partitiontable="MBR" +fi + +echo "${partitiontable} found." + +diskupdate=false + +checkdiskmicrocodetype +checkdiskmicrocode set +checkdisksignature +checkpartitionbootcode set +checkpartitionactive + +if ${diskupdate}; then + echo "Executing command: fdisk -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}" + fdisk -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk} +fi + +echo "Executing command: dd if=/usr/standalone/i386/${partitionloader} of=${bootrdev}" +dd if="${bootvolume}/usr/standalone/i386/${partitionloader}" of=${bootrdev} + +echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}" +cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}" + +echo "Executing command: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}" +"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}" + +# If table is GPT make the first partition active (BadAxe compatibility). +#[ "${partitiontable}" = "GPT" ] && bootslice=1 +fdisk440 -e ${bootdisk} <<-MAKEACTIVE +print +flag ${bootslice} +write +y +quit +MAKEACTIVE + +checkdiskmicrocode check +checkdisksignature +checkpartitionbootcode check +checkpartitionactive + +# Check efi partition +if [ -d /Volumes/EFI ]; then + umount -f /Volumes/EFI + rm -R -f /Volumes/EFI +fi + +if [ -d "${bootvolume}/Extra/Extensions" ]; then +# echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions" + mkdir -p "${bootvolume}/ExtraBackup" + cp -f -R "${bootvolume}/Extra" "${bootvolume}/ExtraBackup" + rm -f -R "${bootvolume}/Extra" +fi +# unpack any existing Extensions.mkext already on the booter volume +if [ -f "${2}/ExtraBackup/Extensions.mkext" ]; then + echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/ExtraBackup/Extensions.mkext" + mkextunpack -d "${2}/.Chameleon/Extra/Extensions" "${2}/.Chameleon/ExtraBackup/Extensions.mkext" + echo "Executing command: rm -R -f ${2}/ExtraBackup/Extensions.mkext" + rm -R -f "${2}/ExtraBackup/Extensions.mkext" +fi + +# setup link for extras +#[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon" +#echo "Executing command: ln -s . ${2}/.Chameleon" +#ln -s "${2}" "${2}/.Chameleon" + +exit Index: branches/iFabio/trunk/package/Scripts/Standardhfs/postinstall =================================================================== --- branches/iFabio/trunk/package/Scripts/Standardhfs/postinstall (revision 185) +++ branches/iFabio/trunk/package/Scripts/Standardhfs/postinstall (revision 186) @@ -1,27 +1,230 @@ -#!/usr/bin/perl +#!/bin/bash -$destino = $ARGV[1]; -$destino =~ s/ /\\ /g; -$volume = $ARGV[2]; -my %mapa; -open (MOUNT, "mount|"); -while () { - chomp; - $line = $_; - if ($line =~ /^([^ ]+) on ([^(]+) \([^)]*\)$/) { - $mapa{$2}=$1; - } +diskloader="boot0hfs" +partitionloader="boot1h" +filesystemloader="boot" + +diskmicrocodetype[1]="GRUB,47525542" +diskmicrocodetype[2]="LILO,4c494c4f" + +start () +{ +# 1 volume + +bootvolume="${@}" +echo "Volume is $bootvolume" +bootresources="${0%/*}" +echo "$bootresources" + +if [ -z "${bootvolume}" ]; then + echo + echo "Cannot find the volume. Exiting." + echo + exit +fi + +bootdev=$( df "${bootvolume}" | sed -n '2p' | awk '{print $1}' ) +bootrdev=${bootdev/disk/rdisk} + +if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then + echo + echo "ERROR Volume does not use slices." + echo + exit +fi + +bootdisk=${bootdev%s*} +bootrdisk=${bootdisk/disk/rdisk} +bootslice=${bootdev#*disk*s} + +echo "Volume is ${bootvolume}" +echo "Volume device is ${bootdev}" +echo "Volume raw device is ${bootrdev}" +echo "Volume slice is ${bootslice}" +echo "Disk device is ${bootdisk}" +echo "Disk raw device is ${bootrdisk}" +echo "Disk loader is ${diskloader}" +echo "Partition loader is ${partitionloader}" +echo "Filesystem loader is ${filesystemloader}" +echo "Boot Resources is ${bootresources}" + } -close (MOUNT); -if ($mapa{$volume}) { - if ($mapa{$volume} =~ /^\/dev\/(disk\d)s(\d)$/) { - $disk = $1; - $partition = $2; - $volume =~ s/ /\\ /g; - system ($destino."/i386/fdisk440 -f ".$destino."/i386/boot0hfs -u -y /dev/r".$disk); - system ("dd if=".$destino."/i386/boot1h of=/dev/r".$disk."s".$partition); - system ("cp ".$destino."/i386/boot ".$volume); - } -} \ No newline at end of file +checkdiskmicrocodetype () +{ +diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + +diskmicrocodetypecounter=0 +while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do + diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 )) + diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,} + if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then + echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found." + fi +done +} + +checkdiskmicrocode () +{ +# 1 action ( check or set ) + +diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) +diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 ) + +if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then + if [ "${1}" = "set" ]; then + echo "No disk microcode found. Updating." + diskupdate=true + else + echo "No disk microcode found." + fi +else + if [ ${1} = set ]; then + echo "Disk microcode found. Preserving." + else + echo "Disk microcode found." + fi + echo "Disk microcode MD5 is ${diskmicrocodemd5}" +fi +} + +checkdisksignature () +{ +disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + +if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then + echo "No disk signature found." +else + echo "Disk signature found." + echo "Disk signature is 0x${disksignature}" +fi +} + +checkpartitionbootcode () +{ +# 1 action ( check or set ) + +partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) +partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + +if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then + if [ "${1}" = "set" ]; then + echo "No partition bootcode found. Updating." + else + echo "No partition bootcode found." + fi +else + if [ "${1}" = "set" ]; then + echo "Partition bootcode found. Overwriting." + else + echo "Partition bootcode found." + fi + if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then + partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 ) + else + partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 ) + echo "Partition bootcode is dual sector." + fi + echo "Partition bootcode MD5 is ${partitionbootcodemd5}" +fi +} + +checkpartitionactive () +{ +partitionactive=$( fdisk440 -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}') + +if [ -n "${partitionactive}" ]; then + echo "Partition flagged active is ${partitionactive}" +else + echo "No partition flagged active." +fi + +} + +start ${3} + +#partitiontable=$( diskutil list ${bootdisk} | sed -n '3p' | awk '{print $2}' ) +#[ "${partitiontable}" = "GUID_partition_scheme" ] && echo "GPT found." +#[ "${partitiontable}" = "FDisk_partition_scheme" ] && echo "MBR found." +#[ "${partitiontable}" = "Apple_partition_scheme" ] && echo "APT found." && exit + +partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) +if [ "${partitiontable:0:16}" == "4546492050415254" ]; then + partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + if [ "${partitiontable:8:2}" == "ee" ]; then + if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then + partitiontable="GPT" + else + partitiontable="GPT/MBR" + fi + fi +else + partitiontable="MBR" +fi + +echo "${partitiontable} found." + +diskupdate=false + +checkdiskmicrocodetype +checkdiskmicrocode set +checkdisksignature +checkpartitionbootcode set +checkpartitionactive + +if ${diskupdate}; then + echo "Executing command: fdisk -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}" + fdisk -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk} +fi + +echo "Executing command: dd if=/usr/standalone/i386/${partitionloader} of=${bootrdev}" +dd if="${bootvolume}/usr/standalone/i386/${partitionloader}" of=${bootrdev} + +echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}" +cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}" + +echo "Executing command: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}" +"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}" + +# If table is GPT make the first partition active (BadAxe compatibility). +[ "${partitiontable}" = "GPT" ] && bootslice=1 +fdisk440 -e ${bootdisk} <<-MAKEACTIVE +print +flag ${bootslice} +write +y +quit +MAKEACTIVE + +checkdiskmicrocode check +checkdisksignature +checkpartitionbootcode check +checkpartitionactive + +# Check efi partition +if [ -d /Volumes/EFI ]; then + umount -f /Volumes/EFI + rm -R -f /Volumes/EFI +fi + +if ! [ -d "${bootvolume}/Extra/Extensions" ]; then +# echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions" + mkdir -p "${bootvolume}/ExtraBackup" + cp -f -R "${bootvolume}/Extra" "${bootvolume}/ExtraBackup" + rm -f -R "${bootvolume}/Extra" +fi +# unpack any existing Extensions.mkext already on the booter volume +if [ -f "${2}/ExtraBackup/Extensions.mkext" ]; then + echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/ExtraBackup/Extensions.mkext" + mkextunpack -d "${2}/.Chameleon/Extra/Extensions" "${2}/.Chameleon/ExtraBackup/Extensions.mkext" + echo "Executing command: rm -R -f ${2}/ExtraBackup/Extensions.mkext" + rm -R -f "${2}/ExtraBackup/Extensions.mkext" +fi + +# setup link for extras +#[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon" +#echo "Executing command: ln -s . ${2}/.Chameleon" +#ln -s "${2}" "${2}/.Chameleon" + +exit Index: branches/iFabio/trunk/package/Scripts/Post/postinstall =================================================================== --- branches/iFabio/trunk/package/Scripts/Post/postinstall (revision 185) +++ branches/iFabio/trunk/package/Scripts/Post/postinstall (revision 186) @@ -1,11 +1,44 @@ -#! /bin/sh +#!/bin/bash -#SCRIPT="Chameleon postinstall Script" +temp="/private/tmp/Chameleon" -targetVolume="$3" +#source com.apple.boot.plist +if ! [ -f "${2}/.Chameleon/Extra/com.apple.Boot.plist" ]; then + if [ -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" ]; then + cp -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" "${2}/.Chameleon/Extra" + fi +fi -rm -rf "$3/binaries" +# fix kext permissions +find "${2}/.Chameleon/Extra/Extensions" -type f -exec chmod 644 {} \; +find "${2}/.Chameleon/Extra/Extensions" -type d -exec chmod 755 {} \; +chown -R 0:0 "${2}/.Chameleon/Extra/Extensions" -echo "Done..." +# build mkext for extras +[ -d "${temp}" ] && rm -R -f "${temp}" +mkdir -p "${temp}/Extensions" +ditto --noextattr --noqtn --arch i386 "${2}/.Chameleon/Extra/Extensions" "${temp}/Extensions" +find "${temp}" -type f -exec chmod 644 {} \; +find "${temp}" -type d -exec chmod 755 {} \; +chown -R 0:0 "${temp}" +kextcache -m "${temp}/Extensions.mkext" "${temp}/Extensions" +cp -f "${temp}/Extensions.mkext" "${2}/.Chameleon/Extra" +#cp -f "${temp}/Extensions.mkext" "${2}/Extra" +rm -f -R "${temp}" +# Check efi partition +if [ -d /Volumes/EFI ]; then + +# remove link for extras install +#unlink -r "${2}/.Chameleon" + + cp -R -f "${2}/.Chameleon/Extra" /Volumes/EFI/ + umount -f /Volumes/EFI + rm -R -f /Volumes/EFI + rm -R -f "${2}/.Chameleon" +fi + + cp -R -f "${2}/.Chameleon/Extra" "${2}/" + rm -R -f "${2}/.Chameleon" + exit 0 Index: branches/iFabio/trunk/package/Scripts/FAT/postinstall =================================================================== --- branches/iFabio/trunk/package/Scripts/FAT/postinstall (revision 185) +++ branches/iFabio/trunk/package/Scripts/FAT/postinstall (revision 186) @@ -1,8 +1,8 @@ #!/bin/bash -diskloader="/i386/boot0" -partitionloader="/i386/boot1f32" -filesystemloader="/i386/boot" +diskloader="/usr/standalone/i386/boot0" +partitionloader="/usr/standalone/i386/boot1f32" +filesystemloader="/usr/standalone/i386/boot" bootervolumename="EFI" booterextensions="Extra/Extensions" Property changes on: branches/iFabio/trunk/package/Resources/Italian.lproj ___________________________________________________________________ Added: svn:ignore + Welcome.rtfd Index: branches/iFabio/trunk/package/Resources/background.tiff =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/iFabio/trunk/package/Resources/German.lproj/Localizable.strings =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/iFabio/trunk/revision =================================================================== --- branches/iFabio/trunk/revision (revision 185) +++ branches/iFabio/trunk/revision (revision 186) @@ -1 +1 @@ -184 \ No newline at end of file +184:185 \ No newline at end of file