Chameleon

Chameleon Commit Details

Date:2011-10-23 03:22:43 (12 years 5 months ago)
Author:ErmaC
Commit:1651
Parents: 1650
Message:- Merge latest Trunk changes - Merge latest blackosx changes - Update the Language file
Changes:
D/branches/ErmaC/Trunk/package/Configuration
D/branches/ErmaC/Trunk/package/Scripts/Sub/CheckFormat.sh
D/branches/ErmaC/Modules/package/Configuration
D/branches/ErmaC/Modules/package/Scripts/Sub/CheckFormat.sh
A/branches/ErmaC/Modules/package/Scripts/Main/ESPpostinstall
A/branches/ErmaC/Trunk/package/Scripts/Main/postinstall
A/branches/ErmaC/Modules/package/Scripts/Main/postinstall
A/branches/ErmaC/Trunk/package/Scripts/Main/ESPpostinstall
A/branches/ErmaC/Modules/package/Scripts/Sub/MountESP.sh
A/branches/ErmaC/Trunk/package/Scripts/Sub/MountESP.sh
A/branches/ErmaC/Trunk/package/Scripts/Main/Standardpostinstall
A/branches/ErmaC/Modules/package/Scripts/Main/Standardpostinstall
M/branches/ErmaC/Modules/package/Resources/nl.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/en.lproj/Description.html
M/branches/ErmaC/Modules/package/Scripts/Main/preinstall
M/branches/ErmaC/Trunk/package/Resources/ru.lproj/Localizable.strings
M/branches/ErmaC/Trunk/i386/boot2/options.c
M/branches/ErmaC/Modules/i386/boot2/options.c
M/branches/ErmaC/Modules/package/Resources/zh_TW.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/id.lproj/Localizable.strings
M/branches/ErmaC/Modules/i386/boot2/boot.c
M/branches/ErmaC/Modules/package/Resources/el.lproj/Localizable.strings
M/branches/ErmaC/Trunk/i386/libsaio/ati.c
M/branches/ErmaC/Trunk/package/Resources/es.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/mk.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Distribution
M/branches/ErmaC/Modules/package/Resources/en.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/ar.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/pt-PT.lproj/Localizable.strings
M/branches/ErmaC/Modules/i386/boot2/boot.h
M/branches/ErmaC/Modules/package/Scripts/Sub/CheckPreviousChameleon.sh
M/branches/ErmaC/Modules/package/Distribution
M/branches/ErmaC/Modules/package/slimpkg.sh
M/branches/ErmaC/Trunk/package/Scripts/Main/preinstall
M/branches/ErmaC/Modules/package/Resources/it.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/pt-BR.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/sr.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/Japanese.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/de.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/Japanese.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/he.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/OptionalSettings/Control.txt
M/branches/ErmaC/Modules/package/Resources/bg.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/OptionalSettings/Control.txt
M/branches/ErmaC/Trunk/package/Resources/zh_CN.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Scripts/Sub/WriteChameleonStage2.sh
M/branches/ErmaC/Trunk/package/Scripts/Sub/SetActivePartition.sh
M/branches/ErmaC/Trunk/package/Resources/fr.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/nl.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/hr.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/pl.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/OptionalSettings/Resolution.txt
M/branches/ErmaC/Modules/i386/libsaio/fake_efi.c
M/branches/ErmaC/Trunk/package/Scripts/Sub/InstallLog.sh
M/branches/ErmaC/Modules/package/Resources/pt-BR.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/ru.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/id.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/builddmg.sh
M/branches/ErmaC/Trunk/package/Scripts/Sub/WriteChameleonStage2.sh
M/branches/ErmaC/Trunk/package/Resources/el.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Scripts/Sub/WriteChameleonStage1.sh
M/branches/ErmaC/Trunk/package/Resources/en.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/ar.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/zh_CN.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/buildpkg.sh
M/branches/ErmaC/Trunk/package/slimpkg.sh
M/branches/ErmaC/Modules/package/Scripts/Sub/SetActivePartition.sh
M/branches/ErmaC/Modules/package/Resources/es.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/mk.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/it.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/OptionalSettings/Resolution.txt
M/branches/ErmaC/Trunk/i386/libsaio/fake_efi.c
M/branches/ErmaC/Modules/package/Resources/en.lproj/Description.html
M/branches/ErmaC/Trunk/package/Scripts/Sub/UnMountEFIvolumes.sh
M/branches/ErmaC/Trunk/package/Resources/bg.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/sr.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/OptionalSettings/General.txt
M/branches/ErmaC/Modules/package/Scripts/Sub/UnMountEFIvolumes.sh
M/branches/ErmaC/Trunk/package/Resources/zh_TW.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Scripts/Sub/WriteChameleonStage1.sh
M/branches/ErmaC/Modules/package/Resources/de.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Scripts/Sub/InstallLog.sh
M/branches/ErmaC/Modules/package/OptionalSettings/General.txt
M/branches/ErmaC/Trunk/i386/boot2/boot.c
M/branches/ErmaC/Modules/package/Resources/he.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/buildpkg.sh
M/branches/ErmaC/Trunk/i386/boot2/boot.h
M/branches/ErmaC/Trunk/package/Resources/pt-PT.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Scripts/Sub/CheckPreviousChameleon.sh
M/branches/ErmaC/Trunk/package/Resources/hr.lproj/Localizable.strings
M/branches/ErmaC/Trunk/package/Resources/pl.lproj/Localizable.strings
M/branches/ErmaC/Modules/package/Resources/fr.lproj/Localizable.strings

File differences

