Sha256: 9bd8e9d5797ac01e11a7e1ba35f7099c26646d9946947842114b6173a2884e48

Contents?: true

Size: 1.94 KB

Versions: 5

Compression:

Stored size: 1.94 KB

Contents

#!/usr/bin/env ratch

# Install package to site_ruby.
#
# This script installs Facets to site_ruby location
# using Ruby's defualt configuration settings.
# If you want to change these, you can supply
# configuration settings for 'prefix' and/or 'sitedir'.

main :install do

  system_prefix = Config::CONFIG['prefix']
  system_libdir = Config::CONFIG['sitelibdir']

  config = configuration['install'] || {}

  prefix = config['prefix'] || system_prefix
  libdir = config['libdir']

  unless libdir
    if (prefix == system_prefix) then
      libdir = system_libdir
    else
      libdir = File.join(prefix, system_libdir[system_prefix.size..-1])
    end
  end

  # If Rolls is being used.

  if roll_file = File.glob('{,meta/}*.roll').first
    roll = Roll::Package.open
    lib_paths = roll.lib_paths
  else
    lib_paths = config['lib_path'] || ['lib']
  end

  # We need to copy them into site_ruby in the opposite order they
  # would be searched for by require.

  lib_paths.reverse!

  # Copy lib files to site_ruby location, in proper order!

  lib_paths.each do |loc|
    files = glob(File.join(loc, "**/*"))
    files = files.select{ |f| File.file?(f) }
    files.each do |file|
      dest = File.dirname(file)
      dest.sub!(loc, '')
      dest = File.join(libdir, dest)
      if noharm?
        puts "mkdir -p #{dest}" unless File.directory?(dest)
        puts "install -m 0444 #{file} #{dest}"
      else
        mkdir_p dest unless File.directory?(dest)
        install file, dest, :mode => 0444
      end
    end
  end

  # Copy bin files to site_ruby location.

  bin_files = glob("bin/*")
  bin_files = bin_files.select{ |f| File.file?(f) }
  bin_files.each do |file|
    dest = File.dirname(file)
    dest = File.join(prefix, dest)
    if noharm?
      puts "mkdir -p #{dest}" unless File.directory?(dest)
      puts "install -m 0555 #{file} #{dest}"
    else
      mkdir_p dest unless File.directory?(dest)
      install file, dest, :mode => 0555
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ratch-0.2.2 data/ratch/rubyproject/install
ratch-0.2.3 lib/ratch/toolset/ruby/install
ratch-0.3.0 lib/ratch/toolset/ruby/install
ratch-0.4.0 lib/ratch/toolset/ruby/install
ratch-0.4.1 lib/ratch/toolset/ruby/install