csd 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. data/.gitignore +1 -0
  2. data/COPYING +367 -0
  3. data/Rakefile +10 -10
  4. data/VERSION +1 -1
  5. data/bin/ai +19 -0
  6. data/csd.gemspec +257 -35
  7. data/lib/active_support.rb +75 -0
  8. data/lib/active_support/all.rb +3 -0
  9. data/lib/active_support/backtrace_cleaner.rb +94 -0
  10. data/lib/active_support/base64.rb +42 -0
  11. data/lib/active_support/basic_object.rb +21 -0
  12. data/lib/active_support/benchmarkable.rb +60 -0
  13. data/lib/active_support/buffered_logger.rb +132 -0
  14. data/lib/active_support/builder.rb +6 -0
  15. data/lib/active_support/cache.rb +626 -0
  16. data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -0
  17. data/lib/active_support/cache/file_store.rb +188 -0
  18. data/lib/active_support/cache/mem_cache_store.rb +191 -0
  19. data/lib/active_support/cache/memory_store.rb +159 -0
  20. data/lib/active_support/cache/strategy/local_cache.rb +164 -0
  21. data/lib/active_support/cache/synchronized_memory_store.rb +11 -0
  22. data/lib/active_support/callbacks.rb +600 -0
  23. data/lib/active_support/concern.rb +29 -0
  24. data/lib/active_support/configurable.rb +36 -0
  25. data/lib/active_support/core_ext.rb +3 -0
  26. data/lib/active_support/core_ext/array.rb +7 -0
  27. data/lib/active_support/core_ext/array/access.rb +46 -0
  28. data/lib/active_support/core_ext/array/conversions.rb +164 -0
  29. data/lib/active_support/core_ext/array/extract_options.rb +29 -0
  30. data/lib/active_support/core_ext/array/grouping.rb +100 -0
  31. data/lib/active_support/core_ext/array/random_access.rb +20 -0
  32. data/lib/active_support/core_ext/array/uniq_by.rb +17 -0
  33. data/lib/active_support/core_ext/array/wrap.rb +22 -0
  34. data/lib/active_support/core_ext/benchmark.rb +7 -0
  35. data/lib/active_support/core_ext/big_decimal.rb +1 -0
  36. data/lib/active_support/core_ext/big_decimal/conversions.rb +27 -0
  37. data/lib/active_support/core_ext/cgi.rb +1 -0
  38. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +19 -0
  39. data/lib/active_support/core_ext/class.rb +4 -0
  40. data/lib/active_support/core_ext/class/attribute.rb +67 -0
  41. data/lib/active_support/core_ext/class/attribute_accessors.rb +63 -0
  42. data/lib/active_support/core_ext/class/delegating_attributes.rb +44 -0
  43. data/lib/active_support/core_ext/class/inheritable_attributes.rb +232 -0
  44. data/lib/active_support/core_ext/class/subclasses.rb +55 -0
  45. data/lib/active_support/core_ext/date/acts_like.rb +8 -0
  46. data/lib/active_support/core_ext/date/calculations.rb +240 -0
  47. data/lib/active_support/core_ext/date/conversions.rb +99 -0
  48. data/lib/active_support/core_ext/date/freeze.rb +31 -0
  49. data/lib/active_support/core_ext/date_time/acts_like.rb +13 -0
  50. data/lib/active_support/core_ext/date_time/calculations.rb +113 -0
  51. data/lib/active_support/core_ext/date_time/conversions.rb +102 -0
  52. data/lib/active_support/core_ext/date_time/zones.rb +17 -0
  53. data/lib/active_support/core_ext/enumerable.rb +119 -0
  54. data/lib/active_support/core_ext/exception.rb +3 -0
  55. data/lib/active_support/core_ext/file.rb +2 -0
  56. data/lib/active_support/core_ext/file/atomic.rb +41 -0
  57. data/lib/active_support/core_ext/file/path.rb +5 -0
  58. data/lib/active_support/core_ext/float.rb +1 -0
  59. data/lib/active_support/core_ext/float/rounding.rb +19 -0
  60. data/lib/active_support/core_ext/hash.rb +8 -0
  61. data/lib/active_support/core_ext/hash/conversions.rb +150 -0
  62. data/lib/active_support/core_ext/hash/deep_merge.rb +16 -0
  63. data/lib/active_support/core_ext/hash/diff.rb +13 -0
  64. data/lib/active_support/core_ext/hash/except.rb +24 -0
  65. data/lib/active_support/core_ext/hash/indifferent_access.rb +14 -0
  66. data/lib/active_support/core_ext/hash/keys.rb +45 -0
  67. data/lib/active_support/core_ext/hash/reverse_merge.rb +28 -0
  68. data/lib/active_support/core_ext/hash/slice.rb +38 -0
  69. data/lib/active_support/core_ext/integer.rb +3 -0
  70. data/lib/active_support/core_ext/integer/inflections.rb +14 -0
  71. data/lib/active_support/core_ext/integer/multiple.rb +6 -0
  72. data/lib/active_support/core_ext/integer/time.rb +39 -0
  73. data/lib/active_support/core_ext/kernel.rb +5 -0
  74. data/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
  75. data/lib/active_support/core_ext/kernel/debugger.rb +16 -0
  76. data/lib/active_support/core_ext/kernel/reporting.rb +62 -0
  77. data/lib/active_support/core_ext/kernel/requires.rb +26 -0
  78. data/lib/active_support/core_ext/kernel/singleton_class.rb +13 -0
  79. data/lib/active_support/core_ext/load_error.rb +23 -0
  80. data/lib/active_support/core_ext/logger.rb +146 -0
  81. data/lib/active_support/core_ext/module.rb +12 -0
  82. data/lib/active_support/core_ext/module/aliasing.rb +70 -0
  83. data/lib/active_support/core_ext/module/anonymous.rb +24 -0
  84. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  85. data/lib/active_support/core_ext/module/attr_internal.rb +32 -0
  86. data/lib/active_support/core_ext/module/attribute_accessors.rb +66 -0
  87. data/lib/active_support/core_ext/module/delegation.rb +146 -0
  88. data/lib/active_support/core_ext/module/deprecation.rb +9 -0
  89. data/lib/active_support/core_ext/module/introspection.rb +88 -0
  90. data/lib/active_support/core_ext/module/method_names.rb +14 -0
  91. data/lib/active_support/core_ext/module/reachable.rb +10 -0
  92. data/lib/active_support/core_ext/module/remove_method.rb +6 -0
  93. data/lib/active_support/core_ext/module/synchronization.rb +42 -0
  94. data/lib/active_support/core_ext/name_error.rb +18 -0
  95. data/lib/active_support/core_ext/numeric.rb +2 -0
  96. data/lib/active_support/core_ext/numeric/bytes.rb +44 -0
  97. data/lib/active_support/core_ext/numeric/time.rb +77 -0
  98. data/lib/active_support/core_ext/object.rb +14 -0
  99. data/lib/active_support/core_ext/object/acts_like.rb +10 -0
  100. data/lib/active_support/core_ext/object/blank.rb +76 -0
  101. data/lib/active_support/core_ext/object/conversions.rb +4 -0
  102. data/lib/active_support/core_ext/object/duplicable.rb +65 -0
  103. data/lib/active_support/core_ext/object/extending.rb +11 -0
  104. data/lib/active_support/core_ext/object/instance_variables.rb +67 -0
  105. data/lib/active_support/core_ext/object/misc.rb +2 -0
  106. data/lib/active_support/core_ext/object/returning.rb +42 -0
  107. data/lib/active_support/core_ext/object/to_param.rb +49 -0
  108. data/lib/active_support/core_ext/object/to_query.rb +27 -0
  109. data/lib/active_support/core_ext/object/try.rb +36 -0
  110. data/lib/active_support/core_ext/object/with_options.rb +26 -0
  111. data/lib/active_support/core_ext/proc.rb +14 -0
  112. data/lib/active_support/core_ext/process.rb +1 -0
  113. data/lib/active_support/core_ext/process/daemon.rb +23 -0
  114. data/lib/active_support/core_ext/range.rb +4 -0
  115. data/lib/active_support/core_ext/range/blockless_step.rb +29 -0
  116. data/lib/active_support/core_ext/range/conversions.rb +21 -0
  117. data/lib/active_support/core_ext/range/include_range.rb +21 -0
  118. data/lib/active_support/core_ext/range/overlaps.rb +8 -0
  119. data/lib/active_support/core_ext/regexp.rb +5 -0
  120. data/lib/active_support/core_ext/rexml.rb +46 -0
  121. data/lib/active_support/core_ext/string.rb +12 -0
  122. data/lib/active_support/core_ext/string/access.rb +99 -0
  123. data/lib/active_support/core_ext/string/behavior.rb +7 -0
  124. data/lib/active_support/core_ext/string/conversions.rb +61 -0
  125. data/lib/active_support/core_ext/string/encoding.rb +11 -0
  126. data/lib/active_support/core_ext/string/exclude.rb +6 -0
  127. data/lib/active_support/core_ext/string/filters.rb +49 -0
  128. data/lib/active_support/core_ext/string/inflections.rb +149 -0
  129. data/lib/active_support/core_ext/string/interpolation.rb +2 -0
  130. data/lib/active_support/core_ext/string/multibyte.rb +72 -0
  131. data/lib/active_support/core_ext/string/output_safety.rb +109 -0
  132. data/lib/active_support/core_ext/string/starts_ends_with.rb +4 -0
  133. data/lib/active_support/core_ext/string/xchar.rb +18 -0
  134. data/lib/active_support/core_ext/time/acts_like.rb +8 -0
  135. data/lib/active_support/core_ext/time/calculations.rb +282 -0
  136. data/lib/active_support/core_ext/time/conversions.rb +85 -0
  137. data/lib/active_support/core_ext/time/marshal.rb +56 -0
  138. data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +10 -0
  139. data/lib/active_support/core_ext/time/zones.rb +78 -0
  140. data/lib/active_support/core_ext/uri.rb +22 -0
  141. data/lib/active_support/dependencies.rb +628 -0
  142. data/lib/active_support/dependencies/autoload.rb +50 -0
  143. data/lib/active_support/deprecation.rb +18 -0
  144. data/lib/active_support/deprecation/behaviors.rb +38 -0
  145. data/lib/active_support/deprecation/method_wrappers.rb +29 -0
  146. data/lib/active_support/deprecation/proxy_wrappers.rb +74 -0
  147. data/lib/active_support/deprecation/reporting.rb +56 -0
  148. data/lib/active_support/duration.rb +105 -0
  149. data/lib/active_support/gzip.rb +25 -0
  150. data/lib/active_support/hash_with_indifferent_access.rb +145 -0
  151. data/lib/active_support/i18n.rb +8 -0
  152. data/lib/active_support/inflections.rb +56 -0
  153. data/lib/active_support/inflector.rb +7 -0
  154. data/lib/active_support/inflector/inflections.rb +211 -0
  155. data/lib/active_support/inflector/methods.rb +141 -0
  156. data/lib/active_support/inflector/transliterate.rb +97 -0
  157. data/lib/active_support/json.rb +2 -0
  158. data/lib/active_support/json/backends/jsongem.rb +43 -0
  159. data/lib/active_support/json/backends/yajl.rb +40 -0
  160. data/lib/active_support/json/backends/yaml.rb +90 -0
  161. data/lib/active_support/json/decoding.rb +51 -0
  162. data/lib/active_support/json/encoding.rb +254 -0
  163. data/lib/active_support/json/variable.rb +11 -0
  164. data/lib/active_support/lazy_load_hooks.rb +27 -0
  165. data/lib/active_support/locale/en.yml +36 -0
  166. data/lib/active_support/memoizable.rb +103 -0
  167. data/lib/active_support/message_encryptor.rb +71 -0
  168. data/lib/active_support/message_verifier.rb +62 -0
  169. data/lib/active_support/multibyte.rb +44 -0
  170. data/lib/active_support/multibyte/chars.rb +480 -0
  171. data/lib/active_support/multibyte/exceptions.rb +8 -0
  172. data/lib/active_support/multibyte/unicode.rb +393 -0
  173. data/lib/active_support/multibyte/utils.rb +60 -0
  174. data/lib/active_support/notifications.rb +81 -0
  175. data/lib/active_support/notifications/fanout.rb +93 -0
  176. data/lib/active_support/notifications/instrumenter.rb +56 -0
  177. data/lib/active_support/option_merger.rb +25 -0
  178. data/lib/active_support/ordered_hash.rb +158 -0
  179. data/lib/active_support/ordered_options.rb +27 -0
  180. data/lib/active_support/railtie.rb +100 -0
  181. data/lib/active_support/rescuable.rb +114 -0
  182. data/lib/active_support/ruby/shim.rb +22 -0
  183. data/lib/active_support/secure_random.rb +199 -0
  184. data/lib/active_support/string_inquirer.rb +21 -0
  185. data/lib/active_support/test_case.rb +42 -0
  186. data/lib/active_support/testing/assertions.rb +82 -0
  187. data/lib/active_support/testing/declarative.rb +40 -0
  188. data/lib/active_support/testing/default.rb +9 -0
  189. data/lib/active_support/testing/deprecation.rb +55 -0
  190. data/lib/active_support/testing/isolation.rb +154 -0
  191. data/lib/active_support/testing/pending.rb +48 -0
  192. data/lib/active_support/testing/performance.rb +455 -0
  193. data/lib/active_support/testing/setup_and_teardown.rb +111 -0
  194. data/lib/active_support/time.rb +34 -0
  195. data/lib/active_support/time/autoload.rb +5 -0
  196. data/lib/active_support/time_with_zone.rb +341 -0
  197. data/lib/active_support/values/time_zone.rb +377 -0
  198. data/lib/active_support/values/unicode_tables.dat +0 -0
  199. data/lib/active_support/version.rb +10 -0
  200. data/lib/active_support/whiny_nil.rb +60 -0
  201. data/lib/active_support/xml_mini.rb +158 -0
  202. data/lib/active_support/xml_mini/jdom.rb +168 -0
  203. data/lib/active_support/xml_mini/libxml.rb +80 -0
  204. data/lib/active_support/xml_mini/libxmlsax.rb +85 -0
  205. data/lib/active_support/xml_mini/nokogiri.rb +78 -0
  206. data/lib/active_support/xml_mini/nokogirisax.rb +83 -0
  207. data/lib/active_support/xml_mini/rexml.rb +129 -0
  208. data/lib/csd.rb +82 -2
  209. data/lib/csd/application.rb +2 -0
  210. data/lib/csd/application/default.rb +51 -0
  211. data/lib/csd/application/default/base.rb +15 -0
  212. data/lib/csd/application/minisip.rb +25 -0
  213. data/lib/csd/application/minisip/about.yml +14 -0
  214. data/lib/csd/application/minisip/base.rb +161 -0
  215. data/lib/csd/application/minisip/error.rb +11 -0
  216. data/lib/csd/application/minisip/options/common.rb +0 -0
  217. data/lib/csd/application/minisip/options/compile.rb +59 -0
  218. data/lib/csd/{applications → application}/minisip/unix/base.rb +10 -11
  219. data/lib/csd/application/opensips/about.yml +2 -0
  220. data/lib/csd/applications.rb +55 -0
  221. data/lib/csd/commands.rb +88 -65
  222. data/lib/csd/error.rb +31 -0
  223. data/lib/csd/extensions.rb +1 -0
  224. data/lib/{extensions → csd/extensions}/core/array.rb +2 -2
  225. data/lib/csd/extensions/core/dir.rb +46 -0
  226. data/lib/{extensions → csd/extensions}/core/file.rb +2 -2
  227. data/lib/{extensions → csd/extensions}/core/object.rb +2 -2
  228. data/lib/csd/extensions/core/option_parser.rb +33 -0
  229. data/lib/{extensions → csd/extensions}/core/pathname.rb +12 -3
  230. data/lib/{extensions → csd/extensions}/core/string.rb +2 -2
  231. data/lib/{extensions → csd/extensions}/gem/platform.rb +6 -2
  232. data/lib/csd/global_open_struct.rb +18 -0
  233. data/lib/csd/options.rb +124 -95
  234. data/lib/csd/path.rb +31 -0
  235. data/lib/csd/ui.rb +1 -0
  236. data/lib/csd/ui/cli.rb +7 -0
  237. data/lib/csd/ui/ui.rb +46 -0
  238. data/lib/csd/version.rb +9 -0
  239. data/lib/term/ansicolor.rb +102 -0
  240. data/lib/term/ansicolor/.keep +0 -0
  241. data/lib/term/ansicolor/version.rb +10 -0
  242. data/test/functional/test_applications.rb +86 -0
  243. data/test/functional/test_commands.rb +42 -29
  244. data/test/functional/test_options.rb +98 -0
  245. data/test/helper.rb +14 -0
  246. data/test/unit/test_dir.rb +38 -0
  247. data/test/unit/test_pathname.rb +32 -0
  248. metadata +253 -40
  249. data/LICENSE +0 -20
  250. data/bin/csd +0 -8
  251. data/lib/csd/applications/base.rb +0 -33
  252. data/lib/csd/applications/minisip/base.rb +0 -125
  253. data/lib/csd/applications/minisip/init.rb +0 -20
  254. data/lib/csd/init.rb +0 -69
  255. data/lib/csd/path_container.rb +0 -15
  256. data/publish +0 -29
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), 'default')
2
+ Dir.glob(File.join(File.dirname(__FILE__), 'minisip', '*.rb')) { |file| require file }
3
+ Dir.glob(File.join(File.dirname(__FILE__), 'minisip', 'unix', '*.rb')) { |file| require file }
4
+ require 'ostruct'
5
+
6
+ module CSD
7
+ module Application
8
+ module Minisip
9
+ class << self
10
+
11
+ include CSD::Application::Default
12
+
13
+ def instance
14
+ @instance ||= case Gem::Platform.local.os
15
+ when 'linux'
16
+ Unix::Base.new
17
+ else
18
+ Base.new
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ human: MiniSIP
2
+ description: An open-source SIP client for high-definition video conferencing.
3
+ actions:
4
+ :public:
5
+ #- show: Shows further information about MiniSIP
6
+ - download: Downloads MiniSIP components (e.g. source code, configurations, docs,...)
7
+ #- install: Installs an application
8
+ #- check: Checks whether the environment dependencies for the application are satisfied
9
+ :developer:
10
+ - compile: Downloads and compiles MiniSIP from scratch
11
+ #- package: Packages a compiled application
12
+ #- publish: Submits a compiled package to the CSD package repository
13
+ scopes:
14
+ --- {}
@@ -0,0 +1,161 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'default', 'base')
2
+
3
+ module CSD
4
+ module Application
5
+ module Minisip
6
+ class Base < CSD::Application::Base
7
+
8
+ def compile!
9
+ define_root_path
10
+ define_paths
11
+ UI.separator
12
+ UI.info "This operation will download and compile MiniSIP.".green.bold
13
+ UI.separator
14
+ UI.info " Working directory: ".green + Path.work.to_s.yellow
15
+ UI.info " Your Platform: ".green + Gem::Platform.local.humanize.to_s.yellow
16
+ UI.info(" Application module: ".green + self.class.name.to_s.yellow) if Options.developer
17
+ UI.separator
18
+ if Options.help
19
+ UI.info Options.helptext
20
+ else
21
+ unless Options.yes
22
+ exit unless UI.ask_yes_no("Continue?".red.bold, true)
23
+ end
24
+ compile_process
25
+ end
26
+ UI.separator
27
+ end
28
+
29
+ def compile_process
30
+ unless Options.only_fix_giomm
31
+ before_compile
32
+ Cmd.mkdir Path.work
33
+ make_hdviper if checkout_hdviper or Options.dry
34
+ checkout_minisip
35
+ end
36
+ fix_ubuntu_10_04 if Gem::Platform.local.kernel_version == '#36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010' or Options.only_fix_giomm
37
+ unless Options.only_fix_giomm
38
+ make_minisip
39
+ after_compile
40
+ end
41
+ end
42
+
43
+ def define_root_path
44
+ if Options.path
45
+ if File.directory?(Options.path)
46
+ Path.root = File.expand_path(Options.path)
47
+ else
48
+ raise Error::Options::PathNotFound, "The path `#{Options.path}´ doesn't exist."
49
+ end
50
+ else
51
+ Path.root = Options.temp ? Dir.mktmpdir : Dir.pwd
52
+ end
53
+ end
54
+
55
+ def define_paths
56
+ Path.work = Pathname.new(File.join(Path.root, 'minisip'))
57
+ Path.repository = Pathname.new(File.join(Path.work, 'repository'))
58
+ Path.open_gl_display = Pathname.new(File.join(Path.repository, 'libminisip', 'source', 'subsystem_media', 'video', 'display', 'OpenGLDisplay.cxx'))
59
+ Path.hdviper = Pathname.new(File.join(Path.work, 'hdviper'))
60
+ Path.hdviper_x264 = Pathname.new(File.join(Path.hdviper, 'x264'))
61
+ Path.hdviper_x264_test_x264api = Pathname.new(File.join(Path.hdviper_x264, 'test', 'x264API'))
62
+ Path.build = Pathname.new(File.join(Path.work, 'build'))
63
+ Path.build_bin = Pathname.new(File.join(Path.build, 'bin'))
64
+ Path.build_include = Pathname.new(File.join(Path.build, 'include'))
65
+ Path.build_lib = Pathname.new(File.join(Path.build, 'lib'))
66
+ Path.build_lib_pkg_config = Pathname.new(File.join(Path.build_lib, 'pkgconfig'))
67
+ Path.build_share = Pathname.new(File.join(Path.build, 'share'))
68
+ Path.build_share_aclocal = Pathname.new(File.join(Path.build_share, 'aclocal'))
69
+ Path.giomm_header = Pathname.new(File.join('/', 'usr', 'bin', 'giomm', 'giomm.h'))
70
+ end
71
+
72
+ def checkout_hdviper
73
+ if Path.hdviper.directory?
74
+ UI.warn "Skipping hdviper, because the directory already exists: #{Path.hdviper}"
75
+ else
76
+ if Path.hdviper.parent.writable? or Options.dry
77
+ UI.info "Downloading hdviper to: #{Path.hdviper}".green.bold
78
+ Cmd.run("git clone http://github.com/csd/libraries.git #{Path.hdviper}", :die_on_failure => true)
79
+ #Cmd.run("svn co --quiet svn://hdviper.org/hdviper/wp3/src #{Path.hdviper}")
80
+ return true
81
+ else
82
+ UI.error "Could not download hdviper (no permission): #{Path.hdviper}"
83
+ end
84
+ end
85
+ end
86
+
87
+ def make_hdviper
88
+ Cmd.cd Path.hdviper_x264
89
+ Cmd.run('./configure')
90
+ Cmd.run('make')
91
+ Cmd.cd Path.hdviper_x264_test_x264api
92
+ Cmd.run('make')
93
+ end
94
+
95
+ def checkout_minisip # TODO: Refactor because redudancy with checkout_hdviper
96
+ if Path.repository.directory?
97
+ UI.warn "Skipping repository download, because the directory already exists: #{Path.repository}"
98
+ else
99
+ if Path.repository.parent.writable? or Options.dry
100
+ UI.info "Downloading minisip repository to: #{Path.repository}".green.bold
101
+ Cmd.run("git clone http://github.com/csd/minisip.git #{Path.repository}", :die_on_failure => true)
102
+ # Fixing hard-coded stuff
103
+ Cmd.replace(Path.open_gl_display, '/home/erik', Path.build)
104
+ else
105
+ UI.error "Could not download minisip repository (no permission): #{Path.hdviper}"
106
+ end
107
+ end
108
+ end
109
+
110
+ def fix_ubuntu_10_04
111
+ Path.new_giomm_header = File.join(Dir.mktmpdir, 'header.h')
112
+ Cmd.copy(Path.giomm_header, Path.new_giomm_header)
113
+ Cmd.replace(Path.new_giomm_header, '#include <giomm/socket.h>', "/* ----- AI COMMENTING OUT START ----- \n#include <giomm/socket.h>")
114
+ Cmd.replace(Path.new_giomm_header, '#include <giomm/srvtarget.h>', "#include <giomm/srvtarget.h>\n ----- AI COMMENTING OUT END ----- */")
115
+ Cmd.replace(Path.new_giomm_header, '#include <giomm/unixconnection.h>', "// #include <giomm/unixconnection.h> // COMMENTED OUT BY AI")
116
+ Cmd.run("sudo cp #{Path.giomm_header} #{Path.giomm_header}.backup")
117
+ Cmd.run("sudo cp #{Path.new_giomm_header} #{Path.giomm_header}")
118
+ end
119
+
120
+ def make_minisip
121
+ [Path.build, Path.build_include, Path.build_lib, Path.build_share, Path.build_share_aclocal].each { |target| Cmd.mkdir target }
122
+ ['libmutil', 'libmnetutil', 'libmcrypto', 'libmikey', 'libmsip', 'libmstun', 'libminisip', 'minisip'].each do |library|
123
+ directory = Pathname.new(File.join(Path.repository, library))
124
+ next if Options.only and !Options.only.include?(library)
125
+ if Cmd.cd(directory) or Options.dry
126
+ if Options.bootstrap
127
+ UI.info "Bootstrapping #{library}".green.bold
128
+ Cmd.run("./bootstrap -I #{Path.build_share_aclocal.enquote}", :die_on_failure => true)
129
+ end
130
+ if Options.configure
131
+ UI.info "Configuring #{library}".green.bold
132
+ individual_options = case library
133
+ when 'libminisip'
134
+ %Q{--enable-debug --enable-video --disable-mil --enable-decklink --enable-opengl --disable-sdl CPPFLAGS="-I#{Path.hdviper_x264_test_x264api} -I#{Path.hdviper_x264}" LDFLAGS="#{File.join(Path.hdviper_x264_test_x264api, 'libx264api.a')} #{File.join(Path.hdviper_x264, 'libtidx264.a')} -lpthread -lrt"}
135
+ #%Q{--enable-debug --enable-video --disable-mil --disable-decklink --enable-opengl --disable-sdl CPPFLAGS="-I#{Path.hdviper_x264}" LDFLAGS="#{File.join(Path.hdviper_x264, 'libx264.a')} -lpthread -lrt"}
136
+ when 'minisip'
137
+ %Q{--enable-debug --enable-video --enable-textui --enable-opengl}
138
+ else
139
+ ''
140
+ end
141
+ Cmd.run(%Q{./configure #{individual_options} --prefix=#{Path.build.enquote} PKG_CONFIG_PATH=#{Path.build_lib_pkg_config.enquote} ACLOCAL_FLAGS=#{Path.build_share_aclocal} LD_LIBRARY_PATH=#{Path.build_lib.enquote} --silent}, :die_on_failure => true)
142
+ end
143
+ if Options.make
144
+ UI.info "Make #{library}".green.bold
145
+ Cmd.run("make", :die_on_failure => true)
146
+ end
147
+ if Options.make_install
148
+ maker_command = Options.make_dist ? 'dist' : 'install'
149
+ UI.info "Make #{maker_command} #{library}".green.bold
150
+ Cmd.run("make #{maker_command}", :die_on_failure => true)
151
+ end
152
+ else
153
+ UI.warn "Skipping minisip library #{library} because it not be found: #{directory}".green.bold
154
+ end
155
+ end
156
+ end
157
+
158
+ end
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'error')
2
+
3
+ module CSD
4
+ module Error
5
+
6
+ module Options
7
+ class PathNotFound < CSDError; status_code(200); end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,59 @@
1
+ # This file gets eval'ed by the global options parser in lib/csd/rb
2
+ # TODO: There must be a nicer solution for this.
3
+
4
+ self.temp = false
5
+ opts.on("-t", "--temp",
6
+ "Use a subdirectory in the system's temporary directory",
7
+ "to download files and not the current directory") do |value|
8
+ self.temp = value
9
+ end
10
+
11
+ self.path = nil
12
+ opts.on("--path [PATH]",
13
+ "Defines the working directory manually.",
14
+ "(This will override the --temp option)") do |value|
15
+ self.path = value
16
+ end
17
+
18
+ #self.owner = nil
19
+ #opts.on("-o", "--owner [OWNER]","Specify OWNER:GROUP for this operation") do |value|
20
+ # if owner = value
21
+ # chmod = owner.split(':')
22
+ # self.owner = chmod.first
23
+ # self.group = chmod.last
24
+ # end
25
+ #end
26
+
27
+ self.apt_get = true
28
+ opts.on("--no-apt-get","Don't run any apt-get commands") do |value|
29
+ self.apt_get = value
30
+ end
31
+
32
+ self.bootstrap = true
33
+ opts.on("--no-bootstrap","Don't run any bootstrap commands") do |value|
34
+ self.bootstrap = value
35
+ end
36
+
37
+ self.configure = true
38
+ opts.on("--no-configure","Don't run any configure commands") do |value|
39
+ self.configure = value
40
+ end
41
+
42
+ self.make = true
43
+ opts.on("--no-make","Don't run any make commands") do |value|
44
+ self.make = value
45
+ end
46
+
47
+ self.make_install = true
48
+ opts.on("--no-make-install","Don't run any make install commands") do |value|
49
+ self.make_install = value
50
+ end
51
+
52
+ self.make_dist = false
53
+ opts.on("--make-dist","Use `make dist´ instead of `make install´") do |value|
54
+ self.make_dist = value
55
+ end
56
+
57
+ opts.on("--only libmcrypto,libmnetuli,etc.", Array, "Process only these libraries") do |list|
58
+ self.only = list
59
+ end
@@ -1,28 +1,28 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'base')
2
2
 
