Sha256: 438a46b3986c54083b08afeb2a625a93193e8c5d0a7f30f0e7abb8d5402bce3f

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 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

  libpaths = configuration('meta/project.yaml')['libpaths']

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

  libpaths.reverse!

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

  lib_files = Dir.glob("lib/**/*").select{ |f| File.file?(f) }

  #['core', 'fore', 'more' ]
  libpaths.each do |loc|
    files = lib_files.grep(/^#{loc}/)
    files.each do |file|
      dest = File.dirname(file)
      #dest.sub!('lib/', '')
      #dest.sub!(loc, '')
      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
    lib_files -= files  # speed things up be removing what we've already covered.
  end

  # Copy bin files to site_ruby location.

  bin_files = Dir.glob("bin/*").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

1 entries across 1 versions & 1 rubygems

Version Path
ratch-0.2.1 data/ratch/rubyproject/install3