summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-18 06:36:30 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-18 06:36:30 (GMT)
commitf80c80f004b62dd29ec808d5674874a2ada900a9 (patch)
treee656c005a07a4f53d338da04f500bafa412db9d3 /tool
parent9fa69f7e52c366f33ad4827f84d0bfd79d37b7c9 (diff)
make-snapshot: package with TarHeader
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rwxr-xr-xtool/make-snapshot42
1 files changed, 41 insertions, 1 deletions
diff --git a/tool/make-snapshot b/tool/make-snapshot
index 0481197..33e4512 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -155,6 +155,46 @@ unless tmp = $exported
} unless $keep_temp
end
+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
+
def package(vcs, rev, destdir, tmp = nil)
patchlevel = false
prerelease = false
@@ -417,7 +457,7 @@ _touch-unicode-files:
else
tarball = "#{$archname||v}.tar"
print "creating tarball... #{tarball}"
- if system("tar", "cf", tarball, v)
+ if tar_create(tarball, v)
puts $colorize.pass(" done")
else
puts $colorize.fail(" failed")