3
- module Csd
3
+ module CSD
4
4
  module Application
5
5
  module Minisip
6
6
  module Unix
7
- class Base < Csd::Application::Minisip::Base
7
+ class Base < CSD::Application::Minisip::Base
8
8
 
9
9
  # A list of apt-get packages that are required by this application.
10
10
  #
11
- DEBIAN_DEPENDENCIES = %w{ libssl-dev libglademm-2.4-dev libsdl-dev git-core subversion automake libtool libltdl3-dev build-essential libavcodec-dev libswscale-dev nasm yasm libasound2-dev libsdl-ttf2.0-dev }
11
+ DEBIAN_DEPENDENCIES = %w{ libssl-dev libglademm-2.4-dev libsdl-dev git-core subversion automake libtool libltdl3-dev build-essential libavcodec-dev libswscale-dev libasound2-dev libsdl-ttf2.0-dev nasm yasm ffmpeg }
12
12
 
13
- def before_build
14
- fix_aclocal_dirlist
15
- install_aptitude_dependencies
13
+ def before_compile
14
+ #fix_aclocal_dirlist
15
+ install_aptitude_dependencies if Options.apt_get
16
16
  end
17
17
 
18
- def after_build
18
+ def after_compile
19
19
  ldconfig_and_gtkgui
