File: install.rb

package info (click to toggle)
libhttp-access2-ruby 2.0.6-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 228 kB
  • ctags: 336
  • sloc: ruby: 3,008; makefile: 50
file content (44 lines) | stat: -rw-r--r-- 906 bytes parent folder | download
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
#!/usr/bin/env ruby
#
# Installer for http-access2

require "rbconfig"
require "ftools"

include Config

RV = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
SITELIBDIR = CONFIG["sitedir"] + "/" +  RV 
SRCPATH = File.join(File.dirname($0), 'lib')

def install_file(from, to)
  to_path = File.catname(from, to)
  unless FileTest.exist?(to_path) and File.compare(from, to_path)
    File.install(from, to_path, 0644, true)
  end
end

def install(*path)
  from_path = File.join(SRCPATH, *path)
  if FileTest.directory?(from_path)
    to_path_sitelib = File.join(SITELIBDIR, *path)
    Dir[File.join(from_path, '*.rb')].each do |name|
      File.mkpath(to_path_sitelib, true)
      install_file(name, to_path_sitelib)
    end
  else
    install_file(from_path, SITELIBDIR)
  end
end

begin
  install('http-access2.rb')
  install('http-access2')

  puts "install succeed!"

rescue 
  puts "install failed!"
  raise

end