summaryrefslogtreecommitdiff
path: root/tool/make-snapshot
diff options
context:
space:
mode:
Diffstat (limited to 'tool/make-snapshot')
-rwxr-xr-xtool/make-snapshot80
1 files changed, 44 insertions, 36 deletions
diff --git a/tool/make-snapshot b/tool/make-snapshot
index 5c66d5b76f..7446f18578 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -22,6 +22,7 @@ $keep_temp ||= nil
$patch_file ||= nil
$packages ||= nil
$digests ||= nil
+$no7z ||= nil
$tooldir = File.expand_path("..", __FILE__)
$unicode_version = nil if ($unicode_version ||= nil) == ""
$colorize = Colorize.new
@@ -37,8 +38,6 @@ options:
-packages=PKG[,...] make PKG packages (#{PACKAGES.keys.join(", ")})
-digests=ALG[,...] show ALG digests (#{DIGESTS.join(", ")})
-unicode_version=VER Unicode version to generate encodings
- -svn[=URL] make snapshot from SVN repository
- (#{SVNURL})
-help, --help show this message
version:
master, trunk, stable, branches/*, tags/*, X.Y, X.Y.Z, X.Y.Z-pL
@@ -68,13 +67,12 @@ if mflags = ENV["GNUMAKEFLAGS"] and /\A-(\S*)j\d*/ =~ mflags
ENV["GNUMAKEFLAGS"] = (mflags unless mflags.empty?)
end
ENV["LC_ALL"] = ENV["LANG"] = "C"
-SVNURL = URI.parse("https://svn.ruby-lang.org/repos/ruby/")
# https git clone is disabled at git.ruby-lang.org/ruby.git.
GITURL = URI.parse("https://github.com/ruby/ruby.git")
RUBY_VERSION_PATTERN = /^\#define\s+RUBY_VERSION\s+"([\d.]+)"/
ENV["VPATH"] ||= "include/ruby"
-YACC = ENV["YACC"] ||= "bison"
+YACC = ENV["YACC"] ||= "#{$tooldir}/lrama/exe/lrama"
ENV["BASERUBY"] ||= "ruby"
ENV["RUBY"] ||= "ruby"
ENV["MV"] ||= "mv"
@@ -146,7 +144,7 @@ unless destdir = ARGV.shift
end
revisions = ARGV.empty? ? [nil] : ARGV
-if $exported
+if defined?($exported)
abort "#{File.basename $0}: -exported option is deprecated; use -srcdir instead"
end
@@ -294,7 +292,7 @@ def package(vcs, rev, destdir, tmp = nil)
if info = vcs.get_revisions(url)
modified = info[2]
else
- modified = Time.now - 10
+ _, _, modified = VCS::Null.new(nil).get_revisions(url)
end
if !revision and info
revision = info
@@ -332,6 +330,10 @@ def package(vcs, rev, destdir, tmp = nil)
end
end
+ Dir.glob("#{exported}/.*.yml") do |file|
+ FileUtils.rm(file, verbose: $VERBOSE)
+ end
+
status = IO.read(File.dirname(__FILE__) + "/prereq.status")
Dir.chdir(tmp) if tmp
@@ -341,12 +343,8 @@ def package(vcs, rev, destdir, tmp = nil)
v = v[0]
end
- open("#{v}/revision.h", "wb") {|f|
- short = vcs.short_revision(revision)
- f.puts "#define RUBY_REVISION #{short.inspect}"
- unless short == revision
- f.puts "#define RUBY_FULL_REVISION #{revision.inspect}"
- end
+ File.open("#{v}/revision.h", "wb") {|f|
+ f.puts vcs.revision_header(revision, modified)
}
version ||= (versionhdr = IO.read("#{v}/version.h"))[RUBY_VERSION_PATTERN, 1]
version ||=
@@ -366,7 +364,7 @@ def package(vcs, rev, destdir, tmp = nil)
end
elsif prerelease
versionhdr ||= IO.read("#{v}/version.h")
- versionhdr.sub!(/^\#define\s+RUBY_PATCHLEVEL_STR\s+"\K.+?(?=")/, tag)
+ versionhdr.sub!(/^\#\s*define\s+RUBY_PATCHLEVEL_STR\s+"\K.+?(?=")/, tag) or raise "no match of RUBY_PATCHLEVEL_STR to replace"
IO.write("#{v}/version.h", versionhdr)
else
tag ||= vcs.revision_name(revision)
@@ -386,7 +384,21 @@ def package(vcs, rev, destdir, tmp = nil)
puts $colorize.fail("patching failed")
return
end
- def (clean = []).add(n) push(n); n end
+
+ class << (clean = [])
+ def add(n) push(n)
+ n
+ end
+ def create(file, content = "", &block)
+ add(file)
+ if block
+ File.open(file, "wb", &block)
+ else
+ File.binwrite(file, content)
+ end
+ end
+ end
+
Dir.chdir(v) do
unless File.exist?("ChangeLog")
vcs.export_changelog(url, nil, revision, "ChangeLog")
@@ -407,7 +419,7 @@ def package(vcs, rev, destdir, tmp = nil)
puts
end
- File.open(clean.add("cross.rb"), "w") do |f|
+ clean.create("cross.rb") do |f|
f.puts "Object.__send__(:remove_const, :CROSS_COMPILING) if defined?(CROSS_COMPILING)"
f.puts "CROSS_COMPILING=true"
f.puts "Object.__send__(:remove_const, :RUBY_PLATFORM)"
@@ -415,6 +427,7 @@ def package(vcs, rev, destdir, tmp = nil)
f.puts "Object.__send__(:remove_const, :RUBY_VERSION)"
f.puts "RUBY_VERSION='#{version}'"
end
+ puts "cross.rb:", File.read("cross.rb").gsub(/^/, "> "), "" if $VERBOSE
unless File.exist?("configure")
print "creating configure..."
unless system([ENV["AUTOCONF"]]*2)
@@ -434,14 +447,13 @@ def package(vcs, rev, destdir, tmp = nil)
rescue Errno::ENOENT
# use fallback file
end
- File.open(clean.add("config.status"), "w") {|f|
- f.print status
- }
+ clean.create("config.status", status)
+ clean.create("noarch-fake.rb", "require_relative 'cross'\n")
FileUtils.mkpath(hdrdir = "#{extout}/include/ruby")
- File.open("#{hdrdir}/config.h", "w") {}
+ File.binwrite("#{hdrdir}/config.h", "")
FileUtils.mkpath(defaults = "#{extout}/rubygems/defaults")
- File.open("#{defaults}/operating_system.rb", "w") {}
- File.open("#{defaults}/ruby.rb", "w") {}
+ File.binwrite("#{defaults}/operating_system.rb", "")
+ File.binwrite("#{defaults}/ruby.rb", "")
miniruby = ENV['MINIRUBY'] + " -I. -I#{extout} -rcross"
baseruby = ENV["BASERUBY"]
mk = (IO.read("template/Makefile.in") rescue IO.read("Makefile.in")).
@@ -477,11 +489,9 @@ update-gems:
$(UNICODE_SRC_DATA_DIR)/.unicode-tables.time:
touch-unicode-files:
APPEND
- open(clean.add("Makefile"), "w") do |f|
- f.puts mk
- end
- File.open(clean.add("revision.tmp"), "w") {}
- File.open(clean.add(".revision.time"), "w") {}
+ clean.create("Makefile", mk)
+ clean.create("revision.tmp")
+ clean.create(".revision.time")
ENV["CACHE_SAVE"] = "no"
make = MAKE.new(args)
return unless make.run("update-download")
@@ -508,8 +518,7 @@ touch-unicode-files:
end
vcs.after_export(".") if exported
clean.concat(Dir.glob("ext/**/autom4te.cache"))
- FileUtils.rm_rf(clean) unless $keep_temp
- FileUtils.rm_rf(".downloaded-cache")
+ clean.add(".downloaded-cache")
if File.exist?("gems/bundled_gems")
gems = Dir.glob("gems/*.gem")
gems -= File.readlines("gems/bundled_gems").map {|line|
@@ -517,10 +526,11 @@ touch-unicode-files:
name, version, _ = line.split(' ')
"gems/#{name}-#{version}.gem"
}
- FileUtils.rm_f(gems)
+ clean.concat(gems)
else
- FileUtils.rm_rf("gems")
+ clean.add("gems")
end
+ FileUtils.rm_rf(clean)
if modified
touch_all(modified, "**/*/", 0) do |name, stat|
stat.mtime > modified
@@ -589,20 +599,18 @@ ensure
Dir.chdir(pwd)
end
-if [$srcdir, ($svn||=nil), ($git||=nil)].compact.size > 1
- abort "#{File.basename $0}: -srcdir, -svn, and -git are exclusive"
+if [$srcdir, ($git||=nil)].compact.size > 1
+ abort "#{File.basename $0}: -srcdir and -git are exclusive"
end
if $srcdir
vcs = VCS.detect($srcdir)
-elsif $svn
- vcs = VCS::SVN.new($svn == true ? SVNURL : URI.parse($svn))
elsif $git
abort "#{File.basename $0}: use -srcdir with cloned local repository"
else
begin
vcs = VCS.detect(File.expand_path("../..", __FILE__))
rescue VCS::NotFoundError
- vcs = VCS::SVN.new(SVNURL)
+ abort "#{File.expand_path("../..", __FILE__)}: cannot find git repository"
end
end
@@ -615,7 +623,7 @@ revisions.collect {|rev| package(vcs, rev, destdir, tmp)}.flatten.each do |name|
success = false
next
end
- str = open(name, "rb") {|f| f.read}
+ str = File.binread(name)
pathname = Pathname(name)
basename = pathname.basename.to_s
extname = pathname.extname.sub(/\A\./, '')