20
20
  end
21
21
 
22
22
  def install_aptitude_dependencies
23
23
  DEBIAN_DEPENDENCIES.each do |apt|
24
- run_command("sudo apt-get --yes install #{apt}")
25
- end if options.apt_get
24
+ Cmd.run("sudo apt-get --yes install #{apt}")
25
+ end
26
26
  end
27
27
 
28
28
  def fix_aclocal_dirlist
@@ -43,8 +43,7 @@ module Csd
43
43
  end
44
44
 
45
45
  def ldconfig_and_gtkgui
46
- run_command("ldconfig /usr/local/lib/libminisip.so.0")
47
- run_command("minisip_gtkgui")
46
+ Cmd.run(File.join(Path.build, "minisip_gtkgui"))
48
47
  end
49
48
 
50
49
  end
@@ -0,0 +1,2 @@
1
+ human: opensips
2
+ description: An open-source SIP server.
@@ -0,0 +1,55 @@
1
+ require 'ostruct'
2
+ require 'active_support/inflector'
3
+ require 'active_support/core_ext/string/inflections'
4
+
5
+ module CSD
6
+
7
+ # A convenience wrapper to get information about the available applications
8
+ #
9
+ class Applications
10
+
11
+ # Returns nil if application could not be found
12
+ #
13
+ def self.find(app_name)
14
+ begin
15
+ require File.join(Path.applications, app_name.to_s)
16
+ ActiveSupport::Inflector.constantize "CSD::Application::#{app_name.camelize}"
17
+ rescue LoadError
18
+ UI.debug "The Application `#{app_name}´ could not be loaded properly."
19
+ nil
20
+ end
21
+ end
22
+
23
+ def self.all(&block)
24
+ result = []
25
+ Dir.directories(Path.applications) do |dir|
26
+ next if dir == 'default'
27
+ if app = find(dir)
28
+ block_given? ? yield(app) : result << app
29
+ end
30
+ end
31
+ result
32
+ end
33
+
34
+ def self.valid?(name)
35
+ list.include?(name)
36
+ end
37
+
38
+ # This method identifies the desired application and initializes it in to +@@current+.
39
+ # It is meant to be very robust, we expect the application to be any one of the first three arguments.
40
+ #
41
+ def self.current
42
+ @@current ||= begin
43
+ Applications.find(ARGV.first) || Applications.find(ARGV.second) || Applications.find(ARGV.third)
44
+ end
45
+ end
46
+
47
+ # Forces a reload of the current application. This method is useful for functional tests.
48
+ #
49
+ def self.current!
50
+ @@current = false
51
+ current
52
+ end
53
+
54
+ end
55
+ end
@@ -1,10 +1,10 @@
1
1
  require 'pathname'
