autoproj 1.8.5 → 1.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,12 +29,17 @@ module Autoproj
29
29
  # Dummy package manager used for unknown OSes. It simply displays a
30
30
  # message to the user when packages are needed
31
31
  class UnknownOSManager < Manager
32
+ def initialize
33
+ super(['unknown'])
34
+ @installed_osdeps = Set.new
35
+ end
36
+
32
37
  def osdeps_interaction_unknown_os(osdeps)
33
38
  puts <<-EOMSG
34
- #{Autoproj.color("The build process requires some other software packages to be installed on our operating system", :bold)}
35
- #{Autoproj.color("If they are already installed, simply ignore this message", :red)}
39
+ #{Autoproj.color("The build process requires some other software packages to be installed on our operating system", :bold)}
40
+ #{Autoproj.color("If they are already installed, simply ignore this message", :red)}
36
41
 
37
- #{osdeps.join("\n ")}
42
+ #{osdeps.to_a.sort.join("\n ")}
38
43
 
39
44
  EOMSG
40
45
  print Autoproj.color("Press ENTER to continue", :bold)
@@ -44,12 +49,17 @@ module Autoproj
44
49
  nil
45
50
  end
46
51
 
47
-
48
52
  def install(osdeps)
49
53
  if silent?
50
54
  return false
51
55
  else
52
- return osdeps_interaction_unknown_os(osdeps)
56
+ osdeps = osdeps.to_set
57
+ osdeps -= @installed_osdeps
58
+ if !osdeps.empty?
59
+ result = osdeps_interaction_unknown_os(osdeps)
60
+ end
61
+ @installed_osdeps |= osdeps
62
+ return result
53
63
  end
54
64
  end
55
65
  end
@@ -167,6 +177,16 @@ fi
167
177
  end
168
178
  end
169
179
 
180
+ # Package manager interface for systems that use port (i.e. MacPorts/Darwin) as
181
+ # their package manager
182
+ class PortManager < ShellScriptManager
183
+ def initialize
184
+ super(['port'], true,
185
+ "port '%s'",
186
+ "port '%s'")
187
+ end
188
+ end
189
+
170
190
  # Package manager interface for systems that use pacman (i.e. arch) as
171
191
  # their package manager
172
192
  class PacmanManager < ShellScriptManager
@@ -530,12 +550,14 @@ fi
530
550
  PackageManagers::GemManager,
531
551
  PackageManagers::EmergeManager,
532
552
  PackageManagers::PacmanManager,
533
- PackageManagers::YumManager]
553
+ PackageManagers::YumManager,
554
+ PackageManagers::PortManager]
534
555
  OS_PACKAGE_HANDLERS = {
535
556
  'debian' => 'apt-dpkg',
536
557
  'gentoo' => 'emerge',
537
558
  'arch' => 'pacman',
538
- 'fedora' => 'yum'
559
+ 'fedora' => 'yum',
560
+ 'darwin' => 'port'
539
561
  }
540
562
 
541
563
  # The information contained in the OSdeps files, as a hash
@@ -753,6 +775,11 @@ fi
753
775
  [['gentoo'], [version]]
754
776
  elsif File.exists?('/etc/arch-release')
755
777
  [['arch'], []]
778
+ elsif Autobuild.macos?
779
+ version=`sw_vers | head -2 | tail -1`.split(":")[1]
780
+ [['darwin'], [version.strip]]
781
+ elsif Autobuild.windows?
782
+ [['windows'], []]
756
783
  end
757
784
  end
758
785
 
@@ -774,8 +801,14 @@ fi
774
801
  end
775
802
 
776
803
  def self.os_from_lsb
777
- has_lsb_release = `which lsb_release`
778
- return unless $?.success?
804
+ has_lsb_release = nil
805
+ begin
806
+ has_lsb_release = `which lsb_release`
807
+ return unless $?.success?
808
+ rescue Exception => e
809
+ #seems which is not installes (e.g. on windows)
810
+ return
811
+ end
779
812
 
