fiddle 1.1.0 → 1.1.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.
data/bin/extlibs.rb DELETED
@@ -1,262 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # Used to download, extract and patch extension libraries (extlibs)
4
- # for Ruby. See common.mk for Ruby's usage.
5
-
6
- require 'digest'
7
- require_relative 'downloader'
8
-
9
- class Vars < Hash
10
- def pattern
11
- /\$\((#{Regexp.union(keys)})\)/
12
- end
13
-
14
- def expand(str)
15
- if empty?
16
- str
17
- else
18
- str.gsub(pattern) {self[$1]}
19
- end
20
- end
21
- end
22
-
23
- class ExtLibs
24
- def cache_file(url, cache_dir)
25
- Downloader.cache_file(url, nil, :cache_dir => cache_dir)
26
- end
27
-
28
- def do_download(url, cache_dir)
29
- Downloader.download(url, nil, nil, nil, :cache_dir => cache_dir)
30
- end
31
-
32
- def do_checksum(cache, chksums)
33
- chksums.each do |sum|
34
- name, sum = sum.split(/:/)
35
- if $VERBOSE
36
- $stdout.print "checking #{name} of #{cache} ..."
37
- $stdout.flush
38
- end
39
- hd = Digest(name.upcase).file(cache).hexdigest
40
- if hd == sum
41
- if $VERBOSE
42
- $stdout.puts " OK"
43
- $stdout.flush
44
- end
45
- else
46
- if $VERBOSE
47
- $stdout.puts " NG"
48
- $stdout.flush
49
- end
50
- raise "checksum mismatch: #{cache}, #{name}:#{hd}, expected #{sum}"
51
- end
52
- end
53
- end
54
-
55
- def do_extract(cache, dir)
56
- if $VERBOSE
57
- $stdout.puts "extracting #{cache} into #{dir}"
58
- $stdout.flush
59
- end
60
- ext = File.extname(cache)
61
- case ext
62
- when '.gz', '.tgz'
63
- f = IO.popen(["gzip", "-dc", cache])
64
- cache = cache.chomp('.gz')
65
- when '.bz2', '.tbz'
66
- f = IO.popen(["bzip2", "-dc", cache])
67
- cache = cache.chomp('.bz2')
68
- when '.xz', '.txz'
69
- f = IO.popen(["xz", "-dc", cache])
70
- cache = cache.chomp('.xz')
71
- else
72
- inp = cache
73
- end
74
- inp ||= f.binmode
75
- ext = File.extname(cache)
76
- case ext
77
- when '.tar', /\A\.t[gbx]z\z/
78
- pid = Process.spawn("tar", "xpf", "-", in: inp, chdir: dir)
79
- when '.zip'
80
- pid = Process.spawn("unzip", inp, "-d", dir)
81
- end
82
- f.close if f
83
- Process.wait(pid)
84
- $?.success? or raise "failed to extract #{cache}"
85
- end
86
-
87
- def do_patch(dest, patch, args)
88
- if $VERBOSE
89
- $stdout.puts "applying #{patch} under #{dest}"
90
- $stdout.flush
91
- end
92
- Process.wait(Process.spawn("patch", "-d", dest, "-i", patch, *args))
93
- $?.success? or raise "failed to patch #{patch}"
94
- end
95
-
96
- def do_link(file, src, dest)
97
- file = File.join(dest, file)
98
- if (target = src).start_with?("/")
99
- target = File.join([".."] * file.count("/"), src)
100
- end
101
- return unless File.exist?(File.expand_path(target, File.dirname(file)))
102
- File.unlink(file) rescue nil
103
- begin
104
- File.symlink(target, file)
105
- rescue
106
- else
107
- if $VERBOSE
108
- $stdout.puts "linked #{target} to #{file}"
109
- $stdout.flush
110
- end
111
- return
112
- end
113
- begin
114
- src = src.sub(/\A\//, '')
115
- File.copy_stream(src, file)
116
- rescue
117
- if $VERBOSE
118
- $stdout.puts "failed to link #{src} to #{file}: #{$!.message}"
119
- end
120
- else
121
- if $VERBOSE
122
- $stdout.puts "copied #{src} to #{file}"
123
- end
124
- end
125
- end
126
-
127
- def do_exec(command, dir, dest)
128
- dir = dir ? File.join(dest, dir) : dest
129
- if $VERBOSE
130
- $stdout.puts "running #{command.dump} under #{dir}"
131
- $stdout.flush
132
- end
133
- system(command, chdir: dir) or raise "failed #{command.dump}"
134
- end
135
-
136
- def do_command(mode, dest, url, cache_dir, chksums)
137
- extracted = false
138
- base = /.*(?=\.tar(?:\.\w+)?\z)/
139
-
140
- case mode
141
- when :download
142
- cache = do_download(url, cache_dir)
143
- do_checksum(cache, chksums)
144
- when :extract
145
- cache = cache_file(url, cache_dir)
146
- target = File.join(dest, File.basename(cache)[base])
147
- unless File.directory?(target)
148
- do_checksum(cache, chksums)
149
- extracted = do_extract(cache, dest)
150
- end
151
- when :all
152
- cache = do_download(url, cache_dir)
153
- target = File.join(dest, File.basename(cache)[base])
154
- unless File.directory?(target)
155
- do_checksum(cache, chksums)
156
- extracted = do_extract(cache, dest)
157
- end
158
- end
159
- extracted
160
- end
161
-
162
- def run(argv)
163
- cache_dir = nil
164
- mode = :all
165
- until argv.empty?
166
- case argv[0]
167
- when '--download'
168
- mode = :download
169
- when '--extract'
170
- mode = :extract
171
- when '--patch'
172
- mode = :patch
173
- when '--all'
174
- mode = :all
175
- when '--cache'
176
- argv.shift
177
- cache_dir = argv[0]
178
- when /\A--cache=/
179
- cache_dir = $'
180
- when '--'
181
- argv.shift
182
- break
183
- when /\A-/
184
- warn "unknown option: #{argv[0]}"
185
- return false
186
- else
187
- break
188
- end
189
- argv.shift
190
- end
191
-
192
- success = true
193
- argv.each do |dir|
194
- Dir.glob("#{dir}/**/extlibs") do |list|
195
- if $VERBOSE
196
- $stdout.puts "downloading for #{list}"
197
- $stdout.flush
198
- end
199
- vars = Vars.new
200
- extracted = false
201
- dest = File.dirname(list)
202
- url = chksums = nil
203
- IO.foreach(list) do |line|
204
- line.sub!(/\s*#.*/, '')
205
- if /^(\w+)\s*=\s*(.*)/ =~ line
206
- vars[$1] = vars.expand($2)
207
- next
208
- end
209
- if chksums
210
- chksums.concat(line.split)
211
- elsif /^\t/ =~ line
212
- if extracted and (mode == :all or mode == :patch)
213
- patch, *args = line.split.map {|s| vars.expand(s)}
214
- do_patch(dest, patch, args)
215
- end
216
- next
217
- elsif /^!\s*(?:chdir:\s*([^|\s]+)\|\s*)?(.*)/ =~ line
218
- if extracted and (mode == :all or mode == :patch)
219
- command = vars.expand($2.strip)
220
- chdir = $1 and chdir = vars.expand(chdir)
221
- do_exec(command, chdir, dest)
222
- end
223
- next
224
- elsif /->/ =~ line
225
- if extracted and (mode == :all or mode == :patch)
226
- link, file = $`.strip, $'.strip
227
- do_link(vars.expand(link), vars.expand(file), dest)
228
- end
229
- next
230
- else
231
- url, *chksums = line.split(' ')
232
- end
233
- if chksums.last == '\\'
234
- chksums.pop
235
- next
236
- end
237
- unless url
238
- chksums = nil
239
- next
240
- end
241
- url = vars.expand(url)
242
- begin
243
- extracted = do_command(mode, dest, url, cache_dir, chksums)
244
- rescue => e
245
- warn e.inspect
246
- success = false
247
- end
248
- url = chksums = nil
249
- end
250
- end
251
- end
252
- success
253
- end
254
-
255
- def self.run(argv)
256
- self.new.run(argv)
257
- end
258
- end
259
-
260
- if $0 == __FILE__
261
- exit ExtLibs.run(ARGV)
262
- end
data/ext/fiddle/extlibs DELETED
@@ -1,13 +0,0 @@
1
- ver = 3.2.1
2
- pkg = libffi-$(ver)
3
-
4
- https://ftp.osuosl.org/pub/blfs/conglomeration/libffi/$(pkg).tar.gz \
5
- md5:83b89587607e3eb65c70d361f13bab43 \
6
- sha512:980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483 \
7
- #
8
- win32/$(pkg)-mswin.patch -p0
9
-
10
- $(pkg)/config.guess -> /tool/config.guess
11
- $(pkg)/config.sub -> /tool/config.sub
12
-
13
- ! chdir: $(pkg)| autoconf || exit 0