2
2
  require 'ostruct'
3
- require 'active_support'
4
3
 
5
- module Csd
6
- # This module contains wrapper methods for standard file system commands. They are meant to be
4
+ module CSD
5
+ # This module contains wrapper methods for standard file system operations. They are meant to be
7
6
  # a little bit more robust (e.g. raising no exceptions) and return elaborate feedback on their operation.
7
+ # All of these methods, except for the +run+ method, are platform independent.
8
8
  #
9
9
  module Commands
10
10
 
@@ -54,20 +54,20 @@ module Csd
54
54
  target = target.pathnamify
55
55
  result = CommandResult.new
56
56
  if target.directory?
57
- # Don't say anything if the directory already exists
57
+ # Don't do anything if the directory already exists
58
58
  result.already_existed = true
59
59
  else
60
60
  begin
61
- say "Creating directory: #{target}".cyan unless options.quiet
61
+ UI.info "Creating directory: #{target}".cyan
62
62
  # Try to create the directory
63
- target.mkpath unless options.dry
63
+ target.mkpath unless (Options.dry or Options.reveal)
64
64
  rescue Errno::EACCES => e
65
- say "Cannot create directory (no permission): #{target}".red unless options.quiet
65
+ UI.error "Cannot create directory (no permission): #{target}"
66
66
  return result