780
813
  distributor = `lsb_release -i -s`
781
814
  distributor = distributor.strip.downcase
@@ -841,6 +874,14 @@ fi
841
874
  end
842
875
  end
843
876
 
877
+ # Recursive resolutions
878
+ found, pkg = partition_osdep_entry(name, dep_def, ['osdep'], [], os_names, os_versions)
879
+ if found
880
+ pkg.each do |pkg_name|
881
+ result.concat(resolve_package(pkg_name))
882
+ end
883
+ end
884
+
844
885
  result.map do |handler, status, entries|
845
886
  if handler.respond_to?(:parse_package_entry)
846
887
  [handler, status, entries.map { |s| handler.parse_package_entry(s) }]
@@ -1009,19 +1050,24 @@ fi
1009
1050
  result = resolve_package(name)
1010
1051
  if !result
1011
1052
  raise MissingOSDep.new, "there is no osdeps definition for #{name}"
1012
- elsif result.empty?
1013
- os_names, os_versions = OSDependencies.operating_system
1014
- 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(", ")})"
1015
- else
1016
- result.each do |handler, status, packages|
1017
- if status == FOUND_NONEXISTENT
1018
- raise MissingOSDep.new, "there is an osdep definition for #{name}, and it explicitely states that this package does not exist on your OS"
1019
- end
1020
- if entry = all_packages.find { |h, _| h == handler }
1021
- entry[1].concat(packages)
1022
- else
1023
- all_packages << [handler, packages]
1024
- end
1053
+ end
1054
+
1055
+ if result.empty?
1056
+ if OSDependencies.supported_operating_system?
1057
+ os_names, os_versions = OSDependencies.operating_system
1058
+ 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(", ")})"
1059
+ end
1060
+ result = [[os_package_handler, FOUND_PACKAGES, [name]]]
1061
+ end
1062
+
1063
+ result.each do |handler, status, packages|
1064
+ if status == FOUND_NONEXISTENT
1065
+ raise MissingOSDep.new, "there is an osdep definition for #{name}, and it explicitely states that this package does not exist on your OS"
1066
+ end
1067
+ if entry = all_packages.find { |h, _| h == handler }
1068
+ entry[1].concat(packages)
1069
+ else
1070
+ all_packages << [handler, packages]
1025
1071
  end
1026
1072
  end
1027
1073
  end
@@ -1079,8 +1125,9 @@ fi
1079
1125
  if resolved.empty?
1080
1126
  if !OSDependencies.operating_system
1081
1127
  return UNKNOWN_OS
1082
- else
1083
- return WRONG_OS
1128
+ elsif !OSDependencies.supported_operating_system?
1129
+ return AVAILABLE
1130
+ else return WRONG_OS
1084
1131
  end
1085
1132
  end
1086
1133
 
@@ -1192,7 +1239,7 @@ So, what do you want ? (all, ruby, os or none)
1192
1239
  end
1193
1240
 
1194
1241
  def self.osdeps_mode_string_to_value(string)
1195
- string = string.downcase
1242
+ string = string.to_s.downcase
1196
1243
  case string
1197
1244
  when 'all' then HANDLE_ALL
1198
1245
  when 'ruby' then HANDLE_RUBY
@@ -1278,7 +1325,14 @@ So, what do you want ? (all, ruby, os or none)
1278
1325
 
1279
1326
  # Requests the installation of the given set of packages
1280
1327
  def install(packages, package_osdeps = Hash.new)
1328
+ #not sure here, simply show that it is installed even we dont install anything,
1329
+ #because this functions seems to called sometimes even --no-osdeps is given or the installs_os_packages? return false
1330
+ #it seems its not checked everywhere, so add this sainty check here
1331
+ return true if not installs_os_packages?
1332
+
1333
+
1281
1334
  os_package_handler.enabled = installs_os_packages?
1335
+ os_package_handler.silent = self.silent?
1282
1336
  package_handlers['gem'].enabled = installs_ruby_packages?
