make-snapshot: deprecated -exported option [Bug #16167]

This commit is contained in:
Nobuyoshi Nakada 2019-09-15 02:07:00 +09:00
parent e9c7fc7ca9
commit 1ad4be13cb
No known key found for this signature in database
GPG Key ID: 4BC7D6DF58D8DF60

View File

@ -12,7 +12,6 @@ require File.expand_path("../lib/colorize", __FILE__)
STDOUT.sync = true STDOUT.sync = true
$srcdir ||= nil $srcdir ||= nil
$exported = nil if ($exported ||= nil) == ""
$archname = nil if ($archname ||= nil) == "" $archname = nil if ($archname ||= nil) == ""
$keep_temp ||= nil $keep_temp ||= nil
$patch_file ||= nil $patch_file ||= nil
@ -28,7 +27,6 @@ def usage
usage: #{File.basename $0} [option...] new-directory-to-save [version ...] usage: #{File.basename $0} [option...] new-directory-to-save [version ...]
options: options:
-srcdir=PATH source directory path -srcdir=PATH source directory path
-exported=PATH make snapshot from already exported working directory
-archname=NAME make the basename of snapshots NAME -archname=NAME make the basename of snapshots NAME
-keep_temp keep temporary working directory -keep_temp keep temporary working directory
-patch_file=PATCH apply PATCH file after export -patch_file=PATCH apply PATCH file after export
@ -143,17 +141,20 @@ unless destdir = ARGV.shift
abort usage abort usage
end end
revisions = ARGV.empty? ? [nil] : ARGV revisions = ARGV.empty? ? [nil] : ARGV
unless tmp = $exported
FileUtils.mkpath(destdir) if $exported
destdir = File.expand_path(destdir) abort "#{File.basename $0}: -exported option is deprecated; use -srcdir instead"
tmp = Dir.mktmpdir("ruby-snapshot")
FileUtils.mkpath(tmp)
at_exit {
Dir.chdir "/"
FileUtils.rm_rf(tmp)
} unless $keep_temp
end end
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
def tar_create(tarball, dir) def tar_create(tarball, dir)
require 'rubygems' require 'rubygems'
require 'rubygems/package' require 'rubygems/package'
@ -273,34 +274,28 @@ def package(vcs, rev, destdir, tmp = nil)
end end
revision = vcs.get_revisions(url)[1] revision = vcs.get_revisions(url)[1]
end end
v = nil
if $exported v = "ruby"
if String === $exported puts "Exporting #{rev}@#{revision}"
v = $exported exported = tmp ? File.join(tmp, v) : v
end unless vcs = vcs.export(revision, url, exported, true) {|line| print line}
else warn("Export failed")
v = "ruby" return
puts "Exporting #{rev}@#{revision}" end
exported = tmp ? File.join(tmp, v) : v if $srcdir
unless vcs = vcs.export(revision, url, exported, true) {|line| print line} Dir.glob($srcdir + "/{tool/config.{guess,sub},gems/*.gem,.downloaded-cache/*,enc/unicode/data/**/*.txt}") do |file|
warn("Export failed") puts "copying #{file}"
return dest = exported + file[$srcdir.size..-1]
end FileUtils.mkpath(File.dirname(dest))
if $srcdir begin
Dir.glob($srcdir + "/{tool/config.{guess,sub},gems/*.gem,.downloaded-cache/*,enc/unicode/data/**/*.txt}") do |file| FileUtils.ln(file, dest, force: true)
puts "copying #{file}" next unless File.symlink?(dest)
dest = exported + file[$srcdir.size..-1] File.unlink(dest)
FileUtils.mkpath(File.dirname(dest)) rescue SystemCallError
begin end
FileUtils.ln(file, dest, force: true) begin
next unless File.symlink?(dest) FileUtils.cp_r(file, dest)
File.unlink(dest) rescue SystemCallError
rescue SystemCallError
end
begin
FileUtils.cp_r(file, dest)
rescue SystemCallError
end
end end
end end
end end
@ -344,17 +339,17 @@ def package(vcs, rev, destdir, tmp = nil)
else else
tag ||= vcs.revision_name(revision) tag ||= vcs.revision_name(revision)
end end
unless v == $exported
if $archname if $archname
n = $archname n = $archname
elsif tag.empty? elsif tag.empty?
n = "ruby-#{version}" n = "ruby-#{version}"
else else
n = "ruby-#{version}-#{tag}" n = "ruby-#{version}-#{tag}"
end
File.directory?(n) or File.rename v, n
vcs.chdir(File.expand_path(v = n))
end end
File.directory?(n) or File.rename v, n
vcs.chdir(File.expand_path(v = n))
system(*%W"patch -d #{v} -p0 -i #{$patch_file}") if $patch_file system(*%W"patch -d #{v} -p0 -i #{$patch_file}") if $patch_file
def (clean = []).add(n) push(n); n end def (clean = []).add(n) push(n); n end
Dir.chdir(v) do Dir.chdir(v) do
@ -362,7 +357,7 @@ def package(vcs, rev, destdir, tmp = nil)
vcs.export_changelog(url, nil, revision, "ChangeLog") vcs.export_changelog(url, nil, revision, "ChangeLog")
end end
if !$exported or $patch_file and !touch_all(modified, "**/*", File::FNM_DOTMATCH) unless touch_all(modified, "**/*", File::FNM_DOTMATCH)
modified = nil modified = nil
colors = %w[red yellow green cyan blue magenta] colors = %w[red yellow green cyan blue magenta]
"take a breath, and go ahead".scan(/./) do |c| "take a breath, and go ahead".scan(/./) do |c|
@ -553,7 +548,7 @@ touch-unicode-files:
end end
end.compact end.compact
ensure ensure
FileUtils.rm_rf(tmp ? File.join(tmp, v) : v) if v and !$exported and !$keep_temp FileUtils.rm_rf(tmp ? File.join(tmp, v) : v) if v and !$keep_temp
Dir.chdir(pwd) Dir.chdir(pwd)
end end