[前][次][番号順一覧][スレッド一覧]

ruby-changes:40383

From: nobu <ko1@a...>
Date: Fri, 6 Nov 2015 14:09:48 +0900 (JST)
Subject: [ruby-changes:40383] nobu:r52464 (trunk): rbinstall.rb: compress man pages.

nobu	2015-11-06 14:09:42 +0900 (Fri, 06 Nov 2015)

  New Revision: 52464

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52464

  Log:
    rbinstall.rb: compress man pages.
    
    * tool/rbinstall.rb (man): get rid of prompt from compress
      program.

  Modified files:
    trunk/tool/rbinstall.rb
Index: tool/rbinstall.rb
===================================================================
--- tool/rbinstall.rb	(revision 52463)
+++ tool/rbinstall.rb	(revision 52464)
@@ -524,9 +524,14 @@ install?(:local, :comm, :man) do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L524
   mdocs = Dir["#{srcdir}/man/*.[1-9]"]
   prepare "manpages", mandir, ([] | mdocs.collect {|mdoc| mdoc[/\d+$/]}).sort.collect {|sec| "man#{sec}"}
 
+  case $mantype
+  when /\.(?:(gz)|bz2)\z/
+    compress = $1 ? "gzip" : "bzip2"
+    suffix = $&
+  end
   mandir = File.join(mandir, "man")
   has_goruby = File.exist?(goruby_install_name+exeext)
-  require File.join(srcdir, "tool/mdoc2man.rb") if $mantype != "doc"
+  require File.join(srcdir, "tool/mdoc2man.rb") if /\Adoc\b/ !~ $mantype
   mdocs.each do |mdoc|
     next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'}
     base = File.basename(mdoc)
@@ -539,11 +544,21 @@ install?(:local, :comm, :man) do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L544
     destfile = File.join(destdir, "#{destname}.#{section}")
 
     if /\Adoc\b/ =~ $mantype
-      install mdoc, destfile, :mode => $data_mode
-      case $mantype
-      when /\.(?:(gz)|bz2)\z/
-        compress = $1 ? "gzip" : "bzip2"
-        system(compress, dest)
+      if compress
+        w = open(mdoc) {|f|
+          stdin = STDIN.dup
+          STDIN.reopen(f)
+          begin
+            destfile << suffix
+            IO.popen(compress) {|f| f.read}
+          ensure
+            STDIN.reopen(stdin)
+            stdin.close
+          end
+        }
+        open_for_install(destfile, $data_mode) {w}
+      else
+        install mdoc, destfile, :mode => $data_mode
       end
     else
       class << (w = [])
@@ -551,10 +566,7 @@ install?(:local, :comm, :man) do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L566
       end
       open(mdoc) {|r| Mdoc2Man.mdoc2man(r, w)}
       w = w.join("")
-      case $mantype
-      when /\.(?:(gz)|bz2)\z/
-        suffix = $&
-        compress = $1 ? "gzip" : "bzip2"
+      if compress
         require 'tmpdir'
         Dir.mktmpdir("man") {|d|
           dest = File.join(d, File.basename(destfile))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]