Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOCheckRequiresPListVerifierStage Class Reference

#include <OOCheckRequiresPListVerifierStage.h>

+ Inheritance diagram for OOCheckRequiresPListVerifierStage:
+ Collaboration diagram for OOCheckRequiresPListVerifierStage:

Instance Methods

(NSString *) - name [implementation]
 
(BOOL) - shouldRun [implementation]
 
(void) - run [implementation]
 
- Instance Methods inherited from OOFileHandlingVerifierStage
(NSSet *) - dependencies [implementation]
 
(NSSet *) - dependents [implementation]
 
- Instance Methods inherited from OOOXPVerifierStage
(OOOXPVerifier *) - verifier
 
(BOOL) - completed
 
(id) - init [implementation]
 
(void) - dealloc [implementation]
 
(id) - description [implementation]
 
(void) - setVerifier: [implementation]
 
(BOOL) - isDependentOf: [implementation]
 
(void) - registerDependency: [implementation]
 
(void) - dependencyRegistrationComplete [implementation]
 
(BOOL) - canRun [implementation]
 
(void) - performRun [implementation]
 
(void) - noteSkipped [implementation]
 
(NSSet *) - resolvedDependencies [implementation]
 
(NSSet *) - resolvedDependents [implementation]
 
(void) - registerDepedent: [implementation]
 
(void) - dependencyCompleted: [implementation]
 

Detailed Description

Definition at line 33 of file OOCheckRequiresPListVerifierStage.h.

Method Documentation

◆ name

- (NSString *) name
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 33 of file OOCheckRequiresPListVerifierStage.m.

39{
40 return kStageName;
41}
static NSString *const kStageName

References kStageName.

◆ run

- (void) run
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 33 of file OOCheckRequiresPListVerifierStage.m.

57{
58 OOFileScannerVerifierStage *fileScanner = nil;
59 NSDictionary *requiresPList = nil;
60 NSSet *knownKeys = nil;
61 NSMutableSet *actualKeys = nil;
62 NSString *version = nil,
63 *maxVersion = nil;
64 NSArray *ooVersionComponents = nil,
65 *versionComponents = nil,
66 *maxVersionComponents = nil;
67
68 fileScanner = [[self verifier] fileScannerStage];
69 requiresPList = [fileScanner plistNamed:@"requires.plist"
70 inFolder:@"Config"
72 checkBuiltIn:NO];
73
74 if (requiresPList == nil) return;
75
76 // Check that it's a dictionary
77 if (![requiresPList isKindOfClass:[NSDictionary class]])
78 {
79 OOLog(@"verifyOXP.requiresPList.notDict", @"%@", @"***** ERROR: requires.plist is not a dictionary.");
80 return;
81 }
82
83 // Check that all the keys are known.
84 knownKeys = [[self verifier] configurationSetForKey:@"requiresPListSupportedKeys"];
85 actualKeys = [NSMutableSet setWithArray:[requiresPList allKeys]];
86 [actualKeys minusSet:knownKeys];
87
88 if ([actualKeys count] != 0)
89 {
90
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:@", "]);
92 }
93
94 // Sanity check the known keys.
95 version = [requiresPList objectForKey:@"version"];
96 if (version != nil)
97 {
98 if (![version isKindOfClass:[NSString class]])
99 {
100 OOLog(@"verifyOXP.requiresPList.badValue", @"%@", @"***** ERROR: Value for 'version' is not a string.");
101 version = nil;
102 }
103 }
104
105 maxVersion = [requiresPList objectForKey:@"max_version"];
106 if (maxVersion != nil)
107 {
108 if (![maxVersion isKindOfClass:[NSString class]])
109 {
110 OOLog(@"verifyOXP.requiresPList.badValue", @"%@", @"***** ERROR: Value for 'max_version' is not a string.");
111 maxVersion = nil;
112 }
113 }
114
115 if (version != nil || maxVersion != nil)
116 {
117 ooVersionComponents = ComponentsFromVersionString([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]);
118 if (ooVersionComponents == nil)
119 {
120 OOLog(@"verifyOXP.requiresPList.cantFindOoliteVersion", @"%@", @"----- WARNING: could not find Oolite's version for requires.plist sanity check.");
121 }
122 if (version != nil)
123 {
124 versionComponents = ComponentsFromVersionString(version);
125 if (versionComponents == nil)
126 {
127 OOLog(@"verifyOXP.requiresPList.badValue", @"***** ERROR: could not interpret version string \"%@\" as version number.", version);
128 }
129 else if (ooVersionComponents != nil)
130 {
131 if (CompareVersions(ooVersionComponents, versionComponents) == NSOrderedAscending)
132 {
133 OOLog(@"verifyOXP.requiresPList.oxpRequiresNewerOolite", @"----- WARNING: this OXP requires a newer version of Oolite (%@) to work.", version);
134 }
135 }
136 }
137 if (maxVersion != nil)
138 {
139 maxVersionComponents = ComponentsFromVersionString(maxVersion);
140 if (maxVersionComponents == nil)
141 {
142 OOLog(@"verifyOXP.requiresPList.badValue", @"***** ERROR: could not interpret max_version string \"%@\" as version number.", maxVersion);
143 }
144 else if (ooVersionComponents != nil)
145 {
146 if (CompareVersions(ooVersionComponents, maxVersionComponents) == NSOrderedDescending)
147 {
148 OOLog(@"verifyOXP.requiresPList.oxpRequiresOlderOolite", @"----- WARNING: this OXP requires an older version of Oolite (%@) to work.", maxVersion);
149 }
150 }
151 }
152
153 if (versionComponents != nil && maxVersionComponents != nil)
154 {
155 if (CompareVersions(versionComponents, maxVersionComponents) == NSOrderedDescending)
156 {
157 OOLog(@"verifyOXP.requiresPList.noVersionsInRange", @"***** ERROR: this OXP's maximum version (%@) is less than its minimum version (%@).", maxVersion, version);
158 }
159 }
160 }
161}
#define OOLog(class, format,...)
Definition OOLogging.h:88
unsigned count
return nil
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)

◆ shouldRun

- (BOOL) shouldRun
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 33 of file OOCheckRequiresPListVerifierStage.m.

45{
46 OOFileScannerVerifierStage *fileScanner = nil;
47
48 fileScanner = [[self verifier] fileScannerStage];
49 return [fileScanner fileExists:@"requires.plist"
50 inFolder:@"Config"
52 checkBuiltIn:NO];
53}
BOOL fileExists:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)

The documentation for this class was generated from the following files: