2008-08-12 14:11:11 +04:00
|
|
|
#!/usr/bin/ruby -s
|
2008-11-06 19:24:32 +03:00
|
|
|
# -*- coding: us-ascii -*-
|
2008-06-21 10:31:18 +04:00
|
|
|
require 'uri'
|
2014-12-27 04:03:50 +03:00
|
|
|
require 'digest/sha1'
|
2008-06-21 10:31:18 +04:00
|
|
|
require 'digest/sha2'
|
|
|
|
require 'fileutils'
|
2015-01-17 03:05:09 +03:00
|
|
|
require 'shellwords'
|
2008-06-21 10:31:18 +04:00
|
|
|
require 'tmpdir'
|
2018-02-27 17:08:26 +03:00
|
|
|
require 'pathname'
|
2014-12-15 04:02:52 +03:00
|
|
|
require File.expand_path("../vcs", __FILE__)
|
2017-06-15 05:39:06 +03:00
|
|
|
require File.expand_path("../colorize", __FILE__)
|
2008-06-21 10:31:18 +04:00
|
|
|
STDOUT.sync = true
|
2007-12-22 09:14:50 +03:00
|
|
|
|
2014-12-15 04:28:58 +03:00
|
|
|
$srcdir ||= nil
|
2014-12-15 04:02:32 +03:00
|
|
|
$exported = nil if ($exported ||= nil) == ""
|
|
|
|
$archname = nil if ($archname ||= nil) == ""
|
2010-08-19 17:45:02 +04:00
|
|
|
$keep_temp ||= nil
|
|
|
|
$patch_file ||= nil
|
2014-12-15 04:02:32 +03:00
|
|
|
$packages ||= nil
|
|
|
|
$digests ||= nil
|
2018-02-27 17:08:26 +03:00
|
|
|
$s3 ||= nil
|
2013-06-14 08:01:54 +04:00
|
|
|
$tooldir = File.expand_path("..", __FILE__)
|
2016-08-16 16:02:33 +03:00
|
|
|
$unicode_version = nil if ($unicode_version ||= nil) == ""
|
2017-06-15 05:39:06 +03:00
|
|
|
$colorize = Colorize.new
|
2010-08-19 17:45:02 +04:00
|
|
|
|
|
|
|
def usage
|
|
|
|
<<USAGE
|
|
|
|
usage: #{File.basename $0} [option...] new-directory-to-save [version ...]
|
2010-08-19 17:50:43 +04:00
|
|
|
options:
|
2014-12-15 04:28:58 +03:00
|
|
|
-srcdir=PATH source directory path
|
2010-08-19 17:45:02 +04:00
|
|
|
-exported=PATH make snapshot from already exported working directory
|
|
|
|
-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 19:47:33 +04:00
|
|
|
-packages=PKG[,...] make PKG packages (#{PACKAGES.keys.join(", ")})
|
2014-05-13 19:47:36 +04:00
|
|
|
-digests=ALG[,...] show ALG digests (#{DIGESTS.join(", ")})
|
2018-02-26 10:57:16 +03:00
|
|
|
-unicode_version=VER Unicode version to generate encodings
|
|
|
|
-svn[=URL] make snapshot from SVN repository
|
|
|
|
(#{SVNURL})
|
|
|
|
-git[=URL] make snapshot from GIT repository
|
|
|
|
(#{GITURL})
|
2018-02-27 17:08:26 +03:00
|
|
|
-s3=PATH s3 bucket path(default=tmp)
|
2018-02-26 10:57:16 +03:00
|
|
|
-help, --help show this message
|
2010-08-19 17:50:43 +04:00
|
|
|
version:
|
2014-09-03 10:05:01 +04:00
|
|
|
trunk, stable, branches/*, tags/*, X.Y, X.Y.Z, X.Y.Z-pL
|
2010-08-19 17:50:43 +04:00
|
|
|
each versions may be followed by optional @revision.
|
2010-08-19 17:45:02 +04:00
|
|
|
USAGE
|
|
|
|
end
|
2008-09-26 13:40:04 +04:00
|
|
|
|
2015-01-29 14:28:31 +03:00
|
|
|
DIGESTS = %w[SHA1 SHA256 SHA512]
|
2014-05-13 14:09:41 +04:00
|
|
|
PACKAGES = {
|
|
|
|
"bzip" => %w".tar.bz2 bzip2 -c",
|
|
|
|
"gzip" => %w".tar.gz gzip -c",
|
|
|
|
"xz" => %w".tar.xz xz -c",
|
|
|
|
"zip" => %w".zip zip -qr",
|
|
|
|
}
|
|
|
|
|
2016-12-12 16:20:00 +03:00
|
|
|
if system("7z", out: IO::NULL)
|
2017-06-15 14:51:39 +03:00
|
|
|
PACKAGES["gzip"] = %w".tar.gz 7z a dummy -tgzip -mx -so"
|
|
|
|
PACKAGES["zip"] = %w".zip 7z a -tzip -mx" << {out: IO::NULL}
|
2016-12-12 16:20:00 +03:00
|
|
|
end
|
2016-08-17 04:13:00 +03:00
|
|
|
if gzip = ENV.delete("GZIP")
|
|
|
|
PACKAGES["gzip"].concat(gzip.shellsplit)
|
|
|
|
end
|
|
|
|
|
2018-02-26 09:00:09 +03: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 10:31:18 +04:00
|
|
|
ENV["LC_ALL"] = ENV["LANG"] = "C"
|
2018-07-28 13:00:27 +03:00
|
|
|
SVNURL = URI.parse("https://svn.ruby-lang.org/repos/ruby/")
|
2018-07-28 15:47:36 +03:00
|
|
|
GITURL = URI.parse("https://git.ruby-lang.org/ruby.git")
|
2008-06-21 10:31:18 +04:00
|
|
|
RUBY_VERSION_PATTERN = /^\#define\s+RUBY_VERSION\s+"([\d.]+)"/
|
2008-06-19 16:35:35 +04:00
|
|
|
|
2008-06-21 10:31:18 +04:00
|
|
|
ENV["VPATH"] ||= "include/ruby"
|
|
|
|
YACC = ENV["YACC"] ||= "bison"
|
|
|
|
ENV["BASERUBY"] ||= "ruby"
|
|
|
|
ENV["RUBY"] ||= "ruby"
|
|
|
|
ENV["MV"] ||= "mv"
|
2009-01-16 12:42:33 +03:00
|
|
|
ENV["RM"] ||= "rm -f"
|
2008-06-21 10:31:18 +04:00
|
|
|
ENV["MINIRUBY"] ||= "ruby"
|
2009-01-16 12:42:33 +03:00
|
|
|
ENV["PROGRAM"] ||= "ruby"
|
2013-05-26 19:51:13 +04:00
|
|
|
ENV["AUTOCONF"] ||= "autoconf"
|
2014-11-25 20:12:03 +03:00
|
|
|
ENV["BUILTIN_TRANSOBJS"] ||= "newline.o"
|
2007-12-22 09:14:50 +03:00
|
|
|
|
2008-10-28 10:13:39 +03:00
|
|
|
class String
|
|
|
|
# for older ruby
|
|
|
|
alias bytesize size unless method_defined?(:bytesize)
|
|
|
|
end
|
|
|
|
|
2010-03-24 22:38:22 +03: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 19:47:33 +04:00
|
|
|
$packages &&= $packages.split(/[, ]+/).tap {|pkg|
|
2017-06-15 06:12:32 +03:00
|
|
|
if all = pkg.index("all")
|
|
|
|
pkg[all, 1] = PACKAGES.keys - pkg
|
|
|
|
end
|
2014-05-13 19:47:33 +04:00
|
|
|
pkg -= PACKAGES.keys
|
|
|
|
pkg.empty? or abort "#{File.basename $0}: unknown packages - #{pkg.join(", ")}"
|
|
|
|
}
|
|
|
|
$packages ||= PACKAGES.keys
|
|
|
|
|
2014-05-13 19: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 14:11:11 +04:00
|
|
|
$patch_file &&= File.expand_path($patch_file)
|
2008-06-21 10:31:18 +04:00
|
|
|
path = ENV["PATH"].split(File::PATH_SEPARATOR)
|
|
|
|
%w[YACC BASERUBY RUBY MV MINIRUBY].each do |var|
|
2015-01-17 03:05:09 +03:00
|
|
|
cmd, = ENV[var].shellsplit
|
2008-06-21 10:31:18 +04:00
|
|
|
unless path.any? {|dir|
|
2008-09-26 13:40:04 +04:00
|
|
|
file = File.expand_path(cmd, dir)
|
2008-06-21 10: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 09:14:50 +03:00
|
|
|
|
2012-12-11 20:18:01 +04:00
|
|
|
%w[BASERUBY RUBY MINIRUBY].each do |var|
|
2018-02-28 14:12:36 +03:00
|
|
|
%x[#{ENV[var]} --disable-gem -e1 2>&1]
|
2012-12-11 20:18:01 +04:00
|
|
|
if $?.success?
|
|
|
|
ENV[var] += ' --disable-gem'
|
|
|
|
end
|
2012-12-11 10:13:43 +04:00
|
|
|
end
|
|
|
|
|
2014-12-15 04:02:32 +03:00
|
|
|
if defined?($help) or defined?($_help)
|
2010-08-19 17:45:02 +04:00
|
|
|
puts usage
|
|
|
|
exit
|
|
|
|
end
|
2008-06-21 10:31:18 +04:00
|
|
|
unless destdir = ARGV.shift
|
2010-08-19 17:45:02 +04:00
|
|
|
abort usage
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
|
|
|
revisions = ARGV.empty? ? ["trunk"] : ARGV
|
2008-08-12 14:11:11 +04:00
|
|
|
unless tmp = $exported
|
|
|
|
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
|
|
|
|
end
|
2008-06-19 16:35:35 +04:00
|
|
|
|
2018-10-18 09:36:30 +03:00
|
|
|
def tar_create(tarball, dir)
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/package'
|
|
|
|
require 'rubygems/package/tar_writer'
|
|
|
|
header = Gem::Package::TarHeader
|
|
|
|
dir_type = "5"
|
|
|
|
uname = gname = "ruby"
|
|
|
|
File.open(tarball, "wb") do |f|
|
|
|
|
w = Gem::Package::TarWriter.new(f)
|
|
|
|
Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH) do |path|
|
|
|
|
next if File.basename(path) == "."
|
|
|
|
s = File.stat(path)
|
|
|
|
case
|
|
|
|
when s.file?
|
|
|
|
type = nil
|
|
|
|
size = s.size
|
|
|
|
when s.directory?
|
|
|
|
path += "/"
|
|
|
|
type = dir_type
|
|
|
|
size = 0
|
|
|
|
else
|
|
|
|
next
|
|
|
|
end
|
|
|
|
name, prefix = w.split_name(path)
|
|
|
|
h = header.new(name: name, prefix: prefix,
|
|
|
|
mode: s.mode, size: size, mtime: s.mtime,
|
|
|
|
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
|
|
|
|
|
2014-12-15 04:02:52 +03:00
|
|
|
def package(vcs, rev, destdir, tmp = nil)
|
2008-06-21 10:31:18 +04:00
|
|
|
patchlevel = false
|
2013-12-21 00:46:21 +04:00
|
|
|
prerelease = false
|
2010-08-19 17:34:40 +04:00
|
|
|
if revision = rev[/@(\d+)\z/, 1]
|
|
|
|
rev = $`
|
|
|
|
end
|
2008-06-21 10:31:18 +04:00
|
|
|
case rev
|
2014-12-15 04:02:52 +03:00
|
|
|
when /\Atrunk\z/
|
|
|
|
url = vcs.trunk
|
|
|
|
when /\Abranches\//
|
|
|
|
url = vcs.branch($')
|
|
|
|
when /\Atags\//
|
|
|
|
url = vcs.tag($')
|
2008-06-21 10:31:18 +04:00
|
|
|
when /\Astable\z/
|
2014-12-23 20:12:25 +03:00
|
|
|
vcs.branch_list("ruby_[0-9]*") {|n| url = n[/\Aruby_\d+_\d+\z/]}
|
2014-12-15 04:02:52 +03:00
|
|
|
url &&= vcs.branch(url)
|
2012-11-01 22:22:31 +04:00
|
|
|
when /\A(.*)\.(.*)\.(.*)-(preview|rc)(\d+)/
|
2013-12-21 00:46:21 +04:00
|
|
|
prerelease = true
|
2008-08-25 21:47:57 +04:00
|
|
|
tag = "#{$4}#{$5}"
|
2014-12-15 04:02:52 +03:00
|
|
|
url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}#{$5}")
|
2012-11-01 22:22:31 +04:00
|
|
|
when /\A(.*)\.(.*)\.(.*)-p(\d+)/
|
|
|
|
patchlevel = true
|
|
|
|
tag = "p#{$4}"
|
2014-12-15 04:02:52 +03:00
|
|
|
url = vcs.tag("v#{$1}_#{$2}_#{$3}_#{$4}")
|
2014-09-03 09:47:31 +04:00
|
|
|
when /\A(\d+)\.(\d+)(?:\.(\d+))?\z/
|
|
|
|
if $3 && ($1 > "2" || $1 == "2" && $2 >= "1")
|
2013-12-25 19:46:02 +04:00
|
|
|
patchlevel = true
|
|
|
|
tag = ""
|
2014-12-15 04:02:52 +03:00
|
|
|
url = vcs.tag("v#{$1}_#{$2}_#{$3}")
|
2013-12-25 19:46:02 +04:00
|
|
|
else
|
2014-12-15 04:02:52 +03:00
|
|
|
url = vcs.branch("ruby_#{rev.tr('.', '_')}")
|
2013-12-25 19:46:02 +04:00
|
|
|
end
|
2008-06-21 10:31:18 +04:00
|
|
|
else
|
|
|
|
warn "#{$0}: unknown version - #{rev}"
|
|
|
|
return
|
|
|
|
end
|
2014-12-15 04:02:52 +03:00
|
|
|
revision ||= vcs.get_revisions(url)[1]
|
2008-06-21 10:31:18 +04:00
|
|
|
version = nil
|
|
|
|
unless revision
|
2014-12-15 04:02:52 +03:00
|
|
|
url = vcs.trunk
|
|
|
|
vcs.grep(RUBY_VERSION_PATTERN, url, "version.h") {version = $1}
|
2008-06-21 10:31:18 +04:00
|
|
|
unless rev == version
|
|
|
|
warn "#{$0}: #{rev} not found"
|
|
|
|
return
|
|
|
|
end
|
2014-12-15 04:02:52 +03:00
|
|
|
revision = vcs.get_revisions(url)[1]
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2008-09-26 13:40:04 +04:00
|
|
|
v = nil
|
|
|
|
if $exported
|
|
|
|
if String === $exported
|
|
|
|
v = $exported
|
|
|
|
end
|
|
|
|
else
|
|
|
|
v = "ruby"
|
2008-08-12 14:11:11 +04:00
|
|
|
puts "Exporting #{rev}@#{revision}"
|
2014-12-15 04:30:30 +03:00
|
|
|
exported = tmp ? File.join(tmp, v) : v
|
2015-01-21 02:57:38 +03:00
|
|
|
unless vcs.export(revision, url, exported, true) {|line| print line}
|
2008-08-12 14:11:11 +04:00
|
|
|
warn("Export failed")
|
|
|
|
return
|
|
|
|
end
|
2014-12-15 04:30:30 +03:00
|
|
|
if $srcdir
|
2016-01-19 08:05:47 +03:00
|
|
|
Dir.glob($srcdir + "/{tool/config.{guess,sub},gems/*.gem,.downloaded-cache/*,enc/unicode/data/**/*.txt}") do |file|
|
2014-12-15 04:30:30 +03:00
|
|
|
puts "copying #{file}"
|
2014-12-23 16:24:33 +03:00
|
|
|
dest = exported + file[$srcdir.size..-1]
|
|
|
|
FileUtils.mkpath(File.dirname(dest))
|
|
|
|
begin
|
|
|
|
FileUtils.ln(file, dest, force: true)
|
2017-06-27 20:10:56 +03:00
|
|
|
next unless File.symlink?(dest)
|
|
|
|
File.unlink(dest)
|
|
|
|
rescue SystemCallError
|
|
|
|
end
|
|
|
|
begin
|
|
|
|
FileUtils.cp_r(file, dest, preserve: true)
|
2014-12-23 16:24:33 +03:00
|
|
|
rescue SystemCallError
|
|
|
|
end
|
2014-12-15 04:30:30 +03:00
|
|
|
end
|
|
|
|
end
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2008-08-12 14:11:11 +04:00
|
|
|
|
2017-05-07 16:06:34 +03:00
|
|
|
status = IO.read(File.dirname(__FILE__) + "/prereq.status")
|
2014-12-15 04:02:52 +03:00
|
|
|
Dir.chdir(tmp) if tmp
|
|
|
|
|
2008-09-26 13:40:04 +04:00
|
|
|
if !File.directory?(v)
|
2008-08-13 05:45:35 +04:00
|
|
|
v = Dir.glob("ruby-*").select(&File.method(:directory?))
|
2016-11-10 06:50:46 +03:00
|
|
|
v.size == 1 or abort "#{File.basename $0}: not exported"
|
2008-08-13 05:45:35 +04:00
|
|
|
v = v[0]
|
|
|
|
end
|
2016-11-06 15:57:45 +03:00
|
|
|
|
2008-08-12 14:11:11 +04:00
|
|
|
open("#{v}/revision.h", "wb") {|f| f.puts "#define RUBY_REVISION #{revision}"}
|
|
|
|
version ||= (versionhdr = IO.read("#{v}/version.h"))[RUBY_VERSION_PATTERN, 1]
|
2008-06-21 10:31:18 +04:00
|
|
|
version or return
|
|
|
|
if patchlevel
|
2013-12-25 19:46:02 +04:00
|
|
|
unless tag.empty?
|
|
|
|
versionhdr ||= IO.read("#{v}/version.h")
|
|
|
|
patchlevel = versionhdr[/^\#define\s+RUBY_PATCHLEVEL\s+(\d+)/, 1]
|
|
|
|
tag = (patchlevel ? "p#{patchlevel}" : "r#{revision}")
|
|
|
|
end
|
2013-12-21 00:46:21 +04: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 10:31:18 +04:00
|
|
|
else
|
2008-08-25 21:47:57 +04:00
|
|
|
tag ||= "r#{revision}"
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2008-09-26 13:40:04 +04:00
|
|
|
unless v == $exported
|
2014-06-26 04:46:30 +04:00
|
|
|
if $archname
|
|
|
|
n = $archname
|
|
|
|
elsif tag.empty?
|
2013-12-25 19:46:02 +04:00
|
|
|
n = "ruby-#{version}"
|
|
|
|
else
|
|
|
|
n = "ruby-#{version}-#{tag}"
|
|
|
|
end
|
2008-09-26 13:40:04 +04:00
|
|
|
File.directory?(n) or File.rename v, n
|
|
|
|
v = n
|
|
|
|
end
|
2014-10-24 12:16:52 +04:00
|
|
|
system(*%W"patch -d #{v} -p0 -i #{$patch_file}") if $patch_file
|
2014-11-11 12:10:03 +03:00
|
|
|
if !$exported or $patch_file
|
2017-06-15 05:39:06 +03: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
|
2014-11-11 12:10:03 +03:00
|
|
|
end
|
2008-08-13 08:09:15 +04:00
|
|
|
def (clean = []).add(n) push(n); n end
|
2008-06-21 10:31:18 +04:00
|
|
|
Dir.chdir(v) do
|
2018-02-26 09:00:10 +03:00
|
|
|
unless File.exist?("ChangeLog")
|
|
|
|
# get last revision from previous ChangeLog archive
|
|
|
|
last_ChangeLog = Dir["doc/ChangeLog-*"].grep(/-(\d+)\z/) {|n| [$1.to_i, n]}.max[1]
|
|
|
|
open(last_ChangeLog) do |f|
|
|
|
|
f.readline
|
|
|
|
unless /\Ar(\d+) / =~ f.readline
|
|
|
|
abort "#{File.basename $0}: Cannot find revision from '#{last_ChangeLog}'"
|
|
|
|
end
|
|
|
|
vcs.export_changelog(url, $1.to_i, revision.to_i, "ChangeLog")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-03-27 07: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 09:55:09 +03:00
|
|
|
f.puts "Object.__send__(:remove_const, :RUBY_PLATFORM)"
|
|
|
|
f.puts "RUBY_PLATFORM='none'"
|
2015-03-25 10:07:23 +03:00
|
|
|
f.puts "Object.__send__(:remove_const, :RUBY_VERSION)"
|
|
|
|
f.puts "RUBY_VERSION='#{version}'"
|
2012-03-27 07:11:48 +04:00
|
|
|
end
|
2008-08-12 14:11:11 +04:00
|
|
|
unless File.exist?("configure")
|
|
|
|
print "creating configure..."
|
2014-10-24 12:16:52 +04:00
|
|
|
unless system([ENV["AUTOCONF"]]*2)
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.fail(" failed")
|
2008-08-12 14:11:11 +04:00
|
|
|
return
|
|
|
|
end
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.pass(" done")
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2008-08-13 08:09:15 +04:00
|
|
|
clean.add("autom4te.cache")
|
2016-01-19 08:41:11 +03:00
|
|
|
clean.add("enc/unicode/data")
|
2008-06-21 10:31:18 +04:00
|
|
|
print "creating prerequisites..."
|
|
|
|
if File.file?("common.mk") && /^prereq/ =~ commonmk = IO.read("common.mk")
|
2008-08-12 14:11:11 +04:00
|
|
|
puts
|
2008-08-13 08:09:15 +04:00
|
|
|
extout = clean.add('tmp')
|
2017-05-07 16:06:34 +03:00
|
|
|
begin
|
|
|
|
status = IO.read("tool/prereq.status")
|
|
|
|
rescue Errno::ENOENT
|
|
|
|
# use fallback file
|
|
|
|
end
|
2008-08-13 08:09:15 +04:00
|
|
|
File.open(clean.add("config.status"), "w") {|f|
|
2017-05-07 16:06:34 +03:00
|
|
|
f.print status
|
2008-08-12 14:11:11 +04:00
|
|
|
}
|
2008-08-13 08:09:15 +04:00
|
|
|
FileUtils.mkpath(hdrdir = "#{extout}/include/ruby")
|
|
|
|
File.open("#{hdrdir}/config.h", "w") {}
|
2015-02-09 10:36:16 +03:00
|
|
|
FileUtils.mkpath(defaults = "#{extout}/rubygems/defaults")
|
|
|
|
File.open("#{defaults}/operating_system.rb", "w") {}
|
|
|
|
File.open("#{defaults}/ruby.rb", "w") {}
|
|
|
|
miniruby = ENV['MINIRUBY'] + " -I. -I#{extout} -rcross"
|
2015-03-07 14:54:58 +03:00
|
|
|
baseruby = ENV["BASERUBY"]
|
2015-03-22 03:51:31 +03:00
|
|
|
mk = IO.read("Makefile.in").gsub(/^@.*\n/, '')
|
|
|
|
vars = {
|
2017-05-07 16:06:34 +03:00
|
|
|
"EXTOUT"=>extout,
|
2015-03-22 03:51:31 +03:00
|
|
|
"PATH_SEPARATOR"=>File::PATH_SEPARATOR,
|
|
|
|
"MINIRUBY"=>miniruby,
|
|
|
|
"RUBY"=>ENV["RUBY"],
|
|
|
|
"BASERUBY"=>baseruby,
|
|
|
|
"PWD"=>Dir.pwd,
|
2017-05-07 16:06:34 +03:00
|
|
|
"ruby_version"=>version,
|
2015-03-22 03:51:31 +03:00
|
|
|
}
|
2017-05-07 16:06:34 +03:00
|
|
|
status.scan(/^s([%,])@([A-Za-z_][A-Za-z_0-9]*)@\1(.*?)\1g$/) do
|
2017-07-09 07:17:49 +03:00
|
|
|
vars[$2] ||= $3
|
2017-05-07 16:06:34 +03:00
|
|
|
end
|
2016-08-16 16:02:33 +03:00
|
|
|
vars["UNICODE_VERSION"] = $unicode_version if $unicode_version
|
2015-03-25 10:44:58 +03:00
|
|
|
args = vars.dup
|
|
|
|
mk.gsub!(/@([A-Za-z_]\w*)@/) {args.delete($1); vars[$1] || ENV[$1]}
|
2016-07-14 09:46:53 +03:00
|
|
|
mk << commonmk.gsub(/\{\$([^(){}]*)[^{}]*\}/, "")
|
2015-03-22 03:51:31 +03:00
|
|
|
mk << <<-'APPEND'
|
|
|
|
|
|
|
|
prereq: clean-cache $(CLEAN_CACHE)
|
2017-09-17 09:50:31 +03:00
|
|
|
clean-cache $(CLEAN_CACHE): after-update
|
2017-07-09 07:17:49 +03:00
|
|
|
touch-unicode-files: _touch-unicode-files
|
2017-03-24 06:42:28 +03:00
|
|
|
update-download:: touch-unicode-files
|
2016-01-19 08:05:47 +03:00
|
|
|
update-download:: update-gems
|
2017-09-17 09:50:31 +03:00
|
|
|
after-update:: extract-gems
|
2016-01-19 08:05:47 +03:00
|
|
|
extract-gems: update-gems
|
|
|
|
update-gems:
|
2017-07-09 07:17:49 +03:00
|
|
|
_touch-unicode-files:
|
|
|
|
$(MAKEDIRS) $(UNICODE_SRC_DATA_DIR)
|
|
|
|
touch $(UNICODE_SRC_DATA_DIR)/.unicode-tables.time $(UNICODE_DATA_HEADERS)
|
2015-03-22 03:51:31 +03:00
|
|
|
APPEND
|
|
|
|
open(clean.add("Makefile"), "w") do |f|
|
2016-01-19 08:05:47 +03:00
|
|
|
f.puts "prereq: update-download"
|
2014-10-21 07:33:18 +04:00
|
|
|
f.puts mk
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2017-06-27 20:10:56 +03:00
|
|
|
ENV["CACHE_SAVE"] = "no"
|
2017-06-08 01:25:23 +03:00
|
|
|
system(ENV["MAKE"] || ENV["make"] || "make", "prereq", *args.map {|arg| arg.join("=")})
|
2009-01-30 08:32:43 +03:00
|
|
|
clean.push("rbconfig.rb", ".rbconfig.time", "enc.mk")
|
2008-08-12 14:11:11 +04:00
|
|
|
print "prerequisites"
|
2008-06-19 16:35:35 +04:00
|
|
|
else
|
2014-10-24 12:16:52 +04:00
|
|
|
system(*%W"#{YACC} -o parse.c parse.y")
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2015-01-21 02:57:38 +03:00
|
|
|
vcs.after_export(".") if exported
|
2015-03-07 14:54:58 +03:00
|
|
|
FileUtils.rm_rf(clean) unless $keep_temp
|
2015-01-21 02:57:53 +03: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|
|
2017-10-25 09:58:24 +03:00
|
|
|
name, version, _ = line.split(' ')
|
|
|
|
"gems/#{name}-#{version}.gem"
|
2015-01-21 02:57:53 +03:00
|
|
|
}
|
|
|
|
FileUtils.rm_f(gems)
|
|
|
|
else
|
|
|
|
FileUtils.rm_rf("gems")
|
|
|
|
end
|
2008-06-21 10:31:18 +04:00
|
|
|
unless $?.success?
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.fail(" failed")
|
2008-06-21 10:31:18 +04:00
|
|
|
return
|
|
|
|
end
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.pass(" done")
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2008-06-19 16:35:35 +04:00
|
|
|
|
2008-09-26 13:40:04 +04:00
|
|
|
if v == "."
|
|
|
|
v = File.basename(Dir.pwd)
|
|
|
|
Dir.chdir ".."
|
2009-01-16 12:42:33 +03:00
|
|
|
else
|
|
|
|
Dir.chdir(File.dirname(v))
|
|
|
|
v = File.basename(v)
|
2008-09-26 13:40:04 +04:00
|
|
|
end
|
|
|
|
|
2014-05-13 14:09:41 +04:00
|
|
|
tarball = nil
|
2014-05-13 19:47:33 +04:00
|
|
|
return $packages.collect do |mesg|
|
|
|
|
(ext, *cmd) = PACKAGES[mesg]
|
2014-05-13 14:09:41 +04:00
|
|
|
File.directory?(destdir) or FileUtils.mkpath(destdir)
|
2013-08-09 09:05:15 +04:00
|
|
|
file = File.join(destdir, "#{$archname||v}#{ext}")
|
2014-05-13 14:09:41 +04:00
|
|
|
case ext
|
|
|
|
when /\.tar/
|
|
|
|
if tarball
|
|
|
|
next if tarball.empty?
|
|
|
|
else
|
|
|
|
tarball = "#{$archname||v}.tar"
|
|
|
|
print "creating tarball... #{tarball}"
|
2018-10-18 09:36:30 +03:00
|
|
|
if tar_create(tarball, v)
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.pass(" done")
|
2014-05-13 14:09:41 +04:00
|
|
|
else
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.fail(" failed")
|
2014-05-13 14:09:41 +04:00
|
|
|
tarball = ""
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
print "creating #{mesg} tarball... #{file}"
|
2014-10-24 12:16:52 +04:00
|
|
|
done = system(*cmd, tarball, out: file)
|
2014-05-13 14:09:41 +04:00
|
|
|
else
|
|
|
|
print "creating #{mesg} archive... #{file}"
|
2017-06-15 05:33:57 +03:00
|
|
|
if Hash === cmd.last
|
|
|
|
*cmd, opt = *cmd
|
|
|
|
cmd << file << v << opt
|
|
|
|
else
|
|
|
|
(cmd = cmd.dup) << file << v
|
|
|
|
end
|
|
|
|
done = system(*cmd)
|
2014-05-13 14:09:41 +04:00
|
|
|
end
|
|
|
|
if done
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.pass(" done")
|
2008-06-21 10:31:18 +04:00
|
|
|
file
|
|
|
|
else
|
2017-06-15 05:39:06 +03:00
|
|
|
puts $colorize.fail(" failed")
|
2008-06-21 10:31:18 +04:00
|
|
|
nil
|
2008-06-21 03:39:45 +04:00
|
|
|
end
|
2008-06-21 10:31:18 +04:00
|
|
|
end.compact
|
|
|
|
ensure
|
2008-08-12 14:11:11 +04:00
|
|
|
FileUtils.rm_rf(v) if v and !$exported and !$keep_temp
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
|
|
|
|
2016-11-10 06:50:47 +03: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
|
|
|
|
vcs = VCS::GIT.new($git == true ? GITURL : URI.parse($git))
|
|
|
|
else
|
|
|
|
vcs = VCS::SVN.new(SVNURL)
|
|
|
|
end
|
2014-12-15 04:02:52 +03:00
|
|
|
|
2013-07-04 15:40:11 +04:00
|
|
|
success = true
|
2014-12-15 04:02:52 +03:00
|
|
|
revisions.collect {|rev| package(vcs, rev, destdir, tmp)}.flatten.each do |name|
|
2013-07-04 15:40:11 +04:00
|
|
|
if !name
|
|
|
|
success = false
|
|
|
|
next
|
|
|
|
end
|
2008-11-06 19:24:32 +03:00
|
|
|
str = open(name, "rb") {|f| f.read}
|
2018-02-27 17:08:26 +03:00
|
|
|
if $s3
|
2018-02-28 14:12:36 +03:00
|
|
|
%x[aws s3 cp #{name} s3://ftp.r-l.o/pub/#{$s3}/#{Pathname(name).basename}]
|
2018-02-27 17:08:26 +03:00
|
|
|
FileUtils.rm_f name
|
|
|
|
name = "https://s3.amazonaws.com/ftp.r-l.o/pub/#{$s3}/#{Pathname(name).basename}"
|
|
|
|
end
|
2017-06-15 05:39:06 +03:00
|
|
|
puts "* #{$colorize.pass(name)}"
|
2008-10-28 11:21:57 +03:00
|
|
|
puts " SIZE: #{str.bytesize} bytes"
|
2014-05-13 19:47:36 +04:00
|
|
|
$digests.each do |alg|
|
2014-05-13 14:09:43 +04:00
|
|
|
printf " %-8s%s\n", "#{alg}:", Digest.const_get(alg).hexdigest(str)
|
|
|
|
end
|
2008-06-21 10:31:18 +04:00
|
|
|
end
|
2008-10-28 11:21:57 +03:00
|
|
|
|
2013-07-04 15:40:11 +04:00
|
|
|
exit false if !success
|
|
|
|
|
2008-10-28 11:21:57 +03:00
|
|
|
# vim:fileencoding=US-ASCII sw=2 ts=4 noexpandtab ff=unix
|