#! /usr/bin/ruby if RUBY_VERSION < "1.9.2" STDERR.puts "autoproj requires Ruby >= 1.9.2" exit 1 end require 'rbconfig' module Autobuild @windows = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw|[Ww]indows)! def self.windows? @windows end @macos = RbConfig::CONFIG["host_os"] =~ %r!([Dd]arwin)! def self.macos? @macos end end require 'yaml' require 'set' module Autoproj class ConfigError < RuntimeError; end class << self attr_reader :verbose end def self.color(string, *args) string end def self.warn(str, *args) STDERR.puts "WARN #{str}" end def self.message(str) STDERR.puts " #{str}" end end module Autobuild class Exception < RuntimeError; end def self.do_update true end def self.message(str) STDERR.puts " #{str}" end def self.progress(key, str) STDERR.puts " #{str}" end def self.progress_done(key) end def self.message(str) STDERR.puts " #{str}" end class << self attr_reader :programs end @programs = Hash.new def self.tool(name) # Let the ability to set programs[name] to nil to make sure we don't use # that program. This is used later on in this file to make sure we # aren't using the wrong rubygems binary if programs.has_key?(name) programs[name] else name end end module Subprocess def self.run(name, phase, *cmd) output = `#{cmd.join(" ")}` if $?.exitstatus != 0 STDERR.puts "ERROR: failed to run #{cmd.join(" ")}" STDERR.puts "ERROR: command output is: #{output}" exit 1 end end end end BUILD_OPTION_CODE CONFIG_CODE module Autoproj def self.config @config ||= Configuration.new end end OSDEPS_CODE TOOLS_CODE OPTIONS_CODE SYSTEM_CODE DEFS = < gem_home, 'GEM_PATH' => gem_path] ENV['GEM_HOME'] = gem_home ENV['GEM_PATH'] = gem_path ENV['PATH'] = "#{ENV['GEM_HOME']}/bin:#{ENV['PATH']}" Autoproj::OSDependencies.define_osdeps_mode_option osdeps_mode = Autoproj::OSDependencies.osdeps_mode.join(",") ENV['AUTOPROJ_OSDEPS_MODE'] = osdeps_mode # First thing we do is install a proper ruby environment. We make sure that we # aren't installing any gems for now (as we need to choose the right gem # binary) by setting Autobuild.programs['gem'] to nil Autobuild.programs['gem'] = nil Autoproj::OSDependencies.autodetect_ruby Autoproj::OSDependencies.autodetect_ruby_program osdeps_management = if ENV['AUTOPROJ_DEFAULT_OSDEPS'] Autoproj::OSDependencies.load(ENV['AUTOPROJ_DEFAULT_OSDEPS']) else Autoproj::OSDependencies.new(YAML.load(DEFS)) end osdeps_management.silent = false Autoproj::PackageManagers::GemManager.use_cache_dir begin STDERR.puts "autoproj: installing a proper Ruby environment (this can take a long time)" osdeps_management.install(['ruby']) rescue Autoproj::ConfigError => e STDERR.puts "failed: #{e.message}" exit(1) end # Now try to find out the name of the gem binary PACKAGES = ['build-essential', 'sudo'] STDERR.puts "autoproj: installing autoproj and its dependencies (this can take a long time)" # First install the dependencies of autoproj, as we don't want them to be # affected by the prerelease flag begin if !PACKAGES.empty? osdeps_management.install(PACKAGES) end rescue Autoproj::ConfigError => e STDERR.puts "failed: #{e.message}" exit(1) end File.open('env.sh', 'w') do |io| io.write <<-EOSHELL export RUBYOPT=-rubygems export GEM_PATH=#{gem_path} export GEM_HOME=#{gem_home} export PATH=$GEM_HOME/bin:$PATH EOSHELL end # If the user specifies "dev" on the command line, install the prerelease # version of autoproj. If it is "localdev", expect him to install autoproj and # run autoproj bootstrap manually. if ARGV.first != "localdev" if ARGV.first == "dev" || (ENV['AUTOPROJ_USE_PRERELEASE'] == '1') ENV['AUTOPROJ_USE_PRERELEASE'] = '1' Autoproj::PackageManagers::GemManager.with_prerelease = true ARGV.shift end begin osdeps_management.install(['autobuild']) osdeps_management.install(['autoproj']) rescue Autoproj::ConfigError => e STDERR.puts "failed: #{e.message}" exit(1) end Autoproj::PackageManagers::GemManager.with_prerelease = false if !system('autoproj', 'bootstrap', *ARGV) STDERR.puts "ERROR: failed to run autoproj bootstrap #{ARGV.join(", ")}" exit 1 end end