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:
|
{$(srcdir)}.list.chksum:
|
||||||
@$(RUBY) -I$(top_srcdir)/tool -rchecksum \
|
@$(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)
|
-- --make=$(MAKE) -I$(srcdir) $(<F) $(@F:.chksum=.inc)
|
||||||
|
|
|
@ -7,15 +7,22 @@ class Checksum
|
||||||
@vpath = vpath
|
@vpath = vpath
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr_reader :source, :target
|
||||||
|
|
||||||
def source=(source)
|
def source=(source)
|
||||||
@source = source
|
@source = source
|
||||||
@checksum = File.basename(source, ".*") + ".chksum"
|
@checksum = File.basename(source, ".*") + ".chksum"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def target=(target)
|
||||||
|
@target = target
|
||||||
|
end
|
||||||
|
|
||||||
def update?
|
def update?
|
||||||
src = @vpath.read(@source)
|
src = @vpath.read(@source)
|
||||||
@len = src.length
|
@len = src.length
|
||||||
@sum = src.sum
|
@sum = src.sum
|
||||||
|
return false unless @vpath.search(File.method(:exist?), @target)
|
||||||
begin
|
begin
|
||||||
data = @vpath.read(@checksum)
|
data = @vpath.read(@checksum)
|
||||||
rescue
|
rescue
|
||||||
|
@ -47,8 +54,8 @@ class Checksum
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def make(arg)
|
def make(*args)
|
||||||
system([@make, arg].compact.join(' '))
|
system(@make, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def def_options(opt = (require 'optparse'; OptionParser.new))
|
def def_options(opt = (require 'optparse'; OptionParser.new))
|
||||||
|
@ -59,7 +66,7 @@ class Checksum
|
||||||
|
|
||||||
def self.update(argv)
|
def self.update(argv)
|
||||||
k = new(VPath.new)
|
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)}
|
k.update {|k| yield(k, *argv)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue