mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
checksum.rb: check the target
* tool/checksum.rb (Checksum#update?): check if the target exists too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
19e0fa010e
commit
8869cdf576
2 changed files with 11 additions and 4 deletions
|
@ -15,5 +15,5 @@ win32_vk.inc: win32_vk.list
|
|||
|
||||
{$(srcdir)}.list.chksum:
|
||||
@$(RUBY) -I$(top_srcdir)/tool -rchecksum \
|
||||
-e "Checksum.update(ARGV) {|k,f|k.copy(f) rescue k.make(f)}" \
|
||||
-e "Checksum.update(ARGV) {|k|k.copy(k.target) rescue k.make(k.target)}" \
|
||||
-- --make=$(MAKE) -I$(srcdir) $(<F) $(@F:.chksum=.inc)
|
||||
|
|
|
@ -7,15 +7,22 @@ class Checksum
|
|||
@vpath = vpath
|
||||
end
|
||||
|
||||
attr_reader :source, :target
|
||||
|
||||
def source=(source)
|
||||
@source = source
|
||||
@checksum = File.basename(source, ".*") + ".chksum"
|
||||
end
|
||||
|
||||
def target=(target)
|
||||
@target = target
|
||||
end
|
||||
|
||||
def update?
|
||||
src = @vpath.read(@source)
|
||||
@len = src.length
|
||||
@sum = src.sum
|
||||
return false unless @vpath.search(File.method(:exist?), @target)
|
||||
begin
|
||||
data = @vpath.read(@checksum)
|
||||
rescue
|
||||
|
@ -47,8 +54,8 @@ class Checksum
|
|||
true
|
||||
end
|
||||
|
||||
def make(arg)
|
||||
system([@make, arg].compact.join(' '))
|
||||
def make(*args)
|
||||
system(@make, *args)
|
||||
end
|
||||
|
||||
def def_options(opt = (require 'optparse'; OptionParser.new))
|
||||
|
@ -59,7 +66,7 @@ class Checksum
|
|||
|
||||
def self.update(argv)
|
||||
k = new(VPath.new)
|
||||
k.source, *argv = k.def_options.parse(*argv)
|
||||
k.source, k.target, *argv = k.def_options.parse(*argv)
|
||||
k.update {|k| yield(k, *argv)}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue