csd 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,18 +1,32 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rdoc'
1
+ # -*- encoding: UTF-8 -*-
2
+ begin
3
+ require 'rubygems'
4
+ rescue LoadError
5
+ puts 'RubyGems could not be found. Please install it first.'
6
+ end
4
7
 
5
8
  begin
9
+ require 'rake'
10
+ require 'rake/testtask'
11
+ require 'rake/rdoctask'
12
+ require 'rdoc'
6
13
  require 'jeweler'
7
- Jeweler::Tasks.new do |gemspec|
8
- gemspec.name = "csd"
9
- gemspec.summary = "Installation and compilation handler for software used in CSD projects."
10
- gemspec.description = "CSD stands for Communication Systems Design and is a project of the Telecommunication Systems Laboratory (TSLab) of the Royal Institute of Technology in Stockholm, Sweden. Within CSD many software tools are used to build up various networks and services. This gem is supposed to automate processes to handle the compilation and installation of these software tools. Technology Transfer Alliance (TTA) is the project team, which maintains this code."
11
- gemspec.email = "mtoday11@gmail.com"
12
- gemspec.homepage = "http://github.com/csd/csd"
13
- gemspec.authors = ["Technology Transfer Alliance Team"]
14
- gemspec.executables = ['tta', 'ai']
15
- gemspec.post_install_message = %q{
14
+ rescue LoadError
15
+ puts 'Some gem dependencies are missing. Please install them with:'
16
+ puts '[sudo] gem install rake rdoc shoulda redgreen autotest jeweler activesupport'
17
+ end
18
+
19
+ # This is where we specify the details of this gem. The csd.gemspec file will be generated *automatically* from these specifications.
20
+ #
21
+ Jeweler::Tasks.new do |gemspec|
22
+ gemspec.name = "csd"
23
+ gemspec.summary = "Installation and compilation handler for software used in CSD projects."
24
+ gemspec.description = "CSD stands for Communication Systems Design and is a project of the Telecommunication Systems Laboratory (TSLab) of the Royal Institute of Technology in Stockholm, Sweden. Within CSD many software tools are used to build up various networks and services. This gem is supposed to automate processes to handle the compilation and installation of these software tools. Technology Transfer Alliance (TTA) is the project team, which maintains this code."
25
+ gemspec.email = "mtoday11@gmail.com"
26
+ gemspec.homepage = "http://github.com/csd/csd"
27
+ gemspec.authors = ["Technology Transfer Alliance Team"]
28
+ gemspec.executables = ['ai']
29
+ gemspec.post_install_message = %q{
16
30
  ============================================================
17
31
 
18
32
  Thank you for installing the TTA Automated Installer!
@@ -22,51 +36,45 @@ begin
22
36
  NOTE: On DEBIAN and UBUNTU the executable `tta´ is *maybe*
23
37
  not in your PATH by default. If that is the case,
24
38
  you can fix it by running this command:
25
-
39
+
26
40
  echo "export PATH=\$PATH:$(gem env | grep "E D" | sed "s/[^\w]* //")" >> ~/.bashrc;. ~/.bashrc
27
-
41
+
28
42
  ============================================================
29
43
  }
30
- end
31
- rescue LoadError
32
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
33
44
  end
34
45
 
35
- require 'rake/testtask'
36
- Rake::TestTask.new(:test) do |test|
37
- test.libs << 'lib' << 'test'
38
- test.test_files = FileList['test/functional/**/test*.rb', 'test/unit/**/test_*.rb']
46
+ # Here we define the default task when no task was specified by the user
47
+ task :default => :test
48
+
49
+ # Checks for dependencies and runs all test. Note that it requires you to be online
50
+ task :test => :check_dependencies
51
+ Rake::TestTask.new :test do |t|
52
+ t.libs << 'lib' << 'test'
53
+ t.pattern = 'test/**/test_*.rb'
54
+ #t.verbose = true
39
55
  end
40
56
 
41
- Rake::TestTask.new('test:all') do |test|
42
- test.libs << 'lib' << 'test'
43
- test.pattern = 'test/**/test_*.rb'
44
- test.verbose = true
57
+ # Generates the source code documentation
58
+ Rake::RDocTask.new do |r|
59
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
60
+ r.rdoc_dir = 'rdoc'
61
+ r.title = "csd #{version}"
62
+ r.rdoc_files.include('README*')
63
+ r.rdoc_files.include('lib/csd.rb')
64
+ r.rdoc_files.include('lib/csd/**/*.rb')
45
65
  end
46
66
 
67
+ # Analyzes the code test coverage ratio
47
68
  begin
48
69
  require 'rcov/rcovtask'
49
- Rcov::RcovTask.new do |test|
50
- test.libs << 'test'
51
- test.pattern = 'test/**/test_*.rb'
52
- test.verbose = true
70
+ Rcov::RcovTask.new do |t|
71
+ t.rcov_opts = ['--sort', 'coverage', '--text-report', '--exclude', "features,kernel,load-diff-lcs\.rb,instance_exec\.rb,lib/spec.rb,lib/spec/runner.rb,^spec/*,bin/spec,examples,/gems,/Library/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
72
+ t.libs << 'test'
73
+ t.pattern = 'test/**/test_*.rb'
74
+ #t.verbose = true
53
75
  end
54
76
  rescue LoadError
55
77
  task :rcov do
56
78
  abort "RCov is not available. In order to run rcov, you must: sudo gem install rcov"
57
79
  end
58
80
  end
59
-
60
- task :test => :check_dependencies
61
-
62
- task :default => :test
63
-
64
- require 'rake/rdoctask'
65
- Rake::RDocTask.new do |rdoc|
66
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
67
- rdoc.rdoc_dir = 'rdoc'
68
- rdoc.title = "csd #{version}"
69
- rdoc.rdoc_files.include('README*')
70
- rdoc.rdoc_files.include('lib/csd.rb')
71
- rdoc.rdoc_files.include('lib/csd/**/*.rb')
72
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
data/bin/ai CHANGED
@@ -1,22 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # NOTE: If you would like to execute this file as a developer
4
+ # but not install the CSD gem, you can use this command:
5
+ # ruby -I path/to/csd/lib path/to/csd/bin/tta
3
6
 
4
-
5
- # This executable is DEPRECATED
6
- # Please use 'tta' instead.
7
-
8
- puts
9
- puts "`ai´ is DEPRECATED. Please use `tta´ instead."
10
-
7
+ # First, let's load the RubyGems framework and the CSD gem.
8
+ # Even though RubyGems is already loaded for Ruby >= 1.9,
9
+ # we want to go sure here and load it to provide robustness
11
10
  require 'rubygems'
12
11
  require 'csd'
13
12
 
14
13
  begin
14
+ # Running the CSD library and telling it who started it
15
15
  CSD.bootstrap :executable => 'ai'
16
16
  rescue CSD::Error::CSDError => e
17
+ # Here we catch CSD internal errors and exit with the propriate status code
18
+ # We output the error message only for status codes 50 and higher, because they are rather severe
17
19
  CSD.ui.error e.message unless e.status_code <= 49
18
20
  exit e.status_code
19
21
  rescue Interrupt
22
+ # Lastly, close the AI gracefully on abnormal termination
20
23
  CSD.ui.separator
21
24
  CSD.ui.info "Quitting the AI...".red
22
25
  exit
data/csd.gemspec CHANGED
@@ -5,14 +5,15 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{csd}
8
- s.version = "0.1.8"
8
+ s.version = "0.1.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Technology Transfer Alliance Team"]
12
- s.date = %q{2010-07-28}
12
+ s.date = %q{2010-07-29}
13
+ s.default_executable = %q{ai}
13
14
  s.description = %q{CSD stands for Communication Systems Design and is a project of the Telecommunication Systems Laboratory (TSLab) of the Royal Institute of Technology in Stockholm, Sweden. Within CSD many software tools are used to build up various networks and services. This gem is supposed to automate processes to handle the compilation and installation of these software tools. Technology Transfer Alliance (TTA) is the project team, which maintains this code.}
14
15
  s.email = %q{mtoday11@gmail.com}
15
- s.executables = ["tta", "ai"]
16
+ s.executables = ["ai"]
16
17
  s.extra_rdoc_files = [
17
18
  "README.rdoc"
18
19
  ]
@@ -24,7 +25,6 @@ Gem::Specification.new do |s|
24
25
  "Rakefile",
25
26
  "VERSION",
26
27
  "bin/ai",
27
- "bin/tta",
28
28
  "csd.gemspec",
29
29
  "lib/csd.rb",
30
30
  "lib/csd/application.rb",
@@ -50,7 +50,9 @@ Gem::Specification.new do |s|
50
50
  "lib/csd/extensions.rb",
51
51
  "lib/csd/extensions/core/array.rb",
52
52
  "lib/csd/extensions/core/dir.rb",
53
+ "lib/csd/extensions/core/kernel.rb",
53
54
  "lib/csd/extensions/core/object.rb",
55
+ "lib/csd/extensions/core/open_struct.rb",
54
56
  "lib/csd/extensions/core/option_parser.rb",
55
57
  "lib/csd/extensions/core/pathname.rb",
56
58
  "lib/csd/extensions/core/string.rb",
@@ -60,18 +62,26 @@ Gem::Specification.new do |s|
60
62
  "lib/csd/user_interface.rb",
61
63
  "lib/csd/user_interface/base.rb",
62
64
  "lib/csd/user_interface/cli.rb",
65
+ "lib/csd/user_interface/silent.rb",
63
66
  "lib/csd/vendor/active_support/MIT-LICENSE",
64
67
  "lib/csd/vendor/active_support/inflector.rb",
68
+ "lib/csd/vendor/active_support/object_extensions.rb",
65
69
  "lib/csd/vendor/term/GPL2-LICENSE",
66
70
  "lib/csd/vendor/term/ansicolor.rb",
67
71
  "lib/csd/vendor/zentest/zentest_assertions.rb",
68
72
  "lib/csd/version.rb",
69
73
  "test/application/test_minisip.rb",
74
+ "test/functional/test_application_base.rb",
75
+ "test/functional/test_application_default.rb",
70
76
  "test/functional/test_applications.rb",
77
+ "test/functional/test_cli.rb",
71
78
  "test/functional/test_commands.rb",
79
+ "test/functional/test_csd.rb",
72
80
  "test/functional/test_options.rb",
73
81
  "test/helper.rb",
82
+ "test/unit/test_container.rb",
74
83
  "test/unit/test_dir.rb",
84
+ "test/unit/test_open_struct.rb",
75
85
  "test/unit/test_pathname.rb",
76
86
  "test/unit/test_string.rb"
77
87
  ]
@@ -86,9 +96,9 @@ Gem::Specification.new do |s|
86
96
  NOTE: On DEBIAN and UBUNTU the executable `tta´ is *maybe*
87
97
  not in your PATH by default. If that is the case,
88
98
  you can fix it by running this command:
89
-
99
+
90
100
  echo "export PATH=\$PATH:$(gem env | grep "E D" | sed "s/[^\w]* //")" >> ~/.bashrc;. ~/.bashrc
91
-
101
+
92
102
  ============================================================
93
103
  }
94
104
  s.rdoc_options = ["--charset=UTF-8"]
@@ -97,11 +107,17 @@ Gem::Specification.new do |s|
97
107
  s.summary = %q{Installation and compilation handler for software used in CSD projects.}
98
108
  s.test_files = [
99
109
  "test/application/test_minisip.rb",
110
+ "test/functional/test_application_base.rb",
111
+ "test/functional/test_application_default.rb",
100
112
  "test/functional/test_applications.rb",
113
+ "test/functional/test_cli.rb",
101
114
  "test/functional/test_commands.rb",
115
+ "test/functional/test_csd.rb",
102
116
  "test/functional/test_options.rb",
103
117
  "test/helper.rb",
118
+ "test/unit/test_container.rb",
104
119
  "test/unit/test_dir.rb",
120
+ "test/unit/test_open_struct.rb",
105
121
  "test/unit/test_pathname.rb",
106
122
  "test/unit/test_string.rb"
107
123
  ]
data/lib/csd.rb CHANGED
@@ -67,10 +67,7 @@ module CSD
67
67
  end
68
68
  UI.separator
69
69
  UI.info ' To execute a task: '.green.bold + "#{executable} [TASK] #{Applications.current.name}".cyan.bold + " Example: #{executable} compile minisip".dark
70
- #UI.info ' To execute a task: '.green.bold + "#{executable} [TASK] #{Applications.current.name}".cyan.bold
71
70
  UI.info ' For more details: '.green.bold + "#{executable} help [TASK] #{Applications.current.name}".cyan.bold + " Example: #{executable} help compile minisip".dark
72
- #UI.info ' For more details: '.green.bold + "#{executable} help [TASK] #{Applications.current.name}".cyan.bold
73
- #UI.info ' Example: '.green.bold + "#{executable} help install #{Applications.current.name}".cyan.bold
74
71
  UI.separator
75
72
  UI.warn "You did not specify a valid task name."
76
73
  raise Error::Argument::NoAction
@@ -11,6 +11,13 @@ module CSD
11
11
  #
12
12
  module Default
13
13
 
14
+ # This method must be overwritten by the actual application module. It holds the application instance
15
+ # which was chosen for this operating system.
16
+ #
17
+ def instance
18
+ raise Error::Application::NoInstanceMethod, "The application module must define an method called `instance´."
19
+ end
20
+
14
21
  def name
15
22
  self.to_s.demodulize.underscorize
16
23
  end
@@ -5,11 +5,34 @@ module CSD
5
5
  # This namespace holds all individual application Modules
6
6
  #
7
7
  module Application
8
-
9
8
  # This is the root class of all Applications
10
9
  #
11
10
  class Base
12
11
 
12
+ def initialize
13
+ define_working_directory
14
+ end
15
+
16
+ # This method chooses the working directory, which will contain downloads needed for various tasks, etc.
17
+ # Note that this directory is *not* removed by the AI in any case. The user has to make sure she knows the
18
+ # location of it (especially if it is a temporary directory which is physically created right here).
19
+ #
20
+ def define_working_directory
21
+ if Options.work_dir
22
+ # The user specified the working directory manually
23
+ path = Options.work_dir
24
+ elsif Options.temp
25
+ # The user specified the working directory to be a system's temporary directory
26
+ # Note that only with this option, the directory is actually created at this point
27
+ path = Dir.mktmpdir
28
+ else
29
+ # Other than that, we create a subdirectory in the current directory and use that
30
+ app_name = Applications.current ? Applications.current.name : 'application'
31
+ path = File.join(Dir.pwd, "#{app_name}.ai")
32
+ end
33
+ Path.work = path.pathnamify.expand_path
34
+ end
35
+
13
36
  end
14
37
  end
15
38
  end
@@ -41,22 +41,28 @@ module CSD
41
41
  @instance ||= case Gem::Platform.local.os
42
42
 
43
43
  when 'darwin'
44
+ # Mac OS X
45
+ UI.debug "Mac OS X identified"
44
46
  Darwin.new
45
-
47
+
46
48
  when 'linux'
49
+ # Linux
47
50
  UI.debug "Analyzing Linux kernel release: #{Gem::Platform.local.kernel_release}"
48
51
  case Gem::Platform.local.kernel_release
49
52
 
50
53
  when '2.6.32-21-generic', '2.6.32-22-generic'
54
+ # Ubuntu 10.04
51
55
  UI.debug "Ubuntu 10.04 identified"
52
56
  Ubuntu10.new
53
-
57
+
54
58
  else
59
+ # Any other Linux (currently only Debian is supported)
55
60
  UI.debug "Debian identified"
56
61
  Debian.new
57
62
  end
58
63
 
59
64
  else
65
+ # Microsoft Windows, Java, Solaris, etc...
60
66
  UI.debug "This Operating System is not supported."
61
67
  Base.new
62
68
  end
@@ -6,8 +6,18 @@ module CSD
6
6
  module Minisip
7
7
  class Base < CSD::Application::Base
8
8
 
9
+ # This is an +Array+ containing the names of the internal MiniSIP libraries. Note that they
10
+ # are sorted according to the sequence in which they need to be compiled.
11
+ #
9
12
  LIBRARIES = %w{ libmutil libmnetutil libmcrypto libmikey libmsip libmstun libminisip minisip }
10
13
 
14
+ # Tasks to be done before the introduction is evoked.
15
+ #
16
+ def initialize
17
+ super
18
+ define_relative_paths
19
+ end
20
+
11
21
  # MAIN APPLICATION OPERATIONS
12
22
 
13
23
  def compile
@@ -21,8 +31,6 @@ module CSD
21
31
  # GENERAL USER INFORMATION
22
32
 
23
33
  def introduction
24
- define_root_path
25
- define_paths
26
34
  UI.separator
27
35
  UI.info " Working directory: ".green + Path.work.to_s.yellow
28
36
  UI.info " Your Platform: ".green + Gem::Platform.local.humanize.to_s.yellow
@@ -30,6 +38,8 @@ module CSD
30
38
  UI.separator
31
39
  if Options.help
32
40
  UI.info Options.helptext
41
+ # Cleanup in case the working directory was temporary and is empty
42
+ Path.work.rmdir if Options.temp and Path.work.directory? and Path.work.children.empty?
33
43
  exit
34
44
  else
35
45
  raise Interrupt unless (Options.yes or Options.reveal or UI.ask_yes_no("Continue?".red.bold, true))
@@ -101,7 +111,7 @@ module CSD
101
111
  end
102
112
 
103
113
  def libminisip_cpp_flags
104
- if Options.ffmpeg_first?
114
+ if Options.ffmpeg_first
105
115
  %{CPPFLAGS="-I#{Path.hdviper_x264} -I#{Path.hdviper_x264_test_x264api} -I#{Path.ffmpeg_libavutil} -I#{Path.ffmpeg_libavcodec} -I#{Path.ffmpeg_libswscale} -I#{Path.repository_grabber} -I#{Path.repository_decklinksdk}"}
106
116
  else
107
117
  %{CPPFLAGS="-I#{Path.hdviper_x264} -I#{Path.hdviper_x264_test_x264api} -I#{Path.repository_grabber} -I#{Path.repository_decklinksdk}"}
@@ -112,22 +122,15 @@ module CSD
112
122
  %{LDFLAGS="#{Path.hdviper_libx264api} #{Path.hdviper_libtidx264} -lpthread -lrt"}
113
123
  end
114
124
 
115
- # DEFINING PATHS ETC...
116
-
117
- def define_root_path
118
- if Options.path
119
- if File.directory?(Options.path)
120
- Path.root = File.expand_path(Options.path)
121
- else
122
- raise Error::Options::PathNotFound, "The path `#{Options.path}´ doesn't exist."
123
- end
124
- else
125
- Path.root = Options.temp ? Dir.mktmpdir : Dir.pwd
126
- end
127
- end
128
-
129
- def define_paths
130
- Path.work = Pathname.new(File.join(Path.root, 'minisip.ai'))
125
+ def define_relative_paths
126
+ Path.build = Pathname.new(File.join(Path.work, 'build'))
127
+ Path.build_bin = Pathname.new(File.join(Path.build, 'bin'))
128
+ Path.build_gtkgui = Pathname.new(File.join(Path.build_bin, 'minisip_gtkgui'))
129
+ Path.build_include = Pathname.new(File.join(Path.build, 'include'))
130
+ Path.build_lib = Pathname.new(File.join(Path.build, 'lib'))
131
+ Path.build_lib_pkg_config = Pathname.new(File.join(Path.build_lib, 'pkgconfig'))
132
+ Path.build_share = Pathname.new(File.join(Path.build, 'share'))
133
+ Path.build_share_aclocal = Pathname.new(File.join(Path.build_share, 'aclocal'))
131
134
  Path.giomm_header = Pathname.new(File.join('/', 'usr', 'include', 'giomm-2.4', 'giomm.h'))
132
135
  Path.giomm_header_backup = Pathname.new(File.join('/', 'usr', 'include', 'giomm-2.4', 'giomm.h.ai-backup'))
133
136
  Path.repository = Pathname.new(File.join(Path.work, 'repository'))
@@ -151,14 +154,6 @@ module CSD
151
154
  Path.hdviper_libtidx264 = Pathname.new(File.join(Path.hdviper_x264, 'libtidx264.a'))
152
155
  Path.hdviper_x264_test_x264api = Pathname.new(File.join(Path.hdviper_x264, 'test', 'x264API'))
153
156
  Path.hdviper_libx264api = Pathname.new(File.join(Path.hdviper_x264_test_x264api, 'libx264api.a'))
154
- Path.build = Pathname.new(File.join(Path.work, 'build'))
155
- Path.build_bin = Pathname.new(File.join(Path.build, 'bin'))
156
- Path.build_gtkgui = Pathname.new(File.join(Path.build_bin, 'minisip_gtkgui'))
157
- Path.build_include = Pathname.new(File.join(Path.build, 'include'))
158
- Path.build_lib = Pathname.new(File.join(Path.build, 'lib'))
159
- Path.build_lib_pkg_config = Pathname.new(File.join(Path.build_lib, 'pkgconfig'))
160
- Path.build_share = Pathname.new(File.join(Path.build, 'share'))
161
- Path.build_share_aclocal = Pathname.new(File.join(Path.build_share, 'aclocal'))
162
157
  Path.plugins = Pathname.new(File.join(Path.work, 'plugins'))
163
158
  Path.plugins_destination = Pathname.new(File.join(Path.build_lib, 'libminisip', 'plugins'))
164
159
  end
@@ -1 +1,13 @@
1
- # -*- encoding: UTF-8 -*-
1
+ # -*- encoding: UTF-8 -*-
2
+
3
+ opts.headline 'WORKING DIRECTORY OPTIONS'.green.bold
4
+
5
+ self.temp = false
6
+ opts.on("-t", "--temp", "Use a system's temporary directory as working directory.") do |value|
7
+ self.temp = value
8
+ end
9
+
10
+ self.work_dir = nil
11
+ opts.on("--work-dir [PATH]", "Defines and/or creates the working directory. This will override the --temp option.") do |value|
12
+ self.work_dir = value
13
+ end