67
67
  end
68
68
  end
69
- result.success = (target.directory? or options.dry)
70
- result.writable = (target.writable? or options.dry)
69
+ result.success = (target.directory? or Options.reveal)
70
+ result.writable = (target.writable? or Options.reveal)
71
71
  result
72
72
  end
73
73
 
@@ -82,13 +82,55 @@ module Csd
82
82
  def cd(target)
83
83
  target = target.pathnamify
84
84
  result = CommandResult.new
85
- if target.directory? or options.dry
86
- say "cd #{target}".yellow
87
- Dir.chdir(target)
85
+ if target.directory? or Options.reveal
86
+ UI.info "cd #{target}".yellow
87
+ if Options.reveal
88
+ @pwd = target.to_s
89
+ else
90
+ Dir.chdir(target)
91
+ end
88
92
  elsif target.exist?
89
- say "Cannot change to directory because it exists but is not a directory: #{target}".red
93
+ UI.error "Cannot change to directory because it exists but is not a directory: #{target}".red
94
+ end
95
+ result.success = (target.current_path? or Options.reveal)
96
+ result
97
+ end
98
+
99
+ # Copies one or several files to the destination
100
+ #
101
+ def copy(src, dest)
102
+ FileUtils.cp(src, dest)
103
+ end
104
+
105
+ # This returns the current pwd. However, it will return a fake result if we are in reveal-commands-mode.
106
+ #
107
+ def pwd
108
+ if Options.reveal
109
+ @pwd ||= Dir.pwd
110
+ else
111
+ Dir.pwd
112
+ end
113
+ end
114
+
115
+ # Replaces all occurences of a pattern in a file
116
+ #
117
+ # ==== Returns
118
+ #
119
+ # This method returns a CommandResult object with the following values:
120
+ #
121
+ # [+success?+] +true+ if the replacement was successful, +nil+ if not.
122
+ #
123
+ def replace(filepath, pattern, substitution)
124
+ result = CommandResult.new
125
+ begin
126
+ UI.info "Modifying contents of `#{filepath}´ as follows:".blue
127
+ UI.info " (Replacing all occurences of `#{pattern}´ with `#{substitution}´)".blue
128
+ new_file_content = File.read(filepath).gsub(pattern, substitution)
129
+ File.open(filepath, 'w+') { |file| file << new_file_content }
130
+ rescue Errno::ENOENT => e
131
+ result.success = false
90
132
  end
