2008-08-12 06:11:11 -04:00
|
|
|
#!/usr/bin/ruby -s
|
2008-11-06 11:24:32 -05:00
|
|
|
# -*- coding: us-ascii -*-
|
2021-06-23 06:18:22 -04:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/package'
|
|
|
|
require 'rubygems/package/tar_writer'
|
2008-06-21 02:31:18 -04:00
|
|
|
require 'uri'
|
2014-12-26 20:03:50 -05:00
|
|
|
require 'digest/sha1'
|
2008-06-21 02:31:18 -04:00
|
|
|
require 'digest/sha2'
|
|
|
|
require 'fileutils'
|
2015-01-16 19:05:09 -05:00
|
|
|
require 'shellwords'
|
2008-06-21 02:31:18 -04:00
|
|
|
require 'tmpdir'
|
2018-02-27 09:08:26 -05:00
|
|
|
require 'pathname'
|
2019-10-07 06:05:42 -04:00
|
|
|
require 'yaml'
|
|
|
|
require 'json'
|
2019-07-14 19:34:24 -04:00
|
|
|
require File.expand_path("../lib/vcs", __FILE__)
|
2019-07-14 19:54:34 -04:00
|
|
|
require File.expand_path("../lib/colorize", __FILE__)
|
2008-06-21 02:31:18 -04:00
|
|
|
STDOUT.sync = true
|
2007-12-22 01:14:50 -05:00
|
|
|
|
2014-12-14 20:28:58 -05:00
|
|
|
$srcdir ||= nil
|
2014-12-14 20:02:32 -05:00
|
|
|
$archname = nil if ($archname ||= nil) == ""
|
2010-08-19 09:45:02 -04:00
|
|
|
$keep_temp ||= nil
|
|
|
|
$patch_file ||= nil
|
2014-12-14 20:02:32 -05:00
|
|
|
$packages ||= nil
|
|
|
|
$digests ||= nil
|
2022-09-07 01:41:37 -04:00
|
|
|
$no7z ||= nil
|
2013-06-14 00:01:54 -04:00
|
|
|
$tooldir = File.expand_path("..", __FILE__)
|
2016-08-16 09:02:33 -04:00
|
|
|
$unicode_version = nil if ($unicode_version ||= nil) == ""
|
2017-06-14 22:39:06 -04:00
|
|
|
$colorize = Colorize.new
|
2010-08-19 09:45:02 -04:00
|
|
|
|
|
|
|
def usage
|
|
|
|
<<USAGE
|
|
|
|
usage: #{File.basename $0} [option...] new-directory-to-save [version ...]
|
2010-08-19 09:50:43 -04:00
|
|
|
options:
|
2014-12-14 20:28:58 -05:00
|
|
|
-srcdir=PATH source directory path
|
2010-08-19 09:45:02 -04:00
|
|
|
-archname=NAME make the basename of snapshots NAME
|
|
|
|
-keep_temp keep temporary working directory
|
|
|
|
-patch_file=PATCH apply PATCH file after export
|
2014-05-13 11:47:33 -04:00
|
|
|
-packages=PKG[,...] make PKG packages (#{PACKAGES.keys.join(", ")})
|
2014-05-13 11:47:36 -04:00
|
|
|
-digests=ALG[,...] show ALG digests (#{DIGESTS.join(", ")})
|
2018-02-26 02:57:16 -05:00
|
|
|
-unicode_version=VER Unicode version to generate encodings
|
|
|
|
-svn[=URL] make snapshot from SVN repository
|
|
|
|
(#{SVNURL})
|
|
|
|
-help, --help show this message
|
2010-08-19 09:50:43 -04:00
|
|
|
version:
|
2019-07-01 10:16:47 -04:00
|
|
|
master, trunk, stable, branches/*, tags/*, X.Y, X.Y.Z, X.Y.Z-pL
|
2010-08-19 09:50:43 -04:00
|
|
|
each versions may be followed by optional @revision.
|
2010-08-19 09:45:02 -04:00
|
|
|
USAGE
|
|
|
|
end
|
2008-09-26 05:40:04 -04:00
|
|
|
|
2015-01-29 06:28:31 -05:00
|
|
|
DIGESTS = %w[SHA1 SHA256 SHA512]
|
2014-05-13 06:09:41 -04:00
|
|
|
PACKAGES = {
|
2019-09-02 22:14:07 -04:00
|
|
|
"tar" => %w".tar",
|
2014-05-13 06:09:41 -04:00
|
|
|
"bzip" => %w".tar.bz2 bzip2 -c",
|
|
|
|
"gzip" => %w".tar.gz gzip -c",
|
|
|
|
"xz" => %w".tar.xz xz -c",
|
2019-09-22 08:56:58 -04:00
|
|
|
"zip" => %w".zip zip -Xqr",
|
2014-05-13 06:09:41 -04:00
|
|
|
}
|
2019-09-02 22:30:40 -04:00
|
|
|
DEFAULT_PACKAGES = PACKAGES.keys - ["tar"]
|
2021-07-26 02:43:46 -04:00
|
|
|
if !$no7z and system("7z", out: IO::NULL)
|
2017-06-15 07:51:39 -04:00
|
|
|
PACKAGES["gzip"] = %w".tar.gz 7z a dummy -tgzip -mx -so"
|
2020-11-21 21:30:02 -05:00
|
|
|
PACKAGES["zip"] = %w".zip 7z a -tzip -l -mx -mtc=off" << {out: IO::NULL}
|
2019-08-29 11:35:18 -04:00
|
|
|
elsif gzip = ENV.delete("GZIP")
|
2016-08-16 21:13:00 -04:00
|
|
|
PACKAGES["gzip"].concat(gzip.shellsplit)
|
|
|
|
end
|
|
|
|
|
2018-02-26 01:00:09 -05:00
|
|
|
if mflags = ENV["GNUMAKEFLAGS"] and /\A-(\S*)j\d*/ =~ mflags
|
|
|
|
mflags = mflags.gsub(/(\A|\s)(-\S*)j\d*/, '\1\2')
|
|
|
|
mflags.strip!
|
|
|
|
ENV["GNUMAKEFLAGS"] = (mflags unless mflags.empty?)
|
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
ENV["LC_ALL"] = ENV["LANG"] = "C"
|
2018-07-28 06:00:27 -04:00
|
|
|
SVNURL = URI.parse("https://svn.ruby-lang.org/repos/ruby/")
|
2019-07-01 21:40:17 -04:00
|
|
|
# https git clone is disabled at git.ruby-lang.org/ruby.git.
|
|
|
|
GITURL = URI.parse("https://github.com/ruby/ruby.git")
|
2008-06-21 02:31:18 -04:00
|
|
|
RUBY_VERSION_PATTERN = /^\#define\s+RUBY_VERSION\s+"([\d.]+)"/
|
2008-06-19 08:35:35 -04:00
|
|
|
|
2008-06-21 02:31:18 -04:00
|
|
|
ENV["VPATH"] ||= "include/ruby"
|
|
|
|
YACC = ENV["YACC"] ||= "bison"
|
|
|
|
ENV["BASERUBY"] ||= "ruby"
|
|
|
|
ENV["RUBY"] ||= "ruby"
|
|
|
|
ENV["MV"] ||= "mv"
|
2009-01-16 04:42:33 -05:00
|
|
|
ENV["RM"] ||= "rm -f"
|
2008-06-21 02:31:18 -04:00
|
|
|
ENV["MINIRUBY"] ||= "ruby"
|
2009-01-16 04:42:33 -05:00
|
|
|
ENV["PROGRAM"] ||= "ruby"
|
2013-05-26 11:51:13 -04:00
|
|
|
ENV["AUTOCONF"] ||= "autoconf"
|
2014-11-25 12:12:03 -05:00
|
|
|
ENV["BUILTIN_TRANSOBJS"] ||= "newline.o"
|
2019-09-22 12:25:17 -04:00
|
|
|
ENV["TZ"] = "UTC"
|
2007-12-22 01:14:50 -05:00
|
|
|
|
2008-10-28 03:13:39 -04:00
|
|
|
class String
|
|
|
|
# for older ruby
|
|
|
|
alias bytesize size unless method_defined?(:bytesize)
|
|
|
|
end
|
|
|
|
|
2010-03-24 15:38:22 -04:00
|
|
|
class Dir
|
|
|
|
def self.mktmpdir(path)
|
|
|
|
path = File.join(tmpdir, path+"-#{$$}-#{rand(100000)}")
|
|
|
|
begin
|
|
|
|
mkdir(path)
|
|
|
|
rescue Errno::EEXIST
|
|
|
|
path.succ!
|
|
|
|
retry
|
|
|
|
end
|
|
|
|
path
|
|
|
|
end unless respond_to?(:mktmpdir)
|
|
|
|
end
|
|
|
|
|
2014-05-13 11:47:33 -04:00
|
|
|
$packages &&= $packages.split(/[, ]+/).tap {|pkg|
|
2017-06-14 23:12:32 -04:00
|
|
|
if all = pkg.index("all")
|
2019-09-02 22:30:40 -04:00
|
|
|
pkg[all, 1] = DEFAULT_PACKAGES - pkg
|
2017-06-14 23:12:32 -04:00
|
|
|
end
|
2014-05-13 11:47:33 -04:00
|
|
|
pkg -= PACKAGES.keys
|
|
|
|
pkg.empty? or abort "#{File.basename $0}: unknown packages - #{pkg.join(", ")}"
|
|
|
|
}
|
2019-09-02 22:30:40 -04:00
|
|
|
$packages ||= DEFAULT_PACKAGES
|
2014-05-13 11:47:33 -04:00
|
|
|
|
2014-05-13 11:47:36 -04:00
|
|
|
$digests &&= $digests.split(/[, ]+/).tap {|dig|
|
|
|
|
dig -= DIGESTS
|
|
|
|
dig.empty? or abort "#{File.basename $0}: unknown digests - #{dig.join(", ")}"
|
|
|
|
}
|
|
|
|
$digests ||= DIGESTS
|
|
|
|
|
2008-08-12 06:11:11 -04:00
|
|
|
$patch_file &&= File.expand_path($patch_file)
|
2008-06-21 02:31:18 -04:00
|
|
|
path = ENV["PATH"].split(File::PATH_SEPARATOR)
|
|
|
|
%w[YACC BASERUBY RUBY MV MINIRUBY].each do |var|
|
2015-01-16 19:05:09 -05:00
|
|
|
cmd, = ENV[var].shellsplit
|
2008-06-21 02:31:18 -04:00
|
|
|
unless path.any? {|dir|
|
2008-09-26 05:40:04 -04:00
|
|
|
file = File.expand_path(cmd, dir)
|
2008-06-21 02:31:18 -04:00
|
|
|
File.file?(file) and File.executable?(file)
|
|
|
|
}
|
|
|
|
abort "#{File.basename $0}: #{var} command not found - #{cmd}"
|
|
|
|
end
|
|
|
|
end
|
2007-12-22 01:14:50 -05:00
|
|
|
|
2012-12-11 11:18:01 -05:00
|
|
|
%w[BASERUBY RUBY MINIRUBY].each do |var|
|
2018-02-28 06:12:36 -05:00
|
|
|
%x[#{ENV[var]} --disable-gem -e1 2>&1]
|
2012-12-11 11:18:01 -05:00
|
|
|
if $?.success?
|
|
|
|
ENV[var] += ' --disable-gem'
|
|
|
|
end
|
2012-12-11 01:13:43 -05:00
|
|
|
end
|
|
|
|
|
2014-12-14 20:02:32 -05:00
|
|
|
if defined?($help) or defined?($_help)
|
2010-08-19 09:45:02 -04:00
|
|
|
puts usage
|
|
|
|
exit
|
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
unless destdir = ARGV.shift
|
2010-08-19 09:45:02 -04:00
|
|
|
abort usage
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2019-05-22 10:18:09 -04:00
|
|
|
revisions = ARGV.empty? ? [nil] : ARGV
|
2019-09-14 13:07:00 -04:00
|
|
|
|
2022-09-07 01:41:37 -04:00
|
|
|
if defined?($exported)
|
2019-09-14 13:07:00 -04:00
|
|
|
abort "#{File.basename $0}: -exported option is deprecated; use -srcdir instead"
|
2008-08-12 06:11:11 -04:00
|
|
|
end
|
2008-06-19 08:35:35 -04:00
|
|
|
|
2019-09-14 13:07:00 -04:00
|
|
|
FileUtils.mkpath(destdir)
|
|
|
|
destdir = File.expand_path(destdir)
|
|
|
|
tmp = Dir.mktmpdir("ruby-snapshot")
|
|
|
|
FileUtils.mkpath(tmp)
|
|
|
|
at_exit {
|
|
|
|
Dir.chdir "/"
|
|
|
|
FileUtils.rm_rf(tmp)
|
|
|
|
} unless $keep_temp
|
|
|
|
|
2018-10-18 02:36:30 -04:00
|
|
|
def tar_create(tarball, dir)
|
|
|
|
header = Gem::Package::TarHeader
|
|
|
|
dir_type = "5"
|
|
|
|
uname = gname = "ruby"
|
|
|
|
File.open(tarball, "wb") do |f|
|
|
|
|
w = Gem::Package::TarWriter.new(f)
|
2019-09-02 22:14:07 -04:00
|
|
|
list = Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH)
|
|
|
|
list.reject! {|name| name.end_with?("/.")}
|
|
|
|
list.sort_by! {|name| name.split("/")}
|
|
|
|
list.each do |path|
|
2018-10-18 02:36:30 -04:00
|
|
|
next if File.basename(path) == "."
|
|
|
|
s = File.stat(path)
|
2019-01-17 18:52:58 -05:00
|
|
|
mode = 0644
|
2018-10-18 02:36:30 -04:00
|
|
|
case
|
|
|
|
when s.file?
|
|
|
|
type = nil
|
|
|
|
size = s.size
|
2019-01-17 18:52:58 -05:00
|
|
|
mode |= 0111 if s.executable?
|
2018-10-18 02:36:30 -04:00
|
|
|
when s.directory?
|
|
|
|
path += "/"
|
|
|
|
type = dir_type
|
|
|
|
size = 0
|
2019-01-17 18:52:58 -05:00
|
|
|
mode |= 0111
|
2018-10-18 02:36:30 -04:00
|
|
|
else
|
|
|
|
next
|
|
|
|
end
|
|
|
|
name, prefix = w.split_name(path)
|
2018-12-25 08:13:42 -05:00
|
|
|
h = header.new(name: name, prefix: prefix, typeflag: type,
|
2019-01-17 18:52:58 -05:00
|
|
|
mode: mode, size: size, mtime: s.mtime,
|
2018-10-18 02:36:30 -04:00
|
|
|
uname: uname, gname: gname)
|
|
|
|
f.write(h)
|
|
|
|
if size > 0
|
|
|
|
IO.copy_stream(path, f)
|
|
|
|
f.write("\0" * (-size % 512))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
true
|
|
|
|
rescue => e
|
|
|
|
warn e.message
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2019-09-02 22:14:07 -04:00
|
|
|
def touch_all(time, pattern, opt, &cond)
|
2019-09-01 23:15:35 -04:00
|
|
|
Dir.glob(pattern, opt) do |n|
|
2019-09-02 22:14:07 -04:00
|
|
|
stat = File.stat(n)
|
|
|
|
if stat.file? or stat.directory?
|
|
|
|
next if cond and !yield(n, stat)
|
|
|
|
File.utime(time, time, n)
|
|
|
|
end
|
2019-09-01 23:15:35 -04:00
|
|
|
end
|
|
|
|
rescue
|
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2019-10-03 06:12:03 -04:00
|
|
|
class MAKE < Struct.new(:prog, :args)
|
|
|
|
def initialize(vars)
|
|
|
|
vars = vars.map {|arg| arg.join("=")}
|
|
|
|
super(ENV["MAKE"] || ENV["make"] || "make", vars)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run(target)
|
|
|
|
err = IO.pipe do |r, w|
|
|
|
|
begin
|
|
|
|
pid = Process.spawn(self.prog, *self.args, target, {:err => w, r => :close})
|
|
|
|
w.close
|
|
|
|
r.read
|
|
|
|
ensure
|
|
|
|
Process.wait(pid)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if $?.success?
|
|
|
|
true
|
|
|
|
else
|
|
|
|
STDERR.puts err
|
|
|
|
$colorize.fail("#{target} failed")
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-21 21:01:17 -05:00
|
|
|
def measure
|
|
|
|
clock = Process::CLOCK_MONOTONIC
|
|
|
|
t0 = Process.clock_gettime(clock)
|
|
|
|
STDOUT.flush
|
|
|
|
result = yield
|
|
|
|
printf(" %6.3f", Process.clock_gettime(clock) - t0)
|
|
|
|
STDOUT.flush
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2014-12-14 20:02:52 -05:00
|
|
|
def package(vcs, rev, destdir, tmp = nil)
|
2019-09-01 10:24:05 -04:00
|
|
|
pwd = Dir.pwd
|
2008-06-21 02:31:18 -04:00
|
|
|
patchlevel = false
|
2013-12-20 15:46:21 -05:00
|
|
|
prerelease = false
|
2019-08-23 21:20:44 -04:00
|
|
|
if rev and revision = rev[/@(\h+)\z/, 1]
|
2010-08-19 09:34:40 -04:00
|
|
|
rev = $`
|
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
case rev
|
2019-05-22 10:18:09 -04:00
|
|
|
when nil
|
|
|
|
url = nil
|
2019-07-01 10:16:47 -04:00
|
|
|
when /\A(?:master|trunk)\z/
|
2014-12-14 20:02:52 -05:00
|
|
|
url = vcs.trunk
|
|
|
|
when /\Abranches\//
|
|
|
|
url = vcs.branch($')
|
|
|
|
when /\Atags\//
|
|
|
|
url = vcs.tag($')
|
2008-06-21 02:31:18 -04:00
|
|
|
when /\Astable\z/
|
2014-12-23 12:12:25 -05:00
|
|
|
vcs.branch_list("ruby_[0-9]*") {|n| url = n[/\Aruby_\d+_\d+\z/]}
|
2014-12-14 20:02:52 -05:00
|
|
|
url &&= vcs.branch(url)
|
2012-11-01 14:22:31 -04:00
|
|
|
when /\A(.*)\.(.*)\.(.*)-(preview|rc)(\d+)/
|
2013-12-20 15:46:21 -05:00
|
|
|
prerelease = true
|
2008-08-25 13:47:57 -04:00
|
|
|
tag = "#{$4}#{$5}"
|
2014-12-14 20:02:52 -05:00
|
|
|
url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}#{$5}")
|
2012-11-01 14:22:31 -04:00
|
|
|
when /\A(.*)\.(.*)\.(.*)-p(\d+)/
|
|
|
|
patchlevel = true
|
|
|
|
tag = "p#{$4}"
|
2014-12-14 20:02:52 -05:00
|
|
|
url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}")
|
2014-09-03 01:47:31 -04:00
|
|
|
when /\A(\d+)\.(\d+)(?:\.(\d+))?\z/
|
|
|
|
if $3 && ($1 > "2" || $1 == "2" && $2 >= "1")
|
2013-12-25 10:46:02 -05:00
|
|
|
patchlevel = true
|
|
|
|
tag = ""
|
2014-12-14 20:02:52 -05:00
|
|
|
url = vcs.tag("v#{$1}_#{$2}_#{$3}")
|
2013-12-25 10:46:02 -05:00
|
|
|
else
|
2014-12-14 20:02:52 -05:00
|
|
|
url = vcs.branch("ruby_#{rev.tr('.', '_')}")
|
2013-12-25 10:46:02 -05:00
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
else
|
|
|
|
warn "#{$0}: unknown version - #{rev}"
|
|
|
|
return
|
|
|
|
end
|
2019-09-02 22:14:07 -04:00
|
|
|
if info = vcs.get_revisions(url)
|
|
|
|
modified = info[2]
|
|
|
|
else
|
2022-09-29 07:03:51 -04:00
|
|
|
_, _, modified = VCS::Null.new(nil).get_revisions(url)
|
2019-09-02 22:14:07 -04:00
|
|
|
end
|
|
|
|
if !revision and info
|
|
|
|
revision = info
|
2019-05-22 10:18:09 -04:00
|
|
|
url ||= vcs.branch(revision[3])
|
2019-08-29 22:23:06 -04:00
|
|
|
revision = revision[1]
|
2019-05-22 10:18:09 -04:00
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
version = nil
|
|
|
|
unless revision
|
2014-12-14 20:02:52 -05:00
|
|
|
url = vcs.trunk
|
|
|
|
vcs.grep(RUBY_VERSION_PATTERN, url, "version.h") {version = $1}
|
2008-06-21 02:31:18 -04:00
|
|
|
unless rev == version
|
|
|
|
warn "#{$0}: #{rev} not found"
|
|
|
|
return
|
|
|
|
end
|
2022-09-01 06:54:46 -04:00
|
|
|
revision = vcs.get_revisions(url)[1]
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2019-09-14 13:07:00 -04:00
|
|
|
|
|
|
|
v = "ruby"
|
|
|
|
puts "Exporting #{rev}@#{revision}"
|
|
|
|
exported = tmp ? File.join(tmp, v) : v
|
2019-09-14 13:16:15 -04:00
|
|
|
unless vcs.export(revision, url, exported, true) {|line| print line}
|
2019-09-14 13:07:00 -04:00
|
|
|
warn("Export failed")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if $srcdir
|
|
|
|
Dir.glob($srcdir + "/{tool/config.{guess,sub},gems/*.gem,.downloaded-cache/*,enc/unicode/data/**/*.txt}") do |file|
|
2020-11-21 20:59:32 -05:00
|
|
|
puts "copying #{file}" if $VERBOSE
|
2019-09-14 13:07:00 -04:00
|
|
|
dest = exported + file[$srcdir.size..-1]
|
|
|
|
FileUtils.mkpath(File.dirname(dest))
|
|
|
|
begin
|
|
|
|
FileUtils.cp_r(file, dest)
|
2019-12-22 20:10:23 -05:00
|
|
|
FileUtils.chmod_R("a+rwX,go-w", dest)
|
2019-09-14 13:07:00 -04:00
|
|
|
rescue SystemCallError
|
2014-12-14 20:30:30 -05:00
|
|
|
end
|
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2022-03-30 21:40:33 -04:00
|
|
|
|
|
|
|
Dir.glob("#{exported}/.*.yml") do |file|
|
|
|
|
FileUtils.rm(file, verbose: $VERBOSE)
|
|
|
|
end
|
2008-08-12 06:11:11 -04:00
|
|
|
|
2017-05-07 09:06:34 -04:00
|
|
|
status = IO.read(File.dirname(__FILE__) + "/prereq.status")
|
2014-12-14 20:02:52 -05:00
|
|
|
Dir.chdir(tmp) if tmp
|
|
|
|
|
2008-09-26 05:40:04 -04:00
|
|
|
if !File.directory?(v)
|
2008-08-12 21:45:35 -04:00
|
|
|
v = Dir.glob("ruby-*").select(&File.method(:directory?))
|
2016-11-09 22:50:46 -05:00
|
|
|
v.size == 1 or abort "#{File.basename $0}: not exported"
|
2008-08-12 21:45:35 -04:00
|
|
|
v = v[0]
|
|
|
|
end
|
2016-11-06 07:57:45 -05:00
|
|
|
|
2022-08-31 08:53:01 -04:00
|
|
|
File.open("#{v}/revision.h", "wb") {|f|
|
2022-09-17 08:16:06 -04:00
|
|
|
f.puts vcs.revision_header(revision, modified)
|
2019-05-30 13:28:38 -04:00
|
|
|
}
|
2008-08-12 06:11:11 -04:00
|
|
|
version ||= (versionhdr = IO.read("#{v}/version.h"))[RUBY_VERSION_PATTERN, 1]
|
2019-01-10 23:58:33 -05:00
|
|
|
version ||=
|
|
|
|
begin
|
|
|
|
include_ruby_versionhdr = IO.read("#{v}/include/ruby/version.h")
|
|
|
|
api_major_version = include_ruby_versionhdr[/^\#define\s+RUBY_API_VERSION_MAJOR\s+([\d.]+)/, 1]
|
|
|
|
api_minor_version = include_ruby_versionhdr[/^\#define\s+RUBY_API_VERSION_MINOR\s+([\d.]+)/, 1]
|
|
|
|
version_teeny = versionhdr[/^\#define\s+RUBY_VERSION_TEENY\s+(\d+)/, 1]
|
|
|
|
[api_major_version, api_minor_version, version_teeny].join('.')
|
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
version or return
|
|
|
|
if patchlevel
|
2013-12-25 10:46:02 -05:00
|
|
|
unless tag.empty?
|
|
|
|
versionhdr ||= IO.read("#{v}/version.h")
|
|
|
|
patchlevel = versionhdr[/^\#define\s+RUBY_PATCHLEVEL\s+(\d+)/, 1]
|
2019-04-27 13:00:39 -04:00
|
|
|
tag = (patchlevel ? "p#{patchlevel}" : vcs.revision_name(revision))
|
2013-12-25 10:46:02 -05:00
|
|
|
end
|
2013-12-20 15:46:21 -05:00
|
|
|
elsif prerelease
|
|
|
|
versionhdr ||= IO.read("#{v}/version.h")
|
|
|
|
versionhdr.sub!(/^\#define\s+RUBY_PATCHLEVEL_STR\s+"\K.+?(?=")/, tag)
|
|
|
|
IO.write("#{v}/version.h", versionhdr)
|
2008-06-21 02:31:18 -04:00
|
|
|
else
|
2019-04-27 13:00:39 -04:00
|
|
|
tag ||= vcs.revision_name(revision)
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2019-09-14 13:07:00 -04:00
|
|
|
|
|
|
|
if $archname
|
|
|
|
n = $archname
|
|
|
|
elsif tag.empty?
|
|
|
|
n = "ruby-#{version}"
|
|
|
|
else
|
|
|
|
n = "ruby-#{version}-#{tag}"
|
2008-09-26 05:40:04 -04:00
|
|
|
end
|
2019-09-14 13:07:00 -04:00
|
|
|
File.directory?(n) or File.rename v, n
|
2019-09-14 13:16:15 -04:00
|
|
|
v = n
|
2019-09-14 13:07:00 -04:00
|
|
|
|
2019-10-01 23:59:59 -04:00
|
|
|
if $patch_file && !system(*%W"patch -d #{v} -p0 -i #{$patch_file}")
|
|
|
|
puts $colorize.fail("patching failed")
|
|
|
|
return
|
|
|
|
end
|
2008-08-13 00:09:15 -04:00
|
|
|
def (clean = []).add(n) push(n); n end
|
2022-08-31 08:53:01 -04:00
|
|
|
def clean.create(file, content = "") File.binwrite(add(file), content) end
|
2008-06-21 02:31:18 -04:00
|
|
|
Dir.chdir(v) do
|
2018-02-26 01:00:10 -05:00
|
|
|
unless File.exist?("ChangeLog")
|
2019-04-27 23:16:40 -04:00
|
|
|
vcs.export_changelog(url, nil, revision, "ChangeLog")
|
2018-02-26 01:00:10 -05:00
|
|
|
end
|
|
|
|
|
2019-09-14 13:07:00 -04:00
|
|
|
unless touch_all(modified, "**/*", File::FNM_DOTMATCH)
|
2019-09-02 22:14:07 -04:00
|
|
|
modified = nil
|
2019-09-01 23:15:35 -04:00
|
|
|
colors = %w[red yellow green cyan blue magenta]
|
|
|
|
"take a breath, and go ahead".scan(/./) do |c|
|
|
|
|
if c == ' '
|
|
|
|
print c
|
|
|
|
else
|
|
|
|
colors.push(color = colors.shift)
|
|
|
|
print $colorize.decorate(c, color)
|
|
|
|
end
|
|
|
|
sleep(c == "," ? 0.7 : 0.05)
|
|
|
|
end
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
|
2012-03-26 23:11:48 -04:00
|
|
|
File.open(clean.add("cross.rb"), "w") do |f|
|
|
|
|
f.puts "Object.__send__(:remove_const, :CROSS_COMPILING) if defined?(CROSS_COMPILING)"
|
|
|
|
f.puts "CROSS_COMPILING=true"
|
2015-01-17 01:55:09 -05:00
|
|
|
f.puts "Object.__send__(:remove_const, :RUBY_PLATFORM)"
|
|
|
|
f.puts "RUBY_PLATFORM='none'"
|
2015-03-25 03:07:23 -04:00
|
|
|
f.puts "Object.__send__(:remove_const, :RUBY_VERSION)"
|
|
|
|
f.puts "RUBY_VERSION='#{version}'"
|
2012-03-26 23:11:48 -04:00
|
|
|
end
|
2022-09-07 01:41:37 -04:00
|
|
|
puts "cross.rb:", File.read("cross.rb").gsub(/^/, "> "), "" if $VERBOSE
|
2008-08-12 06:11:11 -04:00
|
|
|
unless File.exist?("configure")
|
|
|
|
print "creating configure..."
|
2020-04-04 22:53:07 -04:00
|
|
|
unless system([ENV["AUTOCONF"]]*2)
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.fail(" failed")
|
2008-08-12 06:11:11 -04:00
|
|
|
return
|
|
|
|
end
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.pass(" done")
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2008-08-13 00:09:15 -04:00
|
|
|
clean.add("autom4te.cache")
|
2016-01-19 00:41:11 -05:00
|
|
|
clean.add("enc/unicode/data")
|
2008-06-21 02:31:18 -04:00
|
|
|
print "creating prerequisites..."
|
|
|
|
if File.file?("common.mk") && /^prereq/ =~ commonmk = IO.read("common.mk")
|
2008-08-12 06:11:11 -04:00
|
|
|
puts
|
2008-08-13 00:09:15 -04:00
|
|
|
extout = clean.add('tmp')
|
2017-05-07 09:06:34 -04:00
|
|
|
begin
|
|
|
|
status = IO.read("tool/prereq.status")
|
|
|
|
rescue Errno::ENOENT
|
|
|
|
# use fallback file
|
|
|
|
end
|
2022-08-31 08:53:01 -04:00
|
|
|
clean.create("config.status", status)
|
2022-09-04 22:09:24 -04:00
|
|
|
clean.create("noarch-fake.rb", "require_relative 'cross'\n")
|
2008-08-13 00:09:15 -04:00
|
|
|
FileUtils.mkpath(hdrdir = "#{extout}/include/ruby")
|
2022-08-31 08:53:01 -04:00
|
|
|
File.binwrite("#{hdrdir}/config.h", "")
|
2015-02-09 02:36:16 -05:00
|
|
|
FileUtils.mkpath(defaults = "#{extout}/rubygems/defaults")
|
2022-08-31 08:53:01 -04:00
|
|
|
File.binwrite("#{defaults}/operating_system.rb", "")
|
|
|
|
File.binwrite("#{defaults}/ruby.rb", "")
|
2015-02-09 02:36:16 -05:00
|
|
|
miniruby = ENV['MINIRUBY'] + " -I. -I#{extout} -rcross"
|
2015-03-07 06:54:58 -05:00
|
|
|
baseruby = ENV["BASERUBY"]
|
2019-06-06 20:09:29 -04:00
|
|
|
mk = (IO.read("template/Makefile.in") rescue IO.read("Makefile.in")).
|
|
|
|
gsub(/^@.*\n/, '')
|
2015-03-21 20:51:31 -04:00
|
|
|
vars = {
|
2017-05-07 09:06:34 -04:00
|
|
|
"EXTOUT"=>extout,
|
2015-03-21 20:51:31 -04:00
|
|
|
"PATH_SEPARATOR"=>File::PATH_SEPARATOR,
|
|
|
|
"MINIRUBY"=>miniruby,
|
|
|
|
"RUBY"=>ENV["RUBY"],
|
|
|
|
"BASERUBY"=>baseruby,
|
|
|
|
"PWD"=>Dir.pwd,
|
2017-05-07 09:06:34 -04:00
|
|
|
"ruby_version"=>version,
|
2019-01-10 23:58:33 -05:00
|
|
|
"MAJOR"=>api_major_version,
|
|
|
|
"MINOR"=>api_minor_version,
|
|
|
|
"TEENY"=>version_teeny,
|
2015-03-21 20:51:31 -04:00
|
|
|
}
|
2017-05-07 09:06:34 -04:00
|
|
|
status.scan(/^s([%,])@([A-Za-z_][A-Za-z_0-9]*)@\1(.*?)\1g$/) do
|
2017-07-09 00:17:49 -04:00
|
|
|
vars[$2] ||= $3
|
2017-05-07 09:06:34 -04:00
|
|
|
end
|
2019-02-09 06:04:09 -05:00
|
|
|
vars.delete("UNICODE_FILES") # for stable branches
|
2016-08-16 09:02:33 -04:00
|
|
|
vars["UNICODE_VERSION"] = $unicode_version if $unicode_version
|
2015-03-25 03:44:58 -04:00
|
|
|
args = vars.dup
|
|
|
|
mk.gsub!(/@([A-Za-z_]\w*)@/) {args.delete($1); vars[$1] || ENV[$1]}
|
2019-09-06 22:33:26 -04:00
|
|
|
mk << commonmk.gsub(/\{\$([^(){}]*)[^{}]*\}/, "").sub(/^revision\.tmp::$/, '\& Makefile')
|
2015-03-21 20:51:31 -04:00
|
|
|
mk << <<-'APPEND'
|
|
|
|
|
2019-10-02 00:00:17 -04:00
|
|
|
update-download:: touch-unicode-files
|
|
|
|
prepare-package: prereq after-update
|
2019-09-02 22:14:07 -04:00
|
|
|
clean-cache: $(CLEAN_CACHE)
|
2017-09-17 02:50:31 -04:00
|
|
|
after-update:: extract-gems
|
2016-01-19 00:05:47 -05:00
|
|
|
extract-gems: update-gems
|
|
|
|
update-gems:
|
2019-05-30 09:57:49 -04:00
|
|
|
$(UNICODE_SRC_DATA_DIR)/.unicode-tables.time:
|
|
|
|
touch-unicode-files:
|
2015-03-21 20:51:31 -04:00
|
|
|
APPEND
|
2022-08-31 08:53:01 -04:00
|
|
|
clean.create("Makefile", mk)
|
|
|
|
clean.create("revision.tmp")
|
|
|
|
clean.create(".revision.time")
|
2017-06-27 13:10:56 -04:00
|
|
|
ENV["CACHE_SAVE"] = "no"
|
2019-10-03 06:12:03 -04:00
|
|
|
make = MAKE.new(args)
|
|
|
|
return unless make.run("update-download")
|
2019-09-02 22:14:07 -04:00
|
|
|
clean.push("rbconfig.rb", ".rbconfig.time", "enc.mk", "ext/ripper/y.output", ".revision.time")
|
2019-09-07 11:21:42 -04:00
|
|
|
Dir.glob("**/*") do |dest|
|
|
|
|
next unless File.symlink?(dest)
|
|
|
|
orig = File.expand_path(File.readlink(dest), File.dirname(dest))
|
|
|
|
File.unlink(dest)
|
|
|
|
FileUtils.cp_r(orig, dest)
|
|
|
|
end
|
|
|
|
File.utime(modified, modified, *Dir.glob(["tool/config.{guess,sub}", "gems/*.gem", "tool"]))
|
2019-10-03 06:13:05 -04:00
|
|
|
return unless make.run("prepare-package")
|
|
|
|
return unless make.run("clean-cache")
|
2019-09-02 22:14:07 -04:00
|
|
|
if modified
|
|
|
|
new_time = modified + 2
|
|
|
|
touch_all(new_time, "**/*", File::FNM_DOTMATCH) do |name, stat|
|
|
|
|
stat.mtime > modified unless clean.include?(name)
|
|
|
|
end
|
|
|
|
modified = new_time
|
|
|
|
end
|
2008-08-12 06:11:11 -04:00
|
|
|
print "prerequisites"
|
2008-06-19 08:35:35 -04:00
|
|
|
else
|
2014-10-24 04:16:52 -04:00
|
|
|
system(*%W"#{YACC} -o parse.c parse.y")
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2015-01-20 18:57:38 -05:00
|
|
|
vcs.after_export(".") if exported
|
2020-11-21 20:49:02 -05:00
|
|
|
clean.concat(Dir.glob("ext/**/autom4te.cache"))
|
2015-03-07 06:54:58 -05:00
|
|
|
FileUtils.rm_rf(clean) unless $keep_temp
|
2015-01-20 18:57:53 -05:00
|
|
|
FileUtils.rm_rf(".downloaded-cache")
|
|
|
|
if File.exist?("gems/bundled_gems")
|
|
|
|
gems = Dir.glob("gems/*.gem")
|
|
|
|
gems -= File.readlines("gems/bundled_gems").map {|line|
|
2020-07-05 05:59:06 -04:00
|
|
|
next if /^\s*(?:#|$)/ =~ line
|
2017-10-25 02:58:24 -04:00
|
|
|
name, version, _ = line.split(' ')
|
|
|
|
"gems/#{name}-#{version}.gem"
|
2015-01-20 18:57:53 -05:00
|
|
|
}
|
|
|
|
FileUtils.rm_f(gems)
|
|
|
|
else
|
|
|
|
FileUtils.rm_rf("gems")
|
|
|
|
end
|
2019-09-02 22:43:38 -04:00
|
|
|
if modified
|
|
|
|
touch_all(modified, "**/*/", 0) do |name, stat|
|
|
|
|
stat.mtime > modified
|
|
|
|
end
|
|
|
|
File.utime(modified, modified, ".")
|
2019-09-02 22:14:07 -04:00
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
unless $?.success?
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.fail(" failed")
|
2008-06-21 02:31:18 -04:00
|
|
|
return
|
|
|
|
end
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.pass(" done")
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2008-06-19 08:35:35 -04:00
|
|
|
|
2008-09-26 05:40:04 -04:00
|
|
|
if v == "."
|
|
|
|
v = File.basename(Dir.pwd)
|
|
|
|
Dir.chdir ".."
|
2009-01-16 04:42:33 -05:00
|
|
|
else
|
|
|
|
Dir.chdir(File.dirname(v))
|
|
|
|
v = File.basename(v)
|
2008-09-26 05:40:04 -04:00
|
|
|
end
|
|
|
|
|
2014-05-13 06:09:41 -04:00
|
|
|
tarball = nil
|
2014-05-13 11:47:33 -04:00
|
|
|
return $packages.collect do |mesg|
|
|
|
|
(ext, *cmd) = PACKAGES[mesg]
|
2014-05-13 06:09:41 -04:00
|
|
|
File.directory?(destdir) or FileUtils.mkpath(destdir)
|
2013-08-09 01:05:15 -04:00
|
|
|
file = File.join(destdir, "#{$archname||v}#{ext}")
|
2014-05-13 06:09:41 -04:00
|
|
|
case ext
|
|
|
|
when /\.tar/
|
|
|
|
if tarball
|
|
|
|
next if tarball.empty?
|
|
|
|
else
|
2019-09-02 22:30:40 -04:00
|
|
|
tarball = ext == ".tar" ? file : "#{$archname||v}.tar"
|
2014-05-13 06:09:41 -04:00
|
|
|
print "creating tarball... #{tarball}"
|
2020-11-21 21:01:17 -05:00
|
|
|
if measure {tar_create(tarball, v)}
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.pass(" done")
|
2019-09-02 23:28:00 -04:00
|
|
|
File.utime(modified, modified, tarball) if modified
|
2019-09-02 22:30:40 -04:00
|
|
|
next if tarball == file
|
2014-05-13 06:09:41 -04:00
|
|
|
else
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.fail(" failed")
|
2014-05-13 06:09:41 -04:00
|
|
|
tarball = ""
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print "creating #{mesg} tarball... #{file}"
|
2020-11-21 21:01:17 -05:00
|
|
|
done = measure {system(*cmd, tarball, out: file)}
|
2014-05-13 06:09:41 -04:00
|
|
|
else
|
|
|
|
print "creating #{mesg} archive... #{file}"
|
2017-06-14 22:33:57 -04:00
|
|
|
if Hash === cmd.last
|
|
|
|
*cmd, opt = *cmd
|
|
|
|
cmd << file << v << opt
|
|
|
|
else
|
|
|
|
(cmd = cmd.dup) << file << v
|
|
|
|
end
|
2020-11-21 21:01:17 -05:00
|
|
|
done = measure {system(*cmd)}
|
2014-05-13 06:09:41 -04:00
|
|
|
end
|
|
|
|
if done
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.pass(" done")
|
2008-06-21 02:31:18 -04:00
|
|
|
file
|
|
|
|
else
|
2017-06-14 22:39:06 -04:00
|
|
|
puts $colorize.fail(" failed")
|
2008-06-21 02:31:18 -04:00
|
|
|
nil
|
2008-06-20 19:39:45 -04:00
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
end.compact
|
|
|
|
ensure
|
2019-09-14 13:07:00 -04:00
|
|
|
FileUtils.rm_rf(tmp ? File.join(tmp, v) : v) if v and !$keep_temp
|
2019-09-01 10:24:05 -04:00
|
|
|
Dir.chdir(pwd)
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
|
|
|
|
2016-11-09 22:50:47 -05:00
|
|
|
if [$srcdir, ($svn||=nil), ($git||=nil)].compact.size > 1
|
|
|
|
abort "#{File.basename $0}: -srcdir, -svn, 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
|
2019-09-05 01:37:05 -04:00
|
|
|
abort "#{File.basename $0}: use -srcdir with cloned local repository"
|
2016-11-09 22:50:47 -05:00
|
|
|
else
|
2019-09-07 11:48:18 -04:00
|
|
|
begin
|
|
|
|
vcs = VCS.detect(File.expand_path("../..", __FILE__))
|
|
|
|
rescue VCS::NotFoundError
|
|
|
|
vcs = VCS::SVN.new(SVNURL)
|
|
|
|
end
|
2016-11-09 22:50:47 -05:00
|
|
|
end
|
2014-12-14 20:02:52 -05:00
|
|
|
|
2019-10-07 06:05:42 -04:00
|
|
|
release_date = Time.now.getutc
|
|
|
|
info = {}
|
|
|
|
|
2013-07-04 07:40:11 -04:00
|
|
|
success = true
|
2014-12-14 20:02:52 -05:00
|
|
|
revisions.collect {|rev| package(vcs, rev, destdir, tmp)}.flatten.each do |name|
|
2013-07-04 07:40:11 -04:00
|
|
|
if !name
|
|
|
|
success = false
|
|
|
|
next
|
|
|
|
end
|
2022-08-31 08:53:01 -04:00
|
|
|
str = File.binread(name)
|
2019-10-07 06:05:42 -04:00
|
|
|
pathname = Pathname(name)
|
|
|
|
basename = pathname.basename.to_s
|
|
|
|
extname = pathname.extname.sub(/\A\./, '')
|
|
|
|
version = basename[/\Aruby-(.*)\.(?:tar|zip)/, 1]
|
|
|
|
key = basename[/\A(.*)\.(?:tar|zip)/, 1]
|
|
|
|
info[key] ||= Hash.new{|h,k|h[k]={}}
|
|
|
|
info[key]['version'] = version if version
|
|
|
|
info[key]['date'] = release_date.strftime('%Y-%m-%d')
|
|
|
|
if version
|
|
|
|
info[key]['post'] = "/en/news/#{release_date.strftime('%Y/%m/%d')}/ruby-#{version.tr('.', '-')}-released/"
|
|
|
|
info[key]['url'][extname] = "https://cache.ruby-lang.org/pub/ruby/#{version[/\A\d+\.\d+/]}/#{basename}"
|
|
|
|
else
|
|
|
|
info[key]['filename'][extname] = basename
|
|
|
|
end
|
|
|
|
info[key]['size'][extname] = str.bytesize
|
2017-06-14 22:39:06 -04:00
|
|
|
puts "* #{$colorize.pass(name)}"
|
2019-03-14 18:43:57 -04:00
|
|
|
puts " SIZE: #{str.bytesize} bytes"
|
2014-05-13 11:47:36 -04:00
|
|
|
$digests.each do |alg|
|
2019-10-07 06:05:42 -04:00
|
|
|
digest = Digest(alg).hexdigest(str)
|
|
|
|
info[key][alg.downcase][extname] = digest
|
|
|
|
printf " %-8s%s\n", "#{alg}:", digest
|
2014-05-13 06:09:43 -04:00
|
|
|
end
|
2008-06-21 02:31:18 -04:00
|
|
|
end
|
2008-10-28 04:21:57 -04:00
|
|
|
|
2019-10-07 06:33:33 -04:00
|
|
|
yaml = info.values.to_yaml
|
|
|
|
json = info.values.to_json
|
|
|
|
puts "#{$colorize.pass('YAML:')}"
|
2019-10-07 11:00:24 -04:00
|
|
|
puts yaml
|
|
|
|
puts "#{$colorize.pass('JSON:')}"
|
2019-10-07 06:33:33 -04:00
|
|
|
puts json
|
|
|
|
infodir = Pathname(destdir) + 'info'
|
|
|
|
infodir.mkpath
|
|
|
|
(infodir+'info.yml').write(yaml)
|
|
|
|
(infodir+'info.json').write(json)
|
2019-10-07 06:05:42 -04:00
|
|
|
|
2013-07-04 07:40:11 -04:00
|
|
|
exit false if !success
|
|
|
|
|
2008-10-28 04:21:57 -04:00
|
|
|
# vim:fileencoding=US-ASCII sw=2 ts=4 noexpandtab ff=unix
|