Jump to content

Boot from vanilla Recovery HD, Installation DMG


ErmaC
 Share

7 posts in this topic

Recommended Posts

I open this new topic to discuss/test (and hopefully improve) the proposed changes made by the user N3 on http://forge.voodooprojects.org

Allows zero-config upgrade or reinstall, with app store downloaded installer app, or fresh install, with installer app or official bootable install media, and create bootable Recovery HD during installation. Patch worked on 10.7->10.8, 10.8->10.9 upgrade, reinstall or fresh install.

Updated for Yosemite.

Tested with 10.9->10.10 upgrade, 10.10 reinstall, and fresh install to external disk from existing 10.10.

(Might still require FileNVRAM)

 

So this code and work is not mine (ErmaC), also I not test it right now.

I recentrly merge on the main trunk project the base icons for the recovery disk made long time ago by blackosx (Many thanks! Finally we can use it!)

 

So let's start with the proposed patch:

 

boot.c

--- trunk/i386/boot2/boot.c    2014-10-30 15:01:44.000000000 +0000
+++ trunk_mod/i386/boot2/boot.c    2014-10-30 22:02:41.000000000 +0000
@@ -318,22 +318,28 @@ long LoadKernelCache(const char* cacheFi
     // If boot from a boot helper partition check the kernel cache file on it
     if (gBootVolume->flags & kBVFlagBooter)
     {
-        snprintf(kernelCachePath, sizeof(kernelCachePath), "com.apple.boot.P%s", kernelCacheFile);
+        snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.P/%s", kernelCacheFile);
         ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
 
         if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
         {
-            snprintf(kernelCachePath, sizeof(kernelCachePath), "com.apple.boot.R%s", kernelCacheFile);
+            snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.R/%s", kernelCacheFile);
             ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
 
             if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
             {
-                snprintf(kernelCachePath, sizeof(kernelCachePath), "com.apple.boot.S%s", kernelCacheFile);
+                snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.boot.S/%s", kernelCacheFile);
                 ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
 
-                if ((flags & kFileTypeMask) != kFileTypeFlat)
+                if ((ret == -1) || ((flags & kFileTypeMask) != kFileTypeFlat))
                 {
-                    ret = -1;
+                    snprintf(kernelCachePath, sizeof(kernelCachePath), "/com.apple.recovery.boot/kernelcache", kernelCacheFile);
+                    ret = GetFileInfo(NULL, kernelCachePath, &flags, &cachetime);
+
+                    if ((flags & kFileTypeMask) != kFileTypeFlat)
+                    {
+                        ret = -1;
+                    }
                 }
             }
         }
 

gui.c

--- trunk/i386/boot2/gui.c    2014-10-30 16:41:03.000000000 +0000
+++ trunk_mod/i386/boot2/gui.c    2014-10-30 22:07:31.000000000 +0000
@@ -988,16 +988,14 @@ void drawDeviceIcon(BVRef device, pixmap
         {
             case kPartitionTypeHFS:
             {
-
                 // ErmaC : TODO test needed for recovery icon
-
                 // Use HFSRECOVERY icon.
-//                if (device->flags & kBVFlagBooter)
-//                {
-//                    devicetype = iDeviceHFSRECOVERY;
-//                }
-//                else
-//                {
+                if (device->flags & kBVFlagBooter)
+                {
+                    devicetype = iDeviceHFSRECOVERY;
+                }
+                else
+                {
 
                     // Use HFS or HFSRAID icon depending on bvr flags. Fallbacks are handled by alt_image above.
                     switch (device->OSVersion[3]) {
@@ -1032,7 +1030,7 @@ void drawDeviceIcon(BVRef device, pixmap
                             devicetype = (device->flags & kBVFlagBooter ? iDeviceHFSRAID : iDeviceHFS);
                             break;
                     }
-//                }
+                }
 
                 break;
 

disk.c

--- trunk/i386/libsaio/disk.c    2014-10-30 15:07:54.000000000 +0000
+++ trunk_mod/i386/libsaio/disk.c    2014-10-30 22:03:26.000000000 +0000
@@ -1575,21 +1575,43 @@ static bool getOSVersion(BVRef bvr, char
     config_file_t systemVersion;
     char  dirSpec[512];
 
-    sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
+    sprintf(dirSpec, "hd(%d,%d)/com.apple.recovery.boot/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
 
     if (!loadConfigFile(dirSpec, &systemVersion))
     {
+        bvr->OSisInstaller = true;
         valid = true;
     }
-    else
+
+    if (!valid)
     {
-        sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
+        sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
 
         if (!loadConfigFile(dirSpec, &systemVersion))
         {
-            bvr->OSisServer = true;
+            bvr->OSisInstaller = true;
             valid = true;
         }
+        else
+        {
+            sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
+
+            if (!loadConfigFile(dirSpec, &systemVersion))
+            {
+                bvr->OSisServer = true;
+                valid = true;
+            }
+/*            else
+            {
+                sprintf(dirSpec, "hd(%d,%d)/.IAProductInfo", BIOS_DEV_UNIT(bvr), bvr->part_no);
+
+                if (!loadConfigFile(dirSpec, &systemVersion))
+                {
+
+                }
+            }
+*/
+        }
     }
 
     if (valid)
@@ -1633,7 +1655,19 @@ static bool getOSVersion(BVRef bvr, char
         }
         else
         {
-            close(fh);
+            sprintf(dirSpec, "hd(%d,%d)/.IAPhysicalMedia", BIOS_DEV_UNIT(bvr), bvr->part_no);
+            fh = open(dirSpec, 0);
+
+            if (fh >= 0)
+            {
+                valid = true;
+                bvr->OSisInstaller = true;
+                strcpy(bvr->OSVersion, "10.9"); // 10.9 +
+            }
+            else
+            {
+                close(fh);
+            }
         }
     }
     return valid;
 

stringTable.c

--- trunk/i386/libsaio/stringTable.c    2014-10-30 15:12:08.000000000 +0000
+++ trunk_mod/i386/libsaio/stringTable.c    2014-10-30 22:04:06.000000000 +0000
@@ -614,8 +614,11 @@ int loadConfigFile (const char *configFi
 int loadSystemConfig(config_file_t *config)
 {
     char *dirspec[] = {
+        "/Mac OS X Install Data/com.apple.Boot.plist",
         "/OS X Install Data/com.apple.Boot.plist",
+        "/.IABootFiles/com.apple.Boot.plist", // OS X Installer
         "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist",
+        "/com.apple.recovery.boot/com.apple.Boot.plist" // OS X Recovery
     };
 
     int i, fd, count, ret=-1;
 

Here the diff file to apply on the current trunk(2456) --> recovery.diff recovery.txt (I edit the file extension due to server restriction)

 

Here the precompiled binaries with the changes included.

Please don't upload it on other servers and don't repack it, thank you.

i386_v2456_Recovery_v1.zip

Please don't upload it on other servers and don't repack it, thank you.

 

Credits to N3

 

Cordially

ErmaC

  • Like 3
Link to comment
Share on other sites

  • 2 years later...
  • 2 weeks later...
  • 7 months later...

This is what I get.

Finally got it working by changing

 /Volumes/Recovery\ HD/Extra/org.chameleon.Boot.plist

 

Adding "Kernel Cache" and rp option for "Kernel Flags" make the disk image

mount as root.  I am using AMD cpu and I put all necessary kext to the dmg.

 

 <key>Kernel Cache</key>

<string>\com.apple.recovery.boot\prelinkedkernel</string>

<key>Kernel Flags</key>

<string>rp=file:///com.apple.recovery.boot/BaseSystem.dmg -v npci=0x3000  CsrActiveConfig=1031</string>

Link to comment
Share on other sites

 Share

×
×
  • Create New...