cocoapods 0.39.0.beta.1 → 0.39.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/cocoapods/gem_version.rb +1 -1
- metadata +35 -63
- data/lib/cocoapods/command/cache/clean.rb +0 -90
- data/lib/cocoapods/command/cache/list.rb +0 -69
- data/lib/cocoapods/command/repo/add.rb +0 -53
- data/lib/cocoapods/command/repo/lint.rb +0 -77
- data/lib/cocoapods/command/repo/list.rb +0 -93
- data/lib/cocoapods/command/repo/push.rb +0 -223
- data/lib/cocoapods/command/repo/remove.rb +0 -36
- data/lib/cocoapods/command/repo/update.rb +0 -27
- data/lib/cocoapods/command/spec/cat.rb +0 -51
- data/lib/cocoapods/command/spec/create.rb +0 -279
- data/lib/cocoapods/command/spec/edit.rb +0 -94
- data/lib/cocoapods/command/spec/lint.rb +0 -119
- data/lib/cocoapods/command/spec/which.rb +0 -43
- data/lib/cocoapods/generator/acknowledgements/markdown.rb +0 -38
- data/lib/cocoapods/generator/acknowledgements/plist.rb +0 -80
- data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +0 -260
- data/lib/cocoapods/generator/xcconfig/pod_xcconfig.rb +0 -83
- data/lib/cocoapods/generator/xcconfig/xcconfig_helper.rb +0 -213
- data/lib/cocoapods/installer/analyzer/analysis_result.rb +0 -46
- data/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb +0 -79
- data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +0 -262
- data/lib/cocoapods/installer/analyzer/specs_state.rb +0 -76
- data/lib/cocoapods/installer/analyzer/target_inspection_result.rb +0 -41
- data/lib/cocoapods/installer/analyzer/target_inspector.rb +0 -203
- data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +0 -186
- data/lib/cocoapods/installer/target_installer/pod_target_installer.rb +0 -297
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +0 -318
- data/lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +0 -173
@@ -1,83 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
module Generator
|
3
|
-
module XCConfig
|
4
|
-
# Generates the private xcconfigs for the pod targets.
|
5
|
-
#
|
6
|
-
# The xcconfig file for a Pod target merges the pod target
|
7
|
-
# configuration values with the default configuration values
|
8
|
-
# required by CocoaPods.
|
9
|
-
#
|
10
|
-
class PodXCConfig
|
11
|
-
# @return [Target] the target represented by this xcconfig.
|
12
|
-
#
|
13
|
-
attr_reader :target
|
14
|
-
|
15
|
-
# Initialize a new instance
|
16
|
-
#
|
17
|
-
# @param [Target] target @see target
|
18
|
-
#
|
19
|
-
def initialize(target)
|
20
|
-
@target = target
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [Xcodeproj::Config] The generated xcconfig.
|
24
|
-
#
|
25
|
-
attr_reader :xcconfig
|
26
|
-
|
27
|
-
# Generates and saves the xcconfig to the given path.
|
28
|
-
#
|
29
|
-
# @param [Pathname] path
|
30
|
-
# the path where the prefix header should be stored.
|
31
|
-
#
|
32
|
-
# @return [void]
|
33
|
-
#
|
34
|
-
def save_as(path)
|
35
|
-
generate.save_as(path)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Generates the xcconfig.
|
39
|
-
#
|
40
|
-
# @return [Xcodeproj::Config]
|
41
|
-
#
|
42
|
-
def generate
|
43
|
-
target_search_paths = target.build_headers.search_paths(target.platform)
|
44
|
-
sandbox_search_paths = target.sandbox.public_headers.search_paths(target.platform)
|
45
|
-
search_paths = target_search_paths.concat(sandbox_search_paths).uniq
|
46
|
-
framework_search_paths = target.dependent_targets.flat_map(&:file_accessors).flat_map(&:vendored_frameworks).map { |fw| '${PODS_ROOT}/' << fw.dirname.relative_path_from(target.sandbox.root).to_s }
|
47
|
-
|
48
|
-
config = {
|
49
|
-
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
|
50
|
-
'PODS_ROOT' => '${SRCROOT}',
|
51
|
-
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths),
|
52
|
-
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
|
53
|
-
'SKIP_INSTALL' => 'YES',
|
54
|
-
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ' << XCConfigHelper.quote(framework_search_paths)
|
55
|
-
# 'USE_HEADERMAP' => 'NO'
|
56
|
-
}
|
57
|
-
|
58
|
-
@xcconfig = Xcodeproj::Config.new(config)
|
59
|
-
|
60
|
-
if target.requires_frameworks? && target.scoped?
|
61
|
-
# Only quote the FRAMEWORK_SEARCH_PATHS entry, because it’s a setting that takes multiple values.
|
62
|
-
# In addition, quoting CONFIGURATION_BUILD_DIR would make it be interpreted as a relative path.
|
63
|
-
build_settings = {
|
64
|
-
'PODS_FRAMEWORK_BUILD_PATH' => target.configuration_build_dir,
|
65
|
-
'FRAMEWORK_SEARCH_PATHS' => '"$PODS_FRAMEWORK_BUILD_PATH"',
|
66
|
-
'CONFIGURATION_BUILD_DIR' => '$PODS_FRAMEWORK_BUILD_PATH',
|
67
|
-
}
|
68
|
-
@xcconfig.merge!(build_settings)
|
69
|
-
end
|
70
|
-
|
71
|
-
XCConfigHelper.add_settings_for_file_accessors_of_target(target, @xcconfig)
|
72
|
-
target.file_accessors.each do |file_accessor|
|
73
|
-
@xcconfig.merge!(file_accessor.spec_consumer.pod_target_xcconfig)
|
74
|
-
end
|
75
|
-
XCConfigHelper.add_target_specific_settings(target, @xcconfig)
|
76
|
-
@xcconfig
|
77
|
-
end
|
78
|
-
|
79
|
-
#-----------------------------------------------------------------------#
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,213 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
module Generator
|
3
|
-
module XCConfig
|
4
|
-
# Stores the shared logic of the classes of the XCConfig module.
|
5
|
-
#
|
6
|
-
module XCConfigHelper
|
7
|
-
# Converts an array of strings to a single string where the each string
|
8
|
-
# is surrounded by double quotes and separated by a space. Used to
|
9
|
-
# represent strings in a xcconfig file.
|
10
|
-
#
|
11
|
-
# @param [Array<String>] strings
|
12
|
-
# a list of strings.
|
13
|
-
#
|
14
|
-
# @param [String] prefix
|
15
|
-
# optional prefix, such as a flag or option.
|
16
|
-
#
|
17
|
-
# @return [String] the resulting string.
|
18
|
-
#
|
19
|
-
def self.quote(strings, prefix = nil)
|
20
|
-
prefix = "#{prefix} " if prefix
|
21
|
-
strings.sort.map { |s| %W( #{prefix}"#{s}" ) }.join(' ')
|
22
|
-
end
|
23
|
-
|
24
|
-
# Return the default linker flags
|
25
|
-
#
|
26
|
-
# @param [Target] target
|
27
|
-
# the target, which is used to check if the ARC compatibility
|
28
|
-
# flag is required.
|
29
|
-
#
|
30
|
-
# @return [String] the default linker flags. `-ObjC` is always included
|
31
|
-
# while `-fobjc-arc` is included only if requested in the
|
32
|
-
# Podfile.
|
33
|
-
#
|
34
|
-
def self.default_ld_flags(target, includes_static_libraries = false)
|
35
|
-
ld_flags = ''
|
36
|
-
ld_flags << '-ObjC' if includes_static_libraries
|
37
|
-
if target.podfile.set_arc_compatibility_flag? &&
|
38
|
-
target.spec_consumers.any?(&:requires_arc?)
|
39
|
-
ld_flags << ' -fobjc-arc'
|
40
|
-
end
|
41
|
-
ld_flags.strip
|
42
|
-
end
|
43
|
-
|
44
|
-
# Configures the given Xcconfig
|
45
|
-
#
|
46
|
-
# @param [PodTarget] target
|
47
|
-
# The pod target, which holds the list of +Spec::FileAccessor+.
|
48
|
-
#
|
49
|
-
# @param [Xcodeproj::Config] xcconfig
|
50
|
-
# The xcconfig to edit.
|
51
|
-
#
|
52
|
-
def self.add_settings_for_file_accessors_of_target(target, xcconfig)
|
53
|
-
target.file_accessors.each do |file_accessor|
|
54
|
-
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig)
|
55
|
-
file_accessor.vendored_frameworks.each do |vendored_framework|
|
56
|
-
XCConfigHelper.add_framework_build_settings(vendored_framework, xcconfig, target.sandbox.root)
|
57
|
-
end
|
58
|
-
file_accessor.vendored_libraries.each do |vendored_library|
|
59
|
-
XCConfigHelper.add_library_build_settings(vendored_library, xcconfig, target.sandbox.root)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# Configures the given Xcconfig according to the build settings of the
|
65
|
-
# given Specification.
|
66
|
-
#
|
67
|
-
# @param [Specification::Consumer] consumer
|
68
|
-
# The consumer of the specification.
|
69
|
-
#
|
70
|
-
# @param [Xcodeproj::Config] xcconfig
|
71
|
-
# The xcconfig to edit.
|
72
|
-
#
|
73
|
-
def self.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
|
74
|
-
xcconfig.libraries.merge(consumer.libraries)
|
75
|
-
xcconfig.frameworks.merge(consumer.frameworks)
|
76
|
-
xcconfig.weak_frameworks.merge(consumer.weak_frameworks)
|
77
|
-
add_developers_frameworks_if_needed(xcconfig, consumer.platform_name)
|
78
|
-
end
|
79
|
-
|
80
|
-
# Configures the given Xcconfig with the build settings for the given
|
81
|
-
# framework path.
|
82
|
-
#
|
83
|
-
# @param [Pathname] framework_path
|
84
|
-
# The path of the framework.
|
85
|
-
#
|
86
|
-
# @param [Xcodeproj::Config] xcconfig
|
87
|
-
# The xcconfig to edit.
|
88
|
-
#
|
89
|
-
# @param [Pathname] sandbox_root
|
90
|
-
# The path retrieved from Sandbox#root.
|
91
|
-
#
|
92
|
-
def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root)
|
93
|
-
name = File.basename(framework_path, '.framework')
|
94
|
-
dirname = '$(PODS_ROOT)/' + framework_path.dirname.relative_path_from(sandbox_root).to_s
|
95
|
-
build_settings = {
|
96
|
-
'OTHER_LDFLAGS' => "-framework #{name}",
|
97
|
-
'FRAMEWORK_SEARCH_PATHS' => quote([dirname]),
|
98
|
-
}
|
99
|
-
xcconfig.merge!(build_settings)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Configures the given Xcconfig with the build settings for the given
|
103
|
-
# library path.
|
104
|
-
#
|
105
|
-
# @param [Pathname] library_path
|
106
|
-
# The path of the library.
|
107
|
-
#
|
108
|
-
# @param [Xcodeproj::Config] xcconfig
|
109
|
-
# The xcconfig to edit.
|
110
|
-
#
|
111
|
-
# @param [Pathname] sandbox_root
|
112
|
-
# The path retrieved from Sandbox#root.
|
113
|
-
#
|
114
|
-
def self.add_library_build_settings(library_path, xcconfig, sandbox_root)
|
115
|
-
name = File.basename(library_path, '.a').sub(/\Alib/, '')
|
116
|
-
dirname = '$(PODS_ROOT)/' + library_path.dirname.relative_path_from(sandbox_root).to_s
|
117
|
-
build_settings = {
|
118
|
-
'OTHER_LDFLAGS' => "-l#{name}",
|
119
|
-
'LIBRARY_SEARCH_PATHS' => '$(inherited) ' + quote([dirname]),
|
120
|
-
}
|
121
|
-
xcconfig.merge!(build_settings)
|
122
|
-
end
|
123
|
-
|
124
|
-
# Add the code signing settings for generated targets to ensure that
|
125
|
-
# frameworks are correctly signed to be integrated and re-signed when
|
126
|
-
# building the application and embedding the framework
|
127
|
-
#
|
128
|
-
# @param [Target] target
|
129
|
-
# The target.
|
130
|
-
#
|
131
|
-
# @param [Xcodeproj::Config] xcconfig
|
132
|
-
# The xcconfig to edit.
|
133
|
-
#
|
134
|
-
def self.add_code_signing_settings(target, xcconfig)
|
135
|
-
build_settings = {}
|
136
|
-
if target.platform.to_sym == :osx
|
137
|
-
build_settings['CODE_SIGN_IDENTITY'] = ''
|
138
|
-
end
|
139
|
-
xcconfig.merge!(build_settings)
|
140
|
-
end
|
141
|
-
|
142
|
-
# Checks if the given target requires specific settings and configures
|
143
|
-
# the given Xcconfig.
|
144
|
-
#
|
145
|
-
# @param [Target] target
|
146
|
-
# The target.
|
147
|
-
#
|
148
|
-
# @param [Xcodeproj::Config] xcconfig
|
149
|
-
# The xcconfig to edit.
|
150
|
-
#
|
151
|
-
def self.add_target_specific_settings(target, xcconfig)
|
152
|
-
if target.requires_frameworks?
|
153
|
-
add_code_signing_settings(target, xcconfig)
|
154
|
-
end
|
155
|
-
add_language_specific_settings(target, xcconfig)
|
156
|
-
end
|
157
|
-
|
158
|
-
# Checks if the given target requires language specific settings and
|
159
|
-
# configures the given Xcconfig.
|
160
|
-
#
|
161
|
-
# @param [Target] target
|
162
|
-
# The target.
|
163
|
-
#
|
164
|
-
# @param [Xcodeproj::Config] xcconfig
|
165
|
-
# The xcconfig to edit.
|
166
|
-
#
|
167
|
-
def self.add_language_specific_settings(target, xcconfig)
|
168
|
-
if target.uses_swift?
|
169
|
-
build_settings = {
|
170
|
-
'OTHER_SWIFT_FLAGS' => '$(inherited) ' + quote(%w(-D COCOAPODS)),
|
171
|
-
}
|
172
|
-
xcconfig.merge!(build_settings)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
# Adds the search paths of the developer frameworks to the specification
|
177
|
-
# if needed. This is done because the `SenTestingKit` requires them and
|
178
|
-
# adding them to each specification which requires it is repetitive and
|
179
|
-
# error prone.
|
180
|
-
#
|
181
|
-
# @param [Xcodeproj::Config] xcconfig
|
182
|
-
# The xcconfig to edit.
|
183
|
-
#
|
184
|
-
# @return [void]
|
185
|
-
#
|
186
|
-
def self.add_developers_frameworks_if_needed(xcconfig, platform)
|
187
|
-
matched_frameworks = xcconfig.frameworks & %w(XCTest SenTestingKit)
|
188
|
-
unless matched_frameworks.empty?
|
189
|
-
search_paths = xcconfig.attributes['FRAMEWORK_SEARCH_PATHS'] ||= ''
|
190
|
-
search_paths_to_add = []
|
191
|
-
search_paths_to_add << '$(inherited)'
|
192
|
-
if platform == :ios || platform == :watchos
|
193
|
-
search_paths_to_add << '"$(SDKROOT)/Developer/Library/Frameworks"'
|
194
|
-
else
|
195
|
-
search_paths_to_add << '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
|
196
|
-
end
|
197
|
-
frameworks_path = '"$(PLATFORM_DIR)/Developer/Library/Frameworks"'
|
198
|
-
search_paths_to_add << frameworks_path
|
199
|
-
search_paths_to_add.each do |search_path|
|
200
|
-
unless search_paths.include?(search_path)
|
201
|
-
search_paths << ' ' unless search_paths.empty?
|
202
|
-
search_paths << search_path
|
203
|
-
end
|
204
|
-
end
|
205
|
-
search_paths
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
#---------------------------------------------------------------------#
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
class Installer
|
3
|
-
class Analyzer
|
4
|
-
class AnalysisResult
|
5
|
-
# @return [SpecsState] the states of the Podfile specs.
|
6
|
-
#
|
7
|
-
attr_accessor :podfile_state
|
8
|
-
|
9
|
-
# @return [Hash{TargetDefinition => Array<Specification>}] the
|
10
|
-
# specifications grouped by target.
|
11
|
-
#
|
12
|
-
attr_accessor :specs_by_target
|
13
|
-
|
14
|
-
# @return [Array<Specification>] the specifications of the resolved
|
15
|
-
# version of Pods that should be installed.
|
16
|
-
#
|
17
|
-
attr_accessor :specifications
|
18
|
-
|
19
|
-
# @return [SpecsState] the states of the {Sandbox} respect the resolved
|
20
|
-
# specifications.
|
21
|
-
#
|
22
|
-
attr_accessor :sandbox_state
|
23
|
-
|
24
|
-
# @return [Array<Target>] The Podfile targets containing library
|
25
|
-
# dependencies.
|
26
|
-
#
|
27
|
-
attr_accessor :targets
|
28
|
-
|
29
|
-
# @return [Hash{TargetDefinition => Array<TargetInspectionResult>}] the
|
30
|
-
# results of inspecting the user targets
|
31
|
-
attr_accessor :target_inspections
|
32
|
-
|
33
|
-
# @return [Hash{String=>Symbol}] A hash representing all the user build
|
34
|
-
# configurations across all integration targets. Each key
|
35
|
-
# corresponds to the name of a configuration and its value to
|
36
|
-
# its type (`:debug` or `:release`).
|
37
|
-
#
|
38
|
-
def all_user_build_configurations
|
39
|
-
targets.reduce({}) do |result, target|
|
40
|
-
result.merge(target.user_build_configurations)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'molinillo/dependency_graph'
|
2
|
-
|
3
|
-
module Pod
|
4
|
-
class Installer
|
5
|
-
class Analyzer
|
6
|
-
# Generates dependencies that require the specific version of the Pods
|
7
|
-
# that haven't changed in the {Lockfile}.
|
8
|
-
module LockingDependencyAnalyzer
|
9
|
-
# Generates dependencies that require the specific version of the Pods
|
10
|
-
# that haven't changed in the {Lockfile}.
|
11
|
-
#
|
12
|
-
# These dependencies are passed to the {Resolver}, unless the installer
|
13
|
-
# is in update mode, to prevent it from upgrading the Pods that weren't
|
14
|
-
# changed in the {Podfile}.
|
15
|
-
#
|
16
|
-
# @return [Molinillo::DependencyGraph<Dependency>] the dependencies
|
17
|
-
# generated by the lockfile that prevent the resolver to update
|
18
|
-
# a Pod.
|
19
|
-
#
|
20
|
-
def self.generate_version_locking_dependencies(lockfile, pods_to_update)
|
21
|
-
dependency_graph = Molinillo::DependencyGraph.new
|
22
|
-
|
23
|
-
if lockfile
|
24
|
-
explicit_dependencies = lockfile.to_hash['DEPENDENCIES'] || []
|
25
|
-
explicit_dependencies.each do |string|
|
26
|
-
dependency = Dependency.new(string)
|
27
|
-
dependency_graph.add_root_vertex(dependency.name, nil)
|
28
|
-
end
|
29
|
-
|
30
|
-
pods = lockfile.to_hash['PODS'] || []
|
31
|
-
pods.each do |pod|
|
32
|
-
add_to_dependency_graph(pod, [], dependency_graph)
|
33
|
-
end
|
34
|
-
|
35
|
-
pods_to_update = pods_to_update.flat_map do |u|
|
36
|
-
root_name = Specification.root_name(u).downcase
|
37
|
-
dependency_graph.vertices.keys.select { |n| Specification.root_name(n).downcase == root_name }
|
38
|
-
end
|
39
|
-
|
40
|
-
pods_to_update.each do |u|
|
41
|
-
dependency_graph.detach_vertex_named(u)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
dependency_graph
|
46
|
-
end
|
47
|
-
|
48
|
-
# Generates a completely 'unlocked' dependency graph.
|
49
|
-
#
|
50
|
-
# @return [Molinillo::DependencyGraph<Dependency>] an empty dependency
|
51
|
-
# graph
|
52
|
-
#
|
53
|
-
def self.unlocked_dependency_graph
|
54
|
-
Molinillo::DependencyGraph.new
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def self.add_child_vertex_to_graph(dependency_string, parents, dependency_graph)
|
60
|
-
dependency = Dependency.from_string(dependency_string)
|
61
|
-
dependency_graph.add_child_vertex(dependency.name, parents.empty? ? dependency : nil, parents, nil)
|
62
|
-
dependency
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.add_to_dependency_graph(object, parents, dependency_graph)
|
66
|
-
case object
|
67
|
-
when String
|
68
|
-
add_child_vertex_to_graph(object, parents, dependency_graph)
|
69
|
-
when Hash
|
70
|
-
object.each do |key, value|
|
71
|
-
dependency = add_child_vertex_to_graph(key, parents, dependency_graph)
|
72
|
-
value.each { |v| add_to_dependency_graph(v, [dependency.name], dependency_graph) }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,262 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
class Installer
|
3
|
-
class Analyzer
|
4
|
-
# Analyze the sandbox to detect which Pods should be removed, and which
|
5
|
-
# ones should be reinstalled.
|
6
|
-
#
|
7
|
-
# The logic is the following:
|
8
|
-
#
|
9
|
-
# Added
|
10
|
-
# - If not present in the sandbox lockfile.
|
11
|
-
# - The directory of the Pod doesn't exits.
|
12
|
-
#
|
13
|
-
# Changed
|
14
|
-
# - The version of the Pod changed.
|
15
|
-
# - The SHA of the specification file changed.
|
16
|
-
# - The specific installed (sub)specs of the same Pod changed.
|
17
|
-
# - The specification is in head mode or from an external source and the
|
18
|
-
# installation process is in update mode.
|
19
|
-
# - The directory of the Pod is empty.
|
20
|
-
# - The Pod has been pre-downloaded.
|
21
|
-
#
|
22
|
-
# Removed
|
23
|
-
# - If a specification is present in the lockfile but not in the resolved
|
24
|
-
# specs.
|
25
|
-
#
|
26
|
-
# Unchanged
|
27
|
-
# - If none of the above conditions match.
|
28
|
-
#
|
29
|
-
class SandboxAnalyzer
|
30
|
-
# @return [Sandbox] The sandbox to analyze.
|
31
|
-
#
|
32
|
-
attr_reader :sandbox
|
33
|
-
|
34
|
-
# @return [Array<Specifications>] The specifications returned by the
|
35
|
-
# resolver.
|
36
|
-
#
|
37
|
-
attr_reader :specs
|
38
|
-
|
39
|
-
# @return [Bool] Whether the installation is performed in update mode.
|
40
|
-
#
|
41
|
-
attr_reader :update_mode
|
42
|
-
|
43
|
-
alias_method :update_mode?, :update_mode
|
44
|
-
|
45
|
-
# @return [Lockfile] The lockfile of the installation as a fall-back if
|
46
|
-
# there is no sandbox manifest. This is indented as a temporary
|
47
|
-
# solution to prevent the full re-installation from users which
|
48
|
-
# are upgrading from CP < 0.17.
|
49
|
-
#
|
50
|
-
# @todo Remove for CP 0.18.
|
51
|
-
#
|
52
|
-
attr_reader :lockfile
|
53
|
-
|
54
|
-
# Init a new SandboxAnalyzer
|
55
|
-
#
|
56
|
-
# @param [Sandbox] sandbox @see sandbox
|
57
|
-
# @param [Array<Specifications>] specs @see specs
|
58
|
-
# @param [Bool] update_mode @see update_mode
|
59
|
-
# @param [Lockfile] lockfile @see lockfile
|
60
|
-
#
|
61
|
-
def initialize(sandbox, specs, update_mode, lockfile = nil)
|
62
|
-
@sandbox = sandbox
|
63
|
-
@specs = specs
|
64
|
-
@update_mode = update_mode
|
65
|
-
@lockfile = lockfile
|
66
|
-
end
|
67
|
-
|
68
|
-
# Performs the analysis to the detect the state of the sandbox respect
|
69
|
-
# to the resolved specifications.
|
70
|
-
#
|
71
|
-
# @return [void]
|
72
|
-
#
|
73
|
-
def analyze
|
74
|
-
state = SpecsState.new
|
75
|
-
if sandbox_manifest
|
76
|
-
all_names = (resolved_pods + sandbox_pods).uniq.sort
|
77
|
-
all_names.sort.each do |name|
|
78
|
-
state.add_name(name, pod_state(name))
|
79
|
-
end
|
80
|
-
else
|
81
|
-
state.added.concat(resolved_pods)
|
82
|
-
end
|
83
|
-
state
|
84
|
-
end
|
85
|
-
|
86
|
-
#---------------------------------------------------------------------#
|
87
|
-
|
88
|
-
private
|
89
|
-
|
90
|
-
# @!group Pod state
|
91
|
-
|
92
|
-
# Returns the state of the Pod with the given name.
|
93
|
-
#
|
94
|
-
# @param [String] pod
|
95
|
-
# the name of the Pod.
|
96
|
-
#
|
97
|
-
# @return [Symbol] The state
|
98
|
-
#
|
99
|
-
def pod_state(pod)
|
100
|
-
return :added if pod_added?(pod)
|
101
|
-
return :deleted if pod_deleted?(pod)
|
102
|
-
return :changed if pod_changed?(pod)
|
103
|
-
:unchanged
|
104
|
-
end
|
105
|
-
|
106
|
-
# Returns whether the Pod with the given name should be installed.
|
107
|
-
#
|
108
|
-
# @note A Pod whose folder doesn't exists is considered added.
|
109
|
-
#
|
110
|
-
# @param [String] pod
|
111
|
-
# the name of the Pod.
|
112
|
-
#
|
113
|
-
# @return [Bool] Whether the Pod is added.
|
114
|
-
#
|
115
|
-
def pod_added?(pod)
|
116
|
-
return true if resolved_pods.include?(pod) && !sandbox_pods.include?(pod)
|
117
|
-
return true unless folder_exist?(pod)
|
118
|
-
false
|
119
|
-
end
|
120
|
-
|
121
|
-
# Returns whether the Pod with the given name should be removed from
|
122
|
-
# the installation.
|
123
|
-
#
|
124
|
-
# @param [String] pod
|
125
|
-
# the name of the Pod.
|
126
|
-
#
|
127
|
-
# @return [Bool] Whether the Pod is deleted.
|
128
|
-
#
|
129
|
-
def pod_deleted?(pod)
|
130
|
-
return true if !resolved_pods.include?(pod) && sandbox_pods.include?(pod)
|
131
|
-
false
|
132
|
-
end
|
133
|
-
|
134
|
-
# Returns whether the Pod with the given name should be considered
|
135
|
-
# changed and thus should be reinstalled.
|
136
|
-
#
|
137
|
-
# @note In update mode, as there is no way to know if a remote source
|
138
|
-
# hash changed the Pods in head mode and the ones from external
|
139
|
-
# sources are always marked as changed.
|
140
|
-
#
|
141
|
-
# @note A Pod whose folder is empty is considered changed.
|
142
|
-
#
|
143
|
-
# @param [String] pod
|
144
|
-
# the name of the Pod.
|
145
|
-
#
|
146
|
-
# @return [Bool] Whether the Pod is changed.
|
147
|
-
#
|
148
|
-
def pod_changed?(pod)
|
149
|
-
spec = root_spec(pod)
|
150
|
-
return true if spec.version != sandbox_version(pod)
|
151
|
-
return true if spec.checksum != sandbox_checksum(pod)
|
152
|
-
return true if resolved_spec_names(pod) != sandbox_spec_names(pod)
|
153
|
-
return true if sandbox.predownloaded?(pod)
|
154
|
-
return true if folder_empty?(pod)
|
155
|
-
return true if sandbox.head_pod?(pod) != sandbox_head_version?(pod)
|
156
|
-
if update_mode
|
157
|
-
return true if sandbox.head_pod?(pod)
|
158
|
-
end
|
159
|
-
false
|
160
|
-
end
|
161
|
-
|
162
|
-
#---------------------------------------------------------------------#
|
163
|
-
|
164
|
-
private
|
165
|
-
|
166
|
-
# @!group Private helpers
|
167
|
-
|
168
|
-
# @return [Lockfile] The manifest to use for the sandbox.
|
169
|
-
#
|
170
|
-
def sandbox_manifest
|
171
|
-
sandbox.manifest || lockfile
|
172
|
-
end
|
173
|
-
|
174
|
-
#--------------------------------------#
|
175
|
-
|
176
|
-
# @return [Array<String>] The name of the resolved Pods.
|
177
|
-
#
|
178
|
-
def resolved_pods
|
179
|
-
specs.map { |spec| spec.root.name }.uniq
|
180
|
-
end
|
181
|
-
|
182
|
-
# @return [Array<String>] The name of the Pods stored in the sandbox
|
183
|
-
# manifest.
|
184
|
-
#
|
185
|
-
def sandbox_pods
|
186
|
-
sandbox_manifest.pod_names.map { |name| Specification.root_name(name) }.uniq
|
187
|
-
end
|
188
|
-
|
189
|
-
# @return [Array<String>] The name of the resolved specifications
|
190
|
-
# (includes subspecs).
|
191
|
-
#
|
192
|
-
# @param [String] pod
|
193
|
-
# the name of the Pod.
|
194
|
-
#
|
195
|
-
def resolved_spec_names(pod)
|
196
|
-
specs.select { |s| s.root.name == pod }.map(&:name).uniq.sort
|
197
|
-
end
|
198
|
-
|
199
|
-
# @return [Array<String>] The name of the specifications stored in the
|
200
|
-
# sandbox manifest (includes subspecs).
|
201
|
-
#
|
202
|
-
# @param [String] pod
|
203
|
-
# the name of the Pod.
|
204
|
-
#
|
205
|
-
def sandbox_spec_names(pod)
|
206
|
-
sandbox_manifest.pod_names.select { |name| Specification.root_name(name) == pod }.uniq.sort
|
207
|
-
end
|
208
|
-
|
209
|
-
# @return [Specification] The root specification for the Pod with the
|
210
|
-
# given name.
|
211
|
-
#
|
212
|
-
# @param [String] pod
|
213
|
-
# the name of the Pod.
|
214
|
-
#
|
215
|
-
def root_spec(pod)
|
216
|
-
specs.find { |s| s.root.name == pod }.root
|
217
|
-
end
|
218
|
-
|
219
|
-
#--------------------------------------#
|
220
|
-
|
221
|
-
# @return [Version] The version of Pod with the given name stored in
|
222
|
-
# the sandbox.
|
223
|
-
#
|
224
|
-
# @param [String] pod
|
225
|
-
# the name of the Pod.
|
226
|
-
#
|
227
|
-
def sandbox_version(pod)
|
228
|
-
sandbox_manifest.version(pod)
|
229
|
-
end
|
230
|
-
|
231
|
-
# @return [String] The checksum of the specification of the Pod with
|
232
|
-
# the given name stored in the sandbox.
|
233
|
-
#
|
234
|
-
# @param [String] pod
|
235
|
-
# the name of the Pod.
|
236
|
-
#
|
237
|
-
def sandbox_checksum(pod)
|
238
|
-
sandbox_manifest.checksum(pod)
|
239
|
-
end
|
240
|
-
|
241
|
-
# @return [Bool] Wether the Pod is installed in the sandbox is in head
|
242
|
-
# mode.
|
243
|
-
#
|
244
|
-
def sandbox_head_version?(pod)
|
245
|
-
sandbox_version(pod).head? == true
|
246
|
-
end
|
247
|
-
|
248
|
-
#--------------------------------------#
|
249
|
-
|
250
|
-
def folder_exist?(pod)
|
251
|
-
sandbox.pod_dir(pod).exist?
|
252
|
-
end
|
253
|
-
|
254
|
-
def folder_empty?(pod)
|
255
|
-
Dir.glob(sandbox.pod_dir(pod) + '*').empty?
|
256
|
-
end
|
257
|
-
|
258
|
-
#---------------------------------------------------------------------#
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|