Use FileUtils.cp_r instead of cp command directoly.

This commit is contained in:
Hiroshi SHIBATA 2019-07-14 15:20:25 +09:00
parent d25f355c65
commit e91ff4dbaf

View File

@ -91,135 +91,135 @@ def sync_default_gems(gem)
case gem case gem
when "rubygems" when "rubygems"
FileUtils.rm_rf(%w[lib/rubygems* test/rubygems]) FileUtils.rm_rf(%w[lib/rubygems* test/rubygems])
`cp -r #{upstream}/lib/rubygems* ./lib` FileUtils.cp_r(Dir.glob("#{upstream}/lib/rubygems*"), "lib")
`cp -r #{upstream}/test/rubygems ./test` FileUtils.cp_r("#{upstream}/test/rubygems", "test")
when "bundler" when "bundler"
FileUtils.rm_rf(%w[lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*]) FileUtils.rm_rf(%w[lib/bundler* libexec/bundler libexec/bundle spec/bundler man/bundle* man/gemfile*])
`cp -r #{upstream}/lib/bundler* ./lib` FileUtils.cp_r(Dir.glob("#{upstream}/lib/bundler*"), "lib")
`cp -r #{upstream}/exe/bundle* ./libexec` FileUtils.cp_r(Dir.glob("#{upstream}/exe/bundle*"), "libexec")
`cp #{upstream}/bundler.gemspec ./lib/bundler` FileUtils.cp_r("#{upstream}/bundler.gemspec", "lib/bundler")
`cp -r #{upstream}/spec spec/bundler` FileUtils.cp_r("#{upstream}/spec", "spec/bundler")
`cp -r #{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn} ./man` FileUtils.cp_r(Dir.glob("#{upstream}/man/*.{1,5,1\.txt,5\.txt,ronn}"), "man")
FileUtils.rm_rf(%w[spec/bundler/support/artifice/vcr_cassettes]) FileUtils.rm_rf(%w[spec/bundler/support/artifice/vcr_cassettes])
when "rdoc" when "rdoc"
FileUtils.rm_rf(%w[lib/rdoc* test/rdoc libexec/rdoc libexec/ri]) FileUtils.rm_rf(%w[lib/rdoc* test/rdoc libexec/rdoc libexec/ri])
`cp -rf #{upstream}/lib/rdoc* ./lib` FileUtils.cp_r(Dir.glob("#{upstream}/lib/rdoc*"), "lib")
`cp -rf #{upstream}/test test/rdoc` FileUtils.cp_r("#{upstream}/test", "test/rdoc")
`cp #{upstream}/rdoc.gemspec ./lib/rdoc` FileUtils.cp_r("#{upstream}/rdoc.gemspec", "lib/rdoc")
`cp -rf #{upstream}/exe/rdoc ./libexec` FileUtils.cp_r("#{upstream}/exe/rdoc", "libexec")
`cp -rf #{upstream}/exe/ri ./libexec` FileUtils.cp_r("#{upstream}/exe/ri", "libexec")
FileUtils.rm_rf(%w[lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry]) FileUtils.rm_rf(%w[lib/rdoc/markdown.kpeg lib/rdoc/markdown/literals.kpeg lib/rdoc/rd/block_parser.ry lib/rdoc/rd/inline_parser.ry])
`git checkout lib/rdoc/.document` `git checkout lib/rdoc/.document`
when "reline" when "reline"
FileUtils.rm_rf(%w[lib/reline* test/reline]) FileUtils.rm_rf(%w[lib/reline* test/reline])
`cp -rf #{upstream}/lib/reline* ./lib` FileUtils.cp_r(Dir.glob("#{upstream}/lib/reline*"), "lib")
`cp -rf #{upstream}/test test/reline` FileUtils.cp_r("#{upstream}/test", "test/reline")
`cp #{upstream}/reline.gemspec ./lib/reline` FileUtils.cp_r("#{upstream}/reline.gemspec", "lib/reline")
when "json" when "json"
FileUtils.rm_rf(%w[ext/json test/json]) FileUtils.rm_rf(%w[ext/json test/json])
`cp -rf #{upstream}/ext/json/ext ext/json` FileUtils.cp_r("#{upstream}/ext/json/ext", "ext/json")
`cp -rf #{upstream}/tests test/json` FileUtils.cp_r("#{upstream}/tests", "test/json")
`cp -rf #{upstream}/lib ext/json` FileUtils.cp_r("#{upstream}/lib", "ext/json")
FileUtils.rm_rf(%[ext/json/lib/json/pure*]) FileUtils.rm_rf(%[ext/json/lib/json/pure*])
`cp #{upstream}/json.gemspec ext/json` FileUtils.cp_r("#{upstream}/json.gemspec", "ext/json")
FileUtils.rm_rf(%w[ext/json/lib/json/ext]) FileUtils.rm_rf(%w[ext/json/lib/json/ext])
`git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend` `git checkout ext/json/extconf.rb ext/json/parser/prereq.mk ext/json/generator/depend ext/json/parser/depend`
when "psych" when "psych"
FileUtils.rm_rf(%w[ext/psych test/psych]) FileUtils.rm_rf(%w[ext/psych test/psych])
`cp -rf #{upstream}/ext/psych ./ext` FileUtils.cp_r("#{upstream}/ext/psych", "ext")
`cp -rf #{upstream}/lib ./ext/psych` FileUtils.cp_r("#{upstream}/lib", "ext/psych")
`cp -rf #{upstream}/test/psych ./test` FileUtils.cp_r("#{upstream}/test/psych", "test")
FileUtils.rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb]) FileUtils.rm_rf(%w[ext/psych/lib/org ext/psych/lib/psych.jar ext/psych/lib/psych_jars.rb])
FileUtils.rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*]) FileUtils.rm_rf(%w[ext/psych/lib/psych.{bundle,so} ext/psych/lib/2.*])
FileUtils.rm_rf(["ext/psych/yaml/LICENSE"]) FileUtils.rm_rf(["ext/psych/yaml/LICENSE"])
`cp #{upstream}/psych.gemspec ext/psych/` FileUtils.cp_r("#{upstream}/psych.gemspec", "ext/psych")
`git checkout ext/psych/depend` `git checkout ext/psych/depend`
when "fiddle" when "fiddle"
FileUtils.rm_rf(%w[ext/fiddle test/fiddle]) FileUtils.rm_rf(%w[ext/fiddle test/fiddle])
`cp -rf #{upstream}/ext/fiddle ext` FileUtils.cp_r("#{upstream}/ext/fiddle", "ext")
`cp -rf #{upstream}/lib ext/fiddle` FileUtils.cp_r("#{upstream}/lib", "ext/fiddle")
`cp -rf #{upstream}/test/fiddle test` FileUtils.cp_r("#{upstream}/test/fiddle", "test")
`cp -f #{upstream}/fiddle.gemspec ext/fiddle` FileUtils.cp_r("#{upstream}/fiddle.gemspec", "ext/fiddle")
`git checkout ext/fiddle/depend` `git checkout ext/fiddle/depend`
FileUtils.rm_rf(%w[ext/fiddle/lib/fiddle.{bundle,so}]) FileUtils.rm_rf(%w[ext/fiddle/lib/fiddle.{bundle,so}])
when "stringio" when "stringio"
FileUtils.rm_rf(%w[ext/stringio test/stringio]) FileUtils.rm_rf(%w[ext/stringio test/stringio])
`cp -rf #{upstream}/ext/stringio ext` FileUtils.cp_r("#{upstream}/ext/stringio", "ext")
`cp -rf #{upstream}/test/stringio test` FileUtils.cp_r("#{upstream}/test/stringio", "test")
`cp -f #{upstream}/stringio.gemspec ext/stringio` FileUtils.cp_r("#{upstream}/stringio.gemspec", "ext/stringio")
`git checkout ext/stringio/depend ext/stringio/README.md` `git checkout ext/stringio/depend ext/stringio/README.md`
when "ioconsole" when "ioconsole"
FileUtils.rm_rf(%w[ext/io/console test/io/console]) FileUtils.rm_rf(%w[ext/io/console test/io/console])
`cp -rf #{upstream}/ext/io/console ext/io` FileUtils.cp_r("#{upstream}/ext/io/console", "ext/io")
`cp -rf #{upstream}/test/io/console test/io` FileUtils.cp_r("#{upstream}/test/io/console", "test/io")
`mkdir -p ext/io/console/lib` `mkdir -p ext/io/console/lib`
`cp -rf #{upstream}/lib/io/console ext/io/console/lib` FileUtils.cp_r("#{upstream}/lib/io/console", "ext/io/console/lib")
`cp -f #{upstream}/io-console.gemspec ext/io/console` FileUtils.cp_r("#{upstream}/io-console.gemspec", "ext/io/console")
`git checkout ext/io/console/depend` `git checkout ext/io/console/depend`
when "dbm" when "dbm"
FileUtils.rm_rf(%w[ext/dbm test/dbm]) FileUtils.rm_rf(%w[ext/dbm test/dbm])
`cp -rf #{upstream}/ext/dbm ext` FileUtils.cp_r("#{upstream}/ext/dbm", "ext")
`cp -rf #{upstream}/test/dbm test` FileUtils.cp_r("#{upstream}/test/dbm", "test")
`cp -f #{upstream}/dbm.gemspec ext/dbm` FileUtils.cp_r("#{upstream}/dbm.gemspec", "ext/dbm")
`git checkout ext/dbm/depend` `git checkout ext/dbm/depend`
when "gdbm" when "gdbm"
FileUtils.rm_rf(%w[ext/gdbm test/gdbm]) FileUtils.rm_rf(%w[ext/gdbm test/gdbm])
`cp -rf #{upstream}/ext/gdbm ext` FileUtils.cp_r("#{upstream}/ext/gdbm", "ext")
`cp -rf #{upstream}/test/gdbm test` FileUtils.cp_r("#{upstream}/test/gdbm", "test")
`cp -f #{upstream}/gdbm.gemspec ext/gdbm` FileUtils.cp_r("#{upstream}/gdbm.gemspec", "ext/gdbm")
`git checkout ext/gdbm/depend ext/gdbm/README` `git checkout ext/gdbm/depend ext/gdbm/README`
when "sdbm" when "sdbm"
FileUtils.rm_rf(%w[ext/sdbm test/sdbm]) FileUtils.rm_rf(%w[ext/sdbm test/sdbm])
`cp -rf #{upstream}/ext/sdbm ext` FileUtils.cp_r("#{upstream}/ext/sdbm", "ext")
`cp -rf #{upstream}/test/sdbm test` FileUtils.cp_r("#{upstream}/test/sdbm", "test")
`cp -f #{upstream}/sdbm.gemspec ext/sdbm` FileUtils.cp_r("#{upstream}/sdbm.gemspec", "ext/sdbm")
`git checkout ext/sdbm/depend` `git checkout ext/sdbm/depend`
when "etc" when "etc"
FileUtils.rm_rf(%w[ext/etc test/etc]) FileUtils.rm_rf(%w[ext/etc test/etc])
`cp -rf #{upstream}/ext/etc ext` FileUtils.cp_r("#{upstream}/ext/etc", "ext")
`cp -rf #{upstream}/test/etc test` FileUtils.cp_r("#{upstream}/test/etc", "test")
`cp -f #{upstream}/etc.gemspec ext/etc` FileUtils.cp_r("#{upstream}/etc.gemspec", "ext/etc")
`git checkout ext/etc/depend` `git checkout ext/etc/depend`
when "date" when "date"
FileUtils.rm_rf(%w[ext/date test/date]) FileUtils.rm_rf(%w[ext/date test/date])
`cp -rf #{upstream}/ext/date ext` FileUtils.cp_r("#{upstream}/ext/date", "ext")
`cp -rf #{upstream}/lib ext/date` FileUtils.cp_r("#{upstream}/lib", "ext/date")
`cp -rf #{upstream}/test/date test` FileUtils.cp_r("#{upstream}/test/date", "test")
`cp -f #{upstream}/date.gemspec ext/date` FileUtils.cp_r("#{upstream}/date.gemspec", "ext/date")
`git checkout ext/date/depend` `git checkout ext/date/depend`
FileUtils.rm_rf(["ext/date/lib/date_core.bundle"]) FileUtils.rm_rf(["ext/date/lib/date_core.bundle"])
when "zlib" when "zlib"
FileUtils.rm_rf(%w[ext/zlib test/zlib]) FileUtils.rm_rf(%w[ext/zlib test/zlib])
`cp -rf #{upstream}/ext/zlib ext` FileUtils.cp_r("#{upstream}/ext/zlib", "ext")
`cp -rf #{upstream}/test/zlib test` FileUtils.cp_r("#{upstream}/test/zlib", "test")
`cp -f #{upstream}/zlib.gemspec ext/zlib` FileUtils.cp_r("#{upstream}/zlib.gemspec", "ext/zlib")
`git checkout ext/zlib/depend` `git checkout ext/zlib/depend`
when "fcntl" when "fcntl"
FileUtils.rm_rf(%w[ext/fcntl]) FileUtils.rm_rf(%w[ext/fcntl])
`cp -rf #{upstream}/ext/fcntl ext` FileUtils.cp_r("#{upstream}/ext/fcntl", "ext")
`cp -f #{upstream}/fcntl.gemspec ext/fcntl` FileUtils.cp_r("#{upstream}/fcntl.gemspec", "ext/fcntl")
`git checkout ext/fcntl/depend` `git checkout ext/fcntl/depend`
when "thwait" when "thwait"
FileUtils.rm_rf(%w[lib/thwait*]) FileUtils.rm_rf(%w[lib/thwait*])
`cp -rf #{upstream}/lib/* lib` FileUtils.cp_r(Dir.glob("#{upstream}/lib/*"), "lib")
`cp -rf #{upstream}/thwait.gemspec lib/thwait` FileUtils.cp_r("#{upstream}/thwait.gemspec", "lib/thwait")
when "e2mmap" when "e2mmap"
FileUtils.rm_rf(%w[lib/e2mmap*]) FileUtils.rm_rf(%w[lib/e2mmap*])
`cp -rf #{upstream}/lib/* lib` FileUtils.cp_r(Dir.glob("#{upstream}/lib/*"), "lib")
`cp -rf #{upstream}/e2mmap.gemspec lib` FileUtils.cp_r("#{upstream}/e2mmap.gemspec", "lib")
when "strscan" when "strscan"
FileUtils.rm_rf(%w[ext/strscan test/strscan]) FileUtils.rm_rf(%w[ext/strscan test/strscan])
`cp -rf #{upstream}/ext/strscan ext` FileUtils.cp_r("#{upstream}/ext/strscan", "ext")
`cp -rf #{upstream}/test/strscan test` FileUtils.cp_r("#{upstream}/test/strscan", "test")
`cp -f #{upstream}/strscan.gemspec ext/strscan` FileUtils.cp_r("#{upstream}/strscan.gemspec", "ext/strscan")
FileUtils.rm_rf(%w["ext/strscan/regenc.h ext/strscan/regint.h"]) FileUtils.rm_rf(%w["ext/strscan/regenc.h ext/strscan/regint.h"])
`git checkout ext/strscan/depend` `git checkout ext/strscan/depend`
when "racc" when "racc"
FileUtils.rm_rf(%w[lib/racc* ext/racc test/racc]) FileUtils.rm_rf(%w[lib/racc* ext/racc test/racc])
`cp -rf #{upstream}/lib/racc* lib` FileUtils.cp_r(Dir.glob("#{upstream}/lib/racc*"), "lib")
`mkdir -p ext/racc/cparse` `mkdir -p ext/racc/cparse`
`cp -rf #{upstream}/ext/racc/cparse/* ext/racc/cparse` FileUtils.cp_r(Dir.glob("#{upstream}/ext/racc/cparse/*"), "ext/racc/cparse")
`cp -rf #{upstream}/test test/racc` FileUtils.cp_r("#{upstream}/test", "test/racc")
`git checkout ext/racc/cparse/README` `git checkout ext/racc/cparse/README`
when "rexml", "rss", "matrix", "irb", "csv", "shell", "logger", "ostruct", "scanf", "webrick", "fileutils", "forwardable", "prime", "tracer", "ipaddr", "cmath", "mutex_m", "sync" when "rexml", "rss", "matrix", "irb", "csv", "shell", "logger", "ostruct", "scanf", "webrick", "fileutils", "forwardable", "prime", "tracer", "ipaddr", "cmath", "mutex_m", "sync"
sync_lib gem sync_lib gem
@ -232,19 +232,19 @@ def sync_lib(repo)
abort "Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't." abort "Expected '../#{repo}' (#{File.expand_path("../#{repo}")}) to be a directory, but it wasn't."
end end
FileUtils.rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"]) FileUtils.rm_rf(["lib/#{repo}.rb", "lib/#{repo}/*", "test/test_#{repo}.rb"])
`cp -rf ../#{repo}/lib/* lib` FileUtils.cp_r(Dir.glob("../#{repo}/lib/*"), "lib")
tests = if File.directory?("test/#{repo}") tests = if File.directory?("test/#{repo}")
"test/#{repo}" "test/#{repo}"
else else
"test/test_#{repo}.rb" "test/test_#{repo}.rb"
end end
`cp -rf ../#{repo}/#{tests} test` FileUtils.cp_r("../#{repo}/#{tests}", "test")
gemspec = if File.directory?("lib/#{repo}") gemspec = if File.directory?("lib/#{repo}")
"lib/#{repo}/#{repo}.gemspec" "lib/#{repo}/#{repo}.gemspec"
else else
"lib/#{repo}.gemspec" "lib/#{repo}.gemspec"
end end
`cp -f ../#{repo}/#{repo}.gemspec #{gemspec}` FileUtils.cp_r("../#{repo}/#{repo}.gemspec", "#{gemspec}")
end end
def update_default_gems(gem) def update_default_gems(gem)