28#if OO_OXP_VERIFIER_ENABLED
33static NSString *
const kStageName =
@"Checking requires.plist";
48 fileScanner = [[
self verifier] fileScannerStage];
49 return [fileScanner
fileExists:@"requires.plist"
59 NSDictionary *requiresPList =
nil;
60 NSSet *knownKeys =
nil;
61 NSMutableSet *actualKeys =
nil;
62 NSString *version =
nil,
64 NSArray *ooVersionComponents =
nil,
65 *versionComponents =
nil,
66 *maxVersionComponents =
nil;
68 fileScanner = [[
self verifier] fileScannerStage];
69 requiresPList = [fileScanner
plistNamed:@"requires.plist"
74 if (requiresPList ==
nil)
return;
77 if (![requiresPList isKindOfClass:[NSDictionary
class]])
79 OOLog(
@"verifyOXP.requiresPList.notDict",
@"%@",
@"***** ERROR: requires.plist is not a dictionary.");
84 knownKeys = [[
self verifier] configurationSetForKey:@"requiresPListSupportedKeys"];
85 actualKeys = [NSMutableSet setWithArray:[requiresPList allKeys]];
86 [actualKeys minusSet:knownKeys];
88 if ([actualKeys
count] != 0)
91 OOLog(
@"verifyOXP.requiresPList.unknownKeys",
@"----- WARNING: requires.plist contains unknown keys. This OXP will not be loaded by this version of Oolite. Unknown keys are: %@.", [[actualKeys allObjects] componentsJoinedByString:
@", "]);
95 version = [requiresPList objectForKey:@"version"];
98 if (![version isKindOfClass:[NSString
class]])
100 OOLog(
@"verifyOXP.requiresPList.badValue",
@"%@",
@"***** ERROR: Value for 'version' is not a string.");
105 maxVersion = [requiresPList objectForKey:@"max_version"];
106 if (maxVersion !=
nil)
108 if (![maxVersion isKindOfClass:[NSString
class]])
110 OOLog(
@"verifyOXP.requiresPList.badValue",
@"%@",
@"***** ERROR: Value for 'max_version' is not a string.");
115 if (version !=
nil || maxVersion !=
nil)
118 if (ooVersionComponents ==
nil)
120 OOLog(
@"verifyOXP.requiresPList.cantFindOoliteVersion",
@"%@",
@"----- WARNING: could not find Oolite's version for requires.plist sanity check.");
125 if (versionComponents ==
nil)
127 OOLog(
@"verifyOXP.requiresPList.badValue",
@"***** ERROR: could not interpret version string \"%@\
" as version number.", version);
129 else if (ooVersionComponents !=
nil)
131 if (
CompareVersions(ooVersionComponents, versionComponents) == NSOrderedAscending)
133 OOLog(
@"verifyOXP.requiresPList.oxpRequiresNewerOolite",
@"----- WARNING: this OXP requires a newer version of Oolite (%@) to work.", version);
137 if (maxVersion !=
nil)
140 if (maxVersionComponents ==
nil)
142 OOLog(
@"verifyOXP.requiresPList.badValue",
@"***** ERROR: could not interpret max_version string \"%@\
" as version number.", maxVersion);
144 else if (ooVersionComponents !=
nil)
146 if (
CompareVersions(ooVersionComponents, maxVersionComponents) == NSOrderedDescending)
148 OOLog(
@"verifyOXP.requiresPList.oxpRequiresOlderOolite",
@"----- WARNING: this OXP requires an older version of Oolite (%@) to work.", maxVersion);
153 if (versionComponents !=
nil && maxVersionComponents !=
nil)
155 if (
CompareVersions(versionComponents, maxVersionComponents) == NSOrderedDescending)
157 OOLog(
@"verifyOXP.requiresPList.noVersionsInRange",
@"***** ERROR: this OXP's maximum version (%@) is less than its minimum version (%@).", maxVersion, version);
static NSString *const kStageName
static NSString *const kStageName
#define OOLog(class, format,...)
NSArray * ComponentsFromVersionString(NSString *string)
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2)
id plistNamed:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)
BOOL fileExists:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)