示例#1
0
        public static void Main(string[] args)
        {
            // CreateDirectory(...) sometimes fails unless we wait (race condition?)
            if (Directory.Exists(keyDir))
            {
                Directory.Delete(keyDir, true);
            }
            Thread.Sleep(100);
            Directory.CreateDirectory(keyDir);

#if !DEBUG
            makeBinaryPlists = true;
#endif

            if (makeBinaryPlists)
            {
                if (!File.Exists(plutil))
                {
                    makeBinaryPlists = false;
                    Console.WriteLine("WARNING: plutil not found! Binary plists will NOT be generated.");
                }
            }

            // TODO: Parse the key page using XPath (action=render) [id tags]
            EnumerateFirmwareListAndSaveKeys("Firmware/Apple_TV");
            //EnumerateFirmwareListAndSaveKeys("Firmware/Apple_Watch");
            EnumerateFirmwareListAndSaveKeys("Firmware/iPad");
            EnumerateFirmwareListAndSaveKeys("Firmware/iPad_mini");
            EnumerateFirmwareListAndSaveKeys("Firmware/iPhone");
            EnumerateFirmwareListAndSaveKeys("Firmware/iPod_touch");

            // Build version listing
            PlistDict plistRoot = new PlistDict();
            foreach (var deviceList in versionsList)
            {
                List <FirmwareVersion> versions  = deviceList.Value;
                PlistArray             deviceArr = new PlistArray(new IPlistElement[versions.Count]);
                for (int i = 0; i < versions.Count; i++)
                {
                    FirmwareVersion ver         = versions[i];
                    PlistDict       versionDict = new PlistDict();
                    versionDict.Add("Build", new PlistString(ver.Build));
                    versionDict.Add("Version", new PlistString(ver.Version));
                    versionDict.Add("Has Keys", new PlistBool(ver.HasKeys));
                    deviceArr.Set(i, versionDict);
                }
                plistRoot.Add(deviceList.Key, deviceArr);
            }

            // Save version listing
            PlistDocument versionDoc  = new PlistDocument(plistRoot);
            string        keyListPath = Path.Combine(keyDir, "KeyList.plist");
            versionDoc.Save(keyListPath, PlistDocumentType.Xml);
            ConvertPlist(keyListPath);
        }
示例#2
0
        private static void ParseAndSaveKeyPage(string contents)
        {
            string[] lines = contents
                             .Replace("{{keys", "")
                             .Replace("}}", "")
                             .Split(new char[] { '\n', '\r' }, 100, StringSplitOptions.RemoveEmptyEntries);

            string displayVersion            = null;
            Dictionary <string, string> data = new Dictionary <string, string>();

            for (int i = 0; i < lines.Length; i++)
            {
                Debug.Assert(lines[i].StartsWith(" | "));
                lines[i] = lines[i].Substring(3); // Remove " | "
                string key   = lines[i].Split(' ')[0];
                string value = lines[i].Split('=')[1];
                if (key == "DisplayVersion")
                {
                    displayVersion = value.Trim();
                    continue;
                }
                else if (key == "Device")
                {
                    Debug.Assert(value.Contains(","));
                }
                else if (key == "DownloadURL")
                {
                    key = "Download URL";
                    continue; // Ignore for now
                }
                else if (key == "RootFS" || key == "GMRootFS" || key == "UpdateRamdisk" || key == "RestoreRamdisk")
                {
                    if (String.IsNullOrWhiteSpace(value))
                    {
                        value = "XXX-XXXX-XXX";
                    }
                }
                else if (key.StartsWith("SEPFirmware"))
                {
                    key = key.Replace("SEPFirmware", "SEP-Firmware");
                }

                data.Add(key, value.Trim());
            }
            if (displayVersion != null && data["Device"].StartsWith("AppleTV"))
            {
                data["Version"] = displayVersion; // Will need to be updated to handle betas
            }
            // the rowspan fixer messes with these builds, so don't worry if it already exists, we'd be saving the same data
            string filename = Path.Combine(keyDir, data["Device"] + "_" + data["Build"] + ".plist");

            if (filename.EndsWith("iPhone1,1_1C25.plist") || filename.EndsWith("iPhone1,1_1C28.plist"))
            {
                if (File.Exists(filename))
                {
                    return;
                }
            }
            Debug.Assert(!File.Exists(filename), filename);

            PlistDocument doc = new PlistDocument(BuildPlist(data));

            doc.Save(filename, PlistDocumentType.Xml);
            ConvertPlist(filename);
        }