branches/ErmaC/Trunk/i386/libsaio/ati.c
556556
557557
558558
559
559
560560
561561
562562
563563
564564
565
565
566566
567567
568
568
569569
570
570
571571
572572
573
573
574574
575575
576576
......
578578
579579
580580
581
581
582582
583583
584584
585585
586586
587587
588
588
589589
590
591
592
590
593591
594
595
592
596593
597
598
594
595
596
597
598
599599
600600
601
601
602602
603603
604604
605605
606
607
608
609
606
607
608
609
610610
611611
612612
{ 0x6718,0x31301682, CHIP_FAMILY_CAYMAN,"AMD Radeon HD 6970",kNull},
{ 0x6720,0x04BA1028, CHIP_FAMILY_CAYMAN,"AMD Radeon HD 6970m",kElodea}, // ErmaC no tested
{ 0x6738,0x00D01002, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x21FA1002, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x67381002, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x21FA1458, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x31031682, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x31041682, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0xE178174B, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x20101787, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x23051787, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6739,0x67391002, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6739,0x21F81458, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6739,0x24411462, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6739,0xE177174B, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6740,0x1657103C, CHIP_FAMILY_TURKS,"AMD Radeon HD 6770M",kNull},
{ 0x6741,0x04891025, CHIP_FAMILY_TURKS,"AMD Radeon HD 6650M",kNull}, // ErmaC no tested
{ 0x6741,0x050E1025, CHIP_FAMILY_TURKS,"AMD Radeon HD 6650M",kNull},
{ 0x6741,0x05131025, CHIP_FAMILY_TURKS,"AMD Radeon HD 6650M",kNull},
{ 0x6741,0x1646103C, CHIP_FAMILY_TURKS,"AMD Radeon HD 6750M",kNull},
{ 0x6741,0x9080104D,CHIP_FAMILY_TURKS,"AMD Radeon HD 6630M",kNull},
{ 0x6741,0x9080104D, CHIP_FAMILY_TURKS,"AMD Radeon HD 6630M",kNull},
{ 0x6758,0x67581002,CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x22051458,CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x67581002, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x31811682,CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x31831682,CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x22051458, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0xE1941746,CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x31811682, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x31831682, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0xE1941746, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6759,0xE193174B, CHIP_FAMILY_TURKS,"AMD Radeon HD 6570",kNull},
{ 0x6760,0x04CC1028,CHIP_FAMILY_RV730,"AMD Radeon HD 6490M",kNull},
{ 0x6760,0x04CC1028, CHIP_FAMILY_RV730,"AMD Radeon HD 6490M",kNull},
{ 0x6760,0x1CB21043, CHIP_FAMILY_RV730,"AMD Radeon HD 6470M",kNull},
{ 0x6760,0x167D103C, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6470M",kNull}, // ErmaC no tested
{ 0x6760,0x1656103C, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6490M",kNull}, // ErmaC no tested
{ 0x6779,0x64501092,CHIP_FAMILY_CAICOS,"AMD Radeon HD 6450",kBulrushes},
{ 0x6779,0xE164174B,CHIP_FAMILY_CAICOS,"AMD Radeon HD 6450",kBulrushes},
{ 0x6779,0x64501092, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6450",kBulrushes},
{ 0x6779,0xE164174B, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6450",kBulrushes},
/* standard/default models */
{ 0x9400,0x00000000, CHIP_FAMILY_R600,"ATI Radeon HD 2900 XT",kNull},
{ 0x9405,0x00000000, CHIP_FAMILY_R600,"ATI Radeon HD 2900 GT",kNull},
branches/ErmaC/Trunk/i386/libsaio/fake_efi.c
434434
435435
436436
437
438
439
440
441
442437
443438
444439
......
607602
608603
609604
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625605
626606
627607
......
640620
641621
642622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
643638
644639
645640
......
703698
704699
705700
701
702
703
706704
707705
708706
static const char const SYSTEM_TYPE_PROP[] = "system-type";
static const char const MODEL_PROP[] = "Model";
static const char const BOARDID_PROP[] = "board-id";
// Facetime fix from olegpronin @ insanelymac
// Breaks booting from RAID
static const char const BOOT_UUID_PROP[] = "boot-uuid";
static char uuidStr[64];
//Facetime fix end
/*
* Get an smbios option string option to convert to EFI_CHAR16 string
// Fill /efi/device-properties node.
setupDeviceProperties(node);
// Facetime fix from olegpronin @ insanelymac
// Thanks to Lnx2Mac for the idea of using the key SkipFTFix=Yes as a temporary work around for this breaking RAID booting
bool skipFTFix=false;
getBoolForKey(kSkipFTFix, &skipFTFix, &bootInfo->chameleonConfig);
if (!skipFTFix) {
//Facetime temp fix start
Node *ChoosenNode;
if (gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0)
{
ChoosenNode = DT__FindNode("/chosen", false);
DT__AddProperty(ChoosenNode, BOOT_UUID_PROP, 64, uuidStr);
}
//Facetime fix end
}
}
/*
}
/*
* Populate the chosen node
*/
void setupChosenNode()
{
Node *chosenNode;
chosenNode = DT__FindNode("/chosen", false);
if (chosenNode == 0)
stop("Couldn't get chosen node");
int bootUUIDLength = strlen(gBootUUIDString);
if (bootUUIDLength)
DT__AddProperty(chosenNode, "boot-uuid", bootUUIDLength + 1, gBootUUIDString);
}
/*
* Load the smbios.plist override config file if any
*/
static void setupSmbiosConfigFile(const char *filename)
gST64->Hdr.CRC32 = 0;
gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize);
}
// Setup the chosen node
setupChosenNode();
}
void saveOriginalSMBIOS(void)
branches/ErmaC/Trunk/i386/boot2/boot.c
7272
7373
7474
75
75
7676
7777
7878
static chargCacheNameAdler[64 + 256];
char*gPlatformName = gCacheNameAdler;
chargRootDevice[512];
chargRootDevice[ROOT_DEVICE_SIZE];
chargMKextName[512];
chargMacOSVersion[8];
intbvCount = 0, gDeviceCount = 0;
branches/ErmaC/Trunk/i386/boot2/boot.h
101101
102102
103103
104
105104
106105
107106
......
148147
149148
150149
150
151151
152152
153153
......
225225
226226
227227
228
229
230
228
229
230
231
232
231233
232234
233235
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kSkipFTFix"SkipFTFix"/* fake_efi.c */ //For Work around to bypass olegpronin's Facetime fix
#define kUseMemDetect"UseMemDetect" /* platform.c */
* A global set by boot() to record the device that the booter
* was loaded from.
*/
#define ROOT_DEVICE_SIZE 512
extern int gBIOSDev;
extern long gBootMode;
extern bool sysConfigValid;
/*
* options.c
*/
extern int getBootOptions(bool firstRun);
extern int processBootOptions();
extern int selectAlternateBootDevice(int bootdevice);
extern char gBootUUIDString[];
extern int getBootOptions(bool firstRun);
extern int processBootOptions();
extern int selectAlternateBootDevice(int bootdevice);
extern bool promptForRescanOption(void);
void showHelp();
branches/ErmaC/Trunk/i386/boot2/options.c
10631063
10641064
10651065
1066
10661067
10671068
10681069
......
10711072
10721073
10731074
1075
1076
1077
10741078
10751079
10761080
......
10811085
10821086
10831087
1084
10851088
1089
10861090
10871091
10881092
......
11021106
11031107
11041108
1105
1109
1110
11061111
11071112
11081113
......
11191124
11201125
11211126
1122
1123
1124
1127
1128
11251129
11261130
11271131
......
11311135
11321136
11331137
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1138
1139
1140
1141
1142
1143
1144
1145
1146
11451147
11461148
11471149
......
12211223
12221224
12231225
1224
1225
1226
1227
1228
1229
1226
1227
1228
12301229
12311230
12321231
12331232
1234
1235
1236
1233
1234
1235
12371236
1238
1239
1240
1241
1237
1238
1239
1240
12421241
12431242
1244
1245
1246
1247
1248
1243
1244
1245
12491246
1250
1247
1248
1249
1250
12511251
1252
1252
1253
12531254
12541255
12551256
......
12571258
12581259
12591260
1260
1261
12611262
12621263
12631264
......
12761277
12771278
12781279
1279
1280
1281
12801282
12811283
12821284
//==========================================================================
char gBootUUIDString[32+4+1] = ""; // UUID of the boot volume e.g. 5EB1869F-C4FA-3502-BDEB-3B8ED5D87292
extern unsigned char chainbootdev;
extern unsigned char chainbootflag;
int argLen = argName ? strlen(argName) : 0;
int len = argLen + cnt + 1; // +1 to account for space
if (argName)
len++; // +1 to account for '='
if (len > *cntRemainingP) {
error("Warning: boot arguments too long, truncating\n");
return false;
*argP += argLen;
*argP[0] = '=';
(*argP)++;
len++; // +1 to account for '='
}
strncpy( *argP, val, cnt );
*argP += cnt;
*argP[0] = ' ';
const char *configTable,
char **argP, // Output value
int *cntRemainingP, // Output count
char *foundVal // found value
char *foundVal, // found value
int foundValSize // max found value size
)
{
const char *val;
copyArgument(argName, val, cnt, argP, cntRemainingP);
found = true;
}
if (found && foundVal) {
strlcpy(foundVal, val, cnt+1);
}
if (found && foundVal)
strlcpy(foundVal, val, foundValSize);
return found;
}
int
processBootOptions()
{
const char * cp = gBootArgs;
const char * val = 0;
const char * kernel;
int cnt;
int userCnt;
int cntRemaining;
char * argP;
char uuidStr[64];
bool uuidSet = false;
char * configKernelFlags;
char * valueBuffer;
const char *cp = gBootArgs;
const char *val = 0;
const char *kernel;
int cnt;
int userCnt;
int cntRemaining;
char *argP;
char *configKernelFlags;
char *valueBuffer;
valueBuffer = malloc(VALUE_SIZE);
configKernelFlags = malloc(cnt + 1);
strlcpy(configKernelFlags, val, cnt + 1);
if (processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0)) {
// boot-uuid was set either on the command-line
// or in the config file.
uuidSet = true;
} else {
// boot-uuid can be set either on the command-line or in the config file
if (!processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gBootUUIDString, sizeof(gBootUUIDString))) {
//
// Try an alternate method for getting the root UUID on boot helper partitions.
//
if (gBootVolume->flags & kBVFlagBooter)
{
if((loadHelperConfig(&bootInfo->helperConfig) == 0)
&& getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig) )
{
// Load the configuration store in the boot helper partition
if (loadHelperConfig(&bootInfo->helperConfig) == 0)
{
getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig);
copyArgument(kBootUUIDKey, val, cnt, &argP, &cntRemaining);
uuidSet = true;
}
val = getStringForKey(kHelperRootUUIDKey, &bootInfo->helperConfig);
if (val != NULL)
strlcpy(gBootUUIDString, val, sizeof(gBootUUIDString));
}
}
if (!uuidSet && gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0) {
verbose("Setting boot-uuid to: %s\n", uuidStr);
copyArgument(kBootUUIDKey, uuidStr, strlen(uuidStr), &argP, &cntRemaining);
uuidSet = true;
}
// Try to get the volume uuid string
if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid)
gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);
}
// If we have the volume uuid add it to the commandline arguments
if (strlen(gBootUUIDString))
copyArgument(kBootUUIDKey, gBootUUIDString, strlen(gBootUUIDString), &argP, &cntRemaining);
}
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gRootDevice)) {
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gRootDevice, ROOT_DEVICE_SIZE)) {
cnt = 0;
if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->chameleonConfig)) {
valueBuffer[0] = '*';
strlcpy(valueBuffer + 1, val, cnt);
val = valueBuffer;
} else {
if (uuidSet) {
if (strlen(gBootUUIDString)) {
val = "*uuid";
cnt = 5;
} else {
/*
* Removed. We don't need this anymore.
*
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gPlatformName)) {
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gPlatformName, sizeof(gCacheNameAdler))) {
getPlatformName(gPlatformName);
copyArgument(kPlatformKey, gPlatformName, strlen(gPlatformName), &argP, &cntRemaining);
}
branches/ErmaC/Trunk/package/Distribution
2727
2828
2929
30
30
3131
3232
3333
......
3737
3838
3939
40
41
42
43
44
45
46
47
48
49
50
51
5240
5341
5442
my.result.type = 'Fatal';
return false;
}
system.log('installCheckScript: Passed.');
system.log('installCheckScript: Failed.');
return false;
}
return true;
}
function upgrade_allowed(){
var upgradable = true;
var upgradeAction = my.choice.packageUpgradeAction;
if((upgradeAction == "downgrade") || (upgradeAction == "mixed")){
my.choice.tooltip = system.localizedString('Newer_Package_Installed_message');
upgradable = false;
}
return upgradable;
}
function systemHasGPT(){
var obj = system.ioregistry.matchingName("EFI System Partition");
if (obj)
branches/ErmaC/Trunk/package/slimpkg.sh
33
44
55
6
76
8
97
10
118
129
1310
......
2017
2118
2219
23
2420
25
21
2622
2723
2824
......
5753
5854
5955
56
57
58
59
60
61
62
63
64
65
66
67
68
69
6070
6171
62
63
72
6473
6574
6675
......
7786
7887
7988
89
8090
8191
8292
83
84
85
93
94
95
96
8697
8798
8899
89
100
90101
91102
92103
93104
94105
95
106
96107
97108
98109
99110
100111
101
112
102113
103114
104115
105116
106117
107
118
108119
109120
110121
111122
112123
113
124
114125
115
116
117
126
127
128
118129
119130
120131
......
129140
130141
131142
132
133
143
144
134145
135146
136147
......
172183
173184
174185
175
186
176187
177188
178189
......
183194
184195
185196
197
186198
187199
188
200
189201
202
190203
191204
192205
193206
194
207
195208
209
210
211
196212
197213
198
214
199215
200216
201217
......
269285
270286
271287
272
288
273289
274290
275
291
276292
277
278
293
279294
280295
281296
......
323338
324339
325340
326
341
327342
328343
329344
......
332347
333348
334349
335
336
350
351
337352
338353
339354
......
355370
356371
357372
358
373
359374
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
chamTemp="usr/local/chamTemp"
COL_BLACK="\x1b[30;01m"
COL_BLUE="\x1b[34;01m"
COL_RESET="\x1b[39;49;00m"
#version=$( grep I386BOOT_CHAMELEONVERSION vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}" (.: ErmaC :. branch)"
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build pre install package
echo "================= Preinstall ================="
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Pre/Root
mkdir -p ${1}/Pre/Scripts
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
# build core package
echo "================= Core ================="
((xmlindent++))
packagesidentity="org.chameleon.core"
packagesidentity="org.chameleon"
mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
echo "[BUILD] i386 "
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
# End build core package
# build Chameleon package
echo "================= Chameleon ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Chameleon\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Chameleon\"\n\t\ttitle=\"Chameleon_title\"\n\t\tdescription=\"Chameleon_description\">\n\t</choice>\n"
((xmlindent++))
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/Standard/* ${1}/Standard/Scripts
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
echo "[BUILD] Standard "
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build standard package
# build efi package
mkdir -p ${1}/EFI/Root
mkdir -p ${1}/EFI/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/EFI/* ${1}/EFI/Scripts
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
echo "[BUILD] EFI "
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build efi package
# build reset choice package
mkdir -p ${1}/noboot/Root
echo "[BUILD] Reset choice "
buildpackage "${1}/noboot" "/$chamTemp" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
buildpackage "${1}/noboot" "/$chamTemp" "" "selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
# End build reset choice package
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# End build Chameleon package
# build Modules package
###############################
if [ "$(ls -A "${1%/*}/i386/modules")" ]; then
{
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Module\">"
choices[$((choicescount++))]="<choice\n\tid=\"Module\"\n\ttitle=\"Module_title\"\n\tdescription=\"Module_description\"\n>\n</choice>\n"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Module\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Module\"\n\t\ttitle=\"Module_title\"\n\t\tdescription=\"Module_description\">\n\t</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.modules"
# -
fi
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
}
else
{
# build post install package
echo "================= Post ================="
packagesidentity="org.chameleon"
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Main/Post/* ${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 "
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# End build post install package
#((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
makedistribution "${1}" "${2}" "${3}" "${4}" #"${5}"
# clean up
popd >/dev/null
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="${indent[$xmlindent]}${4}\n"
local choiceoptions="\t\t${4}"
fi
choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${packagename// /}\"\n\t\ttitle=\"${packagename}_title\"\n\t\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' >#${packagename// /}.pkg</pkg-ref>\n\t</choice>\n"
rm -R -f "${1}"
fi
}
find "${1}/${packagename}" -name '.DS_Store' -delete
pushd "${1}/${packagename}" >/dev/null
xar -c -f "${1%/*}/$packagename.pkg" --compression none .
xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
popd >/dev/null
# Here is the place for assign a Icon to the pkg
# ----
ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"
DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc
Rez -append tempicns.rsrc -o "${1%/*}/$packagename.pkg"
SetFile -a C "${1%/*}/$packagename.pkg"
Rez -append tempicns.rsrc -o "${1%/*}/$packagename-${version}-r$revision.pkg"
SetFile -a C "${1%/*}/$packagename-${version}-r$revision.pkg"
rm -f tempicns.rsrc
rm -rf "${pkgroot}/Icons/Icons"
# End
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
main "${1}" "${2}" "${3}" "${4}" #"${5}"
branches/ErmaC/Trunk/package/OptionalSettings/Resolution.txt
2121
2222
2323
24
24
2525
2626
2727
# B) User can select only one of the options from the list.
# Set Exclusive=False for A, or Exclusive=True for B.
#
Exclusive=False
Exclusive=True
# ---------------------------------------------
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
branches/ErmaC/Trunk/package/OptionalSettings/General.txt
3434
3535
3636
37
38
37
UHCIreset:UHCIreset=Yes
UseMemDetect:UseMemDetect=No
UseKernelCache:UseKernelCache=Yes
Wake:Wake=Yes
SkipFTFix:SkipFTFix=Yes
Wake:Wake=Yes
branches/ErmaC/Trunk/package/OptionalSettings/Control.txt
3030
3131
3232
33
33
3434
LegacyLogo:Legacy Logo=Yes
InstantMenu:Instant Menu=Yes
QuietBoot:QuietBoot=Yes
ShowInfo:ShowInfo=No
ShowInfo:ShowInfo=Yes
Wait:Wait=Yes
branches/ErmaC/Trunk/package/Scripts/Main/ESPpostinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
echo "==============================================="
echo "Main EFI System Partition Post-Install Script"
echo "*********************************************"
echo "-----------------------------------------------"
echo ""
# 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
stage0Loader="boot0"
stage0LoaderDualBoot="boot0md"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage2Loader="boot"
targetVolumeChosenByUser=$3
targetDeviceChosenByUser=$( df "${targetVolumeChosenByUser}" | sed -n '2p' | awk '{print $1}' )
targetVolume="/Volumes/EFI"
targetDevice=${targetDeviceChosenByUser%s*}s1
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetDiskRaw=${targetDisk/disk/rdisk}
targetSlice=${targetDevice#*disk*s}
targetResources="${targetVolumeChosenByUser}/usr/local/bin/"
echo "==============================================="
echo "DEBUG: display script variables"
echo "***************************"
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 ""
# 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}"
# Check to see if the selected disk uses a GPT
bootuuid=$( diskutil info "$targetDeviceChosenByUser" | grep Volume\ UUID | awk {'print $3'} )
partitiontable=$( diskutil list ${targetDeviceChosenByUser%s*} | sed -n '3p' | awk '{print $2}' )
if [ ${partitiontable} = "GUID_partition_scheme" ]; then
echo "Confirm this is a GPT partitioned disk."
# Double check we can see the selected partition and it's of the right type.
# If the following script finds anything, it returns 1 to indicate failure.
"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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}" "${targetVolumeChosenByUser}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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=$?
# 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}" "${targetVolumeChosenByUser}" "${scriptDir}"
diskupdate=$?
# check the format of the selected partition.
# result should be either hfs or msdos
# Should really check to make sure!
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}" "${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"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
branches/ErmaC/Trunk/package/Scripts/Main/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
echo "==============================================="
echo "Post Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
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
# Check target exists
if [ ! -e "$3" ]
then
echo "$3 volume does not exist!"
exit 1
fi
# clean up what would otherwise turn into "//" paths
if [ "$3" == "/" ]
then
dest_vol=""
else
dest_vol="$3"
fi
# Find script location so to find the Install Log script.
MYLOCATION="${PWD}/${BASH_ARGV[0]}"
export MYLOCATION="${MYLOCATION%/*}"
scriptDir=$MYLOCATION
# Has install log already been generated?
if [ ! -f "${dest_vol}"/.ChameleonLogFlag ]; then
# Write some information to the Install Log
versionNumber=`cat "${scriptDir}"/Resources/version`
revisionNumber=`cat "${scriptDir}"/Resources/revision`
"$scriptDir"InstallLog.sh "${dest_vol}" "Installer version: ${versionNumber} ${revisionNumber}"
"$scriptDir"InstallLog.sh "${dest_vol}" "Running Post postinstall script"
"$scriptDir"InstallLog.sh "${dest_vol}" "Target volume = ${dest_vol}"
else
"$scriptDir"InstallLog.sh "${dest_vol}" "Running Post postinstall script"
fi
# set temporary directory
chamTemp="$dest_vol/usr/local/chamTemp"
# Check for stopped installation due to Chameleon
# already existing on the same disk.
if [ ! -f "$dest_vol"/.ChameleonExists ]; then
# ---------------------------------------------
# Add any installed modules to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/modules ]; then
ls "${chamTemp}"/Extra/modules | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed module:$FILE"
done
fi
# ---------------------------------------------
# Add any installed themes to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/Themes ]; then
ls "${chamTemp}"/Extra/Themes | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed Theme:$FILE"
done
fi
# ---------------------------------------------
# Build org.chameleon.Boot.plist
# ---------------------------------------------
# All options selected are now dummy files with
# the filename of the option and value residing
# in /usr/local/chamTemp/options/
# for example. Boot Banner=Yes
# Are there any options to build?
if [ "$(ls -A ${chamTemp}/options )" ]; then
# Check for temporary directory/Extra folder.
if [ ! -d "$chamTemp"/Extra ]; then
mkdir "$chamTemp"/Extra
fi
# Create template for org.chameleon.Boot.plist"
tempOCBP="$chamTemp"/Extra/org.chameleon.Boot.plist
cp "$4"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist "$tempOCBP"
# Read list of all boot options the user added.
arrayCount=0
kernelFlagCount=0
while read FILE
do
options[arrayCount]="${FILE##*/}"
# Check keyRead for 'KF' at beginning to
# indicate that should be a kernel flag
if [ ${options[arrayCount]:0:2} = "KF" ];then
# plistbuddy only add's if the key doesn't already exist.
# So let's store any kernelflags and add them all at the
# same time once when we reach the end of the options list.
kernelflag[kernelFlagCount]="${options[arrayCount]##*flag=}"
"$scriptDir"InstallLog.sh "${dest_vol}" "Added kernel flag: ${kernelflag[kernelFlagCount]}"
(( kernelFlagCount++ ))
else
keyRead="${options[$arrayCount]%=*}"
value="${options[$arrayCount]#*=}"
# escape any spaces
keyToUse=$( echo $keyRead | sed 's/ /\\ /g' )
if [ "${keyToUse}" != "DONT" ] && [ "${value}" != "ADD" ]; then
sudo /usr/libexec/plistbuddy -c "Add :${keyToUse} string ${value}" "$tempOCBP"
returnValue=$?
if [ ${returnValue} -ne 1 ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Added boot option: ${keyRead}=${value}"
else
"$scriptDir"InstallLog.sh "${dest_vol}" "Can't add ${keyRead}=${value} as an option already exists for: ${keyRead}"
fi
fi
fi
(( arrayCount++ ))
done < <(ls "${chamTemp}"/options )
# If exclusive options were used and the 'None' option was chosen,
# then a dummy file named DONT=ADD would be in /$chamTemp/Extra/options.
# If that was the only option then the above code would have made a
# temporary Extra folder with a default org.chameleon.Boot.plist
# In this case we don't need it and should discard it otherwise the folder
# will be copied to the users / directory when it's not wanted.
if [ ${arrayCount} == 1 ] && [ "${keyToUse}" == "DONT" ] && [ "${value}" == "ADD" ]; then
if [ -e "${chamTemp}"/Extra ] && [ ! -e "${chamTemp}"/Extra/Themes ] && [ ! -e "${chamTemp}"/Extra/Modules ]; then
rm -r -f "$chamTemp"/Extra
fi
fi
if [ $kernelFlagCount -gt 0 ]; then
# Add kernel flags
for (( i=0 ; i < $kernelFlagCount ; i++ ))
do
# Add any kernel flags together in to one string.
kernelFlagString="${kernelFlagString} ${kernelflag[i]}"
done
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
if [ ${returnValue}=1 ]; then # key already exists.
sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP"
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
fi
fi
fi
# ---------------------------------------------
# Copy temp Extra folder to target destination
# ---------------------------------------------
# If we've made a temporary Extra folder to use then
# check for an existing /Extra folder. If found, back it up
# before copying the temporary Extra folder to destination.
# Extra folder now resides in /usr/local/chamTemp/
# Copy /usr/local/chamTemp/Extra to correct location.
if [ -d "$chamTemp"/Extra ]; then
if [ ! -f "$dest_vol"/.ChameleonEFI ]; then
# The Standard install option chosen
# Does an /Extra folder already exist?
if [ -e "$dest_vol"/Extra ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing $dest_vol/Extra folder. Renaming it $dest_vol/Extra-OLD-$( date "+%H-%M-%S" )"
mv "$dest_vol/Extra" "$dest_vol/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: $dest_vol/Extra"
cp -R "$chamTemp"/Extra "$dest_vol"
else
# The EFI system partition install option was chosen
# Does a /Volumes/Extra folder already exist?
if [ -e "/Volumes/EFI/Extra" ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing /Volumes/EFI/Extra folder. Renaming it Extra-OLD-$( date "+%H-%M-%S" )"
mv "/Volumes/EFI/Extra" "/Volumes/EFI/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: /Volumes/EFI/Extra"
cp -R "$chamTemp"/Extra "/Volumes/EFI"
fi
fi
# Unmount ALL mounted volumes named EFI
"$scriptDir"UnMountEFIvolumes.sh "${dest_vol}" "${scriptDir}"
else
cleanUp="${cleanUp},0"
rm "$dest_vol"/.ChameleonExists
fi
# ---------------------------------------------
# Cleanup
# ---------------------------------------------
# remove any temporary boot sector files if they exist
if [ -d /tmp/newbs ]; then
cleanUp="${cleanUp},1a"
rm /tmp/newbs
fi
if [ -d /tmp/origbs ]; then
cleanUp="${cleanUp},1b"
rm /tmp/origbs
fi
if [ -d /tmp/newBootSector ]; then
cleanUp="${cleanUp},1c"
rm /tmp/newbs
fi
if [ -d /tmp/originalBootSector ]; then
cleanUp="${cleanUp},1d"
rm /tmp/origbs
fi
# delete the temporary Chameleon folder
if [ -e "$chamTemp" ]; then
cleanUp="${cleanUp},2"
rm -rf "$chamTemp"
fi
# Remove /.ChameleonEFI file
if [ -f "$dest_vol"/.ChameleonEFI ]; then
cleanUp="${cleanUp},3"
rm "$dest_vol"/.ChameleonEFI
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup: ${cleanUp}"
"$scriptDir"InstallLog.sh "${dest_vol}" "LineBreak"
"$scriptDir"InstallLog.sh "${dest_vol}" "Post script complete"
echo "==============================================="
echo "END - Post Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
branches/ErmaC/Trunk/package/Scripts/Main/Standardpostinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
echo "==============================================="
echo "Main Standard Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
# 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
stage0Loader="boot0"
stage0LoaderDualBoot="boot0md"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage2Loader="boot"
targetVolume=$3
targetDevice=$( df "${targetVolume}" | sed -n '2p' | awk '{print $1}' )
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetDiskRaw=${targetDisk/disk/rdisk}
targetSlice=${targetDevice#*disk*s}
targetResources="${targetVolume}/usr/local/bin/"
echo "==============================================="
echo "DEBUG: display script variables"
echo "*******************************"
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 ""
# Write some information to the Install Log
"$scriptDir"InstallLog.sh "${targetVolume}" "Running Standard postinstall script"
"$scriptDir"InstallLog.sh "${targetVolume}" "Target volume = ${targetVolume} on ${targetDevice}"
# Double check we can see the selected partition and it's of the right type.
# If the following script finds anything, it returns 1 to indicate failure.
"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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=$?
# 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=$?
# check the format of the selected partition.
# result should be either hfs or msdos
# Should really check to make sure!
targetFormat=$( fstyp "$targetDevice" )
# 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
# 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
# Append a line break to the installer log
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
if [ ${diskupdate} = "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
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
# Next we look to check for existing Chameleon installations.
# But as it will check /Volumes/EFI for the stage 2 loader,
# we need to make sure it's mounted.
# Tell the user what's going on.
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${targetVolume}" "About to check your disk for previous installations"
"$scriptDir"InstallLog.sh "${targetVolume}" "which involves checking the EFI system partition if"
"$scriptDir"InstallLog.sh "${targetVolume}" "appropriate for this disk."
# Unmount ALL mounted volumes named EFI.
# Returns 0=success, 1=fail
"$scriptDir"UnMountEFIvolumes.sh "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
if [ ${partitionScheme} = 1 ] || [ ${partitionScheme} = 2 ]; then
# Mount the EFI system partition
"$scriptDir"MountESP.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
fi
# Check for another existing Chameleon installation on the same disk
"$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
fi
# 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
fi
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${targetVolume}" "Standard script complete"
echo "==============================================="
echo "END - Standard Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
exit 0
branches/ErmaC/Trunk/package/Scripts/Main/preinstall
66
77
88
9
9
10
11
12
1013
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
1145
1246
1347
echo "-----------------------------------------------"
echo ""
# Place holder for maybe setting up install log here?
# Creates text file named 'Chameleon_Installer_Log.txt'
# at the root of the target volume. This is to help show the
# user why the installation process failed (even though the
# package installer ends reading 'Installation Successful'.
# 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
targetVolume=$3
logName="Chameleon_Installer_Log.txt"
logFile="${targetVolume}"/$logName
versionNumber=`cat "${scriptDir}"/Resources/version`
revisionNumber=`cat "${scriptDir}"/Resources/revision`
# Setup Chameleon_Installer_Log.txt file
# by writing header and diskutil list
echo "Chameleon installer log - $( date )
Installer version: ${versionNumber} ${revisionNumber}
======================================================" >"${logFile}"
diskutil list >>"${logFile}"
echo "======================================================" >>"${logFile}"
echo "==============================================="
echo "END - Pre-Install Script"
echo "*********************************"
branches/ErmaC/Trunk/package/Scripts/Sub/CheckFormat.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
echo "==============================================="
echo "CheckFormat: Is target HFS or MSDOS?"
echo "**********************************************"
# if the selected partition is formatted as HFS then exit with 1
# if the selected partition is formatted as MSDOS then exit with 2
# if fstyp doesn't return a value then exit with 0
# Receives targetDevice: for example, /dev/disk0s2
# Receives targetVolume: Volume to install to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 3 ]; then
targetDevice="$1"
targetVolume="$2"
scriptDir="$3"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
echo "DEBUG: passed argument for scriptDir = $scriptDir"
else
echo "Error - wrong number of values passed"
exit 9
fi
if [ "$( fstyp "$targetDevice" | grep hfs )" ]; then
#echo "DEBUG: ${targetDevice} is currently formatted as HFS"
#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDevice} is currently formatted as HFS"
exit 1
fi
if [ "$( fstyp "$targetDevice" | grep msdos )" ]; then
#echo "DEBUG: ${targetDevice} is currently formatted as msdos"
#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDevice} is currently formatted as msdos"
exit 2
fi
#echo "DEBUG: WARNING: ${targetDevice} is currently not formatted as either HFS or msdos"
"$scriptDir"InstallLog.sh "${targetVolume}" "WARNING: ${targetDevice} is currently not formatted as either HFS or msdos"
exit 0
branches/ErmaC/Trunk/package/Scripts/Sub/CheckPreviousChameleon.sh
44
55
66
7
8
7
8
9
910
11
12
13
1014
1115
1216
......
3034
3135
3236
33
34
35
37
38
39
40
3641
37
3842
3943
4044
......
4246
4347
4448
45
49
50
51
52
53
4654
47
55
56
57
58
59
60
61
62
63
64
65
4866
4967
5068
51
52
53
69
70
71
72
73
74
75
5476
55
56
57
58
59
60
61
62
63
64
65
66
67
77
6878
6979
7080
71
72
73
81
82
7483
75
76
77
84
85
7886
7987
80
81
88
89
8290
83
84
91
92
8593
86
87
88
89
90
91
92
93
94
95
96
97
98
94
95
9996
10097
101
102
103
104
98
99
100
101
102
103
104
105
106
107
108
105109
110
111
112
113
114
115
116
106117
107
108
118
119
109120
110121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
111144
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
132183
133
134
135184
136185
186
137187
138
139188
140189
141190
142191
143
192
echo "Check Previous Chameleon: Will there be problems?"
echo "***********************************************"
# Checks the selected volume is present and the disk is partitioned
# Now also check for another existing Chameleon installation on the same disk.
# Checks for another existing Chameleon installation on the same disk
# and tries to make sure the user doesn't end up with an un-bootable
# system due to having installed Chameleon previously elsewhere.
# Called from the Standard/postinstall and EFI/postinstall scripts
# /Volumes/EFI should already be mounted before this is called.
# Receives targetDisk: for example, /dev/disk3.
# Receives targetDeviceRaw: for example, /dev/rdisk3s1.
# Receives targetDevice: Stores device number, for example /dev/disk2s1.
fi
# Check for existing Chameleon installations on a different
# partition of the same target disk.
#echo "DEBUG: Checking for existing Chameleon installations on ${targetDisk#/dev/}..."
# ===============================================
# Prepare some vars
# ===============================================
sliceNumber=$( echo ${targetDeviceRaw#*disk*s} )
sliceNumber=$( echo ${targetDeviceRaw#*disk*s} )
# strip slice from end
targetDiskRawNoSlice=$( echo ${targetDeviceRaw%$sliceNumber} )
# How many actual partitions are there?
numSlices=$(( $( diskutil list | grep $( echo ${targetDisk#/dev/} ) | sed -n '$=' ) -2 ))
# Only check the disk for Chameleon installations if there is more than one partition.
# ===============================================
# Checking the disk for existing Chameleon installations
# if there is more than one partition on the disk.
# ===============================================
if [ $numSlices -gt 1 ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${installerVolume}" "Checking for previous chameleon installations on ${targetDisk#/dev/}"
# Check the disk's MBR for existing stage 0 boot code (code from CheckDiskMicrocode.sh script)
stage0type=$( dd 2>/dev/null if="$targetDisk" count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
if [ "${stage0type}" == "0a803c" ] || [ "${stage0type}" == "ee7505" ] || [ "${stage0type}" == "742b80" ]; then
stage0type=2
elif [ "${stage0type}" == "0b807c" ]; then
stage0type=1
fi
#Scan all partitions for Chameleon code
for (( i=1; i <= $numSlices; i++ ));
do
stageExistence=0
stage0FirstBootable=0
previousExistence="NONE"
if [ $stage0type == 1 ] || [ $stage0type == 2 ]; then
stagesFound=1
else
stagesFound=0
fi
stage1Existence="NONE"
stage2Existence=0
targetDiskRaw=$targetDiskRawNoSlice$i
# Check for existing stage 0 boot file (same code as CheckDiskMicrocode.sh script)
stage0type=$( dd 2>/dev/null if="$targetDisk" count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
if [ "${stage0type}" == "0b807c" ] || [ "${stage0type}" == "0a803c" ] || [ "${stage0type}" == "ee7505" ] || [ "${stage0type}" == "742b80" ]; then
#echo "DEBUG: boot0 found on $targetDisk"
(( stageExistence++ ))
# While here, check just for either existing boot0hfs, boot0md or boot0md (dmazar's boot0workV2)
if [ "${stage0type}" == "0a803c" ] || [ "${stage0type}" == "ee7505" ] || [ "${stage0type}" == "742b80" ]; then
stage0FirstBootable=1
fi
fi
# Check for existence of a bootable partition boot sector containing either boot1h or boot1f32
boot1Search=$( dd 2>/dev/null if="$targetDiskRaw" count=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${boot1Search:0:16}" == "fa31c08ed0bcf0ff" ] && [ "${boot1Search:1020:2}" == "55" ]; then
#echo "DEBUG: boot1h found on "$targetDiskRaw
(( stageExistence++ ))
previousExistence="boot1"
(( stagesFound++ ))
stage1Existence="boot1h"
elif [ "${boot1Search:0:4}" == "e962" ] && [ "${boot1Search:180:12}" == "424f4f542020" ] && [ "${boot1Search:1020:2}" == "55" ]; then
#echo "DEBUG: boot1f32 found on "$targetDiskRaw
(( stageExistence++ ))
previousExistence="boot1f32"
(( stagesFound++ ))
stage1Existence="boot1f32"
fi
# Check for existing stage 2 boot file also
# NOTE: This will fail to find /boot on /Volumes/EFI as it won't be mounted!
# Check for existing stage 2 boot file.
# Include checking the EFI system partition if it exists and is mounted.
if [ -e "$( df | grep ${targetDisk}s${i} | awk '{ print $6 }' )"/boot ]; then
#echo "DEBUG: boot found on $targetDiskRaw"
(( stageExistence++ ))
(( stagesFound++ ))
stage2Existence=1
fi
#if [ $stageExistence == 3 ] && [ $i -ne $sliceNumber ]; then
#echo "DEBUG: STOP: There is already an existing Chameleon installation on $targetDiskRaw"
#"$scriptDir"InstallLog.sh "${installerVolume}" "STOP: There is already an existing Chameleon installation on $targetDiskRaw."
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: This is allowed and does work as long as you aren't dual booting Windows"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: from the same disk and are happy to control which partition is used by"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: flagging the required partition active. General use doesn't require two"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: Chameleon installs on the same disk, though might be done by advanced users."
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: If you still want to do this then proceed by installing Chameleon manually."
#exit 1
#fi
if [ $stageExistence -ge 2 ] && [ "$previousExistence" != "NONE" ] && [ $i -ne $sliceNumber ]; then
if [ $stagesFound -ge 2 ] && [ "$stage1Existence" != "NONE" ] && [ $i -ne $sliceNumber ]; then
# There is previous Chameleon stage 1 code on a partition boot sector,
# and either a complete or incomplete installation (ie. boot0 or boot are missing).
if [ $stageExistence == 3 ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: There is already an existing Chameleon installation on $targetDiskRaw."
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: $previousExistence already exists at ${targetDisk}s${i}"
if [ $stagesFound == 3 ] && [ $i -lt $sliceNumber ]; then
# Exisitng installation found which will still be default.
message="************************** TAKE NOTE *****************************
**** There is an existing Chameleon installation on $targetDiskRaw
**** and that installation will still be the default loader as it's
**** on an earlier partition. If you want this new installation on
**** $installerVolume to be default then you will need to remove the
**** boot file from $targetDiskRaw and re-run this installer.
**************************************************************"
"$scriptDir"InstallLog.sh "${installerVolume}" "${message}"
fi
if [ $stagesFound == 3 ] && [ $i -gt $sliceNumber ]; then
# Exisitng installation found which will no longer be default.
message="NOTE: There is an existing Chameleon installation on $targetDiskRaw
NOTE: but this installation on $targetDevice will be the default loader
NOTE: because you're installing to an earlier partition on the disk."
"$scriptDir"InstallLog.sh "${installerVolume}" "${message}"
fi
# This could prove problematic and result in either a b1f:error or boot0:error
# if the following conditions are true:
# User could see a b1f:error or boot0:error if the following conditions are true:
# A) Boot0hfs, Boot0md or Boot0md (dmazar's Boot0workV2) is being used.
# B) The previous stage 1 code is on a lower partiton than the one being installed to now.
# C) boot is missing from that partition.
if [ $stagesFound == 2 ] && [ $stage2Existence == 0 ]; then
# Exisitng boot0 and boot1 only found - missing boot
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: Found $stage1Existence installed to ${targetDisk}s${i}"
# stage0type=2 is used to know if 'A' is true.
if [ $stage0type == 2 ]; then
# i = current slice we're checking, slicenumber = slice trying to install to.
if [ $i -lt $sliceNumber ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: Conditions point to the possibility of a boot failure"
# Fix by making previous paritionboot sector un-bootable
# Change Byte 01FExh to 00 (510 decimal)
message="---
FIX: Make ${targetDisk}s${i} boot sector un-bootable by changing byte 1FEh to 00.
NOTE: Any Extra folder you had there will still be there. If you want to use
NOTE: ${targetDisk}s${i} again as your boot partition then re-run this installer
NOTE: selecting it as the target, ONLY choosing the 'Chameleon Bootloader' option
NOTE: and NONE of the other options.
---"
"$scriptDir"InstallLog.sh "${installerVolume}" "${message}"
# stage0FirstBootable=1 is used to know if 'A' is true.
if [ $stage0FirstBootable == 1 ]; then
# i = current slice we're checking, slicenumber = slice trying to install to.
if [ $i -lt $sliceNumber ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: Conditions point to you receiving a boot failure"
# Fix by making previous paritionboot sector un-bootable
# Change Byte 01FExh to 00 (510 decimal)
"$scriptDir"InstallLog.sh "${installerVolume}" "---"
"$scriptDir"InstallLog.sh "${installerVolume}" "FIX: Make ${targetDisk}s${i} boot sector un-bootable by changing byte 1FEh to 00."
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: Any Extra folder you had there will still be there. If you want to use"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: ${targetDisk}s${i} again as your boot partition then re-run this installer"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: selecting it as the target, ONLY choosing the 'Chameleon Bootloader' option"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: and NONE of the other options."
"$scriptDir"InstallLog.sh "${installerVolume}" "---"
dd if=${targetDisk}s${i} count=1 bs=512 of=/tmp/originalBootSector
cp /tmp/originalBootSector /tmp/newBootSector
dd if="$scriptDir/patch" of=/tmp/newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=/tmp/newBootSector of=${targetDisk}s${i} count=1 bs=512
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: but won't interfere as you're installing to an earlier partition."
# /Volumes/EFI needs unmounting before changing partition boot sector
if [ $i == 1 ]; then
umount /Volumes/EFI
else
diskutil unmount "${targetDisk}"s${i}
fi
if [ "$( fstyp "${targetDisk}"s${i} | grep hfs )" ]; then
#echo "DEBUG: HFS - changing byte 1FEh to 00"
dd if=${targetDisk}s${i} count=2 bs=512 of=originalBootSector
cp originalBootSector newBootSector
dd if="patch" of=newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=newBootSector of=${targetDisk}s${i} count=2 bs=510
fi
if [ "$( fstyp "${targetDisk}"s${i} | grep msdos )" ]; then
#echo "DEBUG: MSDOS - changing byte 1FEh to 00"
dd if=${targetDisk}s${i} count=1 bs=512 of=/tmp/originalBootSector
cp /tmp/originalBootSector /tmp/newBootSector
dd if="$scriptDir/patch" of=/tmp/newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=/tmp/newBootSector of=${targetDisk}s${i} count=1 bs=512
fi
# /Volumes/EFI needs re-mounting so EFI/postinstall script can use it.
# Don't check for a GPT as wouldn't have got here if it wasn't
if [ $i == 1 ]; then
"$scriptDir"MountESP.sh "${targetDisk}" "${installerVolume}" "${scriptDir}"
else
diskutil mount "${targetDisk}"s${i}
fi
else
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: but won't interfere as you're installing to an earlier partition."
fi
elif [ $stage0type == 1 ]; then
# boot0 was found which looks for boot1 on the first active partition.
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: so select to boot that partition (if used) with active flag."
#else
#echo "DEBUG: Boot0 not found"
fi
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: so select to boot that partition (if used) with active flag."
fi
fi
done
#else
#echo "DEBUG: Just one slice"
fi
exit 0
exit 0
branches/ErmaC/Trunk/package/Scripts/Sub/InstallLog.sh
44
55
66
7
8
9
10
7
8
119
1210
1311
......
2321
2422
2523
24
25
2626
2727
2828
29
30
31
32
3329
34
35
36
37
30
3831
39
40
41
42
43
44
45
46
47
48
49
5032
5133
5234
......
6850
6951
7052
71
53
echo "InstallLog: Create/Append installation log"
echo "**********************************************"
# Creates text file named 'Chameleon_Installer_Log.txt'
# at the root of the target volume. This is to help show the
# user why the installation process failed (even though the
# package installer ends reading 'Installation Successful'.
# Writes to the Chameleon_Installer_Log.txt file created
# by the preinstall script at the start of installation.
# Receives two parameters
# $1 = selected volume for location of the install log
exit 9
fi
logName="Chameleon_Installer_Log.txt"
logFile="${logLocation}"/$logName
# On first run, create a file named .ChameleonLogFlag at
# the root of the target volume. Then check for this file
# on subsequent runs to know the initialisation sequence
# has been done.
if [ ! -f "${logLocation}"/.ChameleonLogFlag ]; then
# This is the first run, so setup
# Chameleon_Installer_Log.txt file
# by writing header.
if [ -f "${logFile}" ]; then
# Also include the first message that this script
# would be called with which will be version/revision
# of Chameleon package.
echo "Chameleon installer log - $( date )
${verboseText}
======================================================" >"${logFile}"
# Create /.ChameleonLogFlag file.
echo "Log" >"${logLocation}"/.ChameleonLogFlag
else
# Append messages to the log as passed by other scripts.
if [ "${verboseText}" = "Diskutil" ]; then
diskutil list >>"${logFile}"
fi
fi
exit 0
exit 0
branches/ErmaC/Trunk/package/Scripts/Sub/MountESP.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
echo "==============================================="
echo "MountESP: Mount the EFI system partition"
echo "***********************************************"
# Creates a mountpoint and mounts /Volumes/EFI of the
# supplied disk which would have been pre-checked as using a GPT
# Receives targetDisk: for example /dev/disk2.
# Receives installerVolume: Volume to write the installer log to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 3 ]; then
targetDisk="$1"
installerVolume="$2"
scriptDir="$3"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
echo "DEBUG: passed argument for installerVolume = $installerVolume"
echo "DEBUG: passed argument for scriptDir = $scriptDir"
else
echo "Error - wrong number of values passed"
exit 9
fi
# Does the mountpoint exist?
if [ ! -e "/Volumes/EFI" ]; then
mkdir -p "/Volumes/EFI"
fi
# Mount '/Volumes/EFI' using the correct format type
if [ "$( fstyp "${targetDisk}"s1 | grep hfs )" ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "Mounting ${targetDisk}s1 as /Volumes/EFI"
mount_hfs "${targetDisk}"s1 "/Volumes/EFI"
fi
if [ "$( fstyp "${targetDisk}"s1 | grep msdos )" ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "Mounting ${targetDisk}s1 as /Volumes/EFI"
mount_msdos -u 0 -g 0 "${targetDisk}"s1 "/Volumes/EFI"
fi
exit 0
branches/ErmaC/Trunk/package/Scripts/Sub/WriteChameleonStage1.sh
66
77
88
9
9
1010
1111
1212
......
1515
1616
1717
18
18
1919
2020
2121
2222
2323
2424
25
25
2626
2727
2828
......
3434
3535
3636
37
38
37
3938
4039
4140
......
4342
4443
4544
46
47
45
4846
4947
5048
# Writes Chameleon stage 1 loader.
# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives targetFormat: either hfs or msdos
# Receives stage1LoaderHFS: Name of file - boot1h
# Receives stage1LoaderFAT: Name of file - boot1f32
# Receives selectedDestination: for example, /Volumes/USB
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 7 ]; then
espformat="$1"
targetFormat="$1"
stage1LoaderHFS="$2"
stage1LoaderFAT="$3"
selectedDestination="$4"
targetDeviceRaw="$5"
targetVolume="$6"
scriptDir="$7"
echo "DEBUG: passed argument for espformat = $espformat"
echo "DEBUG: passed argument for targetFormat = $targetFormat"
echo "DEBUG: passed argument for stage1LoaderHFS = $stage1LoaderHFS"
echo "DEBUG: passed argument for stage1LoaderFAT = $stage1LoaderFAT"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
exit 9
fi
if [ ${espformat} = "1" ]; then
# the selected partition is HFS formatted
if [ ${targetFormat} = "hfs" ]; then
#echo "DEBUG: Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"
dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}
"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderHFS} to ${targetDeviceRaw}."
fi
if [ ${espformat} = "2" ]; then
# the selected partition FAT formatted
if [ ${targetFormat} = "msdos" ]; then
#echo "DEBUG: Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"
dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs
branches/ErmaC/Trunk/package/Scripts/Sub/WriteChameleonStage2.sh
44
55
66
7
8
9
107
118
129
......
1411
1512
1613
17
18
19
20
21
22
23
24
14
15
16
17
18
19
2520
2621
2722
......
3429
3530
3631
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
6232
6333
6434
echo "Write Chameleon Stage 2 Loader:"
echo "*******************************"
# Writes Chameleon stage 2 loader.
# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives stage2Loader: Name of file - boot
# Receives selectedDestination: for example, /Volumes/ChameleonBootUSB (or /Volumes/EFI if ESP install).
# Receives targetDevice: for example, /dev/disk3s1
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 6 ]; then
espformat="$1"
stage2Loader="$2"
selectedDestination="$3"
targetDevice="$4"
targetVolume="$5"
scriptDir="$6"
echo "DEBUG: passed argument for espformat = $espformat"
if [ "$#" -eq 5 ]; then
stage2Loader="$1"
selectedDestination="$2"
targetDevice="$3"
targetVolume="$4"
scriptDir="$5"
echo "DEBUG: passed argument for stage2Loader = $stage2Loader"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
# check to see if install to EFI system partition was selected
if [ "${selectedDestination}" = "/Volumes/EFI" ]; then
#echo "DEBUG: EFI install chosen"
if [ ! -e "${selectedDestination}" ]; then
#echo "DEBUG: Executing Command: mkdir -p ${selectedDestination}"
mkdir -p "${selectedDestination}"
#else
#echo "DEBUG: folder /Volumes/EFI already exists"
fi
#if the EFI system partition was selected then
# mount '/Volumes/EFI' with the correct format type
if [ ${espformat} = 1 ]; then
#echo "Executing command: mount_hfs ${targetDevice} ${targetVolume}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
mount_hfs "${targetDevice}" "${selectedDestination}"
fi
if [ ${espformat} = 2 ]; then
[ -d "${selectedDestination}" ] || mkdir -p "${selectedDestination}"
#echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${selectedDestination}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
mount_msdos -u 0 -g 0 "${targetDevice}" "${selectedDestination}"
fi
#echo "DEBUG: Executing command: cp "${targetVolume}"/usr/standalone/i386/${stage2Loader} ${selectedDestination}"
cp "${targetVolume}"/usr/standalone/i386/"${stage2Loader}" "${selectedDestination}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Written boot to ${selectedDestination}."
branches/ErmaC/Trunk/package/Scripts/Sub/SetActivePartition.sh
66
77
88
9
109
1110
1211
1312
1413
1514
16
17
18
19
20
21
22
15
16
17
18
19
20
2321
24
2522
2623
2724
# Sets partition active if Windows is not installed.
# Receives efiformat: code is 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives diskSigCheck: code is 1 for a Windows install, 0 for no Windows install
# Receives targetDiskRaw: for example, /dev/rdisk1
# Receives targetSlice: for example, 1
# Receives targetVolume: Volume to install to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 6 ]; then
efiformat="$1"
diskSigCheck="$2"
targetDiskRaw="$3"
targetSlice="$4"
targetVolume="$5"
scriptDir="$6"
if [ "$#" -eq 5 ]; then
diskSigCheck="$1"
targetDiskRaw="$2"
targetSlice="$3"
targetVolume="$4"
scriptDir="$5"
echo "DEBUG: passed argument for efiformat = $efiformat"
echo "DEBUG: passed argument for diskSigCheck = $diskSigCheck"
echo "DEBUG: passed argument for targetDiskRaw = $targetDiskRaw"
echo "DEBUG: passed argument for targetSlice = $targetSlice"
branches/ErmaC/Trunk/package/Scripts/Sub/UnMountEFIvolumes.sh
66
77
88
9
9
1010
1111
1212
......
2323
2424
2525
26
27
28
26
27
2928
3029
3130
3231
33
3432
3533
3634
# loop through and un-mount ALL mounted 'EFI' system partitions - Thanks kizwan
# Receives targetVolumeChosenByUser: Stores original target if EFI install selected.
# Receives targetVolumeChosenByUser: To write install log to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 2 ]; then
# be unmounted in which case the loop would run forever.
attempts=1
while [ "$( df | grep EFI )" ] && [ $attempts -lt 5 ]; do
#echo "DEBUG: Unmounting $( df | grep EFI | awk '{print $1}' )"
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Find and unmount any volume named 'EFI':"
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "$( df | grep EFI | awk '{print $1}' )"
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Volume named 'EFI' is mounted..."
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Unmounting $( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
(( attempts++ ))
done
if [ $attempts = 5 ]; then
#echo "DEBUG: failed to unmount 'EFI' System Partition."
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Failed to unmount 'EFI' System Partition."
exit 1
fi
branches/ErmaC/Trunk/package/Resources/en.lproj/Description.html
11
22
33
4
4
55
66
7
8
79
8
10
11
12
13
14
15
16
17
18
19
920
1021
1122
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2844
2945
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.36">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Lucida Grande;}
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; min-height: 12.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; color: #0000ee; min-height: 12.0px}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; color: #0418ee}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; color: #0000ee}
span.s1 {color: #0000ee}
span.s2 {text-decoration: underline ; color: #0418ee}
span.s3 {text-decoration: underline ; color: #0000ee}
span.s4 {text-decoration: underline}
span.s5 {color: #000000}
</style>
</head>
<body>
<p class="p1">Chameleon is combination of various boot loader components.<br />It is based on David Elliott's fake EFI implementation added to Apple's boot-132 project.<br />Chameleon is extended with the following key features:</p>
<br />
<p class="p1">New features in Chameleon 2.0</p>
<br>
<p class="p1"> - Fully customizable GUI to bring some color to the Darwin Bootloader.</p>
<p class="p1"> - Booting retail DVDs by directly loading a ramdisk image without help of additional programs.</p>
<p class="p1"> - Hibernation. Enjoy resuming your Mac OS X with a preview image.</p>
<p class="p1"> - SMBIOS override to modify the factory SMBIOS values.</p>
<p class="p1"> - DSDT override to use a modified fixed DSDT which can solve several issues.</p>
<br>
<p class="p1"> - Device Property Injection via device-properties string.</p>
<p class="p1"> - hybrid boot0 / boot1h for MBR and GPT partitioned disks.</p>
<p class="p1"> - automatic FSB detection code even for recent AMD CPUs.</p>
<p class="p1"> - Apple Software RAID support.</p>
<br />
<p class="p1">For detailed information, visit : <a href="http://chameleon.osx86.hu">http://chameleon.osx86.hu</a></p>
<p class="p1">Chameleon is a boot loader built using a combination of components which evolved from the development of David Elliott's fake EFI implementation added to Apple's boot-132 project.</p>
<p class="p2"><br></p>
<p class="p1">Chameleon v2 is extended with many features. For example:</p>
<p class="p2"><br></p>
<p class="p1">- Fully customizable GUI to bring some color to the Darwin Bootloader.</p>
<p class="p1">- Load a ramdisk to directly boot retail DVDs without additional programs.</p>
<p class="p1">- Hibernation. Enjoy resuming your Mac OS X with a preview image.</p>
<p class="p1">- SMBIOS override to modify the factory SMBIOS values.</p>
<p class="p1">- DSDT override to use a modified fixed DSDT which can solve several issues.</p>
<p class="p1">- Device Property Injection via device-properties string.</p>
<p class="p1">- hybrid boot0 / boot1h for MBR and GPT partitioned disks.</p>
<p class="p1">- Automatic FSB detection code even for recent AMD CPUs.</p>
<p class="p1">- Apple Software RAID support.</p>
<p class="p1">- Module support</p>
<p class="p1">- Memory detection adapted from memtest86: <a href="http://www.memtest.org">http://www.memtest.org</a></p>
<p class="p3"><br></p>
<p class="p3"><br></p>
<p class="p1">The code is released under version 2 of the Gnu Public License.</p>
<p class="p4"><a href="http://forge.voodooprojects.org/p/chameleon/">http://forge.voodooprojects.org/p/chameleon</a></p>
<p class="p2"><br></p>
<p class="p1">FAQ's: <a href="http://forum.voodooprojects.org/index.php/topic,754.0.html">http://forum.voodooprojects.org/index.php/topic,754.0.html</a></p>
</body>
</html>
branches/ErmaC/Trunk/package/buildpkg.sh
33
44
55
6
76
8
97
10
118
129
1310
......
2017
2118
2219
23
2420
2521
2622
......
5854
5955
6056
61
62
6357
6458
6559
6660
6761
62
63
6864
65
6966
7067
7168
......
10097
10198
10299
103
100
104101
105102
106
107
108103
109
104
110105
111106
112107
113108
114109
115
110
116111
117112
118
119
120113
121
114
122115
123116
124117
125118
126119
127
120
128121
129122
130123
......
186179
187180
188181
189
182
190183
191184
192185
......
195188
196189
197190
198
199191
200192
201193
......
220212
221213
222214
223
215
224216
225217
226218
......
269261
270262
271263
272
264
273265
274266
275267
......
302294
303295
304296
305
306
297
307298
308299
309300
310301
311302
312303
313
304
314305
306
315307
316308
317309
......
327319
328320
329321
330
322
331323
332324
333325
......
411403
412404
413405
414
406
407
408
409
410
411
412
413
414
415415
416416
417417
......
447447
448448
449449
450
450
451451
452452
453453
......
481481
482482
483483
484
485
486484
487
485
488486
489487
490488
......
565563
566564
567565
568
566
569567
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
chamTemp="usr/local/chamTemp"
COL_BLACK="\x1b[30;01m"
COL_BLUE="\x1b[34;01m"
COL_RESET="\x1b[39;49;00m"
#version=$( grep I386BOOT_CHAMELEONVERSION vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build pre install package
# This is run before any other package - so this could
# be a good place to initialise the install log???
echo "================= Preinstall ================="
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Pre/Root
mkdir -p ${1}/Pre/Scripts
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
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/Standard/* ${1}/Standard/Scripts
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
echo "[BUILD] Standard "
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build standard package
# build efi package
mkdir -p ${1}/EFI/Root
mkdir -p ${1}/EFI/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/EFI/* ${1}/EFI/Scripts
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
echo "[BUILD] EFI "
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build efi package
# build reset choice package
mkdir -p ${1}/noboot/Root
echo "[BUILD] Reset choice "
buildpackage "${1}/noboot" "/$chamTemp" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
buildpackage "${1}/noboot" "/$chamTemp" "" "selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
# End build reset choice package
((xmlindent--))
fi
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
}
else
{
fi
# End build Modules packages
# build Extras package
# build options packages
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${builtOptionsList}\"\n\t\ttitle=\"${builtOptionsList}_title\"\n\t\tdescription=\"${builtOptionsList}_description\">\n\t</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.options.$builtOptionsList"
# ------------------------------------------------------
# Read boot option file in to an array.
# ------------------------------------------------------
done
# to indicate exclusive option, call buildoptionalsettings with the 2nd parameter set to 1 .
buildoptionalsettings "$1" "0" "keylayout"
buildoptionalsettings "$1" "1" "keylayout"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# End build theme packages
# End build Extras package
# End build theme packages# End build Extras package
# build post install package
echo "================= Post ================="
packagesidentity="org.chameleon"
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Main/Post/* ${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 "
# clean up
rm -R -f "${1}"
#rm -R -f "${1}"
}
fi
done
x="${x}${stringEnd}"
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\" ${x}" >/dev/null 2>&1
# First exclusive option is the 'no choice' option, so let's make that selected by default.
if [ $c = 0 ]; then
initialChoice="true"
else
initialChoice="false"
fi
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"${initialChoice}\" ${x}" >/dev/null 2>&1
else
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1
fi
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
#rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
if [ "${4}" ]; then
local choiceoptions="\t\t${4}"
fi
#choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${packagename// /}\"\n\t\ttitle=\"${packagename}_title\"\n\t\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' >#${packagename// /}.pkg</pkg-ref>\n\t</choice>\n"
rm -R -f "${1}"
#rm -R -f "${1}"
fi
}
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
main "${1}" "${2}" "${3}" "${4}" #"${5}"
branches/ErmaC/Modules/i386/libsaio/fake_efi.c
434434
435435
436436
437
438
439
440
441
442437
443438
444439
......
607602
608603
609604
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625605
626606
627607
......
640620
641621
642622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
643638
644639
645640
......
703698
704699
705700
701
702
703
706704
707705
708706
static const char const SYSTEM_TYPE_PROP[] = "system-type";
static const char const MODEL_PROP[] = "Model";
static const char const BOARDID_PROP[] = "board-id";
// Facetime fix from olegpronin @ insanelymac
// Breaks booting from RAID
static const char const BOOT_UUID_PROP[] = "boot-uuid";
static char uuidStr[64];
//Facetime fix end
/*
* Get an smbios option string option to convert to EFI_CHAR16 string
// Fill /efi/device-properties node.
setupDeviceProperties(node);
// Facetime fix from olegpronin @ insanelymac
// Thanks to Lnx2Mac for the idea of using the key SkipFTFix=Yes as a temporary work around for this breaking RAID booting
bool skipFTFix=false;
getBoolForKey(kSkipFTFix, &skipFTFix, &bootInfo->chameleonConfig);
if (!skipFTFix) {
//Facetime temp fix start
Node *ChoosenNode;
if (gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0)
{
ChoosenNode = DT__FindNode("/chosen", false);
DT__AddProperty(ChoosenNode, BOOT_UUID_PROP, 64, uuidStr);
}
//Facetime fix end
}
}
/*
}
/*
* Populate the chosen node
*/
void setupChosenNode()
{
Node *chosenNode;
chosenNode = DT__FindNode("/chosen", false);
if (chosenNode == 0)
stop("Couldn't get chosen node");
int bootUUIDLength = strlen(gBootUUIDString);
if (bootUUIDLength)
DT__AddProperty(chosenNode, "boot-uuid", bootUUIDLength + 1, gBootUUIDString);
}
/*
* Load the smbios.plist override config file if any
*/
static void setupSmbiosConfigFile(const char *filename)
gST64->Hdr.CRC32 = 0;
gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize);
}
// Setup the chosen node
setupChosenNode();
}
void saveOriginalSMBIOS(void)
branches/ErmaC/Modules/i386/boot2/boot.c
7272
7373
7474
75
75
7676
7777
7878
static chargCacheNameAdler[64 + 256];
char*gPlatformName = gCacheNameAdler;
chargRootDevice[512];
chargRootDevice[ROOT_DEVICE_SIZE];
chargMKextName[512];
chargMacOSVersion[8];
intbvCount = 0, gDeviceCount = 0;
branches/ErmaC/Modules/i386/boot2/boot.h
101101
102102
103103
104
105104
106105
107106
......
138137
139138
140139
140
141141
142142
143143
......
215215
216216
217217
218
219
220
218
219
220
221
222
221223
222224
223225
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kSkipFTFix"SkipFTFix"/* fake_efi.c */ //For Work around to bypass olegpronin's Facetime fix
#define kUseMemDetect"UseMemDetect" /* platform.c */
* A global set by boot() to record the device that the booter
* was loaded from.
*/
#define ROOT_DEVICE_SIZE 512
extern int gBIOSDev;
extern long gBootMode;
extern bool sysConfigValid;
/*
* options.c
*/
extern int getBootOptions(bool firstRun);
extern int processBootOptions();
extern int selectAlternateBootDevice(int bootdevice);
extern char gBootUUIDString[];
extern int getBootOptions(bool firstRun);
extern int processBootOptions();
extern int selectAlternateBootDevice(int bootdevice);
extern bool promptForRescanOption(void);
void showHelp();
branches/ErmaC/Modules/i386/boot2/options.c
10631063
10641064
10651065
1066
10661067
10671068
10681069
......
10711072
10721073
10731074
1075
1076
1077
10741078
10751079
10761080
......
10811085
10821086
10831087
1084
10851088
1089
10861090
10871091
10881092
......
11021106
11031107
11041108
1105
1109
1110
11061111
11071112
11081113
......
11191124
11201125
11211126
1122
1123
1124
1127
1128
11251129
11261130
11271131
......
11311135
11321136
11331137
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1138
1139
1140
1141
1142
1143
1144
1145
1146
11451147
11461148
11471149
......
12211223
12221224
12231225
1224
1225
1226
1227
1228
1229
1226
1227
1228
12301229
12311230
12321231
12331232
1234
1235
1236
1233
1234
1235
12371236
1238
1239
1240
1241
1237
1238
1239
1240
12421241
12431242
1244
1245
1246
1247
1248
1243
1244
1245
12491246
1250
1247
1248
1249
1250
12511251
1252
1252
1253
12531254
12541255
12551256
......
12571258
12581259
12591260
1260
1261
12611262
12621263
12631264
......
12761277
12771278
12781279
1279
1280
1281
12801282
12811283
12821284
//==========================================================================
char gBootUUIDString[32+4+1] = ""; // UUID of the boot volume e.g. 5EB1869F-C4FA-3502-BDEB-3B8ED5D87292
extern unsigned char chainbootdev;
extern unsigned char chainbootflag;
int argLen = argName ? strlen(argName) : 0;
int len = argLen + cnt + 1; // +1 to account for space
if (argName)
len++; // +1 to account for '='
if (len > *cntRemainingP) {
error("Warning: boot arguments too long, truncating\n");
return false;
*argP += argLen;
*argP[0] = '=';
(*argP)++;
len++; // +1 to account for '='
}
strncpy( *argP, val, cnt );
*argP += cnt;
*argP[0] = ' ';
const char *configTable,
char **argP, // Output value
int *cntRemainingP, // Output count
char *foundVal // found value
char *foundVal, // found value
int foundValSize // max found value size
)
{
const char *val;
copyArgument(argName, val, cnt, argP, cntRemainingP);
found = true;
}
if (found && foundVal) {
strlcpy(foundVal, val, cnt+1);
}
if (found && foundVal)
strlcpy(foundVal, val, foundValSize);
return found;
}
int
processBootOptions()
{
const char * cp = gBootArgs;
const char * val = 0;
const char * kernel;
int cnt;
int userCnt;
int cntRemaining;
char * argP;
char uuidStr[64];
bool uuidSet = false;
char * configKernelFlags;
char * valueBuffer;
const char *cp = gBootArgs;
const char *val = 0;
const char *kernel;
int cnt;
int userCnt;
int cntRemaining;
char *argP;
char *configKernelFlags;
char *valueBuffer;
valueBuffer = malloc(VALUE_SIZE);
configKernelFlags = malloc(cnt + 1);
strlcpy(configKernelFlags, val, cnt + 1);
if (processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0)) {
// boot-uuid was set either on the command-line
// or in the config file.
uuidSet = true;
} else {
// boot-uuid can be set either on the command-line or in the config file
if (!processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gBootUUIDString, sizeof(gBootUUIDString))) {
//
// Try an alternate method for getting the root UUID on boot helper partitions.
//
if (gBootVolume->flags & kBVFlagBooter)
{
if((loadHelperConfig(&bootInfo->helperConfig) == 0)
&& getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig) )
{
// Load the configuration store in the boot helper partition
if (loadHelperConfig(&bootInfo->helperConfig) == 0)
{
getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig);
copyArgument(kBootUUIDKey, val, cnt, &argP, &cntRemaining);
uuidSet = true;
}
val = getStringForKey(kHelperRootUUIDKey, &bootInfo->helperConfig);
if (val != NULL)
strlcpy(gBootUUIDString, val, sizeof(gBootUUIDString));
}
}
if (!uuidSet && gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0) {
verbose("Setting boot-uuid to: %s\n", uuidStr);
copyArgument(kBootUUIDKey, uuidStr, strlen(uuidStr), &argP, &cntRemaining);
uuidSet = true;
}
// Try to get the volume uuid string
if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid)
gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);
}
// If we have the volume uuid add it to the commandline arguments
if (strlen(gBootUUIDString))
copyArgument(kBootUUIDKey, gBootUUIDString, strlen(gBootUUIDString), &argP, &cntRemaining);
}
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gRootDevice)) {
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gRootDevice, ROOT_DEVICE_SIZE)) {
cnt = 0;
if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->chameleonConfig)) {
valueBuffer[0] = '*';
strlcpy(valueBuffer + 1, val, cnt);
val = valueBuffer;
} else {
if (uuidSet) {
if (strlen(gBootUUIDString)) {
val = "*uuid";
cnt = 5;
} else {
/*
* Removed. We don't need this anymore.
*
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gPlatformName)) {
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config,
&argP, &cntRemaining, gPlatformName, sizeof(gCacheNameAdler))) {
getPlatformName(gPlatformName);
copyArgument(kPlatformKey, gPlatformName, strlen(gPlatformName), &argP, &cntRemaining);
}
branches/ErmaC/Modules/package/Distribution
2727
2828
2929
30
30
3131
3232
3333
......
3737
3838
3939
40
41
42
43
44
45
46
47
48
49
50
51
5240
5341
5442
my.result.type = 'Fatal';
return false;
}
system.log('installCheckScript: Passed.');
system.log('installCheckScript: Failed.');
return false;
}
return true;
}
function upgrade_allowed(){
var upgradable = true;
var upgradeAction = my.choice.packageUpgradeAction;
if((upgradeAction == "downgrade") || (upgradeAction == "mixed")){
my.choice.tooltip = system.localizedString('Newer_Package_Installed_message');
upgradable = false;
}
return upgradable;
}
function systemHasGPT(){
var obj = system.ioregistry.matchingName("EFI System Partition");
if (obj)
branches/ErmaC/Modules/package/slimpkg.sh
33
44
55
6
76
8
97
10
118
129
1310
......
2017
2118
2219
23
2420
25
21
2622
2723
2824
......
5753
5854
5955
56
57
58
59
60
61
62
63
64
65
66
67
68
69
6070
6171
62
63
72
6473
6574
6675
......
7786
7887
7988
89
8090
8191
8292
83
84
85
93
94
95
96
8697
8798
8899
89
100
90101
91102
92103
93104
94105
95
106
96107
97108
98109
99110
100111
101
112
102113
103114
104115
105116
106117
107
118
108119
109120
110121
111122
112123
113
124
114125
115
116
117
126
127
128
118129
119130
120131
......
133144
134145
135146
136
137
147
148
138149
139150
140151
......
212223
213224
214225
215
226
216227
217228
218229
......
223234
224235
225236
237
226238
227239
228
240
229241
242
230243
231244
232245
233246
234
247
235248
249
250
251
236252
237253
238
254
239255
240256
241257
......
309325
310326
311327
312
328
313329
314330
315
331
316332
317
318
333
319334
320335
321336
......
363378
364379
365380
366
381
367382
368383
369384
......
372387
373388
374389
375
376
390
391
377392
378393
379394
......
395410
396411
397412
398
413
399414
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
chamTemp="usr/local/chamTemp"
COL_BLACK="\x1b[30;01m"
COL_BLUE="\x1b[34;01m"
COL_RESET="\x1b[39;49;00m"
#version=$( grep I386BOOT_CHAMELEONVERSION vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}" (.: ErmaC :. branch)"
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build pre install package
echo "================= Preinstall ================="
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Pre/Root
mkdir -p ${1}/Pre/Scripts
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
# build core package
echo "================= Core ================="
((xmlindent++))
packagesidentity="org.chameleon.core"
packagesidentity="org.chameleon"
mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
echo "[BUILD] i386 "
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
# End build core package
# build Chameleon package
echo "================= Chameleon ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Chameleon\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Chameleon\"\n\t\ttitle=\"Chameleon_title\"\n\t\tdescription=\"Chameleon_description\">\n\t</choice>\n"
((xmlindent++))
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/Standard/* ${1}/Standard/Scripts
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
echo "[BUILD] Standard "
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build standard package
# build efi package
mkdir -p ${1}/EFI/Root
mkdir -p ${1}/EFI/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/EFI/* ${1}/EFI/Scripts
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
echo "[BUILD] EFI "
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build efi package
# build reset choice package
mkdir -p ${1}/noboot/Root
echo "[BUILD] Reset choice "
buildpackage "${1}/noboot" "/$chamTemp" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
buildpackage "${1}/noboot" "/$chamTemp" "" "selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
# End build reset choice package
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# End build Chameleon package
# build Modules package
###############################
if [ "$(ls -A "${1%/*}/i386/modules")" ]; then
{
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Module\">"
choices[$((choicescount++))]="<choice\n\tid=\"Module\"\n\ttitle=\"Module_title\"\n\tdescription=\"Module_description\"\n>\n</choice>\n"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Module\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Module\"\n\t\ttitle=\"Module_title\"\n\t\tdescription=\"Module_description\">\n\t</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.modules"
# -
fi
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
}
else
{
# build post install package
echo "================= Post ================="
packagesidentity="org.chameleon"
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Main/Post/* ${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 "
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# End build post install package
#((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
makedistribution "${1}" "${2}" "${3}" "${4}" #"${5}"
# clean up
popd >/dev/null
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="${indent[$xmlindent]}${4}\n"
local choiceoptions="\t\t${4}"
fi
choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${packagename// /}\"\n\t\ttitle=\"${packagename}_title\"\n\t\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' >#${packagename// /}.pkg</pkg-ref>\n\t</choice>\n"
rm -R -f "${1}"
fi
}
find "${1}/${packagename}" -name '.DS_Store' -delete
pushd "${1}/${packagename}" >/dev/null
xar -c -f "${1%/*}/$packagename.pkg" --compression none .
xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
popd >/dev/null
# Here is the place for assign a Icon to the pkg
# ----
ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"
DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc
Rez -append tempicns.rsrc -o "${1%/*}/$packagename.pkg"
SetFile -a C "${1%/*}/$packagename.pkg"
Rez -append tempicns.rsrc -o "${1%/*}/$packagename-${version}-r$revision.pkg"
SetFile -a C "${1%/*}/$packagename-${version}-r$revision.pkg"
rm -f tempicns.rsrc
rm -rf "${pkgroot}/Icons/Icons"
# End
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
main "${1}" "${2}" "${3}" "${4}" #"${5}"
branches/ErmaC/Modules/package/builddmg.sh
3939
4040
4141
42
4243
4344
4445
......
5152
5253
5354
54
55
5556
5657
5758
58
59
5960
6061
6162
......
7576
7677
7778
78
79
80
79
80
81
82
83
84
8185
8286
8387
84
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
85105
86106
87107
......
138158
139159
140160
141
161
142162
143163
144164
......
155175
156176
157177
158
159
160
161
178
179
180
181
162182
163183
164184
......
211231
212232
213233
234
214235
revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
CHAMELEON_PACKAGE_NAME=${VOLUME_NAME}-${version}-r${revision}
# =========================
# Start of building process
echo ""
# =================================
# 1) Clean previus builded contents
# 1) Clean previous builded contents
# =================================
if [ -x ${SRC_FOLDER} ]; then
echo "Deleting previus existing source folder/content "
echo "Deleting previous existing source folder/content "
rm -R ${SRC_FOLDER}
rm -f ${DMG_TEMP_NAME}
fi
ditto -xk "${pkgroot}/Icons/doc.zip" "${SRC_FOLDER}/"
ditto -xk "${pkgroot}/Icons/pan.zip" "${SRC_FOLDER}/"
ditto -xk "${pkgroot}/Icons/tm.zip" "${SRC_FOLDER}/"
mv ${SYM_ROOT}/${VOLUME_NAME}.pkg ${SRC_FOLDER}/${VOLUME_NAME}.pkg
cp -r ${pkgroot}/doc/* ${SRC_FOLDER}/Documentation/
#mv ${SYM_ROOT}/${VOLUME_NAME}.pkg ${SRC_FOLDER}/${VOLUME_NAME}.pkg
cp -r ${SYM_ROOT}/${CHAMELEON_PACKAGE_NAME}.pkg ${SRC_FOLDER}/${CHAMELEON_PACKAGE_NAME}.pkg
#cp -r ${pkgroot}/doc/* ${SRC_FOLDER}/Documentation/
cp -r ${SYM_ROOT%/*}/doc/BootHelp.txt ${SRC_FOLDER}/Documentation/
cp -r ${SYM_ROOT%/*}/doc/Users_Guide0.5.pdf ${SRC_FOLDER}/Documentation/
cp -r ${pkgroot}/Configuration/PrefPanel/* ${SRC_FOLDER}/PrefPanel/
cp -r ${SYM_ROOT}/i386/* ${SRC_FOLDER}/i386/
cp -r ${SYM_ROOT%/*}/artwork/themes/* ${SRC_FOLDER}/Themes/
rm -rf ${SRC_FOLDER}`find . -type d -name .svn`
#rm -rf ${SRC_FOLDER}`find . -type d -name .svn`
# The above line caused problems with svn reporting changes to all
# directories in the Chameleon source folder that exist before compiling
# svn status would show the following:
# ~ Chameleon.xcodeproj
# ~ artwork
# ~ i386
# ~ package
# ~ doc
# I've changed the code to this for now to get round the problem.
# Hopefully someone else can find out why it was happenening.
svnFilesToRemove=($( find "${SRC_FOLDER}" -type d -name '.svn'))
for (( i = 0 ; i < ${#svnFilesToRemove[@]} ; i++ ))
do
rm -rf ${svnFilesToRemove[$i]}
done
# =======================================
# 4) Find the size of the folder contents
# 9) Make sure it's not world writeable
# =====================================
mv ${SRC_FOLDER}/${VOLUME_NAME}.pkg ${MOUNT_DIR}/${VOLUME_NAME}.pkg
mv ${SRC_FOLDER}/${CHAMELEON_PACKAGE_NAME}.pkg ${MOUNT_DIR}/${VOLUME_NAME}.pkg
cp -R ${SRC_FOLDER}/Documentation ${MOUNT_DIR}/
cp -R ${SRC_FOLDER}/PrefPanel ${MOUNT_DIR}/
cp -R ${SRC_FOLDER}/i386 ${MOUNT_DIR}/
# =============================================
echo "[openUp] Setting auto open flag"
if [ -x ${OPENUP_TOOL} ]; then
echo "Applying openUp..."
${OPENUP_TOOL} "${MOUNT_DIR}" >/dev/null 2>&1
fi
if [ -x ${OPENUP_TOOL} ]; then
echo "Applying openUp..."
${OPENUP_TOOL} "${MOUNT_DIR}" >/dev/null 2>&1
fi
echo " "
# ===========
echo "===================="
echo ""
#-----
exit 0
branches/ErmaC/Modules/package/OptionalSettings/Resolution.txt
2121
2222
2323
24
24
2525
2626
2727
# B) User can select only one of the options from the list.
# Set Exclusive=False for A, or Exclusive=True for B.
#
Exclusive=False
Exclusive=True
# ---------------------------------------------
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
branches/ErmaC/Modules/package/OptionalSettings/General.txt
3535
3636
3737
38
UseMemDetect:UseMemDetect=No
UseKernelCache:UseKernelCache=Yes
Wake:Wake=Yes
SkipFTFix:SkipFTFix=Yes
branches/ErmaC/Modules/package/OptionalSettings/Control.txt
3030
3131
3232
33
33
3434
LegacyLogo:Legacy Logo=Yes
InstantMenu:Instant Menu=Yes
QuietBoot:QuietBoot=Yes
ShowInfo:ShowInfo=No
ShowInfo:ShowInfo=Yes
Wait:Wait=Yes
branches/ErmaC/Modules/package/Scripts/Main/ESPpostinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
echo "==============================================="
echo "Main EFI System Partition Post-Install Script"
echo "*********************************************"
echo "-----------------------------------------------"
echo ""
# 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
stage0Loader="boot0"
stage0LoaderDualBoot="boot0md"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage2Loader="boot"
targetVolumeChosenByUser=$3
targetDeviceChosenByUser=$( df "${targetVolumeChosenByUser}" | sed -n '2p' | awk '{print $1}' )
targetVolume="/Volumes/EFI"
targetDevice=${targetDeviceChosenByUser%s*}s1
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetDiskRaw=${targetDisk/disk/rdisk}
targetSlice=${targetDevice#*disk*s}
targetResources="${targetVolumeChosenByUser}/usr/local/bin/"
echo "==============================================="
echo "DEBUG: display script variables"
echo "***************************"
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 ""
# 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}"
# Check to see if the selected disk uses a GPT
bootuuid=$( diskutil info "$targetDeviceChosenByUser" | grep Volume\ UUID | awk {'print $3'} )
partitiontable=$( diskutil list ${targetDeviceChosenByUser%s*} | sed -n '3p' | awk '{print $2}' )
if [ ${partitiontable} = "GUID_partition_scheme" ]; then
echo "Confirm this is a GPT partitioned disk."
# Double check we can see the selected partition and it's of the right type.
# If the following script finds anything, it returns 1 to indicate failure.
"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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}" "${targetVolumeChosenByUser}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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=$?
# 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}" "${targetVolumeChosenByUser}" "${scriptDir}"
diskupdate=$?
# check the format of the selected partition.
# result should be either hfs or msdos
# Should really check to make sure!
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}" "${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"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
branches/ErmaC/Modules/package/Scripts/Main/postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
echo "==============================================="
echo "Post Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
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
# Check target exists
if [ ! -e "$3" ]
then
echo "$3 volume does not exist!"
exit 1
fi
# clean up what would otherwise turn into "//" paths
if [ "$3" == "/" ]
then
dest_vol=""
else
dest_vol="$3"
fi
# Find script location so to find the Install Log script.
MYLOCATION="${PWD}/${BASH_ARGV[0]}"
export MYLOCATION="${MYLOCATION%/*}"
scriptDir=$MYLOCATION
# Has install log already been generated?
if [ ! -f "${dest_vol}"/.ChameleonLogFlag ]; then
# Write some information to the Install Log
versionNumber=`cat "${scriptDir}"/Resources/version`
revisionNumber=`cat "${scriptDir}"/Resources/revision`
"$scriptDir"InstallLog.sh "${dest_vol}" "Installer version: ${versionNumber} ${revisionNumber}"
"$scriptDir"InstallLog.sh "${dest_vol}" "Running Post postinstall script"
"$scriptDir"InstallLog.sh "${dest_vol}" "Target volume = ${dest_vol}"
else
"$scriptDir"InstallLog.sh "${dest_vol}" "Running Post postinstall script"
fi
# set temporary directory
chamTemp="$dest_vol/usr/local/chamTemp"
# Check for stopped installation due to Chameleon
# already existing on the same disk.
if [ ! -f "$dest_vol"/.ChameleonExists ]; then
# ---------------------------------------------
# Add any installed modules to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/modules ]; then
ls "${chamTemp}"/Extra/modules | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed module:$FILE"
done
fi
# ---------------------------------------------
# Add any installed themes to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/Themes ]; then
ls "${chamTemp}"/Extra/Themes | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed Theme:$FILE"
done
fi
# ---------------------------------------------
# Build org.chameleon.Boot.plist
# ---------------------------------------------
# All options selected are now dummy files with
# the filename of the option and value residing
# in /usr/local/chamTemp/options/
# for example. Boot Banner=Yes
# Are there any options to build?
if [ "$(ls -A ${chamTemp}/options )" ]; then
# Check for temporary directory/Extra folder.
if [ ! -d "$chamTemp"/Extra ]; then
mkdir "$chamTemp"/Extra
fi
# Create template for org.chameleon.Boot.plist"
tempOCBP="$chamTemp"/Extra/org.chameleon.Boot.plist
cp "$4"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist "$tempOCBP"
# Read list of all boot options the user added.
arrayCount=0
kernelFlagCount=0
while read FILE
do
options[arrayCount]="${FILE##*/}"
# Check keyRead for 'KF' at beginning to
# indicate that should be a kernel flag
if [ ${options[arrayCount]:0:2} = "KF" ];then
# plistbuddy only add's if the key doesn't already exist.
# So let's store any kernelflags and add them all at the
# same time once when we reach the end of the options list.
kernelflag[kernelFlagCount]="${options[arrayCount]##*flag=}"
"$scriptDir"InstallLog.sh "${dest_vol}" "Added kernel flag: ${kernelflag[kernelFlagCount]}"
(( kernelFlagCount++ ))
else
keyRead="${options[$arrayCount]%=*}"
value="${options[$arrayCount]#*=}"
# escape any spaces
keyToUse=$( echo $keyRead | sed 's/ /\\ /g' )
if [ "${keyToUse}" != "DONT" ] && [ "${value}" != "ADD" ]; then
sudo /usr/libexec/plistbuddy -c "Add :${keyToUse} string ${value}" "$tempOCBP"
returnValue=$?
if [ ${returnValue} -ne 1 ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Added boot option: ${keyRead}=${value}"
else
"$scriptDir"InstallLog.sh "${dest_vol}" "Can't add ${keyRead}=${value} as an option already exists for: ${keyRead}"
fi
fi
fi
(( arrayCount++ ))
done < <(ls "${chamTemp}"/options )
# If exclusive options were used and the 'None' option was chosen,
# then a dummy file named DONT=ADD would be in /$chamTemp/Extra/options.
# If that was the only option then the above code would have made a
# temporary Extra folder with a default org.chameleon.Boot.plist
# In this case we don't need it and should discard it otherwise the folder
# will be copied to the users / directory when it's not wanted.
if [ ${arrayCount} == 1 ] && [ "${keyToUse}" == "DONT" ] && [ "${value}" == "ADD" ]; then
if [ -e "${chamTemp}"/Extra ] && [ ! -e "${chamTemp}"/Extra/Themes ] && [ ! -e "${chamTemp}"/Extra/Modules ]; then
rm -r -f "$chamTemp"/Extra
fi
fi
if [ $kernelFlagCount -gt 0 ]; then
# Add kernel flags
for (( i=0 ; i < $kernelFlagCount ; i++ ))
do
# Add any kernel flags together in to one string.
kernelFlagString="${kernelFlagString} ${kernelflag[i]}"
done
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
if [ ${returnValue}=1 ]; then # key already exists.
sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP"
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
fi
fi
fi
# ---------------------------------------------
# Copy temp Extra folder to target destination
# ---------------------------------------------
# If we've made a temporary Extra folder to use then
# check for an existing /Extra folder. If found, back it up
# before copying the temporary Extra folder to destination.
# Extra folder now resides in /usr/local/chamTemp/
# Copy /usr/local/chamTemp/Extra to correct location.
if [ -d "$chamTemp"/Extra ]; then
if [ ! -f "$dest_vol"/.ChameleonEFI ]; then
# The Standard install option chosen
# Does an /Extra folder already exist?
if [ -e "$dest_vol"/Extra ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing $dest_vol/Extra folder. Renaming it $dest_vol/Extra-OLD-$( date "+%H-%M-%S" )"
mv "$dest_vol/Extra" "$dest_vol/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: $dest_vol/Extra"
cp -R "$chamTemp"/Extra "$dest_vol"
else
# The EFI system partition install option was chosen
# Does a /Volumes/Extra folder already exist?
if [ -e "/Volumes/EFI/Extra" ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing /Volumes/EFI/Extra folder. Renaming it Extra-OLD-$( date "+%H-%M-%S" )"
mv "/Volumes/EFI/Extra" "/Volumes/EFI/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: /Volumes/EFI/Extra"
cp -R "$chamTemp"/Extra "/Volumes/EFI"
fi
fi
# Unmount ALL mounted volumes named EFI
"$scriptDir"UnMountEFIvolumes.sh "${dest_vol}" "${scriptDir}"
else
cleanUp="${cleanUp},0"
rm "$dest_vol"/.ChameleonExists
fi
# ---------------------------------------------
# Cleanup
# ---------------------------------------------
# remove any temporary boot sector files if they exist
if [ -d /tmp/newbs ]; then
cleanUp="${cleanUp},1a"
rm /tmp/newbs
fi
if [ -d /tmp/origbs ]; then
cleanUp="${cleanUp},1b"
rm /tmp/origbs
fi
if [ -d /tmp/newBootSector ]; then
cleanUp="${cleanUp},1c"
rm /tmp/newbs
fi
if [ -d /tmp/originalBootSector ]; then
cleanUp="${cleanUp},1d"
rm /tmp/origbs
fi
# delete the temporary Chameleon folder
if [ -e "$chamTemp" ]; then
cleanUp="${cleanUp},2"
rm -rf "$chamTemp"
fi
# Remove /.ChameleonEFI file
if [ -f "$dest_vol"/.ChameleonEFI ]; then
cleanUp="${cleanUp},3"
rm "$dest_vol"/.ChameleonEFI
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup: ${cleanUp}"
"$scriptDir"InstallLog.sh "${dest_vol}" "LineBreak"
"$scriptDir"InstallLog.sh "${dest_vol}" "Post script complete"
echo "==============================================="
echo "END - Post Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
branches/ErmaC/Modules/package/Scripts/Main/Standardpostinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
echo "==============================================="
echo "Main Standard Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
# 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
stage0Loader="boot0"
stage0LoaderDualBoot="boot0md"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage2Loader="boot"
targetVolume=$3
targetDevice=$( df "${targetVolume}" | sed -n '2p' | awk '{print $1}' )
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetDiskRaw=${targetDisk/disk/rdisk}
targetSlice=${targetDevice#*disk*s}
targetResources="${targetVolume}/usr/local/bin/"
echo "==============================================="
echo "DEBUG: display script variables"
echo "*******************************"
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 ""
# Write some information to the Install Log
"$scriptDir"InstallLog.sh "${targetVolume}" "Running Standard postinstall script"
"$scriptDir"InstallLog.sh "${targetVolume}" "Target volume = ${targetVolume} on ${targetDevice}"
# Double check we can see the selected partition and it's of the right type.
# If the following script finds anything, it returns 1 to indicate failure.
"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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=$?
# 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=$?
# check the format of the selected partition.
# result should be either hfs or msdos
# Should really check to make sure!
targetFormat=$( fstyp "$targetDevice" )
# 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
# 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
# Append a line break to the installer log
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
if [ ${diskupdate} = "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
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
# Next we look to check for existing Chameleon installations.
# But as it will check /Volumes/EFI for the stage 2 loader,
# we need to make sure it's mounted.
# Tell the user what's going on.
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${targetVolume}" "About to check your disk for previous installations"
"$scriptDir"InstallLog.sh "${targetVolume}" "which involves checking the EFI system partition if"
"$scriptDir"InstallLog.sh "${targetVolume}" "appropriate for this disk."
# Unmount ALL mounted volumes named EFI.
# Returns 0=success, 1=fail
"$scriptDir"UnMountEFIvolumes.sh "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
if [ ${partitionScheme} = 1 ] || [ ${partitionScheme} = 2 ]; then
# Mount the EFI system partition
"$scriptDir"MountESP.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
fi
# Check for another existing Chameleon installation on the same disk
"$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
fi
# 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
fi
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${targetVolume}" "Standard script complete"
echo "==============================================="
echo "END - Standard Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
exit 0
branches/ErmaC/Modules/package/Scripts/Main/preinstall
66
77
88
9
9
10
11
12
1013
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
1145
1246
1347
echo "-----------------------------------------------"
echo ""
# Place holder for maybe setting up install log here?
# Creates text file named 'Chameleon_Installer_Log.txt'
# at the root of the target volume. This is to help show the
# user why the installation process failed (even though the
# package installer ends reading 'Installation Successful'.
# 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
targetVolume=$3
logName="Chameleon_Installer_Log.txt"
logFile="${targetVolume}"/$logName
versionNumber=`cat "${scriptDir}"/Resources/version`
revisionNumber=`cat "${scriptDir}"/Resources/revision`
# Setup Chameleon_Installer_Log.txt file
# by writing header and diskutil list
echo "Chameleon installer log - $( date )
Installer version: ${versionNumber} ${revisionNumber}
======================================================" >"${logFile}"
diskutil list >>"${logFile}"
echo "======================================================" >>"${logFile}"
echo "==============================================="
echo "END - Pre-Install Script"
echo "*********************************"
branches/ErmaC/Modules/package/Scripts/Sub/CheckFormat.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
echo "==============================================="
echo "CheckFormat: Is target HFS or MSDOS?"
echo "**********************************************"
# if the selected partition is formatted as HFS then exit with 1
# if the selected partition is formatted as MSDOS then exit with 2
# if fstyp doesn't return a value then exit with 0
# Receives targetDevice: for example, /dev/disk0s2
# Receives targetVolume: Volume to install to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 3 ]; then
targetDevice="$1"
targetVolume="$2"
scriptDir="$3"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
echo "DEBUG: passed argument for scriptDir = $scriptDir"
else
echo "Error - wrong number of values passed"
exit 9
fi
if [ "$( fstyp "$targetDevice" | grep hfs )" ]; then
#echo "DEBUG: ${targetDevice} is currently formatted as HFS"
#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDevice} is currently formatted as HFS"
exit 1
fi
if [ "$( fstyp "$targetDevice" | grep msdos )" ]; then
#echo "DEBUG: ${targetDevice} is currently formatted as msdos"
#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDevice} is currently formatted as msdos"
exit 2
fi
#echo "DEBUG: WARNING: ${targetDevice} is currently not formatted as either HFS or msdos"
"$scriptDir"InstallLog.sh "${targetVolume}" "WARNING: ${targetDevice} is currently not formatted as either HFS or msdos"
exit 0
branches/ErmaC/Modules/package/Scripts/Sub/CheckPreviousChameleon.sh
44
55
66
7
8
7
8
9
910
11
12
13
1014
1115
1216
......
3034
3135
3236
33
34
35
37
38
39
40
3641
37
3842
3943
4044
......
4246
4347
4448
45
49
50
51
52
53
4654
47
55
56
57
58
59
60
61
62
63
64
65
4866
4967
5068
51
52
53
69
70
71
72
73
74
75
5476
55
56
57
58
59
60
61
62
63
64
65
66
67
77
6878
6979
7080
71
72
73
81
82
7483
75
76
77
84
85
7886
7987
80
81
88
89
8290
83
84
91
92
8593
86
87
88
89
90
91
92
93
94
95
96
97
98
94
95
9996
10097
101
102
103
104
98
99
100
101
102
103
104
105
106
107
108
105109
110
111
112
113
114
115
116
106117
107
108
118
119
109120
110121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
111144
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
132183
133
134
135184
136185
186
137187
138
139188
140189
141190
142191
143
192
echo "Check Previous Chameleon: Will there be problems?"
echo "***********************************************"
# Checks the selected volume is present and the disk is partitioned
# Now also check for another existing Chameleon installation on the same disk.
# Checks for another existing Chameleon installation on the same disk
# and tries to make sure the user doesn't end up with an un-bootable
# system due to having installed Chameleon previously elsewhere.
# Called from the Standard/postinstall and EFI/postinstall scripts
# /Volumes/EFI should already be mounted before this is called.
# Receives targetDisk: for example, /dev/disk3.
# Receives targetDeviceRaw: for example, /dev/rdisk3s1.
# Receives targetDevice: Stores device number, for example /dev/disk2s1.
fi
# Check for existing Chameleon installations on a different
# partition of the same target disk.
#echo "DEBUG: Checking for existing Chameleon installations on ${targetDisk#/dev/}..."
# ===============================================
# Prepare some vars
# ===============================================
sliceNumber=$( echo ${targetDeviceRaw#*disk*s} )
sliceNumber=$( echo ${targetDeviceRaw#*disk*s} )
# strip slice from end
targetDiskRawNoSlice=$( echo ${targetDeviceRaw%$sliceNumber} )
# How many actual partitions are there?
numSlices=$(( $( diskutil list | grep $( echo ${targetDisk#/dev/} ) | sed -n '$=' ) -2 ))
# Only check the disk for Chameleon installations if there is more than one partition.
# ===============================================
# Checking the disk for existing Chameleon installations
# if there is more than one partition on the disk.
# ===============================================
if [ $numSlices -gt 1 ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${installerVolume}" "Checking for previous chameleon installations on ${targetDisk#/dev/}"
# Check the disk's MBR for existing stage 0 boot code (code from CheckDiskMicrocode.sh script)
stage0type=$( dd 2>/dev/null if="$targetDisk" count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
if [ "${stage0type}" == "0a803c" ] || [ "${stage0type}" == "ee7505" ] || [ "${stage0type}" == "742b80" ]; then
stage0type=2
elif [ "${stage0type}" == "0b807c" ]; then
stage0type=1
fi
#Scan all partitions for Chameleon code
for (( i=1; i <= $numSlices; i++ ));
do
stageExistence=0
stage0FirstBootable=0
previousExistence="NONE"
if [ $stage0type == 1 ] || [ $stage0type == 2 ]; then
stagesFound=1
else
stagesFound=0
fi
stage1Existence="NONE"
stage2Existence=0
targetDiskRaw=$targetDiskRawNoSlice$i
# Check for existing stage 0 boot file (same code as CheckDiskMicrocode.sh script)
stage0type=$( dd 2>/dev/null if="$targetDisk" count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
if [ "${stage0type}" == "0b807c" ] || [ "${stage0type}" == "0a803c" ] || [ "${stage0type}" == "ee7505" ] || [ "${stage0type}" == "742b80" ]; then
#echo "DEBUG: boot0 found on $targetDisk"
(( stageExistence++ ))
# While here, check just for either existing boot0hfs, boot0md or boot0md (dmazar's boot0workV2)
if [ "${stage0type}" == "0a803c" ] || [ "${stage0type}" == "ee7505" ] || [ "${stage0type}" == "742b80" ]; then
stage0FirstBootable=1
fi
fi
# Check for existence of a bootable partition boot sector containing either boot1h or boot1f32
boot1Search=$( dd 2>/dev/null if="$targetDiskRaw" count=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${boot1Search:0:16}" == "fa31c08ed0bcf0ff" ] && [ "${boot1Search:1020:2}" == "55" ]; then
#echo "DEBUG: boot1h found on "$targetDiskRaw
(( stageExistence++ ))
previousExistence="boot1"
(( stagesFound++ ))
stage1Existence="boot1h"
elif [ "${boot1Search:0:4}" == "e962" ] && [ "${boot1Search:180:12}" == "424f4f542020" ] && [ "${boot1Search:1020:2}" == "55" ]; then
#echo "DEBUG: boot1f32 found on "$targetDiskRaw
(( stageExistence++ ))
previousExistence="boot1f32"
(( stagesFound++ ))
stage1Existence="boot1f32"
fi
# Check for existing stage 2 boot file also
# NOTE: This will fail to find /boot on /Volumes/EFI as it won't be mounted!
# Check for existing stage 2 boot file.
# Include checking the EFI system partition if it exists and is mounted.
if [ -e "$( df | grep ${targetDisk}s${i} | awk '{ print $6 }' )"/boot ]; then
#echo "DEBUG: boot found on $targetDiskRaw"
(( stageExistence++ ))
(( stagesFound++ ))
stage2Existence=1
fi
#if [ $stageExistence == 3 ] && [ $i -ne $sliceNumber ]; then
#echo "DEBUG: STOP: There is already an existing Chameleon installation on $targetDiskRaw"
#"$scriptDir"InstallLog.sh "${installerVolume}" "STOP: There is already an existing Chameleon installation on $targetDiskRaw."
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: This is allowed and does work as long as you aren't dual booting Windows"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: from the same disk and are happy to control which partition is used by"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: flagging the required partition active. General use doesn't require two"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: Chameleon installs on the same disk, though might be done by advanced users."
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: If you still want to do this then proceed by installing Chameleon manually."
#exit 1
#fi
if [ $stageExistence -ge 2 ] && [ "$previousExistence" != "NONE" ] && [ $i -ne $sliceNumber ]; then
if [ $stagesFound -ge 2 ] && [ "$stage1Existence" != "NONE" ] && [ $i -ne $sliceNumber ]; then
# There is previous Chameleon stage 1 code on a partition boot sector,
# and either a complete or incomplete installation (ie. boot0 or boot are missing).
if [ $stageExistence == 3 ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: There is already an existing Chameleon installation on $targetDiskRaw."
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: $previousExistence already exists at ${targetDisk}s${i}"
if [ $stagesFound == 3 ] && [ $i -lt $sliceNumber ]; then
# Exisitng installation found which will still be default.
message="************************** TAKE NOTE *****************************
**** There is an existing Chameleon installation on $targetDiskRaw
**** and that installation will still be the default loader as it's
**** on an earlier partition. If you want this new installation on
**** $installerVolume to be default then you will need to remove the
**** boot file from $targetDiskRaw and re-run this installer.
**************************************************************"
"$scriptDir"InstallLog.sh "${installerVolume}" "${message}"
fi
if [ $stagesFound == 3 ] && [ $i -gt $sliceNumber ]; then
# Exisitng installation found which will no longer be default.
message="NOTE: There is an existing Chameleon installation on $targetDiskRaw
NOTE: but this installation on $targetDevice will be the default loader
NOTE: because you're installing to an earlier partition on the disk."
"$scriptDir"InstallLog.sh "${installerVolume}" "${message}"
fi
# This could prove problematic and result in either a b1f:error or boot0:error
# if the following conditions are true:
# User could see a b1f:error or boot0:error if the following conditions are true:
# A) Boot0hfs, Boot0md or Boot0md (dmazar's Boot0workV2) is being used.
# B) The previous stage 1 code is on a lower partiton than the one being installed to now.
# C) boot is missing from that partition.
if [ $stagesFound == 2 ] && [ $stage2Existence == 0 ]; then
# Exisitng boot0 and boot1 only found - missing boot
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: Found $stage1Existence installed to ${targetDisk}s${i}"
# stage0type=2 is used to know if 'A' is true.
if [ $stage0type == 2 ]; then
# i = current slice we're checking, slicenumber = slice trying to install to.
if [ $i -lt $sliceNumber ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: Conditions point to the possibility of a boot failure"
# Fix by making previous paritionboot sector un-bootable
# Change Byte 01FExh to 00 (510 decimal)
message="---
FIX: Make ${targetDisk}s${i} boot sector un-bootable by changing byte 1FEh to 00.
NOTE: Any Extra folder you had there will still be there. If you want to use
NOTE: ${targetDisk}s${i} again as your boot partition then re-run this installer
NOTE: selecting it as the target, ONLY choosing the 'Chameleon Bootloader' option
NOTE: and NONE of the other options.
---"
"$scriptDir"InstallLog.sh "${installerVolume}" "${message}"
# stage0FirstBootable=1 is used to know if 'A' is true.
if [ $stage0FirstBootable == 1 ]; then
# i = current slice we're checking, slicenumber = slice trying to install to.
if [ $i -lt $sliceNumber ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: Conditions point to you receiving a boot failure"
# Fix by making previous paritionboot sector un-bootable
# Change Byte 01FExh to 00 (510 decimal)
"$scriptDir"InstallLog.sh "${installerVolume}" "---"
"$scriptDir"InstallLog.sh "${installerVolume}" "FIX: Make ${targetDisk}s${i} boot sector un-bootable by changing byte 1FEh to 00."
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: Any Extra folder you had there will still be there. If you want to use"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: ${targetDisk}s${i} again as your boot partition then re-run this installer"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: selecting it as the target, ONLY choosing the 'Chameleon Bootloader' option"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: and NONE of the other options."
"$scriptDir"InstallLog.sh "${installerVolume}" "---"
dd if=${targetDisk}s${i} count=1 bs=512 of=/tmp/originalBootSector
cp /tmp/originalBootSector /tmp/newBootSector
dd if="$scriptDir/patch" of=/tmp/newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=/tmp/newBootSector of=${targetDisk}s${i} count=1 bs=512
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: but won't interfere as you're installing to an earlier partition."
# /Volumes/EFI needs unmounting before changing partition boot sector
if [ $i == 1 ]; then
umount /Volumes/EFI
else
diskutil unmount "${targetDisk}"s${i}
fi
if [ "$( fstyp "${targetDisk}"s${i} | grep hfs )" ]; then
#echo "DEBUG: HFS - changing byte 1FEh to 00"
dd if=${targetDisk}s${i} count=2 bs=512 of=originalBootSector
cp originalBootSector newBootSector
dd if="patch" of=newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=newBootSector of=${targetDisk}s${i} count=2 bs=510
fi
if [ "$( fstyp "${targetDisk}"s${i} | grep msdos )" ]; then
#echo "DEBUG: MSDOS - changing byte 1FEh to 00"
dd if=${targetDisk}s${i} count=1 bs=512 of=/tmp/originalBootSector
cp /tmp/originalBootSector /tmp/newBootSector
dd if="$scriptDir/patch" of=/tmp/newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=/tmp/newBootSector of=${targetDisk}s${i} count=1 bs=512
fi
# /Volumes/EFI needs re-mounting so EFI/postinstall script can use it.
# Don't check for a GPT as wouldn't have got here if it wasn't
if [ $i == 1 ]; then
"$scriptDir"MountESP.sh "${targetDisk}" "${installerVolume}" "${scriptDir}"
else
diskutil mount "${targetDisk}"s${i}
fi
else
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: but won't interfere as you're installing to an earlier partition."
fi
elif [ $stage0type == 1 ]; then
# boot0 was found which looks for boot1 on the first active partition.
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: so select to boot that partition (if used) with active flag."
#else
#echo "DEBUG: Boot0 not found"
fi
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: so select to boot that partition (if used) with active flag."
fi
fi
done
#else
#echo "DEBUG: Just one slice"
fi
exit 0
exit 0
branches/ErmaC/Modules/package/Scripts/Sub/InstallLog.sh
44
55
66
7
8
9
10
7
8
119
1210
1311
......
2321
2422
2523
24
25
2626
2727
2828
29
30
31
32
3329
34
35
36
37
30
3831
39
40
41
42
43
44
45
46
47
48
49
5032
5133
5234
......
6850
6951
7052
71
53
echo "InstallLog: Create/Append installation log"
echo "**********************************************"
# Creates text file named 'Chameleon_Installer_Log.txt'
# at the root of the target volume. This is to help show the
# user why the installation process failed (even though the
# package installer ends reading 'Installation Successful'.
# Writes to the Chameleon_Installer_Log.txt file created
# by the preinstall script at the start of installation.
# Receives two parameters
# $1 = selected volume for location of the install log
exit 9
fi
logName="Chameleon_Installer_Log.txt"
logFile="${logLocation}"/$logName
# On first run, create a file named .ChameleonLogFlag at
# the root of the target volume. Then check for this file
# on subsequent runs to know the initialisation sequence
# has been done.
if [ ! -f "${logLocation}"/.ChameleonLogFlag ]; then
# This is the first run, so setup
# Chameleon_Installer_Log.txt file
# by writing header.
if [ -f "${logFile}" ]; then
# Also include the first message that this script
# would be called with which will be version/revision
# of Chameleon package.
echo "Chameleon installer log - $( date )
${verboseText}
======================================================" >"${logFile}"
# Create /.ChameleonLogFlag file.
echo "Log" >"${logLocation}"/.ChameleonLogFlag
else
# Append messages to the log as passed by other scripts.
if [ "${verboseText}" = "Diskutil" ]; then
diskutil list >>"${logFile}"
fi
fi
exit 0
exit 0
branches/ErmaC/Modules/package/Scripts/Sub/MountESP.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
echo "==============================================="
echo "MountESP: Mount the EFI system partition"
echo "***********************************************"
# Creates a mountpoint and mounts /Volumes/EFI of the
# supplied disk which would have been pre-checked as using a GPT
# Receives targetDisk: for example /dev/disk2.
# Receives installerVolume: Volume to write the installer log to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 3 ]; then
targetDisk="$1"
installerVolume="$2"
scriptDir="$3"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
echo "DEBUG: passed argument for installerVolume = $installerVolume"
echo "DEBUG: passed argument for scriptDir = $scriptDir"
else
echo "Error - wrong number of values passed"
exit 9
fi
# Does the mountpoint exist?
if [ ! -e "/Volumes/EFI" ]; then
mkdir -p "/Volumes/EFI"
fi
# Mount '/Volumes/EFI' using the correct format type
if [ "$( fstyp "${targetDisk}"s1 | grep hfs )" ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "Mounting ${targetDisk}s1 as /Volumes/EFI"
mount_hfs "${targetDisk}"s1 "/Volumes/EFI"
fi
if [ "$( fstyp "${targetDisk}"s1 | grep msdos )" ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "Mounting ${targetDisk}s1 as /Volumes/EFI"
mount_msdos -u 0 -g 0 "${targetDisk}"s1 "/Volumes/EFI"
fi
exit 0
branches/ErmaC/Modules/package/Scripts/Sub/WriteChameleonStage1.sh
66
77
88
9
9
1010
1111
1212
......
1515
1616
1717
18
18
1919
2020
2121
2222
2323
2424
25
25
2626
2727
2828
......
3434
3535
3636
37
38
37
3938
4039
4140
......
4342
4443
4544
46
47
45
4846
4947
5048
# Writes Chameleon stage 1 loader.
# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives targetFormat: either hfs or msdos
# Receives stage1LoaderHFS: Name of file - boot1h
# Receives stage1LoaderFAT: Name of file - boot1f32
# Receives selectedDestination: for example, /Volumes/USB
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 7 ]; then
espformat="$1"
targetFormat="$1"
stage1LoaderHFS="$2"
stage1LoaderFAT="$3"
selectedDestination="$4"
targetDeviceRaw="$5"
targetVolume="$6"
scriptDir="$7"
echo "DEBUG: passed argument for espformat = $espformat"
echo "DEBUG: passed argument for targetFormat = $targetFormat"
echo "DEBUG: passed argument for stage1LoaderHFS = $stage1LoaderHFS"
echo "DEBUG: passed argument for stage1LoaderFAT = $stage1LoaderFAT"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
exit 9
fi
if [ ${espformat} = "1" ]; then
# the selected partition is HFS formatted
if [ ${targetFormat} = "hfs" ]; then
#echo "DEBUG: Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"
dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}
"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderHFS} to ${targetDeviceRaw}."
fi
if [ ${espformat} = "2" ]; then
# the selected partition FAT formatted
if [ ${targetFormat} = "msdos" ]; then
#echo "DEBUG: Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"
dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs
branches/ErmaC/Modules/package/Scripts/Sub/WriteChameleonStage2.sh
44
55
66
7
8
9
107
118
129
......
1411
1512
1613
17
18
19
20
21
22
23
24
14
15
16
17
18
19
2520
2621
2722
......
3429
3530
3631
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
6232
6333
6434
echo "Write Chameleon Stage 2 Loader:"
echo "*******************************"
# Writes Chameleon stage 2 loader.
# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives stage2Loader: Name of file - boot
# Receives selectedDestination: for example, /Volumes/ChameleonBootUSB (or /Volumes/EFI if ESP install).
# Receives targetDevice: for example, /dev/disk3s1
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 6 ]; then
espformat="$1"
stage2Loader="$2"
selectedDestination="$3"
targetDevice="$4"
targetVolume="$5"
scriptDir="$6"
echo "DEBUG: passed argument for espformat = $espformat"
if [ "$#" -eq 5 ]; then
stage2Loader="$1"
selectedDestination="$2"
targetDevice="$3"
targetVolume="$4"
scriptDir="$5"
echo "DEBUG: passed argument for stage2Loader = $stage2Loader"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
# check to see if install to EFI system partition was selected
if [ "${selectedDestination}" = "/Volumes/EFI" ]; then
#echo "DEBUG: EFI install chosen"
if [ ! -e "${selectedDestination}" ]; then
#echo "DEBUG: Executing Command: mkdir -p ${selectedDestination}"
mkdir -p "${selectedDestination}"
#else
#echo "DEBUG: folder /Volumes/EFI already exists"
fi
#if the EFI system partition was selected then
# mount '/Volumes/EFI' with the correct format type
if [ ${espformat} = 1 ]; then
#echo "Executing command: mount_hfs ${targetDevice} ${targetVolume}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
mount_hfs "${targetDevice}" "${selectedDestination}"
fi
if [ ${espformat} = 2 ]; then
[ -d "${selectedDestination}" ] || mkdir -p "${selectedDestination}"
#echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${selectedDestination}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
mount_msdos -u 0 -g 0 "${targetDevice}" "${selectedDestination}"
fi
#echo "DEBUG: Executing command: cp "${targetVolume}"/usr/standalone/i386/${stage2Loader} ${selectedDestination}"
cp "${targetVolume}"/usr/standalone/i386/"${stage2Loader}" "${selectedDestination}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Written boot to ${selectedDestination}."
branches/ErmaC/Modules/package/Scripts/Sub/SetActivePartition.sh
66
77
88
9
109
1110
1211
1312
1413
1514
16
17
18
19
20
21
22
15
16
17
18
19
20
2321
24
2522
2623
2724
# Sets partition active if Windows is not installed.
# Receives efiformat: code is 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives diskSigCheck: code is 1 for a Windows install, 0 for no Windows install
# Receives targetDiskRaw: for example, /dev/rdisk1
# Receives targetSlice: for example, 1
# Receives targetVolume: Volume to install to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 6 ]; then
efiformat="$1"
diskSigCheck="$2"
targetDiskRaw="$3"
targetSlice="$4"
targetVolume="$5"
scriptDir="$6"
if [ "$#" -eq 5 ]; then
diskSigCheck="$1"
targetDiskRaw="$2"
targetSlice="$3"
targetVolume="$4"
scriptDir="$5"
echo "DEBUG: passed argument for efiformat = $efiformat"
echo "DEBUG: passed argument for diskSigCheck = $diskSigCheck"
echo "DEBUG: passed argument for targetDiskRaw = $targetDiskRaw"
echo "DEBUG: passed argument for targetSlice = $targetSlice"
branches/ErmaC/Modules/package/Scripts/Sub/UnMountEFIvolumes.sh
66
77
88
9
9
1010
1111
1212
......
2323
2424
2525
26
27
28
26
27
2928
3029
3130
3231
33
3432
3533
3634
# loop through and un-mount ALL mounted 'EFI' system partitions - Thanks kizwan
# Receives targetVolumeChosenByUser: Stores original target if EFI install selected.
# Receives targetVolumeChosenByUser: To write install log to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 2 ]; then
# be unmounted in which case the loop would run forever.
attempts=1
while [ "$( df | grep EFI )" ] && [ $attempts -lt 5 ]; do
#echo "DEBUG: Unmounting $( df | grep EFI | awk '{print $1}' )"
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Find and unmount any volume named 'EFI':"
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "$( df | grep EFI | awk '{print $1}' )"
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Volume named 'EFI' is mounted..."
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Unmounting $( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
(( attempts++ ))
done
if [ $attempts = 5 ]; then
#echo "DEBUG: failed to unmount 'EFI' System Partition."
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Failed to unmount 'EFI' System Partition."
exit 1
fi
branches/ErmaC/Modules/package/Resources/en.lproj/Description.html
11
22
33
4
4
55
66
7
8
79
8
10
11
12
13
14
15
16
17
18
19
920
1021
1122
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2844
2945
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.36">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Lucida Grande;}
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; min-height: 12.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; color: #0000ee; min-height: 12.0px}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; color: #0418ee}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px 'Lucida Grande'; color: #0000ee}
span.s1 {color: #0000ee}
span.s2 {text-decoration: underline ; color: #0418ee}
span.s3 {text-decoration: underline ; color: #0000ee}
span.s4 {text-decoration: underline}
span.s5 {color: #000000}
</style>
</head>
<body>
<p class="p1">Chameleon is combination of various boot loader components.<br />It is based on David Elliott's fake EFI implementation added to Apple's boot-132 project.<br />Chameleon is extended with the following key features:</p>
<br />
<p class="p1">New features in Chameleon 2.0</p>
<br>
<p class="p1"> - Fully customizable GUI to bring some color to the Darwin Bootloader.</p>
<p class="p1"> - Booting retail DVDs by directly loading a ramdisk image without help of additional programs.</p>
<p class="p1"> - Hibernation. Enjoy resuming your Mac OS X with a preview image.</p>
<p class="p1"> - SMBIOS override to modify the factory SMBIOS values.</p>
<p class="p1"> - DSDT override to use a modified fixed DSDT which can solve several issues.</p>
<br>
<p class="p1"> - Device Property Injection via device-properties string.</p>
<p class="p1"> - hybrid boot0 / boot1h for MBR and GPT partitioned disks.</p>
<p class="p1"> - automatic FSB detection code even for recent AMD CPUs.</p>
<p class="p1"> - Apple Software RAID support.</p>
<br />
<p class="p1">For detailed information, visit : <a href="http://chameleon.osx86.hu">http://chameleon.osx86.hu</a></p>
<p class="p1">Chameleon is a boot loader built using a combination of components which evolved from the development of David Elliott's fake EFI implementation added to Apple's boot-132 project.</p>
<p class="p2"><br></p>
<p class="p1">Chameleon v2 is extended with many features. For example:</p>
<p class="p2"><br></p>
<p class="p1">- Fully customizable GUI to bring some color to the Darwin Bootloader.</p>
<p class="p1">- Load a ramdisk to directly boot retail DVDs without additional programs.</p>
<p class="p1">- Hibernation. Enjoy resuming your Mac OS X with a preview image.</p>
<p class="p1">- SMBIOS override to modify the factory SMBIOS values.</p>
<p class="p1">- DSDT override to use a modified fixed DSDT which can solve several issues.</p>
<p class="p1">- Device Property Injection via device-properties string.</p>
<p class="p1">- hybrid boot0 / boot1h for MBR and GPT partitioned disks.</p>
<p class="p1">- Automatic FSB detection code even for recent AMD CPUs.</p>
<p class="p1">- Apple Software RAID support.</p>
<p class="p1">- Module support</p>
<p class="p1">- Memory detection adapted from memtest86: <a href="http://www.memtest.org">http://www.memtest.org</a></p>
<p class="p3"><br></p>
<p class="p3"><br></p>
<p class="p1">The code is released under version 2 of the Gnu Public License.</p>
<p class="p4"><a href="http://forge.voodooprojects.org/p/chameleon/">http://forge.voodooprojects.org/p/chameleon</a></p>
<p class="p2"><br></p>
<p class="p1">FAQ's: <a href="http://forum.voodooprojects.org/index.php/topic,754.0.html">http://forum.voodooprojects.org/index.php/topic,754.0.html</a></p>
</body>
</html>
branches/ErmaC/Modules/package/buildpkg.sh
33
44
55
6
76
8
97
10
118
129
1310
......
2017
2118
2219
23
2420
2521
2622
......
5854
5955
6056
61
62
6357
6458
6559
6660
6761
62
63
6864
65
6966
7067
7168
......
10097
10198
10299
103
100
104101
105102
106
107
108103
109
104
110105
111106
112107
113108
114109
115
110
116111
117112
118
119
120113
121
114
122115
123116
124117
125118
126119
127
120
128121
129122
130123
......
226219
227220
228221
229
222
230223
231224
232225
......
235228
236229
237230
238
239231
240232
241233
......
260252
261253
262254
263
255
264256
265257
266258
......
309301
310302
311303
312
304
313305
314306
315307
......
342334
343335
344336
345
346
337
347338
348339
349340
350341
351342
352343
353
344
354345
346
355347
356348
357349
......
367359
368360
369361
370
362
371363
372364
373365
......
451443
452444
453445
454
446
447
448
449
450
451
452
453
454
455455
456456
457457
......
487487
488488
489489
490
490
491491
492492
493493
......
521521
522522
523523
524
525
526524
527
525
528526
529527
530528
......
605603
606604
607605
608
606
609607
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
chamTemp="usr/local/chamTemp"
COL_BLACK="\x1b[30;01m"
COL_BLUE="\x1b[34;01m"
COL_RESET="\x1b[39;49;00m"
#version=$( grep I386BOOT_CHAMELEONVERSION vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build pre install package
# This is run before any other package - so this could
# be a good place to initialise the install log???
echo "================= Preinstall ================="
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Pre/Root
mkdir -p ${1}/Pre/Scripts
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
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/Standard/* ${1}/Standard/Scripts
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
echo "[BUILD] Standard "
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build standard package
# build efi package
mkdir -p ${1}/EFI/Root
mkdir -p ${1}/EFI/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/EFI/* ${1}/EFI/Scripts
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
echo "[BUILD] EFI "
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build efi package
# build reset choice package
mkdir -p ${1}/noboot/Root
echo "[BUILD] Reset choice "
buildpackage "${1}/noboot" "/$chamTemp" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
buildpackage "${1}/noboot" "/$chamTemp" "" "selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
# End build reset choice package
((xmlindent--))
fi
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
}
else
{
fi
# End build Modules packages
# build Extras package
# build options packages
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${builtOptionsList}\"\n\t\ttitle=\"${builtOptionsList}_title\"\n\t\tdescription=\"${builtOptionsList}_description\">\n\t</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.options.$builtOptionsList"
# ------------------------------------------------------
# Read boot option file in to an array.
# ------------------------------------------------------
done
# to indicate exclusive option, call buildoptionalsettings with the 2nd parameter set to 1 .
buildoptionalsettings "$1" "0" "keylayout"
buildoptionalsettings "$1" "1" "keylayout"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# End build theme packages
# End build Extras package
# End build theme packages# End build Extras package
# build post install package
echo "================= Post ================="
packagesidentity="org.chameleon"
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Main/Post/* ${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 "
# clean up
rm -R -f "${1}"
#rm -R -f "${1}"
}
fi
done
x="${x}${stringEnd}"
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\" ${x}" >/dev/null 2>&1
# First exclusive option is the 'no choice' option, so let's make that selected by default.
if [ $c = 0 ]; then
initialChoice="true"
else
initialChoice="false"
fi
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"${initialChoice}\" ${x}" >/dev/null 2>&1
else
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1
fi
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
#rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
if [ "${4}" ]; then
local choiceoptions="\t\t${4}"
fi
#choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${packagename// /}\"\n\t\ttitle=\"${packagename}_title\"\n\t\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' >#${packagename// /}.pkg</pkg-ref>\n\t</choice>\n"
rm -R -f "${1}"
#rm -R -f "${1}"
fi
}
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
main "${1}" "${2}" "${3}" "${4}" #"${5}"

Archive Download the corresponding diff file

Revision: 1651