mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
extlibs.rb: added variable references
Reduce duplicate parts such as package name and version numbers.
This commit is contained in:
parent
1d2fc91237
commit
d1748484e8
Notes:
git
2020-05-12 15:58:19 +09:00
2 changed files with 30 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
|||
https://ftp.osuosl.org/pub/blfs/conglomeration/libffi/libffi-3.2.1.tar.gz \
|
||||
ver = 3.2.1
|
||||
pkg = libffi-$(ver)
|
||||
|
||||
https://ftp.osuosl.org/pub/blfs/conglomeration/libffi/$(pkg).tar.gz \
|
||||
md5:83b89587607e3eb65c70d361f13bab43 \
|
||||
sha512:980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483 \
|
||||
#
|
||||
win32/libffi-3.2.1-mswin.patch -p0
|
||||
win32/$(pkg)-mswin.patch -p0
|
||||
|
|
|
@ -7,6 +7,20 @@ require 'digest'
|
|||
require_relative 'downloader'
|
||||
require_relative 'lib/colorize'
|
||||
|
||||
class Vars < Hash
|
||||
def pattern
|
||||
/\$\((#{Regexp.union(keys)})\)/
|
||||
end
|
||||
|
||||
def expand(str)
|
||||
if empty?
|
||||
str
|
||||
else
|
||||
str.gsub(pattern) {self[$1]}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ExtLibs
|
||||
def initialize
|
||||
@colorize = Colorize.new
|
||||
|
@ -143,16 +157,21 @@ class ExtLibs
|
|||
$stdout.puts "downloading for #{list}"
|
||||
$stdout.flush
|
||||
end
|
||||
vars = Vars.new
|
||||
extracted = false
|
||||
dest = File.dirname(list)
|
||||
url = chksums = nil
|
||||
IO.foreach(list) do |line|
|
||||
line.sub!(/\s*#.*/, '')
|
||||
if /^(\w+)\s*=\s*(.*)/ =~ line
|
||||
vars[$1] = vars.expand($2)
|
||||
next
|
||||
end
|
||||
if chksums
|
||||
chksums.concat(line.split)
|
||||
elsif /^\t/ =~ line
|
||||
if extracted and (mode == :all or mode == :patch)
|
||||
patch, *args = line.split
|
||||
patch, *args = line.split.map {|s| vars.expand(s)}
|
||||
do_patch(dest, patch, args)
|
||||
end
|
||||
next
|
||||
|
@ -163,7 +182,11 @@ class ExtLibs
|
|||
chksums.pop
|
||||
next
|
||||
end
|
||||
next unless url
|
||||
unless url
|
||||
chksums = nil
|
||||
next
|
||||
end
|
||||
url = vars.expand(url)
|
||||
begin
|
||||
extracted = do_command(mode, dest, url, cache_dir, chksums)
|
||||
rescue => e
|
||||
|
|
Loading…
Add table
Reference in a new issue