bin/autoproj_bootstrap in autoproj-1.13.7 vs bin/autoproj_bootstrap in autoproj-2.0.0.b1

- old
+ new

@@ -72,25 +72,30 @@ end end module Subprocess def self.run(name, phase, *cmd) - output = `'#{cmd.join("' '")}'` + if cmd.last.kind_of?(Hash) + options = cmd.pop + (options[:env] || Hash.new).each do |k, v| + ENV[k] = v + end + end + + 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 module Autoproj - class InputError < RuntimeError; end - # Definition of an autoproj option as defined by - # {Configuration#configuration_option} + # {Configuration#declare} class BuildOption attr_reader :name attr_reader :type attr_reader :options @@ -203,16 +208,19 @@ attr_reader :overrides # Set of options that have been declared with {declare} attr_reader :declared_options # The options that have already been shown to the user attr_reader :displayed_options + # The path to the underlying configuration file + attr_reader :path - def initialize + def initialize(path = nil) @config = Hash.new @overrides = Hash.new @declared_options = Hash.new @displayed_options = Hash.new + @path = path end # Deletes the current value for an option # # The user will be asked for a new value next time the option is needed @@ -247,18 +255,18 @@ def has_value_for?(name) config.has_key?(name) || overrides.has_key?(name) end # Get the value for a given option - def get(key, default_value = nil) + def get(key, *default_value) if overrides.has_key?(key) return overrides[key] end value, validated = config[key] - if value.nil? && !declared?(key) && !default_value.nil? - default_value + if value.nil? && !declared?(key) && !default_value.empty? + default_value.first elsif value.nil? || (declared?(key) && !validated) value = configure(key) else if declared?(key) && (displayed_options[key] != value) doc = declared_options[key].short_doc @@ -330,19 +338,31 @@ else raise ConfigError.new, "undeclared option '#{option_name}'" end end - def load(path, reconfigure = false) - if h = YAML.load(File.read(path)) + def load(options = Hash.new) + options = validate_options options, + path: self.path, + reconfigure: false + + if h = YAML.load(File.read(options[:path])) h.each do |key, value| - set(key, value, !reconfigure) + set(key, value, !options[:reconfigure]) end end end - def save(path) + def reconfigure! + new_config = Hash.new + config.each do |key, (value, user_validated)| + new_config[key] = [value, false] + end + @config = new_config + end + + def save(path = self.path) File.open(path, "w") do |io| h = Hash.new config.each do |key, value| h[key] = value.first end @@ -365,23 +385,19 @@ def import_log_enabled=(value) set('import_log_enabled', !!value) end def ruby_executable - @ruby_executable ||= OSDependencies.autodetect_ruby_program + if path = get('ruby_executable', nil) + path + else + path = OSDependencies.autodetect_ruby_program + set('ruby_executable', path, true) + path + end end - # For Autoproj 2.0 forward compatibility - def shell_helpers? - Autoproj.shell_helpers? - end - - # For Autoproj 2.0 forward compatibility - def shell_helpers=(flag) - Autoproj.shell_helpers = flag - end - def validate_ruby_executable if has_value_for?('ruby_executable') expected = get('ruby_executable') if expected != ruby_executable raise ConfigError.new, "this autoproj installation was bootstrapped using #{expected}, but you are currently running under #{ruby_executable}. This is usually caused by calling a wrong gem program (for instance, gem1.8 instead of gem1.9.1)" @@ -399,10 +415,18 @@ end set "autoproj_use_prerelease", (use_prerelease ? true : false), true use_prerelease end + def shell_helpers? + get 'shell_helpers', true + end + + def shell_helpers=(flag) + set 'shell_helpers', flag, true + end + def apply_autobuild_configuration if has_value_for?('autobuild') params = get('autobuild') if params.kind_of?(Hash) params.each do |k, v| @@ -410,17 +434,52 @@ end end end end - def apply_autoproj_prefix - if has_value_for?('prefix') - Autoproj.prefix = get('prefix') - else Autoproj.prefix = 'install' - end + # The directory in which packages will be installed. + # + # If it is a relative path, it is relative to the root dir of the + # installation. + # + # The default is "install" + # + # @return [String] + def prefix_dir + get('prefix', 'install') end + # Defines the temporary area in which packages should put their build + # files + # + # If absolute, it is handled as {#prefix_dir}: the package name will be + # appended to it. If relative, it is relative to the package's source + # directory + # + # The default is "build" + # + # @return [String] + def build_dir + get('build', 'build') + end + + # Returns true if there should be one prefix per package + # + # The default is false (disabled) + # + # @return [Boolean] + def separate_prefixes? + get('separate_prefixes', false) + end + + # Controls whether there should be one prefix per package + # + # @see separate_prefixes? + def separate_prefixes=(flag) + set('separate_prefixes', flag, true) + end + # Returns true if packages and prefixes should be auto-generated, based # on the SHA of the package names. This is meant to be used for build # services that want to check that dependencies are properly set # # The default is false (disabled) @@ -481,21 +540,21 @@ def utility_enable_all(utility) reset(utility_key(utility)) set("#{utility_key(utility)}_default", true) end - # Enables a utility for a specific package + # Enables a utility for a set of packages # - # Note that if the default for this utility is to be enabled, this is - # essentially a no-op. - # # @param [String] utility the utility name (e.g. 'doc' or 'test') - # @param [String] package the package name + # @param [String] packages the package names # @return [void] - def utility_enable_for(utility, package) + def utility_enable(utility, *packages) utility_config = get(utility_key(utility), Hash.new) - set(utility_key(utility), utility_config.merge(package => true)) + packages.each do |pkg_name| + utility_config[pkg_name] = true + end + set(utility_key(utility), utility_config) end # Disables a utility for all packages # # This both sets the default value for all packages and resets all @@ -513,16 +572,23 @@ # # Note that if the default for this utility is to be disabled, this is # essentially a no-op. # # @param [String] utility the utility name (e.g. 'doc' or 'test') - # @param [String] package the package name + # @param [String] packages the package names # @return [void] - def utility_disable_for(utility, package) + def utility_disable(utility, *packages) utility_config = get(utility_key(utility), Hash.new) - set(utility_key(utility), utility_config.merge(package => false)) + packages.each do |pkg_name| + utility_config[pkg_name] = false + end + set(utility_key(utility), utility_config) end + + def merge(conf) + config.merge!(conf.config) + end end end module Autoproj @@ -563,24 +629,20 @@ @names = names.dup @enabled = true @silent = true end - def parse_package_entry(entry) - entry - end - # The primary name for this package manager def name names.first end # Overload to perform initialization of environment variables in # order to have a properly functioning package manager # # This is e.g. needed for python pip or rubygems - def self.initialize_environment + def self.initialize_environment(_env = nil, _manifest = nil, _root_dir = Autoproj.root_dir) end end # Dummy package manager used for unknown OSes. It simply displays a # message to the user when packages are needed @@ -841,11 +903,11 @@ "brew install '%s'", "brew install '%s'", false) end - def filter_uptodate_packages(packages) + def filter_uptodate_packages(packages, options = Hash.new) # TODO there might be duplicates in packages which should be fixed # somewhere else packages = packages.uniq result = `brew info --json=v1 '#{packages.join("' '")}'` result = begin @@ -908,11 +970,11 @@ super(['zypper'], true, "zypper install '%s'", "zypper -n install '%s'") end - def filter_uptodate_packages(packages) + def filter_uptodate_packages(packages, options = Hash.new) result = `LANG=C rpm -q --whatprovides '#{packages.join("' '")}'` has_all_pkgs = $?.success? if !has_all_pkgs return packages # let zypper filter, we need root now anyways @@ -947,11 +1009,11 @@ super(['yum'], true, "yum install '%s'", "yum install -y '%s'") end - def filter_uptodate_packages(packages) + def filter_uptodate_packages(packages, options = Hash.new) result = `LANG=C rpm -q --queryformat "%{NAME}\n" '#{packages.join("' '")}'` installed_packages = [] new_packages = [] result.split("\n").each_with_index do |line, index| @@ -1050,57 +1112,79 @@ # installed new packages ! @installed_packages = nil end end - def filter_uptodate_packages(packages) + def filter_uptodate_packages(packages, options = Hash.new) packages.find_all do |package_name| !installed?(package_name) end end end # Package manager interface for the RubyGems system class GemManager < Manager class << self - attr_accessor :with_prerelease + attr_writer :with_prerelease attr_accessor :with_doc end @with_prerelease = false @with_doc = false + def self.with_prerelease(*value) + if value.empty? + @with_prerelease + else + begin + saved_flag = @with_prerelease + @with_prerelease = value.first + yield + ensure + @with_prerelease = saved_flag + end + end + end + # Filters all paths that come from other autoproj installations out # of GEM_PATH - def self.initialize_environment - Autobuild::ORIGINAL_ENV['GEM_PATH'] = - (ENV['GEM_PATH'] || "").split(File::PATH_SEPARATOR).find_all do |p| + def self.initialize_environment(env = Autobuild.env, manifest = Autoproj.manifest, root_dir = Autoproj.root_dir) + env.original_env['GEM_PATH'] = + (env['GEM_PATH'] || "").split(File::PATH_SEPARATOR).find_all do |p| !Autoproj.in_autoproj_installation?(p) end.join(File::PATH_SEPARATOR) - Autobuild.env_inherit 'GEM_PATH' - Autobuild.env_init_from_env 'GEM_PATH' + env.inherit 'GEM_PATH' + env.init_from_env 'GEM_PATH' - orig_gem_path = Autobuild::ORIGINAL_ENV['GEM_PATH'].split(File::PATH_SEPARATOR) - Autobuild::SYSTEM_ENV['GEM_PATH'] = Gem.default_path - Autobuild::ORIGINAL_ENV['GEM_PATH'] = orig_gem_path.join(File::PATH_SEPARATOR) + orig_gem_path = env.original_env['GEM_PATH'].split(File::PATH_SEPARATOR) + env.system_env['GEM_PATH'] = Gem.default_path + env.original_env['GEM_PATH'] = orig_gem_path.join(File::PATH_SEPARATOR) - Autoproj.manifest.each_reused_autoproj_installation do |p| + manifest.each_reused_autoproj_installation do |p| p_gems = File.join(p, '.gems') if File.directory?(p_gems) - Autobuild.env_push_path 'GEM_PATH', p_gems - Autobuild.env_push_path 'PATH', File.join(p_gems, 'bin') + env.push_path 'GEM_PATH', p_gems + env.push_path 'PATH', File.join(p_gems, 'bin') end end - Autobuild.env_push_path 'GEM_PATH', gem_home - Autobuild.env_set 'GEM_HOME', gem_home - Autobuild.env_push_path 'PATH', "#{gem_home}/bin" + @gem_home = (ENV['AUTOPROJ_GEM_HOME'] || File.join(root_dir, ".gems")) + env.push_path 'GEM_PATH', gem_home + env.set 'GEM_HOME', gem_home + env.push_path 'PATH', "#{gem_home}/bin" + # Now, reset the directories in our own RubyGems instance - Gem.paths = ENV + Gem.paths = env.resolved_env use_cache_dir end + # Override the gem home detected by {initialize_environment}, or set + # it in cases where calling {initialize_environment} is not possible + def self.gem_home=(gem_home) + @gem_home = gem_home + end + # A global cache directory that should be used to avoid # re-downloading gems def self.cache_dir if dir = ENV['AUTOBUILD_CACHE_DIR'] dir = File.join(dir, 'gems') @@ -1122,11 +1206,11 @@ end end # Return the directory in which RubyGems package should be installed def self.gem_home - ENV['AUTOPROJ_GEM_HOME'] || File.join(Autoproj.root_dir, ".gems") + @gem_home end # Returns the set of default options that are added to gem # # By default, we add --no-user-install to un-break distributions @@ -1216,22 +1300,27 @@ end if gems_interaction(gems, cmdlines) Autoproj.message " installing/updating RubyGems dependencies: #{gems.map { |g| g.join(" ") }.sort.join(", ")}" cmdlines.each do |c| - Autobuild::Subprocess.run 'autoproj', 'osdeps', *c + Autobuild::Subprocess.run 'autoproj', 'osdeps', *c, + env: Hash['GEM_HOME' => Gem.paths.home, + 'GEM_PATH' => Gem.paths.path.join(":")] end gems.each do |name, v| installed_gems << name end true end end # Returns the set of RubyGem packages in +packages+ that are not already # installed, or that can be upgraded - def filter_uptodate_packages(gems) + def filter_uptodate_packages(gems, options = Hash.new) + options = validate_options options, + install_only: !Autobuild.do_update + # Don't install gems that are already there ... gems = gems.dup gems.delete_if do |name, version| next(true) if installed_gems.include?(name) @@ -1245,11 +1334,11 @@ end else Gem.source_index.find_name(name, version_requirements) end - if !installed.empty? && Autobuild.do_update + if !installed.empty? && !options[:install_only] # Look if we can update the package ... dep = Gem::Dependency.new(name, version_requirements) available = if gem_fetcher.respond_to?(:find_matching) non_prerelease = gem_fetcher.find_matching(dep, true, true).map(&:first) @@ -1334,18 +1423,18 @@ # Using pip to install python packages class PipManager < Manager attr_reader :installed_gems - def self.initialize_environment - Autoproj.env_set 'PYTHONUSERBASE', pip_home + def self.initialize_environment(env = Autobuild.env, _manifest = nil, root_dir = Autoproj.root_dir) + env.set 'PYTHONUSERBASE', pip_home(env, root_dir) end # Return the directory where python packages are installed to. # The actual path is pip_home/lib/pythonx.y/site-packages. - def self.pip_home - ENV['AUTOPROJ_PYTHONUSERBASE'] || File.join(Autoproj.root_dir,".pip") + def self.pip_home(env = Autobuild.env, root_dir = Autobuild.root_dir) + env['AUTOPROJ_PYTHONUSERBASE'] || File.join(root_dir,".pip") end def initialize super(['pip']) @@ -1787,16 +1876,12 @@ # Examples: ['debian', ['sid', 'unstable']] or ['ubuntu', ['lucid lynx', '10.04']] def self.operating_system(options = Hash.new) # Validate the options. We check on the availability of # validate_options as to not break autoproj_bootstrap (in which # validate_options is not available) - options = - if Kernel.respond_to?(:validate_options) - Kernel.validate_options options, :force => false - else - options.dup - end + options = validate_options options, force: false, config: Autoproj.config + config = options.fetch(:config) if user_os = ENV['AUTOPROJ_OS'] @operating_system = if user_os.empty? then false else @@ -1809,12 +1894,12 @@ if options[:force] @operating_system = nil elsif !@operating_system.nil? # @operating_system can be set to false to simulate an unknown OS return @operating_system - elsif Autoproj.has_config_key?('operating_system') - os = Autoproj.user_config('operating_system') + elsif config.has_value_for?('operating_system') + os = config.get('operating_system') if os.respond_to?(:to_ary) if os[0].respond_to?(:to_ary) && os[0].all? { |s| s.respond_to?(:to_str) } && os[1].respond_to?(:to_ary) && os[1].all? { |s| s.respond_to?(:to_str) } @operating_system = os return os @@ -1849,11 +1934,11 @@ names = ensure_derivatives_refer_to_their_parents(names) names, versions = normalize_os_representation(names, versions) @operating_system = [names, versions] - Autoproj.change_option('operating_system', @operating_system, true) + config.set('operating_system', @operating_system, true) Autobuild.progress :operating_system_autodetection, "operating system: #{(names - ['default']).join(",")} - #{(versions - ['default']).join(",")}" @operating_system ensure Autobuild.progress_done :operating_system_autodetection end @@ -1976,19 +2061,15 @@ result.concat(resolved) end end result.map do |handler, status, entries| - entries = entries.map do |e| - if e.respond_to?(:to_str) - handler.parse_package_entry(e) - else - e - end + if handler.respond_to?(:parse_package_entry) + [handler, status, entries.map { |s| handler.parse_package_entry(s) }] + else + [handler, status, entries] end - - [handler, status, entries] end end # Value returned by #resolve_package and #partition_osdep_entry in # the status field. See the documentation of these methods for more @@ -2134,12 +2215,10 @@ end return found, result end - class MissingOSDep < ConfigError; end - # Resolves the given OS dependencies into the actual packages that need # to be installed on this particular OS. # # @param [Array<String>] dependencies the list of osdep names that should be resolved # @return [Array<#install,Array<String>>] the set of packages, grouped @@ -2253,11 +2332,11 @@ HANDLE_ALL = 'all' HANDLE_RUBY = 'ruby' HANDLE_OS = 'os' HANDLE_NONE = 'none' - def self.osdeps_mode_option_unsupported_os + def self.osdeps_mode_option_unsupported_os(config = Autoproj.config) long_doc =<<-EOT The software packages that autoproj will have to build may require other prepackaged softwares (a.k.a. OS dependencies) to be installed (RubyGems packages, packages from your operating system/distribution, ...). Autoproj is usually able to install those automatically, but unfortunately your operating @@ -2284,17 +2363,17 @@ So, what do you want ? (all, none or a comma-separated list of: gem pip) EOT message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (all, none or a comma-separated list of: gem pip) ?", long_doc.strip ] - Autoproj.configuration_option 'osdeps_mode', 'string', + config.declare 'osdeps_mode', 'string', :default => 'ruby', :doc => message, :lowercase => true end - def self.osdeps_mode_option_supported_os + def self.osdeps_mode_option_supported_os(config = Autoproj.config) long_doc =<<-EOT The software packages that autoproj will have to build may require other prepackaged softwares (a.k.a. OS dependencies) to be installed (RubyGems packages, packages from your operating system/distribution, ...). Autoproj is able to install those automatically for you. @@ -2325,21 +2404,21 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip) EOT message = [ "Which prepackaged software (a.k.a. 'osdeps') should autoproj install automatically (all, none or a comma-separated list of: os gem pip) ?", long_doc.strip ] - Autoproj.configuration_option 'osdeps_mode', 'string', + config.declare 'osdeps_mode', 'string', :default => 'all', :doc => message, :lowercase => true end - def self.define_osdeps_mode_option + def self.define_osdeps_mode_option(config = Autoproj.config) if supported_operating_system? - osdeps_mode_option_supported_os + osdeps_mode_option_supported_os(config) else - osdeps_mode_option_unsupported_os + osdeps_mode_option_unsupported_os(config) end end def self.osdeps_mode_string_to_value(string) string = string.to_s.downcase.split(',') @@ -2387,37 +2466,37 @@ end @osdeps_mode = OSDependencies.osdeps_mode end - def self.osdeps_mode + def self.osdeps_mode(config = Autoproj.config) while true mode = - if !Autoproj.has_config_key?('osdeps_mode') && + if !config.has_value_for?('osdeps_mode') && mode_name = ENV['AUTOPROJ_OSDEPS_MODE'] begin OSDependencies.osdeps_mode_string_to_value(mode_name) rescue ArgumentError Autoproj.warn "invalid osdeps mode given through AUTOPROJ_OSDEPS_MODE (#{mode})" nil end else - mode_name = Autoproj.user_config('osdeps_mode') + mode_name = config.get('osdeps_mode') begin OSDependencies.osdeps_mode_string_to_value(mode_name) rescue ArgumentError Autoproj.warn "invalid osdeps mode stored in configuration file" nil end end if mode @osdeps_mode = mode - Autoproj.change_option('osdeps_mode', mode_name, true) + config.set('osdeps_mode', mode_name, true) return mode end # Invalid configuration values. Retry - Autoproj.reset_option('osdeps_mode') + config.reset('osdeps_mode') ENV['AUTOPROJ_OSDEPS_MODE'] = nil end end # The set of packages that have already been installed @@ -2435,11 +2514,12 @@ # @return [Array<PackageManagers::Manager>] the set of enabled package # managers def setup_package_handlers(options = Hash.new) options = if Kernel.respond_to?(:validate_options) - Kernel.validate_options options, :osdeps_mode => osdeps_mode + Kernel.validate_options options, + osdeps_mode: osdeps_mode else options = options.dup options[:osdeps_mode] ||= osdeps_mode options end @@ -2478,11 +2558,11 @@ # (i.e. gems) are restored to pristine condition # # This is usually called as a rebuild step to make sure that all these # packages are updated to whatever required the rebuild def pristine(packages, options = Hash.new) - setup_package_handlers(options) + install(packages, options.merge(install_only: true)) packages = resolve_os_dependencies(packages) _, other_packages = packages.partition { |handler, list| handler == os_package_handler } other_packages.each do |handler, list| @@ -2496,16 +2576,20 @@ def install(packages, options = Hash.new) # Remove the set of packages that have already been installed packages = packages.to_set - installed_packages return false if packages.empty? + filter_options, options = + filter_options options, install_only: !Autobuild.do_update setup_package_handlers(options) packages = resolve_os_dependencies(packages) + + needs_filter = (filter_uptodate_packages? || filter_options[:install_only]) packages = packages.map do |handler, list| - if filter_uptodate_packages? && handler.respond_to?(:filter_uptodate_packages) - list = handler.filter_uptodate_packages(list) + if needs_filter && handler.respond_to?(:filter_uptodate_packages) + list = handler.filter_uptodate_packages(list, filter_options) end if !list.empty? [handler, list] end @@ -2521,10 +2605,21 @@ @installed_packages |= list.to_set end end true end + + def reinstall(options = Hash.new) + # We also reinstall the osdeps that provide the + # functionality + managers = setup_package_handlers(options) + managers.each do |mng| + if mng.enabled? && mng.respond_to?(:reinstall) + mng.reinstall + end + end + end end end module Autobuild @@ -2593,72 +2688,10 @@ @programs_in_path = Hash.new end module Autoproj - # @deprecated use config.override instead - def self.override_option(option_name, value) - config.override(option_name, value) - end - # @deprecated use config.reset instead - def self.reset_option(key) - config.reset(key) - end - # @deprecated use config.set(key, value, user_validated) instead - def self.change_option(key, value, user_validated = false) - config.set(key, value, user_validated) - end - # @deprecated use config.validated_values instead - def self.option_set - config.validated_values - end - # @deprecated use config.get(key) instead - def self.user_config(key) - config.get(key) - end - # @deprecated use config.declare(name, type, options, &validator) instead - def self.configuration_option(name, type, options, &validator) - config.declare(name, type, options, &validator) - end - # @deprecated use config.declared?(name, type, options, &validator) instead - def self.declared_option?(name) - config.declared?(name) - end - # @deprecated use config.configure(option_name) instead - def self.configure(option_name) - config.configure(option_name) - end - # @deprecated use config.has_value_for?(name) - def self.has_config_key?(name) - config.has_value_for?(name) - end - - def self.save_config - config.save(File.join(Autoproj.config_dir, "config.yml")) - end - - def self.config - @config ||= Configuration.new - end - - def self.load_config - config_file = File.join(Autoproj.config_dir, "config.yml") - if File.exists?(config_file) - config.load(config_file, reconfigure?) - end - end - - class << self - attr_accessor :reconfigure - end - def self.reconfigure?; @reconfigure end -end - - -module Autoproj - class UserError < RuntimeError; end - # OS-independent creation of symbolic links. Note that on windows, it only # works for directories def self.create_symlink(from, to) if Autobuild.windows? Dir.create_junction(to, from) @@ -2678,10 +2711,13 @@ # Forcefully sets the root directory # # This is mostly useful during bootstrapping (i.e. when the search would # fail) def self.root_dir=(dir) + if @workspace && dir != @workspace.root_dir + raise WorkspaceAlreadyCreated, "cannot switch global root directory after a workspace object got created" + end @root_dir = dir end # Returns the root directory of the current autoproj installation. # @@ -2689,195 +2725,95 @@ # raises UserError. def self.root_dir(dir = Dir.pwd) if @root_dir return @root_dir end - - path = Pathname.pwd - while !path.root? - if (path + "autoproj" + 'manifest').file? - break - end - path = path.parent - end - - if path.root? + path = Workspace.find_root_dir(dir) + if !path raise UserError, "not in a Autoproj installation" end - - result = path.to_s - # I don't know if this is still useful or not ... but it does not hurt - # - # Preventing backslashed in path, that might be confusing on some path compares - if Autobuild.windows? - result = result.gsub(/\\/,'/') - end - result + path end - # Returns the configuration directory for this autoproj installation. - # - # If the current directory is not in an autoproj installation, - # raises UserError. + # @deprecated use workspace.config_dir instead def self.config_dir - File.join(root_dir, "autoproj") + Autoproj.warn "#{__method__} is deprecated, use workspace.config_dir instead" + caller.each { |l| Autoproj.warn " #{l}" } + workspace.config_dir end - - OVERRIDES_DIR = "overrides.d" - - # Returns the directory containing overrides files - # - # If the current directory is not in an autoproj installation, - # raises UserError. + # @deprecated use workspace.overrides_dir instead def self.overrides_dir - File.join(config_dir, OVERRIDES_DIR) + Autoproj.warn "#{__method__} is deprecated, use workspace.overrides_dir instead" + caller.each { |l| Autoproj.warn " #{l}" } + workspace.overrides_dir end - # @deprecated use Autobuild.find_in_path instead # # Warning: the autobuild method returns nil (instead of raising) if the # argument cannot be found def self.find_in_path(name) + Autoproj.warn "#{__method__} is deprecated, use Autobuild.find_in_path instead" + caller.each { |l| Autoproj.warn " #{l}" } if path = Autobuild.find_in_path(name) return path else raise ArgumentError, "cannot find #{name} in PATH (#{ENV['PATH']})" end end - - class << self - # The directory in which packages will be installed. - # - # If it is a relative path, it is relative to the root dir of the - # installation. - # - # The default is "install" - attr_reader :prefix - - # Change the value of 'prefix' - def prefix=(new_path) - @prefix = new_path - Autoproj.change_option('prefix', new_path, true) - end + # @deprecated use workspace.prefix_dir instead + def self.prefix + Autoproj.warn_deprecated(__method__, 'workspace.prefix_dir') + workspace.prefix_dir end - @prefix = "install" - - # Returns the build directory (prefix) for this autoproj installation. - # - # If the current directory is not in an autoproj installation, raises - # UserError. + # @deprecated use workspace.prefix_dir= instead + def self.prefix=(path) + Autoproj.warn_deprecated(__method__, 'workspace.prefix_dir=') + workspace.prefix_dir = path + end + # @deprecated use workspace.prefix_dir instead def self.build_dir - File.expand_path(Autoproj.prefix, root_dir) + Autoproj.warn_deprecated(__method__, 'workspace.prefix_dir') + workspace.prefix_dir end - - # Returns the path to the provided configuration file. - # - # If the current directory is not in an autoproj installation, raises - # UserError. + # @deprecated compute the full path with File.join(config_dir, file) + # directly instead def self.config_file(file) + Autoproj.warn_deprecated(__method__, 'compute the full path with File.join(config_dir, ...) instead') File.join(config_dir, file) end + # @deprecated use workspace.remotes_dir instead + def self.remotes_dir + Autoproj.warn_deprecated(__method__, 'use workspace.remotes_dir instead') + workspace.remotes_dir + end + # @deprecated use workspace.load or add a separate Loader object to your class + def self.load(package_set, *path) + Autoproj.warn_deprecated( + __method__, + 'use workspace.load or add a separate Loader object to your class') + workspace.load(package_set, *path) + end + # @deprecated use workspace.load_if_present or add a separate Loader object to your class + def self.load_if_present(package_set, *path) + Autoproj.warn_deprecated( + __method__, + 'use workspace.load_if_present or add a separate Loader object to your class') + workspace.load_if_present(package_set, *path) + end # Run the provided command as user def self.run_as_user(*args) if !system(*args) raise "failed to run #{args.join(" ")}" end end - # Run the provided command as root, using sudo to gain root access def self.run_as_root(*args) if !system(Autobuild.tool_in_path('sudo'), *args) raise "failed to run #{args.join(" ")} as root" end end - # Return the directory in which remote package set definition should be - # checked out - def self.remotes_dir - File.join(root_dir, ".remotes") - end - - - def self.env_inherit(*names) - Autobuild.env_inherit(*names) - end - - # @deprecated use isolate_environment instead - def self.set_initial_env - isolate_environment - end - - # Initializes the environment variables to a "sane default" - # - # Use this in autoproj/init.rb to make sure that the environment will not - # get polluted during the build. - def self.isolate_environment - Autobuild.env_inherit = false - Autobuild.env_push_path 'PATH', "/usr/local/bin", "/usr/bin", "/bin" - end - - def self.prepare_environment - # Set up some important autobuild parameters - env_inherit 'PATH', 'PKG_CONFIG_PATH', 'RUBYLIB', \ - 'LD_LIBRARY_PATH', 'CMAKE_PREFIX_PATH', 'PYTHONPATH' - - env_set 'AUTOPROJ_CURRENT_ROOT', Autoproj.root_dir - env_set 'RUBYOPT', "-rubygems" - Autoproj::OSDependencies::PACKAGE_HANDLERS.each do |pkg_mng| - pkg_mng.initialize_environment - end - end - - class << self - attr_writer :shell_helpers - def shell_helpers?; !!@shell_helpers end - end - @shell_helpers = true - - # Create the env.sh script in +subdir+. In general, +subdir+ should be nil. - def self.export_env_sh(subdir = nil) - # Make sure that we have as much environment as possible - Autoproj::CmdLine.update_environment - - filename = if subdir - File.join(Autoproj.root_dir, subdir, ENV_FILENAME) - else - File.join(Autoproj.root_dir, ENV_FILENAME) - end - - shell_dir = File.expand_path(File.join("..", "..", "shell"), File.dirname(__FILE__)) - if Autoproj.shell_helpers? - Autoproj.message "sourcing autoproj shell helpers" - Autoproj.message "add \"Autoproj.shell_helpers = false\" in autoproj/init.rb to disable" - Autobuild.env_source_after(File.join(shell_dir, "autoproj_sh")) - end - - File.open(filename, "w") do |io| - if Autobuild.env_inherit - io.write <<-EOF - if test -n "$AUTOPROJ_CURRENT_ROOT" && test "$AUTOPROJ_CURRENT_ROOT" != "#{Autoproj.root_dir}"; then - echo "the env.sh from $AUTOPROJ_CURRENT_ROOT is already loaded. Start a new shell before sourcing this one" - return - fi - EOF - end - Autobuild.export_env_sh(io) - end - end - - # @deprecated use Ops.loader.load or add a proper Loader object to your - # class - def self.load(package_set, *path) - Ops.loader.load(package_set, *path) - end - - # @deprecated use Ops.loader.load_if_present or add a proper Loader object - # to your class - def self.load_if_present(package_set, *path) - Ops.loader.load_if_present(package_set, *path) - end - # Look into +dir+, searching for shared libraries. For each library, display # a warning message if this library has undefined symbols. def self.validate_solib_dependencies(dir, exclude_paths = []) Find.find(File.expand_path(dir)) do |name| next unless name =~ /\.so$/ @@ -2895,19 +2831,35 @@ DEFS = <<EODEFS --- none: ignore ruby19: + debian: + - ruby1.9.1 + - ruby1.9.1-dev + - rubygems1.9.1 + - rake + - rubygems-integration ubuntu: '12.04': - ruby1.9.1 - ruby1.9.1-dev - rubygems1.9.1 - ri1.9.1 - libopenssl-ruby1.9.1 - rake - default: ignore + default: + - ruby1.9.1 + - ruby1.9.1-dev + - rubygems1.9.1 + - ri1.9.1 + - libopenssl-ruby1.9.1 + - rake + - rubygems-integration + gentoo: + - dev-lang/ruby:1.9 + - rake fedora: '17': - ruby - rubygems macos-port: @@ -2938,49 +2890,25 @@ macos-brew: - gem: rake default: ignore ruby21: debian: - jessie: - - ruby2.1 - - ruby2.1-dev - - rake - - rubygems-integration + - ruby2.1 + - ruby2.1-dev + - rake + - rubygems-integration ubuntu: - 14.10,15.04,15.10: + '14.10': - ruby2.1 - ruby2.1-dev - rake - rubygems-integration default: ignore fedora: ruby-devel macos-brew: - gem: rake default: ignore -ruby22: - ubuntu: - '15.10': - - ruby2.2 - - ruby2.2-dev - - rake - - rubygems-integration - default: ignore - default: ignore -ruby23: - debian: - unstable: - - ruby2.3 - - ruby2.3-dev - - rake - - rubygems-integration - ubuntu: - '16.04': - - ruby2.3-dev - - rake - - rubygems-integration - default: ignore - default: ignore build-essential: debian,ubuntu: build-essential gentoo: ignore arch: base-devel fedora: @@ -2991,14 +2919,14 @@ opensuse: - "@devel_C_C++" - gcc-c++ default: clang autobuild: -- gem: autobuild~>1.9.0 +- gem: autobuild - osdep: readline autoproj: -- gem: autoproj~>1.13.0 +- gem: autoproj - osdep: readline readline: debian,ubuntu: libreadline-dev fedora: readline-devel opensuse: readline-devel @@ -3097,11 +3025,10 @@ arch: python2-pip opensuse: python-pip fedora: python-pip freebsd: pip sudo: - macos-brew: ignore default: sudo EODEFS # Override Autoproj.root_dir @@ -3149,10 +3076,28 @@ STDOUT.flush end end end +# While in here, we don't have utilrb +module Kernel + def filter_options(options, defaults) + options = options.dup + filtered = Hash.new + defaults.each do |k, v| + filtered[k] = + if options.has_key?(k) then options.delete(k) + else v + end + end + return filtered, options + end + def validate_options(options, defaults) + defaults.merge(options) + end +end + # Environment is clean, so just mark it as so unconditionally ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] = '1' gem_home = ENV['AUTOPROJ_GEM_HOME'] || File.join(Dir.pwd, '.gems') gem_path = ([gem_home] + Gem.default_path).join(":") @@ -3160,11 +3105,10 @@ 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 @@ -3179,9 +3123,10 @@ Autoproj::OSDependencies.load(ENV['AUTOPROJ_DEFAULT_OSDEPS']) else Autoproj::OSDependencies.new(YAML.load(DEFS)) end osdeps_management.silent = false +Autoproj::PackageManagers::GemManager.gem_home = gem_home 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'])