Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/blackosx/trunk/PackageBuilder/Main_Package_Elements/Scripts/MainStandardPostinstall.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "Main Standard Post-Install Script"
5echo "*********************************"
6echo "-----------------------------------------------"
7echo ""
8
9# Find location of this script in the package installer
10# so we know where all the other scripts are located.
11MYLOCATION="${PWD}/${BASH_ARGV[0]}"
12export MYLOCATION="${MYLOCATION%/*}"
13scriptDir=$MYLOCATION
14
15
16#echo "==============================================="
17#echo "Apple Installer Package Variables"
18#echo "*********************************"
19#echo "DEBUG: $ 1 = Full path to the installation package the installer app is processing: " $1
20#echo "DEBUG: $ 2 = Full path to the installation destination: " $2
21#echo "DEBUG: $ 3 = Installation volume (mountpoint) to receive the payload: " $3
22#echo "DEBUG: $ 4 = Root directory for the system: " $4
23#echo "DEBUG: Script Name: " $SCRIPT_NAME
24#echo "DEBUG: Package Path: " $PACKAGE_PATH
25#echo "DEBUG: Installer Temp: " $INSTALLER_TEMP
26#echo "DEBUG: Full path to the temp directory containing the operation executable: " $RECEIPT_PATH
27#echo "-----------------------------------------------"
28#echo ""
29
30
31
32# Initialise Script Globals
33
34stage0Loader="boot0"
35stage0LoaderDualBoot="boot0hfs"
36stage1LoaderHFS="boot1h"
37stage1LoaderFAT="boot1f32"
38stage2Loader="boot"
39
40targetVolume=$3
41targetDevice=$( df "${targetVolume}" | sed -n '2p' | awk '{print $1}' )
42targetDeviceRaw=${targetDevice/disk/rdisk}
43targetDisk=${targetDevice%s*}
44targetDiskRaw=${targetDisk/disk/rdisk}
45targetSlice=${targetDevice#*disk*s}
46
47
48
49echo "==============================================="
50echo "DEBUG: display script variables"
51echo "*******************************"
52
53echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"
54echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot}"
55echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"
56echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"
57echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}"
58echo "DEBUG: targetVolume: Volume is ${targetVolume}"
59echo "DEBUG: targetDevice: Volume device is ${targetDevice}"
60echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}"
61echo "DEBUG: targetDisk: Disk device is ${targetDisk}"
62echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"
63echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"
64echo "DEBUG: targetResources: Boot Resources is ${targetResources}"
65echo "-----------------------------------------------"
66echo ""
67
68
69# Double check we can see the selected partition and it's of the right type
70# if not the following script returns to indicate failure.
71
72"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDevice}"
73returnValue=$?
74if [ ${returnValue}=0 ]; then
75# OK to proceed
76
77
78# Does a GRUB or Linux loader already exist in the disk's MBR?
79
80"$scriptDir"CheckDiskMicrocodeType.sh "${targetDisk}"
81returnValue=$?
82if [ ${returnValue} = 0 ]; then
83# OK to proceed
84
85
86# check for a 4-byte Windows disk signature in the disk's MBR.
87# the following script returns 1 if a Windows disk signature exists, and 0 if not.
88
89"$scriptDir"CheckDiskSignature.sh "${targetDisk}"
90diskSigCheck=$?
91
92
93# check for existing bootloaders in the disk's MBR
94# and find out if we can write the Chameleon boot files.
95# the following script returns 1 if we can proceed
96# with writing the boot files, and 0 for not.
97
98"$scriptDir"CheckDiskMicrocode.sh "${targetDisk}" "${diskSigCheck}"
99diskupdate=$?
100
101
102# Cancelled this as all it does is read the GPTdiskProtectiveMBR
103# and the GPTdiskGPTHeader and look to see if they're blank
104
105
106#"$scriptDir"FindPartitionBootcode.sh "${targetDeviceRaw}"
107
108
109# check the format of the selected partition.
110# the following script returns 1 if HFS
111# the following script returns 2 if MSDOS
112# the following script returns 0 if nothing
113
114"$scriptDir"CheckFormat.sh "${targetDevice}"
115espformat=$?
116
117
118# check the partition scheme used for the selected disk.
119# the following script returns 1 if GPT
120# the following script returns 2 if GPT/MBR
121# the following script returns 3 if MBR
122# the following script returns 0 if nothing
123
124"$scriptDir"CheckPartitionScheme.sh "${targetDisk}"
125partitionTable=$?
126if [ ${partitionTable} = 3 ]; then
127# If MBR partition scheme then check for FAT16 or FAT32
128
129# the following script returns 1 if FAT16
130# the following script returns 2 if FAT32
131# the following script returns 0 if nothing
132
133"$scriptDir"CheckFatType.sh "${targetDeviceRaw}"
134fatType=$?
135fi
136
137if [ "${fatType}" = 1 ] && [ "${partitionTable}" = 3 ]; then
138echo "ERROR: - Can't install to a device using FAT16"
139# Write error to Chameleon_Error_Log file
140"$scriptDir"WriteInstallerLog.sh "${3}" "${3} is a FAT16 device - Chameleon boot files not written"
141else
142# Continue if the selected device is not a FAT16 format device
143
144# If diskupdate is flagged as 1 then the stage 0 loader can be written to the MBR
145if [ ${diskupdate} = 1 ]; then
146"$scriptDir"WriteChameleonStage0.sh "${diskupdate}" "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetVolume}"
147fi
148
149# Write the stage 1 loader to the partition boot sector
150"$scriptDir"WriteChameleonStage1.sh "${espformat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}"
151
152# Write the stage 2 loader to the root of the selected partition
153"$scriptDir"WriteChameleonStage2.sh "${espformat}" "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}"
154
155# Set the active partition ONLY if Windows is not installed
156"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}"
157fi
158else
159# Write error to Chameleon_Error_Log file
160"$scriptDir"WriteInstallerLog.sh "${targetVolume}" "Error: Target drive has existing GRUB / Linux loader in the MBR - Not sure how to continue"
161fi
162else
163# Write error to Chameleon_Error_Log file
164"$scriptDir"WriteInstallerLog.sh "${targetVolume}" "Error: ${targetVolume} couldn't be found or the disk doesn't use slices"
165fi
166
167exit 0
168

Archive Download this file

Revision: 252