bin/autoproj_bootstrap in autoproj-1.8.5 vs bin/autoproj_bootstrap in autoproj-1.9.0.rc1

- old
+ new

@@ -126,31 +126,41 @@ end # Dummy package manager used for unknown OSes. It simply displays a # message to the user when packages are needed class UnknownOSManager < Manager + def initialize + super(['unknown']) + @installed_osdeps = Set.new + end + def osdeps_interaction_unknown_os(osdeps) puts <<-EOMSG - #{Autoproj.color("The build process requires some other software packages to be installed on our operating system", :bold)} - #{Autoproj.color("If they are already installed, simply ignore this message", :red)} + #{Autoproj.color("The build process requires some other software packages to be installed on our operating system", :bold)} + #{Autoproj.color("If they are already installed, simply ignore this message", :red)} - #{osdeps.join("\n ")} + #{osdeps.to_a.sort.join("\n ")} EOMSG print Autoproj.color("Press ENTER to continue", :bold) STDOUT.flush STDIN.readline puts nil end - def install(osdeps) if silent? return false else - return osdeps_interaction_unknown_os(osdeps) + osdeps = osdeps.to_set + osdeps -= @installed_osdeps + if !osdeps.empty? + result = osdeps_interaction_unknown_os(osdeps) + end + @installed_osdeps |= osdeps + return result end end end # Base class for all package managers that simply require the call of a @@ -264,10 +274,20 @@ end false end end + # Package manager interface for systems that use port (i.e. MacPorts/Darwin) as + # their package manager + class PortManager < ShellScriptManager + def initialize + super(['port'], true, + "port '%s'", + "port '%s'") + end + end + # Package manager interface for systems that use pacman (i.e. arch) as # their package manager class PacmanManager < ShellScriptManager def initialize super(['pacman'], true, @@ -627,16 +647,18 @@ PACKAGE_HANDLERS = [PackageManagers::AptDpkgManager, PackageManagers::GemManager, PackageManagers::EmergeManager, PackageManagers::PacmanManager, - PackageManagers::YumManager] + PackageManagers::YumManager, + PackageManagers::PortManager] OS_PACKAGE_HANDLERS = { 'debian' => 'apt-dpkg', 'gentoo' => 'emerge', 'arch' => 'pacman', - 'fedora' => 'yum' + 'fedora' => 'yum', + 'darwin' => 'port' } # The information contained in the OSdeps files, as a hash attr_reader :definitions # All the information contained in all the OSdeps files, as a mapping @@ -850,10 +872,15 @@ release_string =~ /^.*([^\s]+)$/ version = $1 [['gentoo'], [version]] elsif File.exists?('/etc/arch-release') [['arch'], []] + elsif Autobuild.macos? + version=`sw_vers | head -2 | tail -1`.split(":")[1] + [['darwin'], [version.strip]] + elsif Autobuild.windows? + [['windows'], []] end end if !@operating_system return @@ -871,12 +898,18 @@ Autoproj.change_option('operating_system', @operating_system, true) @operating_system end def self.os_from_lsb - has_lsb_release = `which lsb_release` - return unless $?.success? + has_lsb_release = nil + begin + has_lsb_release = `which lsb_release` + return unless $?.success? + rescue Exception => e + #seems which is not installes (e.g. on windows) + return + end distributor = `lsb_release -i -s` distributor = distributor.strip.downcase codename = `lsb_release -c -s`.strip.downcase version = `lsb_release -r -s`.strip.downcase @@ -938,10 +971,18 @@ if found result << [handler, found, pkg] end end + # Recursive resolutions + found, pkg = partition_osdep_entry(name, dep_def, ['osdep'], [], os_names, os_versions) + if found + pkg.each do |pkg_name| + result.concat(resolve_package(pkg_name)) + end + end + result.map do |handler, status, entries| if handler.respond_to?(:parse_package_entry) [handler, status, entries.map { |s| handler.parse_package_entry(s) }] else [handler, status, entries] @@ -1106,25 +1147,30 @@ all_packages = [] dependencies.each do |name| result = resolve_package(name) if !result raise MissingOSDep.new, "there is no osdeps definition for #{name}" - elsif result.empty? - os_names, os_versions = OSDependencies.operating_system - raise MissingOSDep.new, "there is an osdeps definition for #{name}, but not for this operating system and version (resp. #{os_names.join(", ")} and #{os_versions.join(", ")})" - else - result.each do |handler, status, packages| - if status == FOUND_NONEXISTENT - raise MissingOSDep.new, "there is an osdep definition for #{name}, and it explicitely states that this package does not exist on your OS" - end - if entry = all_packages.find { |h, _| h == handler } - entry[1].concat(packages) - else - all_packages << [handler, packages] - end + end + + if result.empty? + if OSDependencies.supported_operating_system? + os_names, os_versions = OSDependencies.operating_system + raise MissingOSDep.new, "there is an osdeps definition for #{name}, but not for this operating system and version (resp. #{os_names.join(", ")} and #{os_versions.join(", ")})" end + result = [[os_package_handler, FOUND_PACKAGES, [name]]] end + + result.each do |handler, status, packages| + if status == FOUND_NONEXISTENT + raise MissingOSDep.new, "there is an osdep definition for #{name}, and it explicitely states that this package does not exist on your OS" + end + if entry = all_packages.find { |h, _| h == handler } + entry[1].concat(packages) + else + all_packages << [handler, packages] + end + end end all_packages.delete_if do |handler, pkg| pkg.empty? end @@ -1176,12 +1222,13 @@ end if resolved.empty? if !OSDependencies.operating_system return UNKNOWN_OS - else - return WRONG_OS + elsif !OSDependencies.supported_operating_system? + return AVAILABLE + else return WRONG_OS end end resolved = resolved.delete_if { |_, status, list| status == FOUND_PACKAGES && list.empty? } failed = resolved.find_all do |handler, status, list| @@ -1289,11 +1336,11 @@ osdeps_mode_option_unsupported_os end end def self.osdeps_mode_string_to_value(string) - string = string.downcase + string = string.to_s.downcase case string when 'all' then HANDLE_ALL when 'ruby' then HANDLE_RUBY when 'os' then HANDLE_OS when 'none' then HANDLE_NONE @@ -1375,11 +1422,18 @@ end # Requests the installation of the given set of packages def install(packages, package_osdeps = Hash.new) + #not sure here, simply show that it is installed even we dont install anything, + #because this functions seems to called sometimes even --no-osdeps is given or the installs_os_packages? return false + #it seems its not checked everywhere, so add this sainty check here + return true if not installs_os_packages? + + os_package_handler.enabled = installs_os_packages? + os_package_handler.silent = self.silent? package_handlers['gem'].enabled = installs_ruby_packages? package_handlers.each_value do |v| v.silent = self.silent? end @@ -1611,10 +1665,20 @@ module Autoproj class UserError < RuntimeError; end + # OS-independent creation of symbolic links. Note that on windows, it only + # works for directories + def create_symlink(from, to) + if Autobuild.windows? + Dir.create_junction(to, from) + else + FileUtils.ln_sf from, to + end + end + # Returns true if +path+ is part of an autoproj installation def self.in_autoproj_installation?(path) root_dir(File.expand_path(path)) true rescue UserError @@ -1628,16 +1692,26 @@ def self.root_dir(dir = Dir.pwd) if @root_dir return @root_dir end - while dir != "/" && !File.directory?(File.join(dir, "autoproj")) + root_dir_rx = + if Autobuild.windows? then /^[a-zA-Z]:\\\\$/ + else /^\/$/ + end + + while root_dir_rx !~ dir && !File.directory?(File.join(dir, "autoproj")) dir = File.dirname(dir) end - if dir == "/" + if root_dir_rx =~ dir raise UserError, "not in a Autoproj installation" end + + #Preventing backslashed in path, that might be confusing on some path compares + if Autobuild.windows? + dir = dir.gsub(/\\/,'/') + end dir end # Returns the configuration directory for this autoproj installation. # @@ -1703,32 +1777,33 @@ # Return the directory in which RubyGems package should be installed def self.gem_home ENV['AUTOPROJ_GEM_HOME'] || File.join(root_dir, ".gems") end + def self.env_inherit(*names) + Autobuild.env_inherit(*names) + end + # Find the given program in PATH. It raises ArgumentError if the program # can't be found def self.find_in_path(name) result = ENV['PATH'].split(':').find { |dir| File.file?(File.join(dir, name)) } if !result - raise ArgumentError, "#{name} can not be found in PATH" + raise ArgumentError, "#{name} can not be found in PATH (#{ENV['PATH']})" end File.join(result, name) 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.set_initial_env + Autobuild.env_inherit = false Autoproj.env_set 'RUBYOPT', "-rubygems" - Autoproj.env_set 'GEM_HOME', Autoproj.gem_home - Autoproj.env_add_path 'GEM_PATH', Autoproj.gem_home - Autoproj.env_set_path 'PATH', "#{Autoproj.gem_home}/bin", "/usr/local/bin", "/usr/bin", "/bin" - Autoproj.env_set 'PKG_CONFIG_PATH' - Autoproj.env_set 'RUBYLIB' - Autoproj.env_set 'LD_LIBRARY_PATH' + Autobuild.env_push_path 'GEM_PATH', Autoproj.gem_home + Autobuild.env_push_path 'PATH', "#{Autoproj.gem_home}/bin", "/usr/local/bin", "/usr/bin", "/bin" end class << self attr_writer :shell_helpers def shell_helpers?; !!@shell_helpers end @@ -1741,14 +1816,14 @@ Autoproj.manifest.all_selected_packages.each do |pkg_name| Autobuild::Package[pkg_name].update_environment end filename = if subdir - File.join(Autoproj.root_dir, subdir, "env.sh") - else - File.join(Autoproj.root_dir, "env.sh") - end + 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? && shell = ENV['SHELL'] shell_kind = File.basename(shell) if shell_kind =~ /^\w+$/ @@ -1837,11 +1912,14 @@ - rake fedora: '15,16': - ruby - rubygems - default: nonexistent + darwin: + - ruby + - rb-rake + default: nonexistent ruby19: debian: - ruby1.9.1 - ruby1.9.1-dev - rubygems1.9.1 @@ -1862,36 +1940,43 @@ - rake fedora: '17': - ruby - rubygems - default: nonexistent + darwin: + - ruby19 + - rake + default: nonexistent build-essential: debian,ubuntu: build-essential gentoo: ignore arch: ignore fedora: ignore + darwin: ignore autobuild: gem autoproj: gem git: debian: lenny: git default: git-core ubuntu: git-core gentoo: dev-vcs/git arch: git fedora: git + darwin: git-core svn: debian,ubuntu: subversion gentoo: dev-util/subversion arch: subversion fedora: subversion + darwin: subversion cmake: debian,ubuntu: cmake gentoo: dev-util/cmake arch: cmake fedora: cmake + darwin: cmake autotools: debian,ubuntu: - automake1.9 - autoconf gentoo: @@ -1899,15 +1984,19 @@ - sys-devel/autoconf arch: automake autoconf fedora: - automake - autoconf + darwin: + - automake + - autoconf lsb_release: debian,ubuntu: lsb-release gentoo: sys-apps/lsb-release arch: ignore fedora: redhat-lsb + darwin: ignore archive: debian,ubuntu: - tar - unzip gentoo: @@ -1917,13 +2006,17 @@ - tar - unzip fedora: - tar - unzip + darwin: + - gnutar + - unzip cvs: debian,ubuntu: cvs fedora: cvs + darwin: cvs EODEFS Autoproj::OSDependencies.define_osdeps_mode_option osdeps_mode = Autoproj::OSDependencies.osdeps_mode @@ -1968,9 +2061,10 @@ end File.open('env.sh', 'w') do |io| io.write <<-EOSHELL export RUBYOPT=-rubygems +export GEM_PATH=#{needed_gem_home}:$GEM_PATH export GEM_HOME=#{needed_gem_home} export PATH=$GEM_HOME/bin:$PATH EOSHELL end