91
- result.success = (target.current_path? or options.dry)
133
+ result.success = true
92
134
  result
93
135
  end
94
136
 
@@ -96,7 +138,7 @@ module Csd
96
138
  #
97
139
  # ==== Returns
98
140
  #
99
- # The command's output as an +Array+. Note that the exit code can be accessed via the global variable <tt>$?</tt>
141
+ # The command's output as a +String+ (with newline delimiters). Note that the exit code can be accessed via the global variable <tt>$?</tt>
100
142
  #
101
143
  # ==== Options
102
144
  #
@@ -104,68 +146,49 @@ module Csd
104
146
  #
105
147
  # [+:exit_on_failure+] If the exit code of the command was not 0, exit the CSD application.
106
148
  #
107
- #
108
- def sh(cmd, params={})
109
- default_params = { :exit_on_failure => true }
149
+ def run(cmd, params={})
150
+ default_params = { :die_on_failure => true, :silent => false }
110
151
  params = default_params.merge(params)
111
- say "Running command in #{Dir.pwd}".yellow unless options.silent
112
- say cmd.cyan
113
- ret = ''
114
- unless options.dry
115
- IO.popen(cmd) do |stdout|
116
- stdout.each do |line|
117
- say " #{line}" if options.verbose
118
- ret << line
119
- end
120
- end
152
+ unless params[:silent]
153
+ UI.info "Running command in #{pwd}".yellow
154
+ UI.info cmd.cyan
121
155
  end
