Skip to content

Commit 8e39bfa

Browse files
committed
modify guess algorithm to use latest OC version if there have been no
config.plist format changes
1 parent b24a14c commit 8e39bfa

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["rusty-bits <[email protected]>"]
33
edition = "2021"
44
name = "octool"
5-
version = "0.4.4"
5+
version = "0.4.5"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

src/init.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,20 @@ pub fn validate_plist(
428428
/// run through vec of "config_differences" from tool_config_files/octool_config.json
429429
/// if the current config.plist being worked on contains the field in the vec then
430430
/// it is most likely to be the correct version of OpenCore
431-
pub fn guess_version(resources: &Resources) -> String {
431+
pub fn guess_version(resources: &Resources) -> (String, bool) {
432432
let mut found = vec![Found::new()];
433433
let config_differences: Vec<(String, String, String, String)> =
434434
serde_json::from_value(resources.config_differences["config_differences"].clone()).unwrap();
435435

436+
let mut first_diff = true;
436437
for (sec, sub, search, ver) in config_differences {
437438
find(&search, &resources.config_plist, &mut found);
438439
for result in &found {
439440
if result.keys.contains(&sec) && result.keys.contains(&sub) {
440-
return ver.to_owned();
441+
return (ver.to_owned(), first_diff);
441442
}
442443
}
444+
first_diff = false;
443445
}
444-
"".to_string()
446+
("".to_string(), false)
445447
}

src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::edit::read_key;
2626
use crate::init::{guess_version, Manifest, Settings};
2727
use crate::res::Resources;
2828

29-
const OCTOOL_VERSION: &str = &"v0.4.4 2022-07-17";
29+
const OCTOOL_VERSION: &str = &"v0.4.5 2022-07-22";
3030

3131
fn process(
3232
config_plist: &mut PathBuf,
@@ -864,7 +864,18 @@ fn main() {
864864
resources.config_plist = plist::Value::from_file(&config_file)
865865
.expect(format!("Didn't find valid plist at {:?}", config_file).as_str());
866866
if &setup.oc_build_version == "latest" {
867-
setup.oc_build_version = guess_version(&resources);
867+
let first_diff;
868+
(setup.oc_build_version, first_diff) = guess_version(&resources);
869+
//use the latest version of OpenCore as a guess if there have been no changes to the
870+
//config.plist, this makes the assumption that the user wants to keep the OpenCore
871+
//version current, they can always use a Manifest or manually use an older version
872+
if first_diff {
873+
setup.oc_build_version = resources.dortania["OpenCorePkg"]["versions"][0]
874+
["version"]
875+
.as_str()
876+
.unwrap()
877+
.to_owned();
878+
}
868879
if &setup.oc_build_version == "" {
869880
// set to version befoce ocvalidate, maybe do something better in the future
870881
setup.oc_build_version = "0.5.9".to_string();

tool_config_files/config_differences.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"config_differences": [
33
[
4-
"Kernel", "Quirks", "ForceAquantiaEthernet", "0.8.2"
4+
"Kernel", "Quirks", "ForceAquantiaEthernet", "0.8.0"
55
],
66
[
77
"Misc", "Debug", "LogModules", "0.7.9"

tool_config_files/octool_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"octool_version": "v0.4.4 2022-07-17",
2+
"octool_version": "v0.4.5 2022-07-22",
33
"octool_releases_url": "https://github.com/rusty-bits/octool/releases",
44
"octool_latest_config_url": "https://raw.githubusercontent.com/rusty-bits/octool/main/tool_config_files/octool_config.json",
55
"octool_latest_dyn_res_list_url": "https://raw.githubusercontent.com/rusty-bits/octool/main/tool_config_files/dyn_res_list.zip",
@@ -32,7 +32,7 @@
3232
"reset_res_versions": true,
3333

3434
"//comm_clob_local": "replace local res list with updated list when octool is run",
35-
"clobber_local_dyn_res_list": true,
35+
"clobber_local_dyn_res_list": false,
3636

3737
"//comm_build": "set use of either 'X64' or 'IA32' build architecture",
3838
"build_architecture": "X64",

0 commit comments

Comments
 (0)