1283
1337
  package_handlers.each_value do |v|
1284
1338
  v.silent = self.silent?
@@ -1,6 +1,16 @@
1
1
  module Autoproj
2
2
  class UserError < RuntimeError; end
3
3
 
4
+ # OS-independent creation of symbolic links. Note that on windows, it only
5
+ # works for directories
6
+ def create_symlink(from, to)
7
+ if Autobuild.windows?
8
+ Dir.create_junction(to, from)
9
+ else
10
+ FileUtils.ln_sf from, to
11
+ end
12
+ end
13
+
4
14
  # Returns true if +path+ is part of an autoproj installation
5
15
  def self.in_autoproj_installation?(path)
6
16
  root_dir(File.expand_path(path))
@@ -18,12 +28,22 @@ module Autoproj
18
28
  return @root_dir
19
29
  end
20
30
 
21
- while dir != "/" && !File.directory?(File.join(dir, "autoproj"))
31
+ root_dir_rx =
32
+ if Autobuild.windows? then /^[a-zA-Z]:\\\\$/
33
+ else /^\/$/
34
+ end
35
+
36
+ while root_dir_rx !~ dir && !File.directory?(File.join(dir, "autoproj"))
22
37
  dir = File.dirname(dir)
23
38
  end
24
- if dir == "/"
39
+ if root_dir_rx =~ dir
25
40
  raise UserError, "not in a Autoproj installation"
26
41
  end
42
+
43
+ #Preventing backslashed in path, that might be confusing on some path compares
44
+ if Autobuild.windows?
45
+ dir = dir.gsub(/\\/,'/')
46
+ end
27
47
  dir
28
48
  end
29
49
 
@@ -93,12 +113,16 @@ module Autoproj
93
113
  ENV['AUTOPROJ_GEM_HOME'] || File.join(root_dir, ".gems")
94
114
  end
95
115
 
116
+ def self.env_inherit(*names)
117
+ Autobuild.env_inherit(*names)
118
+ end
119
+
96
120
  # Find the given program in PATH. It raises ArgumentError if the program
97
121
  # can't be found
98
122
  def self.find_in_path(name)
99
123
  result = ENV['PATH'].split(':').find { |dir| File.file?(File.join(dir, name)) }
100
124
  if !result
101
- raise ArgumentError, "#{name} can not be found in PATH"
125
+ raise ArgumentError, "#{name} can not be found in PATH (#{ENV['PATH']})"
102
126
  end
103
127
  File.join(result, name)
104
128
  end
@@ -108,13 +132,10 @@ module Autoproj
108
132
  # Use this in autoproj/init.rb to make sure that the environment will not
109
133
  # get polluted during the build.
110
134
  def self.set_initial_env
135
+ Autobuild.env_inherit = false
111
136
  Autoproj.env_set 'RUBYOPT', "-rubygems"
112
- Autoproj.env_set 'GEM_HOME', Autoproj.gem_home
113
- Autoproj.env_add_path 'GEM_PATH', Autoproj.gem_home
114
- Autoproj.env_set_path 'PATH', "#{Autoproj.gem_home}/bin", "/usr/local/bin", "/usr/bin", "/bin"
115
- Autoproj.env_set 'PKG_CONFIG_PATH'
116
- Autoproj.env_set 'RUBYLIB'
117
- Autoproj.env_set 'LD_LIBRARY_PATH'
137
+ Autobuild.env_push_path 'GEM_PATH', Autoproj.gem_home
138
+ Autobuild.env_push_path 'PATH', "#{Autoproj.gem_home}/bin", "/usr/local/bin", "/usr/bin", "/bin"
118
139
  end
119
140
 
120
141
  class << self
@@ -131,10 +152,10 @@ module Autoproj
131
152
  end
132
153
 
133
154
  filename = if subdir
