lg_pod_plugin 1.1.7.4 → 1.1.8.1
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/lib/lg_pod_plugin/db/database.rb +1 -1
- data/lib/lg_pod_plugin/downloader/downloader.rb +9 -48
- data/lib/lg_pod_plugin/downloader/l_cache.rb +58 -66
- data/lib/lg_pod_plugin/downloader/overload_cache.rb +14 -284
- data/lib/lg_pod_plugin/downloader/request.rb +2 -4
- data/lib/lg_pod_plugin/git/github_api.rb +2 -49
- data/lib/lg_pod_plugin/git/github_archive.rb +11 -32
- data/lib/lg_pod_plugin/git/gitlab_api.rb +42 -42
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +7 -80
- data/lib/lg_pod_plugin/git/http_download.rb +3 -8
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/install.rb +15 -12
- data/lib/lg_pod_plugin/installer/main.rb +5 -0
- data/lib/lg_pod_plugin/net/l_uri.rb +1 -34
- data/lib/lg_pod_plugin/pod/external_pod.rb +0 -1
- data/lib/lg_pod_plugin/pod/release-pod.rb +4 -4
- data/lib/lg_pod_plugin/utils/file_path.rb +5 -0
- data/lib/lg_pod_plugin/utils/l_util.rb +0 -24
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +1 -1
- metadata +9 -26
- data/lib/lg_pod_plugin/config/lockfile_model.rb +0 -58
- data/lib/lg_pod_plugin/config/podspec.rb +0 -266
- data/lib/lg_pod_plugin/utils/aes-crypt.rb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64cfe9f5818b1ad35a426e047a1639889db338c028923af2e2cbc9c4e31556da
|
4
|
+
data.tar.gz: ce53c502a2bbbeb261dfe3dc048a8e423848f7f29633956447c0abe1b474712d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a6f5bc095f471f44cb2effd225be4bcf1c10622374adbe7f00d2b7953f0be3b09f763307ba167456169ba862e629e0cdf3e5596228f093461ee98fb35c3b21d
|
7
|
+
data.tar.gz: e081fa09f5ba85d7a9a581b30a8fabf9e83ce89c200bd020b3a9bdc0a8b6b955cf61b01fd1c0279ea2dbec406f77b6b790fd42397a2989632a3eb8fa918c5f28
|
@@ -15,27 +15,18 @@ module LgPodPlugin
|
|
15
15
|
# 预下载处理
|
16
16
|
def pre_download_pod
|
17
17
|
name = self.request.name
|
18
|
-
|
19
|
-
podspec = self.request.lg_spec.spec
|
20
|
-
else
|
21
|
-
podspec = nil
|
22
|
-
end
|
18
|
+
podspec = self.request.podspec
|
23
19
|
checkout_options = Hash.new.merge!(self.request.checkout_options)
|
24
20
|
http = checkout_options[:http]
|
25
21
|
git = checkout_options[:git]
|
26
22
|
tag = checkout_options[:tag]
|
27
23
|
branch = checkout_options[:branch]
|
28
24
|
checkout_options[:name] = name if name
|
29
|
-
checkout_options[:spec] = self.request.lg_spec if podspec
|
30
25
|
unless branch
|
31
26
|
branch = self.request.params[:branch] if self.request.params[:branch]
|
32
27
|
checkout_options[:branch] = branch if branch
|
33
28
|
end
|
34
29
|
commit = checkout_options[:commit]
|
35
|
-
# unless commit
|
36
|
-
# commit = self.request.params[:commit] if self.request.params[:commit]
|
37
|
-
# checkout_options[:commit] = commit if commit
|
38
|
-
# end
|
39
30
|
if branch
|
40
31
|
LgPodPlugin.log_green "Using `#{name}` (#{branch})"
|
41
32
|
elsif tag
|
@@ -49,10 +40,13 @@ module LgPodPlugin
|
|
49
40
|
LgPodPlugin.log_green "Using `#{name}`"
|
50
41
|
end
|
51
42
|
hash_map = self.request.get_cache_key_params
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
if request.single_git
|
44
|
+
commit = hash_map[:commit] unless commit
|
45
|
+
checkout_options[:commit] = commit if commit
|
46
|
+
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, {:git => git}, podspec, self.request.released_pod)
|
47
|
+
else
|
48
|
+
pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
|
49
|
+
end
|
56
50
|
if pod_is_exist
|
57
51
|
LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
|
58
52
|
return nil
|
@@ -62,42 +56,9 @@ module LgPodPlugin
|
|
62
56
|
# 本地 git 下载 pod 目录
|
63
57
|
download_params = self.pre_download_git_repository(checkout_options)
|
64
58
|
if download_params && download_params.is_a?(Hash)
|
59
|
+
download_params["dirname"] = destination.dirname
|
65
60
|
download_params["destination"] = destination
|
66
61
|
download_params["cache_pod_spec_path"] = cache_pod_spec
|
67
|
-
podspec = download_params["podspec"]
|
68
|
-
podspec_content = download_params["podspec_content"]
|
69
|
-
if podspec
|
70
|
-
podspec_json = podspec.to_pretty_json
|
71
|
-
download_params["podspec_json"] = podspec_json if podspec
|
72
|
-
download_params["prepare_command"] = podspec.prepare_command if podspec
|
73
|
-
download_params.delete("podspec")
|
74
|
-
unless self.request.lg_spec
|
75
|
-
self.request.lg_spec = podspec
|
76
|
-
end
|
77
|
-
elsif podspec_content
|
78
|
-
path = download_params["path"]
|
79
|
-
podspec_path = path + "/#{name}.podspec"
|
80
|
-
begin
|
81
|
-
File.open(podspec_path,"w+") do|f|
|
82
|
-
f.write podspec_content
|
83
|
-
end
|
84
|
-
end
|
85
|
-
if File.exist?(podspec_path)
|
86
|
-
lg_spec = LgPodPlugin::PodSpec.form_file podspec_path
|
87
|
-
if lg_spec
|
88
|
-
self.request.lg_spec = lg_spec
|
89
|
-
download_params["podspec_json"] = lg_spec.to_pretty_json
|
90
|
-
download_params["source_files"] = lg_spec.source_files.keys
|
91
|
-
download_params["prepare_command"] = lg_spec.prepare_command if lg_spec.prepare_command
|
92
|
-
download_params.delete("podspec_content")
|
93
|
-
else
|
94
|
-
download_params["source_files"] = ["All"]
|
95
|
-
download_params["prepare_command"] = nil
|
96
|
-
download_params["podspec_json"] = podspec_content
|
97
|
-
download_params.delete("podspec_content")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
62
|
return download_params
|
102
63
|
elsif File.exist?(download_params.to_s) && download_params
|
103
64
|
FileUtils.chdir download_params
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
require 'cocoapods/downloader'
|
3
3
|
require 'cocoapods/downloader/cache'
|
4
4
|
require 'cocoapods/downloader/response'
|
@@ -12,32 +12,34 @@ module LgPodPlugin
|
|
12
12
|
end
|
13
13
|
|
14
14
|
public
|
15
|
+
|
15
16
|
def pod_cache_exist(name, options, spec = nil, released_pod = false)
|
16
17
|
# 参数为空不执行下载任务, 交给 cocoapods 处理下载
|
17
18
|
if options.nil?
|
18
|
-
return
|
19
|
+
return [true, nil, nil]
|
19
20
|
end
|
20
|
-
|
21
21
|
destination, cache_pod_spec = self.find_pod_cache name, options, spec, released_pod
|
22
|
-
lock_temp_file = destination.to_path+ ".lock"
|
22
|
+
lock_temp_file = destination.to_path + ".lock"
|
23
23
|
if File.exist?(lock_temp_file)
|
24
24
|
FileUtils.rm_rf lock_temp_file
|
25
25
|
end
|
26
|
-
if
|
26
|
+
if destination && destination.exist? && !destination.children.empty?
|
27
27
|
return [true, destination, cache_pod_spec]
|
28
28
|
else
|
29
29
|
return [false, destination, cache_pod_spec]
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
# 判断缓存是否存在且有效命中缓存
|
34
|
+
|
34
35
|
public
|
36
|
+
|
35
37
|
def find_pod_cache(name, options, spec = nil, released_pod = false)
|
36
38
|
hash_map = Hash.new.merge!(options)
|
37
39
|
if hash_map.has_key?(:version)
|
38
40
|
hash_map.delete(:version)
|
39
41
|
end
|
40
|
-
request = LCache.
|
42
|
+
request = LCache.create_download_request(name, hash_map, spec, released_pod)
|
41
43
|
destination = LCache.path_for_pod(request)
|
42
44
|
cache_pod_spec = LCache.path_for_spec(request)
|
43
45
|
[destination, cache_pod_spec]
|
@@ -48,32 +50,50 @@ module LgPodPlugin
|
|
48
50
|
Pathname(path)
|
49
51
|
end
|
50
52
|
|
51
|
-
def self.
|
53
|
+
def self.create_download_request(name, params, spec = nil, released_pod = false)
|
52
54
|
if released_pod
|
53
|
-
Pod::Downloader::Request.new(spec: spec, released: true
|
55
|
+
Pod::Downloader::Request.new(spec: spec, released: true, name: name, params: params)
|
56
|
+
else
|
57
|
+
Pod::Downloader::Request.new(spec: nil, released: false, name: name, params: params)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.create_downloader_manager(request, target)
|
62
|
+
result = Pod::Downloader::Response.new
|
63
|
+
result.checkout_options = request.params
|
64
|
+
result.location = target
|
65
|
+
|
66
|
+
if request.released_pod?
|
67
|
+
result.spec = request.spec
|
68
|
+
podspecs = { request.name => request.spec }
|
54
69
|
else
|
55
|
-
Pod::
|
70
|
+
podspecs = Pod::Sandbox::PodspecFinder.new(target).podspecs
|
71
|
+
podspecs[request.name] = request.spec if request.spec
|
72
|
+
podspecs.each do |name, spec|
|
73
|
+
if request.name == name
|
74
|
+
result.spec = spec
|
75
|
+
end
|
76
|
+
end
|
56
77
|
end
|
78
|
+
|
79
|
+
[result, podspecs]
|
57
80
|
end
|
58
|
-
|
81
|
+
|
82
|
+
def self.root_cache
|
83
|
+
cache_path = LFileManager.cache_root_path
|
84
|
+
return Pod::Downloader::Cache.new(cache_path)
|
85
|
+
end
|
86
|
+
|
87
|
+
# MARK - 缓存方法
|
59
88
|
def self.path_for_pod(request, slug_opts = {})
|
60
|
-
|
61
|
-
root + request.slug(**slug_opts)
|
89
|
+
root_path + request.slug(**slug_opts)
|
62
90
|
end
|
63
91
|
|
64
92
|
def self.path_for_spec(request, slug_opts = {})
|
65
|
-
|
66
|
-
path
|
67
|
-
Pathname.new(path.to_path + '.podspec.json')
|
93
|
+
path = root_path + 'Specs' + request.slug(**slug_opts)
|
94
|
+
return Pathname.new(path.to_path + '.podspec.json')
|
68
95
|
end
|
69
96
|
|
70
|
-
# def self.cached_spec(request)
|
71
|
-
# path = path_for_spec(request)
|
72
|
-
# path.file? && Specification.from_file(path)
|
73
|
-
# rescue JSON::ParserError
|
74
|
-
# nil
|
75
|
-
# end
|
76
|
-
|
77
97
|
def self.get_local_spec(request, target)
|
78
98
|
result = Pod::Downloader::Response.new
|
79
99
|
result.location = target
|
@@ -95,62 +115,29 @@ module LgPodPlugin
|
|
95
115
|
[result, local_specs]
|
96
116
|
end
|
97
117
|
|
98
|
-
def self.group_subspecs_by_platform(spec)
|
99
|
-
specs_by_platform = {}
|
100
|
-
[spec, *spec.recursive_subspecs].each do |ss|
|
101
|
-
ss.available_platforms.each do |platform|
|
102
|
-
specs_by_platform[platform] ||= []
|
103
|
-
specs_by_platform[platform] << ss
|
104
|
-
end
|
105
|
-
end
|
106
|
-
specs_by_platform
|
107
|
-
end
|
108
|
-
|
109
118
|
def self.copy_and_clean(source, destination, spec)
|
110
|
-
|
111
|
-
destination.parent.mkpath
|
112
|
-
self.write_lock(destination) do
|
113
|
-
FileUtils.rm_rf(destination)
|
114
|
-
FileUtils.cp_r(source, destination)
|
115
|
-
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
116
|
-
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def self.clean_pod_unused_files(destination, spec)
|
121
|
-
specs_by_platform = group_subspecs_by_platform(spec)
|
122
|
-
destination.parent.mkpath
|
123
|
-
self.write_lock(destination) do
|
124
|
-
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
125
|
-
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def self.write_lock(location, &block)
|
130
|
-
Pod::Downloader::Cache.lock(location, File::LOCK_SH, &block)
|
119
|
+
return self.root_cache.copy_and_clean(source, destination, spec)
|
131
120
|
end
|
132
121
|
|
133
122
|
public
|
123
|
+
|
134
124
|
def self.write_spec(spec, path)
|
135
|
-
|
136
|
-
Pod::Downloader::Cache.write_lock(path) do
|
137
|
-
path.open('w') { |f|
|
138
|
-
f.write spec.to_pretty_json
|
139
|
-
}
|
140
|
-
end
|
125
|
+
self.root_cache.write_spec(spec, path)
|
141
126
|
end
|
142
127
|
|
143
128
|
# 拷贝 pod 缓存文件到 sandbox
|
129
|
+
|
144
130
|
public
|
131
|
+
|
145
132
|
def self.cache_pod(name, target, options = {}, spec = nil, released_pod = false)
|
146
133
|
checkout_options = Hash.new.deep_merge(options).reject do |key, val|
|
147
134
|
!key || !val
|
148
135
|
end
|
149
|
-
request =
|
150
|
-
|
151
|
-
pods_pecs.each do |
|
152
|
-
destination = path_for_pod
|
153
|
-
if !
|
136
|
+
request = create_download_request(name, checkout_options, spec, released_pod)
|
137
|
+
result, pods_pecs = create_downloader_manager(request, target)
|
138
|
+
pods_pecs.each do |name, s_spec|
|
139
|
+
destination = path_for_pod request, { :name => name, :params => checkout_options }
|
140
|
+
if !destination.exist? || destination.children.empty?
|
154
141
|
LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
|
155
142
|
copy_and_clean(target, destination, s_spec)
|
156
143
|
end
|
@@ -158,8 +145,13 @@ module LgPodPlugin
|
|
158
145
|
unless File.exist?(cache_pod_spec)
|
159
146
|
write_spec(s_spec, cache_pod_spec)
|
160
147
|
end
|
148
|
+
if request.name == name
|
149
|
+
result.location = destination
|
150
|
+
end
|
161
151
|
end
|
162
152
|
|
153
|
+
result
|
154
|
+
|
163
155
|
end
|
164
156
|
|
165
157
|
end
|
@@ -1,6 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'cocoapods'
|
4
1
|
require 'fileutils'
|
5
2
|
require 'tmpdir'
|
6
3
|
|
@@ -10,155 +7,9 @@ module Pod
|
|
10
7
|
# them in a cache directory.
|
11
8
|
#
|
12
9
|
class Cache
|
13
|
-
# @return [Pathname] The root directory where this cache store its
|
14
|
-
# downloads.
|
15
|
-
#
|
16
|
-
attr_reader :root
|
17
|
-
|
18
|
-
# Initialize a new instance
|
19
|
-
#
|
20
|
-
# @param [Pathname,String] root
|
21
|
-
# see {#root}
|
22
|
-
#
|
23
|
-
def initialize(root)
|
24
|
-
@root = Pathname(root)
|
25
|
-
ensure_matching_version
|
26
|
-
end
|
27
|
-
|
28
|
-
# Downloads the Pod from the given `request`
|
29
|
-
#
|
30
|
-
# @param [Request] request
|
31
|
-
# the request to be downloaded.
|
32
|
-
#
|
33
|
-
# @return [Response] the response from downloading `request`
|
34
|
-
#
|
35
|
-
def download_pod(request)
|
36
|
-
cached_pod(request) || uncached_pod(request)
|
37
|
-
rescue Informative
|
38
|
-
raise
|
39
|
-
rescue
|
40
|
-
UI.puts("\n[!] Error installing #{request.name}".red)
|
41
|
-
raise
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [Hash<String, Hash<Symbol, String>>]
|
45
|
-
# A hash whose keys are the pod name
|
46
|
-
# And values are a hash with the following keys:
|
47
|
-
# :spec_file : path to the spec file
|
48
|
-
# :name : name of the pod
|
49
|
-
# :version : pod version
|
50
|
-
# :release : boolean to tell if that's a release pod
|
51
|
-
# :slug : the slug path where the pod cache is located
|
52
|
-
#
|
53
|
-
def cache_descriptors_per_pod
|
54
|
-
specs_dir = root + 'Specs'
|
55
|
-
release_specs_dir = specs_dir + 'Release'
|
56
|
-
return {} unless specs_dir.exist?
|
57
|
-
|
58
|
-
spec_paths = specs_dir.find.select { |f| f.fnmatch('*.podspec.json') }
|
59
|
-
spec_paths.reduce({}) do |hash, spec_path|
|
60
|
-
spec = Specification.from_file(spec_path)
|
61
|
-
hash[spec.name] ||= []
|
62
|
-
is_release = spec_path.to_s.start_with?(release_specs_dir.to_s)
|
63
|
-
request = Downloader::Request.new(:spec => spec, :released => is_release)
|
64
|
-
hash[spec.name] << {
|
65
|
-
:spec_file => spec_path,
|
66
|
-
:name => spec.name,
|
67
|
-
:version => spec.version,
|
68
|
-
:release => is_release,
|
69
|
-
:slug => root + request.slug,
|
70
|
-
}
|
71
|
-
hash
|
72
|
-
end
|
73
|
-
end
|
74
10
|
|
75
|
-
# Convenience method for acquiring a shared lock to safely read from the
|
76
|
-
# cache. See `Cache.lock` for more details.
|
77
|
-
#
|
78
|
-
# @param [Pathname] location
|
79
|
-
# the path to require a lock for.
|
80
|
-
#
|
81
|
-
# @param [block] &block
|
82
|
-
# the block to execute inside the lock.
|
83
|
-
#
|
84
|
-
# @return [void]
|
85
|
-
#
|
86
|
-
def self.read_lock(location, &block)
|
87
|
-
Cache.lock(location, File::LOCK_SH, &block)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Convenience method for acquiring an exclusive lock to safely write to
|
91
|
-
# the cache. See `Cache.lock` for more details.
|
92
|
-
#
|
93
|
-
# @param [Pathname] location
|
94
|
-
# the path to require a lock for.
|
95
|
-
#
|
96
|
-
# @param [block] &block
|
97
|
-
# the block to execute inside the lock.
|
98
|
-
#
|
99
|
-
# @return [void]
|
100
|
-
#
|
101
|
-
def self.write_lock(location, &block)
|
102
|
-
Cache.lock(location, File::LOCK_EX, &block)
|
103
|
-
end
|
104
|
-
|
105
|
-
# Creates a .lock file at `location`, aquires a lock of type
|
106
|
-
# `lock_type`, checks that it is valid, and executes passed block while
|
107
|
-
# holding on to that lock. Afterwards, the .lock file is deleted, which is
|
108
|
-
# why validation of the lock is necessary, as you might have a lock on a
|
109
|
-
# file that doesn't exist on the filesystem anymore.
|
110
|
-
#
|
111
|
-
# @param [Pathname] location
|
112
|
-
# the path to require a lock for.
|
113
|
-
#
|
114
|
-
# @param [locking_constant] lock_type
|
115
|
-
# the type of lock, either exclusive (File::LOCK_EX) or shared
|
116
|
-
# (File::LOCK_SH).
|
117
|
-
#
|
118
|
-
# @return [void]
|
119
|
-
#
|
120
|
-
def self.lock(location, lock_type)
|
121
|
-
raise ArgumentError, 'no block given' unless block_given?
|
122
|
-
lockfile = "#{location}.lock"
|
123
|
-
f = nil
|
124
|
-
loop do
|
125
|
-
f.close if f
|
126
|
-
f = File.open(lockfile, File::CREAT, 0o644)
|
127
|
-
f.flock(lock_type)
|
128
|
-
break if Cache.valid_lock?(f, lockfile)
|
129
|
-
end
|
130
|
-
begin
|
131
|
-
yield location
|
132
|
-
ensure
|
133
|
-
if lock_type == File::LOCK_SH
|
134
|
-
f.flock(File::LOCK_EX)
|
135
|
-
File.delete(lockfile) if Cache.valid_lock?(f, lockfile)
|
136
|
-
else
|
137
|
-
File.delete(lockfile)
|
138
|
-
end
|
139
|
-
f.close
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
# Checks that the lock is on a file that still exists on the filesystem.
|
144
|
-
#
|
145
|
-
# @param [File] file
|
146
|
-
# the actual file that we have a lock for.
|
147
|
-
#
|
148
|
-
# @param [String] filename
|
149
|
-
# the filename of the file that we have a lock for.
|
150
|
-
#
|
151
|
-
# @return [Boolean]
|
152
|
-
# true if `filename` still exists and is the same file as `file`
|
153
|
-
#
|
154
|
-
def self.valid_lock?(file, filename)
|
155
|
-
file.stat.ino == File.stat(filename).ino
|
156
|
-
rescue Errno::ENOENT
|
157
|
-
false
|
158
|
-
end
|
159
11
|
|
160
12
|
private
|
161
|
-
|
162
13
|
# Ensures the cache on disk was created with the same CocoaPods version as
|
163
14
|
# is currently running.
|
164
15
|
#
|
@@ -178,152 +29,31 @@ module Pod
|
|
178
29
|
end
|
179
30
|
end
|
180
31
|
|
181
|
-
|
182
|
-
# the request to be downloaded.
|
183
|
-
#
|
184
|
-
# @param [Hash<Symbol,String>] slug_opts
|
185
|
-
# the download options that should be used in constructing the
|
186
|
-
# cache slug for this request.
|
187
|
-
#
|
188
|
-
# @return [Pathname] The path for the Pod downloaded from the given
|
189
|
-
# `request`.
|
190
|
-
#
|
191
|
-
def path_for_pod(request, slug_opts = {})
|
192
|
-
root + request.slug(**slug_opts)
|
193
|
-
end
|
194
|
-
|
195
|
-
# @param [Request] request
|
196
|
-
# the request to be downloaded.
|
197
|
-
#
|
198
|
-
# @param [Hash<Symbol,String>] slug_opts
|
199
|
-
# the download options that should be used in constructing the
|
200
|
-
# cache slug for this request.
|
201
|
-
#
|
202
|
-
# @return [Pathname] The path for the podspec downloaded from the given
|
203
|
-
# `request`.
|
204
|
-
#
|
205
|
-
def path_for_spec(request, slug_opts = {})
|
206
|
-
path = root + 'Specs' + request.slug(**slug_opts)
|
207
|
-
Pathname.new(path.to_path + '.podspec.json')
|
208
|
-
end
|
209
|
-
|
210
|
-
# @param [Request] request
|
211
|
-
# the request to be downloaded.
|
212
|
-
#
|
213
|
-
# @return [Response] The download response for the given `request` that
|
214
|
-
# was found in the download cache.
|
215
|
-
#
|
216
|
-
def cached_pod(request)
|
217
|
-
cached_spec = cached_spec(request)
|
218
|
-
path = path_for_pod(request)
|
219
|
-
|
220
|
-
return unless cached_spec && path.directory?
|
221
|
-
spec = request.spec || cached_spec
|
222
|
-
Response.new(path, spec, request.params)
|
223
|
-
end
|
224
|
-
|
225
|
-
# @param [Request] request
|
226
|
-
# the request to be downloaded.
|
227
|
-
#
|
228
|
-
# @return [Specification] The cached specification for the given
|
229
|
-
# `request`.
|
230
|
-
#
|
231
|
-
def cached_spec(request)
|
232
|
-
path = path_for_spec(request)
|
233
|
-
path.file? && Specification.from_file(path)
|
234
|
-
rescue JSON::ParserError
|
235
|
-
nil
|
236
|
-
end
|
237
|
-
|
238
|
-
# @param [Request] request
|
239
|
-
# the request to be downloaded.
|
240
|
-
#
|
241
|
-
# @return [Response] The download response for the given `request` that
|
242
|
-
# was not found in the download cache.
|
243
|
-
#
|
244
|
-
def uncached_pod(request)
|
245
|
-
in_tmpdir do |target|
|
246
|
-
result, podspecs = download(request, target)
|
247
|
-
result.location = nil
|
248
|
-
|
249
|
-
podspecs.each do |name, spec|
|
250
|
-
destination = path_for_pod(request, :name => name, :params => result.checkout_options)
|
251
|
-
copy_and_clean(target, destination, spec)
|
252
|
-
write_spec(spec, path_for_spec(request, :name => name, :params => result.checkout_options))
|
253
|
-
if request.name == name
|
254
|
-
result.location = destination
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
result
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
def download(request, target)
|
263
|
-
Downloader.download_request(request, target)
|
264
|
-
end
|
265
|
-
|
266
|
-
# Performs the given block inside a temporary directory,
|
267
|
-
# which is removed at the end of the block's scope.
|
268
|
-
#
|
269
|
-
# @return [Object] The return value of the given block
|
270
|
-
#
|
271
|
-
def in_tmpdir(&blk)
|
272
|
-
tmpdir = Pathname(Dir.mktmpdir)
|
273
|
-
blk.call(tmpdir)
|
274
|
-
ensure
|
275
|
-
FileUtils.remove_entry(tmpdir, :force => true) if tmpdir && tmpdir.exist?
|
276
|
-
end
|
277
|
-
|
278
|
-
# Copies the `source` directory to `destination`, cleaning the directory
|
279
|
-
# of any files unused by `spec`.
|
280
|
-
#
|
281
|
-
# @param [Pathname] source
|
282
|
-
#
|
283
|
-
# @param [Pathname] destination
|
284
|
-
#
|
285
|
-
# @param [Specification] spec
|
286
|
-
#
|
287
|
-
# @return [Void]
|
288
|
-
#
|
32
|
+
public
|
289
33
|
def copy_and_clean(source, destination, spec)
|
34
|
+
attributes_hash = spec.send(:attributes_hash) || {}
|
35
|
+
name = attributes_hash["name"] ||= ""
|
290
36
|
specs_by_platform = group_subspecs_by_platform(spec)
|
291
37
|
destination.parent.mkpath
|
292
|
-
Cache.write_lock(destination) do
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
def group_subspecs_by_platform(spec)
|
301
|
-
specs_by_platform = {}
|
302
|
-
[spec, *spec.recursive_subspecs].each do |ss|
|
303
|
-
ss.available_platforms.each do |platform|
|
304
|
-
specs_by_platform[platform] ||= []
|
305
|
-
specs_by_platform[platform] << ss
|
38
|
+
Pod::Downloader::Cache.write_lock(destination) do
|
39
|
+
if source && source.exist? && !source.children.empty?
|
40
|
+
FileUtils.rm_rf(destination)
|
41
|
+
FileUtils.cp_r(source, destination)
|
306
42
|
end
|
43
|
+
LgPodPlugin.log_green "-> Copy #{name} from #{source} to #{destination}"
|
44
|
+
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
45
|
+
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
307
46
|
end
|
308
|
-
specs_by_platform
|
309
47
|
end
|
310
48
|
|
311
|
-
|
312
|
-
#
|
313
|
-
# @param [Specification] spec
|
314
|
-
# the specification to be written.
|
315
|
-
#
|
316
|
-
# @param [Pathname] path
|
317
|
-
# the path the specification is to be written to.
|
318
|
-
#
|
319
|
-
# @return [Void]
|
320
|
-
#
|
49
|
+
public
|
321
50
|
def write_spec(spec, path)
|
322
51
|
path.dirname.mkpath
|
323
|
-
Cache.write_lock(path) do
|
52
|
+
Pod::Downloader::Cache.write_lock(path) do
|
324
53
|
path.open('w') { |f| f.write spec.to_pretty_json }
|
325
54
|
end
|
326
55
|
end
|
56
|
+
|
327
57
|
end
|
328
58
|
end
|
329
|
-
end
|
59
|
+
end
|
@@ -6,7 +6,7 @@ module LgPodPlugin
|
|
6
6
|
class LRequest
|
7
7
|
attr_reader :target
|
8
8
|
attr_reader :name
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :podspec
|
10
10
|
attr_reader :released_pod
|
11
11
|
attr_accessor :single_git
|
12
12
|
attr_accessor :config
|
@@ -16,12 +16,10 @@ module LgPodPlugin
|
|
16
16
|
attr_accessor :checkout_options
|
17
17
|
def initialize(pod)
|
18
18
|
@name = pod.name
|
19
|
+
@podspec = pod.spec
|
19
20
|
@target = pod.target
|
20
21
|
@released_pod = pod.released_pod
|
21
22
|
@checkout_options = pod.checkout_options
|
22
|
-
if pod.spec
|
23
|
-
@lg_spec = pod.spec
|
24
|
-
end
|
25
23
|
self.preprocess_request
|
26
24
|
end
|
27
25
|
|