122
- exit_if_last_command_had_errors if params[:exit_on_failure]
123
- ret
124
- end
125
-
126
-
127
- def test_command(*args)
128
- say "Testing command for success: #{args.join(' ')}".yellow
129
- system(*args)
130
- end
131
-
132
- def run_command(cmd, params={})
133
- default_params = { :exit_on_failure => true }
134
- params = default_params.merge(params)
135
- say "Running command in #{Dir.pwd}".yellow unless options.quiet
136
- say cmd.cyan
156
+ return '' if Options.reveal
137
157
  ret = ''
138
- unless options.dry
139
- IO.popen(cmd) do |stdout|
140
- stdout.each do |line|
141
- say " #{line}"
142
- ret << line
143
- end
158
+ IO.popen(cmd) do |stdout|
159
+ stdout.each do |line|
160
+ UI.info " #{line}" unless params[:silent]
161
+ ret << line
144
162
  end
145
163
  end
146
- exit_if_last_command_had_errors if params[:exit_on_failure]
164
+ die_if_last_command_had_errors if params[:exit_on_failure]
147
165
  ret
148
166
  end
149
167
 
150
- def exit_if_last_command_had_errors
151
- unless $?.try(:success?) or options.dry
152
- say "The last command was unsuccessful.".red unless options.quiet
153
- exit
154
- end
168
+ def die_if_last_command_had_errors
169
+ UI.die "The last command was unsuccessful." unless $?.try(:success?)
155
170
  end
171
+
172
+ end
173
+
174
+ # Having a class to include all command modules
175
+ #
176
+ class CommandsInstance
177
+ include Commands
178
+ end
179
+
180
+ # Wrapping the CommandsInstance class
181
+ #
182
+ class Cmd
183
+ COMMANDS = %w{ mkdir cd run replace }
156
184
 
157
-
158
- def say(something='')
159
- end
160
-
161
- def log(msg="")
162
- say msg.yellow unless options.silent
185
+ def self.instance
186
+ @@instance ||= CommandsInstance.new
163
187
  end
164
188
 
165
- # Dummy to be overwritten by real options
166
- def options
167
- OpenStruct.new
189
+ def self.method_missing(meth, *args, &block)
190
+ COMMANDS.include?(meth.to_s) ? instance.send(meth, *args, &block) : super
168
191
  end
169
-
170
192
  end
193
+
171
194
  end