134
- File.join(Autoproj.root_dir, subdir, "env.sh")
135
- else
136
- File.join(Autoproj.root_dir, "env.sh")
137
- end
155
+ File.join(Autoproj.root_dir, subdir, ENV_FILENAME)
156
+ else
157
+ File.join(Autoproj.root_dir, ENV_FILENAME)
158
+ end
138
159
 
139
160
  shell_dir = File.expand_path(File.join("..", "..", "shell"), File.dirname(__FILE__))
140
161
  if Autoproj.shell_helpers? && shell = ENV['SHELL']
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.8.5"
2
+ VERSION = "1.9.0.rc1"
3
3
  end
@@ -486,5 +486,29 @@ class TC_OSDependencies < Test::Unit::TestCase
486
486
  osdeps.osdeps_mode = 'all'
487
487
  osdeps.install(['pkg0', 'pkg1', 'pkg2'])
488
488
  end
489
+
490
+ def test_resolve_os_dependencies_unsupported_os_non_existent_dependency
491
+ osdeps = create_osdep(Hash.new)
492
+ flexmock(OSDependencies).should_receive(:supported_operating_system?).and_return(false)
493
+ assert_raises(OSDependencies::MissingOSDep) { osdeps.resolve_os_dependencies(['a_package']) }
494
+ end
495
+
496
+ def test_resolve_package_availability_unsupported_os_non_existent_dependency
497
+ osdeps = create_osdep(Hash.new)
498
+ flexmock(OSDependencies).should_receive(:supported_operating_system?).and_return(false)
499
+ assert_equal OSDependencies::NO_PACKAGE, osdeps.availability_of('a_package')
500
+ end
501
+
502
+ def test_resolve_package_availability_unsupported_os_existent_dependency
503
+ osdeps = create_osdep({ 'a_package' => { 'an_os' => 'bla' }})
504
+ flexmock(OSDependencies).should_receive(:supported_operating_system?).and_return(false)
505
+ assert_equal OSDependencies::AVAILABLE, osdeps.availability_of('a_package')
506
+ end
507
+
508
+ def test_resolve_os_dependencies_unsupported_os_existent_dependency
509
+ osdeps = create_osdep({ 'a_package' => { 'an_os' => 'bla' }})
510
+ flexmock(OSDependencies).should_receive(:supported_operating_system?).and_return(false)
511
+ assert_equal [[osdeps.os_package_handler, ['a_package']]], osdeps.resolve_os_dependencies(['a_package'])
512
+ end
489
513
  end
490
514
 
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.5
5
- prerelease:
4
+ version: 1.9.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rock Core Developers
@@ -13,7 +13,7 @@ date: 2012-11-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: autobuild
16
- requirement: &4950240 !ruby/object:Gem::Requirement
16
+ requirement: &18094640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.0.rc1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *4950240
24
+ version_requirements: *18094640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: utilrb
27
- requirement: &4949280 !ruby/object:Gem::Requirement
27
+ requirement: &18093700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *4949280
35
+ version_requirements: *18093700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: highline
38
- requirement: &4948160 !ruby/object:Gem::Requirement
38
+ requirement: &18092320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.5.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *4948160
46
+ version_requirements: *18092320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &4947120 !ruby/object:Gem::Requirement
49
+ requirement: &18091440 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.10'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *4947120
57
+ version_requirements: *18091440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &4946340 !ruby/object:Gem::Requirement
60
+ requirement: &18089940 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '3.3'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *4946340
68
+ version_requirements: *18089940
69
69
  description: autoproj is a manager for sets of software packages. It allows the user
70
70
  to import and build packages from source, still using the underlying distribution's
71
71
  native package manager for software that is available on it.
@@ -158,9 +158,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
158
  required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  none: false
160
160
  requirements:
161
- - - ! '>='
161
+ - - ! '>'
162
162
  - !ruby/object:Gem::Version
163
- version: '0'
163
+ version: 1.3.1
164
164
  requirements: []
165
165
  rubyforge_project: autobuild
166
166
  rubygems_version: 1.8.11