1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
# based on $Id: instdocs.rb,v 1.7 1999/07/06 14:50:39 akira Exp $
require './rbconfig'
include Config
package_name = ARGV.pop
package_dir = if package_name == CONFIG['ruby_install_name']
'tmp'
else
package_name
end
base_dirs = ARGV
base_dir = base_dirs.shift
ruby_dir = 'debian/' + package_dir + '/usr/share/doc/' + CONFIG['ruby_install_name']
dist_dir = 'debian/' + package_dir + '/usr/share/doc/' + package_name
document_dir = dist_dir
example_dir = dist_dir + '/examples'
if File.exist?('debian/instconf.rb')
require 'debian/instconf.rb'
end
if File.exist?("debian/instconf.#{package_name}.rb")
require "debian/instconf.#{package_name}.rb"
end
require 'lib/ftools'
require 'debian/manifest.rb'
if File.exist?(base_dir + '/MANIFEST')
info = Manifest::read_manifest(base_dir + '/MANIFEST')
end
unless info
raise 'can not find MANIFEST file'
end
# adhoc!
base_dirs.each {|x|
if File.exist?(x + '/MANIFEST')
tmp = Manifest::read_manifest(x + '/MANIFEST', x + '/')
# debug
#p tmp
end
if tmp
if info
info.members.each {|n|
eval "info.#{n} += tmp.#{n}"
}
else
info = tmp
end
end
}
# adhoc!
info.document_files.delete_if {|x|
if %r!^(lib|misc)/! =~ x
info.document_dir_files << x
true
end
}
info.example_files.delete_if {|x|
%r!^lib/! =~ x
}
info.example_dir_files.delete_if {|x|
%r!^lib/! =~ x
}
# debug
#p info
# install docments
list = []
if info.document_dir_files.size > 0
list += Manifest::get_install_list2(info.document_dir_files, document_dir)
end
if info.document_files.size > 0
list += Manifest::get_install_list2(info.document_files, document_dir)
end
list.each {|x|
dir = File.dirname(x[1])
unless File.directory?(dir)
File.makedirs(dir, true)
end
next unless FileTest.file?(base_dir + '/' + x[0])
File.install(base_dir + '/' + x[0], x[1], 0444, true)
File.chmod(0444, x[1], true)
}
if list.size > 0 && package_name != CONFIG['ruby_install_name']
symlink_target = '../../' + package_name
symlink_file = ruby_dir + '/ext/' +
package_name.gsub(/^lib|-#{Regexp.quote(CONFIG['ruby_install_name'])}$/o, '')
File.makedirs(ruby_dir + '/ext')
File.symlink(symlink_target, symlink_file)
end
# install examples
list = []
if info.example_dir_files.size > 0
list += Manifest::get_install_list2(info.example_dir_files, example_dir)
end
if info.example_files.size > 0
list += Manifest::get_install_list2(info.example_files, example_dir)
end
list.each {|x|
dir = File.dirname(x[1])
unless File.directory?(dir)
File.makedirs(dir, true)
end
next unless FileTest.file?(base_dir + '/' + x[0])
File.install(base_dir + '/' + x[0], x[1], nil, true)
f = File.open(x[1] + '.tmp', 'w')
exec = nil
IO.foreach(x[1]) {|line|
if exec == nil
if line.sub!(/^\#!\s*((\S*\/)+ruby|(\S*\/)*env ruby)\S*/,
"#!/usr/bin/#{CONFIG['ruby_install_name']}")
exec = true
elsif line.sub!(/^\#!\s*(\S*\/)+(wish|perl|env)/,
'#!/usr/bin/\2')
exec = false
else
exec = false
end
end
f.print line
}
f.close
File.install(x[1] + '.tmp',
x[1], nil, false)
if exec
File.chmod(0555, x[1], true)
else
File.chmod(0444, x[1], true)
end
File.safe_unlink(x[1] + '.tmp')
}
if list.size > 0 && package_name != CONFIG['ruby_install_name']
symlink_target = '../../' + package_name + '/examples'
symlink_file = ruby_dir + '/examples/' +
package_name.gsub(/^lib|-#{Regexp.quote(CONFIG['ruby_install_name'])}$/o, '')
File.makedirs(ruby_dir + '/examples')
File.symlink(symlink_target, symlink_file)
end
|