tpkg 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +20 -0
  5. data/Portfile +39 -0
  6. data/Portfile.template +39 -0
  7. data/README.md +43 -0
  8. data/Rakefile +468 -18
  9. data/bin/gem2tpkg +2 -2
  10. data/bin/tpkg +18 -13
  11. data/bin/tpkg_uploader +132 -0
  12. data/ca.pem +1 -0
  13. data/control +7 -0
  14. data/depend +3 -0
  15. data/externals-etch/authorized_keys +40 -0
  16. data/externals-etch/group +9 -0
  17. data/externals-etch/iptables +38 -0
  18. data/externals-etch/limits +30 -0
  19. data/externals-etch/nfs +30 -0
  20. data/externals-etch/sudo +30 -0
  21. data/externals-etch/supplemental_groups +8 -0
  22. data/externals-etch/sysctl +30 -0
  23. data/externals-etch/user +41 -0
  24. data/externals/group +39 -0
  25. data/externals/supplemental_groups +48 -0
  26. data/externals/user +39 -0
  27. data/lib/tpkg.rb +260 -991
  28. data/lib/tpkg/os.rb +164 -0
  29. data/lib/tpkg/os/debian.rb +159 -0
  30. data/lib/tpkg/os/freebsd.rb +113 -0
  31. data/lib/tpkg/os/macosx.rb +113 -0
  32. data/lib/tpkg/os/redhat.rb +173 -0
  33. data/lib/tpkg/os/solaris.rb +101 -0
  34. data/lib/tpkg/os/windows.rb +26 -0
  35. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify.rb +67 -0
  36. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/errors.rb +127 -0
  37. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/kwalify.schema.yaml +58 -0
  38. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/main.rb +442 -0
  39. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/messages.rb +173 -0
  40. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/meta-validator.rb +275 -0
  41. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/parser/base.rb +127 -0
  42. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/parser/yaml.rb +841 -0
  43. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/rule.rb +559 -0
  44. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-java.eruby +222 -0
  45. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-php.eruby +104 -0
  46. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-ruby.eruby +113 -0
  47. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/types.rb +156 -0
  48. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util.rb +158 -0
  49. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/assert-text-equal.rb +46 -0
  50. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/hash-interface.rb +18 -0
  51. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/hashlike.rb +51 -0
  52. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/option-parser.rb +220 -0
  53. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb +57 -0
  54. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/testcase-helper.rb +112 -0
  55. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/validator.rb +282 -0
  56. data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/yaml-parser.rb +870 -0
  57. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh.rb +219 -0
  58. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/agent.rb +179 -0
  59. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/constants.rb +18 -0
  60. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/key_manager.rb +219 -0
  61. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  62. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  63. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  64. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/password.rb +39 -0
  65. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  66. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/pageant.rb +183 -0
  67. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/session.rb +134 -0
  68. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/buffer.rb +340 -0
  69. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/buffered_io.rb +198 -0
  70. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/config.rb +205 -0
  71. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/channel.rb +630 -0
  72. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/constants.rb +33 -0
  73. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/session.rb +597 -0
  74. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/term.rb +178 -0
  75. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/errors.rb +85 -0
  76. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/key_factory.rb +102 -0
  77. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/known_hosts.rb +129 -0
  78. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/loggable.rb +61 -0
  79. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/packet.rb +102 -0
  80. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/prompt.rb +93 -0
  81. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/command.rb +75 -0
  82. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/errors.rb +14 -0
  83. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/http.rb +94 -0
  84. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/socks4.rb +70 -0
  85. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/socks5.rb +142 -0
  86. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/ruby_compat.rb +43 -0
  87. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/service/forward.rb +288 -0
  88. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test.rb +89 -0
  89. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/channel.rb +129 -0
  90. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/extensions.rb +152 -0
  91. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/kex.rb +44 -0
  92. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/local_packet.rb +51 -0
  93. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/packet.rb +81 -0
  94. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/remote_packet.rb +38 -0
  95. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/script.rb +157 -0
  96. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/socket.rb +64 -0
  97. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/algorithms.rb +384 -0
  98. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/cipher_factory.rb +97 -0
  99. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/constants.rb +30 -0
  100. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac.rb +31 -0
  101. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/abstract.rb +79 -0
  102. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/md5.rb +12 -0
  103. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  104. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/none.rb +15 -0
  105. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  106. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  107. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/identity_cipher.rb +55 -0
  108. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex.rb +13 -0
  109. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  110. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  111. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/openssl.rb +127 -0
  112. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/packet_stream.rb +235 -0
  113. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/server_version.rb +71 -0
  114. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/session.rb +276 -0
  115. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/state.rb +206 -0
  116. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/lenient.rb +30 -0
  117. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/null.rb +12 -0
  118. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/strict.rb +53 -0
  119. data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/version.rb +62 -0
  120. data/lib/tpkg/version.rb +3 -0
  121. data/man/man1/cpan2tpkg.1 +82 -0
  122. data/man/man1/gem2tpkg.1 +120 -0
  123. data/man/man1/tpkg.1 +411 -0
  124. data/pkginfo +8 -0
  125. data/postinstall.solaris +11 -0
  126. data/postremove.solaris +16 -0
  127. data/schema/schema-1.0.5.yml +0 -0
  128. data/schema/schema-1.0.6.yml +0 -0
  129. data/schema/schema-1.0.7.yml +0 -0
  130. data/schema/schema-1.0.8.yml +0 -0
  131. data/schema/schema-1.0.9.yml +0 -0
  132. data/schema/schema.yml +0 -0
  133. data/schema/tpkg-1.0.0.dtd +0 -0
  134. data/schema/tpkg-1.0.1.dtd +0 -0
  135. data/schema/tpkg-1.0.2.dtd +0 -0
  136. data/schema/tpkg-1.0.3.dtd +0 -0
  137. data/schema/tpkg-1.0.4.dtd +0 -0
  138. data/schema/tpkg-1.0.5.dtd +0 -0
  139. data/schema/tpkg-1.0.6.dtd +0 -0
  140. data/schema/tpkg-1.0.7.dtd +0 -0
  141. data/schema/tpkg-1.0.8.dtd +0 -0
  142. data/schema/tpkg-1.0.9.dtd +0 -0
  143. data/schema/tpkg.dtd +0 -0
  144. data/test/TODO +30 -0
  145. data/test/premadetestpkg/pkg_without_file_metadata-1.0-1.tpkg +0 -0
  146. data/test/test_checksum.rb +53 -0
  147. data/test/test_compress.rb +55 -0
  148. data/test/test_conflict.rb +41 -0
  149. data/test/test_crontabs.rb +398 -0
  150. data/test/test_dependency.rb +1113 -0
  151. data/test/test_downgrade.rb +80 -0
  152. data/test/test_download.rb +95 -0
  153. data/test/test_encrypt.rb +136 -0
  154. data/test/test_filemetadata.rb +131 -0
  155. data/test/test_initscript.rb +93 -0
  156. data/test/test_install.rb +186 -0
  157. data/test/test_lock.rb +82 -0
  158. data/test/test_make.rb +410 -0
  159. data/test/test_metadata.rb +805 -0
  160. data/test/test_misc.rb +379 -0
  161. data/test/test_options.rb +1711 -0
  162. data/test/test_os.rb +193 -0
  163. data/test/test_os_debian.rb +99 -0
  164. data/test/test_os_freebsd.rb +89 -0
  165. data/test/test_os_macosx.rb +79 -0
  166. data/test/test_os_redhat.rb +124 -0
  167. data/test/test_os_solaris.rb +85 -0
  168. data/test/test_os_windows.rb +26 -0
  169. data/test/test_query.rb +134 -0
  170. data/test/test_remove.rb +539 -0
  171. data/test/test_tar.rb +99 -0
  172. data/test/test_unpack.rb +977 -0
  173. data/test/test_upgrade.rb +398 -0
  174. data/test/test_version.rb +54 -0
  175. data/test/testcmds/crontab +14 -0
  176. data/test/testcmds/debian/apt-cache +145 -0
  177. data/test/testcmds/debian/dpkg-query +16 -0
  178. data/test/testcmds/freebsd/pkg_info +13 -0
  179. data/test/testcmds/macosx/port +35 -0
  180. data/test/testcmds/redhat/rpmbuild +6 -0
  181. data/test/testcmds/redhat/yum +90 -0
  182. data/test/testcmds/solaris/pkginfo +25 -0
  183. data/test/testcmds/solaris/pkgutil +36 -0
  184. data/test/testpkg/reloc/encfile +2 -0
  185. data/test/testpkg/reloc/file +2 -0
  186. data/test/testpkg/reloc/precryptfile +1 -0
  187. data/test/testpkg/reloc/precryptfile.plaintext +3 -0
  188. data/test/testpkg/tpkg-bad-ownergroup.xml +25 -0
  189. data/test/testpkg/tpkg-bad-ownergroup.yml +18 -0
  190. data/test/testpkg/tpkg-default-perms.xml +28 -0
  191. data/test/testpkg/tpkg-default-perms.yml +20 -0
  192. data/test/testpkg/tpkg-good-ownergroup.xml +25 -0
  193. data/test/testpkg/tpkg-good-ownergroup.yml +18 -0
  194. data/test/testpkg/tpkg-nativedeps.yml +13 -0
  195. data/test/testpkg/tpkg-nofiles.xml +14 -0
  196. data/test/testpkg/tpkg-nofiles.yml +9 -0
  197. data/test/testpkg/tpkg.xml +35 -0
  198. data/test/testpkg/tpkg.yml +25 -0
  199. data/test/tpkgtest.rb +300 -0
  200. data/tpkg.conf +16 -0
  201. data/tpkg.gemspec +24 -0
  202. data/tpkg.spec +28 -0
  203. data/tpkg.xml +17 -0
  204. data/tpkg_profile.sh +32 -0
  205. metadata +306 -31
@@ -0,0 +1,193 @@
1
+ #
2
+ # Tests OS abstraction code
3
+ #
4
+
5
+ require File.expand_path('tpkgtest', File.dirname(__FILE__))
6
+
7
+ class Tpkg::OS::TestImplementation < Tpkg::OS
8
+ end
9
+
10
+ class TpkgOSTests < Test::Unit::TestCase
11
+ include TpkgTests
12
+
13
+ def setup
14
+ @os = Tpkg::OS.new
15
+ end
16
+
17
+ def test_register_implementation
18
+ Tpkg::OS.register_implementation(Tpkg::OS::TestImplementation)
19
+ assert_includes Tpkg::OS.class_variable_get(:@@implementations), Tpkg::OS::TestImplementation
20
+ end
21
+ def test_create
22
+ fact = Facter::Util::Fact.new('operatingsystem')
23
+ Facter.stubs(:[]).returns(fact)
24
+ fact.stubs(:value).returns('RedHat')
25
+ assert_instance_of Tpkg::OS::RedHat, Tpkg::OS.create
26
+ end
27
+ def test_initialize
28
+ [true, false].each do |debugval|
29
+ os = Tpkg::OS.new(:debug => debugval)
30
+ assert_equal debugval, os.instance_variable_get(:@debug)
31
+ end
32
+ # Reach into Facter's guts to test that initialize called Facter.loadfacts
33
+ if Facter.collection.respond_to?(:internal_loader)
34
+ assert Facter.collection.internal_loader.instance_variable_get(:@loaded_all)
35
+ else
36
+ assert Facter.collection.loader.instance_variable_get(:@loaded_all)
37
+ end
38
+ end
39
+
40
+ def test_init_links
41
+ # assert_raise(NotImplementedError) { @os.init_links('/path/to/init/script', {:init => {}}) }
42
+ assert_equal [], @os.init_links('/path/to/init/script', {:init => {}})
43
+ end
44
+ def test_available_native_packages
45
+ assert_raise(NotImplementedError) { @os.available_native_packages('curl') }
46
+ end
47
+ def test_install_native_package
48
+ assert_raise(NotImplementedError) { @os.install_native_package({}) }
49
+ end
50
+ def test_upgrade_native_package
51
+ assert_raise(NotImplementedError) { @os.upgrade_native_package({}) }
52
+ end
53
+ def test_stub_native_pkg
54
+ # See comment in method
55
+ # assert_raise NotImplementedError { @os.stub_native_pkg({}) }
56
+ pkgfile = make_package
57
+ metadata = Tpkg::metadata_from_package(pkgfile)
58
+ pkg = { :metadata => metadata, :source => pkgfile }
59
+ assert_nil @os.stub_native_pkg(pkg)
60
+ end
61
+ def test_remove_native_stub_pkg
62
+ # See comment in method
63
+ # assert_raise NotImplementedError { @os.remove_native_stub_pkg({}) }
64
+ assert_nil @os.remove_native_stub_pkg({})
65
+ end
66
+ def test_os_version
67
+ verfact = Facter::Util::Fact.new('operatingsystemrelease')
68
+ verfact.stubs(:value).returns('1.2.3')
69
+ Facter.expects(:[]).with('operatingsystemrelease').returns(verfact).at_least_once
70
+ assert_equal '1.2.3', @os.os_version
71
+
72
+ # Muck with the returned variable and ensure that doesn't stick. I.e.
73
+ # ensure that the method called dup on the string before returning it.
74
+ ver = @os.os_version
75
+ goodver = ver.dup
76
+ ver << 'junk'
77
+ assert_equal(goodver, @os.os_version)
78
+
79
+ end
80
+ def test_native_pkg_to_install_string
81
+ assert_equal 'pkg-1.0-1', @os.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0', :package_version => '1'}})
82
+ assert_equal 'pkg-1.0', @os.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0'}})
83
+ end
84
+
85
+ def test_os
86
+ osfact = Facter::Util::Fact.new('operatingsystem')
87
+ osfact.stubs(:value).returns('TestOS')
88
+ Facter.expects(:[]).with('operatingsystem').returns(osfact).at_least_once
89
+ verfact = Facter::Util::Fact.new('operatingsystemrelease')
90
+ verfact.stubs(:value).returns('1.2.3')
91
+ Facter.expects(:[]).with('operatingsystemrelease').returns(verfact).at_least_once
92
+ assert_equal 'TestOS-1.2.3', @os.os
93
+
94
+ # Muck with the returned variable and ensure that doesn't stick. I.e.
95
+ # ensure that the method called dup on the string before returning it.
96
+ os = @os.os
97
+ goodos = os.dup
98
+ os << 'junk'
99
+ assert_equal(goodos, @os.os)
100
+ end
101
+ def test_os_name
102
+ osfact = Facter::Util::Fact.new('operatingsystem')
103
+ osfact.stubs(:value).returns('TestOS')
104
+ Facter.expects(:[]).with('operatingsystem').returns(osfact).at_least_once
105
+ assert_equal 'TestOS', @os.os_name
106
+
107
+ # Muck with the returned variable and ensure that doesn't stick. I.e.
108
+ # ensure that the method called dup on the string before returning it.
109
+ name = @os.os_name
110
+ goodname = name.dup
111
+ name << 'junk'
112
+ assert_equal(goodname, @os.os_name)
113
+ end
114
+ def test_arch
115
+ hwfact = Facter::Util::Fact.new('hardwaremodel')
116
+ hwfact.stubs(:value).returns('i286')
117
+ Facter.expects(:[]).with('hardwaremodel').returns(hwfact).at_least_once
118
+ assert_equal 'i286', @os.arch
119
+
120
+ # Muck with the returned variable and ensure that doesn't stick. I.e.
121
+ # ensure that the method called dup on the string before returning it.
122
+ arch = @os.arch
123
+ goodarch = arch.dup
124
+ arch << 'junk'
125
+ assert_equal(goodarch, @os.arch)
126
+ end
127
+ def test_fqdn
128
+ fqdnfact = Facter::Util::Fact.new('fqdn')
129
+ fqdnfact.stubs(:value).returns('test.example.com')
130
+ Facter.expects(:[]).with('fqdn').returns(fqdnfact).at_least_once
131
+ assert_equal 'test.example.com', @os.fqdn
132
+ # Test fallback to hostname + domain
133
+ hostfact = Facter::Util::Fact.new('hostname')
134
+ hostfact.stubs(:value).returns('test2')
135
+ domainfact = Facter::Util::Fact.new('domain')
136
+ domainfact.stubs(:value).returns('example.com')
137
+ Facter.expects(:[]).with('fqdn').returns(nil)
138
+ Facter.expects(:[]).with('hostname').returns(hostfact).at_least_once
139
+ Facter.expects(:[]).with('domain').returns(domainfact).at_least_once
140
+ assert_equal 'test2.example.com', @os.fqdn
141
+ end
142
+ def test_cron_dot_d_directory
143
+ assert_nil @os.cron_dot_d_directory
144
+ end
145
+ def test_sudo_default
146
+ assert @os.sudo_default?
147
+ end
148
+
149
+ def test_sys_v_init_links
150
+ installed_path = '/path/to/init/script'
151
+ tpkgfile = {
152
+ :init => {}
153
+ }
154
+ default_levels = ['1', '2', '3']
155
+ init_directory = '/etc/rc.d'
156
+ assert_equal(
157
+ ['/etc/rc.d/rc1.d/S99script',
158
+ '/etc/rc.d/rc2.d/S99script',
159
+ '/etc/rc.d/rc3.d/S99script'],
160
+ @os.sys_v_init_links(installed_path, tpkgfile, default_levels, init_directory))
161
+
162
+ tpkgfile = {
163
+ :init => {
164
+ :start => '98'
165
+ }
166
+ }
167
+ assert_equal(
168
+ ['/etc/rc.d/rc1.d/S98script',
169
+ '/etc/rc.d/rc2.d/S98script',
170
+ '/etc/rc.d/rc3.d/S98script'],
171
+ @os.sys_v_init_links(installed_path, tpkgfile, default_levels, init_directory))
172
+
173
+ tpkgfile = {
174
+ :init => {
175
+ :levels => ['1', '2']
176
+ }
177
+ }
178
+ assert_equal(
179
+ ['/etc/rc.d/rc1.d/S99script',
180
+ '/etc/rc.d/rc2.d/S99script'],
181
+ @os.sys_v_init_links(installed_path, tpkgfile, default_levels, init_directory))
182
+
183
+ tpkgfile = {
184
+ :init => {
185
+ :levels => '13'
186
+ }
187
+ }
188
+ assert_equal(
189
+ ['/etc/rc.d/rc1.d/S99script',
190
+ '/etc/rc.d/rc3.d/S99script'],
191
+ @os.sys_v_init_links(installed_path, tpkgfile, default_levels, init_directory))
192
+ end
193
+ end
@@ -0,0 +1,99 @@
1
+ #
2
+ # Tests Debian OS abstraction code
3
+ #
4
+
5
+ require File.expand_path('tpkgtest', File.dirname(__FILE__))
6
+
7
+ class TpkgOSDebianTests < Test::Unit::TestCase
8
+ include TpkgTests
9
+
10
+ def setup
11
+ @debian = Tpkg::OS::Debian.new(
12
+ :dpkgquerycmd => File.join(TESTCMDDIR, 'debian/dpkg-query'),
13
+ :aptcachecmd => File.join(TESTCMDDIR, 'debian/apt-cache'),
14
+ )
15
+ end
16
+
17
+ def test_supported
18
+ fact = Facter::Util::Fact.new('operatingsystem')
19
+ Facter.expects(:[]).with('operatingsystem').returns(fact).at_least_once
20
+ fact.stubs(:value).returns('Debian')
21
+ assert Tpkg::OS::Debian.supported?
22
+ fact.stubs(:value).returns('Ubuntu')
23
+ assert Tpkg::OS::Debian.supported?
24
+ fact.stubs(:value).returns('Other')
25
+ refute Tpkg::OS::Debian.supported?
26
+ end
27
+ def test_initialize
28
+ [:dpkgquerycmd, :aptcachecmd, :aptgetcmd].each do |cmdvar|
29
+ debian = Tpkg::OS::Debian.new(cmdvar => TESTCMD)
30
+ assert_equal TESTCMD, debian.instance_variable_get("@#{cmdvar}")
31
+ debian = Tpkg::OS::Debian.new(:testcmd => TESTCMD)
32
+ assert_equal TESTCMD, debian.instance_variable_get("@#{cmdvar}")
33
+ end
34
+ # Test that super is called
35
+ [true, false].each do |debugval|
36
+ debian = Tpkg::OS::Debian.new(:debug => debugval)
37
+ assert_equal debugval, debian.instance_variable_get(:@debug)
38
+ end
39
+ end
40
+ def test_init_links
41
+ correct = (2..5).collect{|i| "/etc/rc#{i}.d/S99script"}
42
+ assert_equal correct, @debian.init_links('/path/to/init/script', {:init => {}})
43
+ end
44
+ def test_cron_dot_d_directory
45
+ assert_equal '/etc/cron.d', @debian.cron_dot_d_directory
46
+ end
47
+ def test_available_native_packages
48
+ assert_equal(
49
+ [
50
+ {:metadata=>
51
+ {:name=>'ruby1.9.1', :version=>'1.9.3.194', :package_version=>'3'},
52
+ :source=>:native_installed,
53
+ :prefer=>true},
54
+ {:metadata=>
55
+ {:name=>'ruby1.9.1', :version=>'1.9.3.194', :package_version=>'7'},
56
+ :source=>:native_available},
57
+ ],
58
+ @debian.available_native_packages('ruby1.9.1'))
59
+ assert_equal(
60
+ [
61
+ {:metadata=>
62
+ {:name=>'exim4', :version=>'4.80', :package_version=>'7'},
63
+ :source=>:native_available}
64
+ ],
65
+ @debian.available_native_packages('exim4'))
66
+ assert_equal [], @debian.available_native_packages('bogus')
67
+ end
68
+ def test_native_pkg_to_install_string
69
+ assert_equal 'pkg=1.0-1', @debian.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0', :package_version => '1'}})
70
+ assert_equal 'pkg=1.0', @debian.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0'}})
71
+ end
72
+ def test_install_native_package
73
+ @debian.expects(:system).with('apt-get -y install ruby1.9.1=1.9.3.194-7')
74
+ @debian.install_native_package({:metadata => {:name => 'ruby1.9.1', :version => '1.9.3.194', :package_version => '7'}})
75
+ end
76
+ def test_upgrade_native_package
77
+ @debian.expects(:system).with('apt-get -y install ruby1.9.1=1.9.3.194-7')
78
+ @debian.upgrade_native_package({:metadata => {:name => 'ruby1.9.1', :version => '1.9.3.194', :package_version => '7'}})
79
+ end
80
+ def test_os_version
81
+ # The os_version method caches its result, so we need a new object for
82
+ # each test
83
+ fact = Facter::Util::Fact.new('lsbmajdistrelease')
84
+ Facter.expects(:[]).with('lsbmajdistrelease').returns(fact).at_least_once
85
+ fact.stubs(:value).returns('6')
86
+ assert_equal '6', Tpkg::OS::Debian.new.os_version
87
+ fact.stubs(:value).returns('testing')
88
+ assert_equal 'testing', Tpkg::OS::Debian.new.os_version
89
+ fact.stubs(:value).returns('testing/unstable')
90
+ assert_equal 'testing', Tpkg::OS::Debian.new.os_version
91
+
92
+ # Test fallback to lsbdistrelease
93
+ fact = Facter::Util::Fact.new('lsbdistrelease')
94
+ fact.stubs(:value).returns('6.0.7')
95
+ Facter.expects(:[]).with('lsbmajdistrelease').returns(nil)
96
+ Facter.expects(:[]).with('lsbdistrelease').returns(fact).at_least_once
97
+ assert_equal '6', Tpkg::OS::Debian.new.os_version
98
+ end
99
+ end
@@ -0,0 +1,89 @@
1
+ #
2
+ # Tests FreeBSD OS abstraction code
3
+ #
4
+
5
+ require File.expand_path('tpkgtest', File.dirname(__FILE__))
6
+
7
+ class TpkgOSFreeBSDTests < Test::Unit::TestCase
8
+ include TpkgTests
9
+
10
+ def setup
11
+ @freebsd = Tpkg::OS::FreeBSD.new(
12
+ :pkginfocmd => File.join(TESTCMDDIR, 'freebsd/pkg_info'),
13
+ )
14
+ end
15
+ def setup_mock_os
16
+ fact = Facter::Util::Fact.new('hardwaremodel')
17
+ fact.stubs(:value).returns('i386')
18
+ Facter.expects(:[]).with('hardwaremodel').returns(fact).at_least_once
19
+ fact = Facter::Util::Fact.new('operatingsystemrelease')
20
+ fact.stubs(:value).returns('9.1-RELEASE')
21
+ Facter.expects(:[]).with('operatingsystemrelease').returns(fact).at_least_once
22
+ end
23
+
24
+ def test_supported
25
+ fact = Facter::Util::Fact.new('operatingsystem')
26
+ Facter.expects(:[]).with('operatingsystem').returns(fact).at_least_once
27
+ fact.stubs(:value).returns('FreeBSD')
28
+ assert Tpkg::OS::FreeBSD.supported?
29
+ fact.stubs(:value).returns('Other')
30
+ refute Tpkg::OS::FreeBSD.supported?
31
+ end
32
+ def test_initialize
33
+ [:pkginfocmd, :pkgaddcmd, :pkgdeletecmd].each do |cmdvar|
34
+ freebsd = Tpkg::OS::FreeBSD.new(cmdvar => TESTCMD)
35
+ assert_equal TESTCMD, freebsd.instance_variable_get("@#{cmdvar}")
36
+ freebsd = Tpkg::OS::FreeBSD.new(:testcmd => TESTCMD)
37
+ assert_equal TESTCMD, freebsd.instance_variable_get("@#{cmdvar}")
38
+ end
39
+ # Test that super is called
40
+ [true, false].each do |debugval|
41
+ freebsd = Tpkg::OS::FreeBSD.new(:debug => debugval)
42
+ assert_equal debugval, freebsd.instance_variable_get(:@debug)
43
+ end
44
+ end
45
+
46
+ def test_packagesite
47
+ setup_mock_os
48
+ assert_equal 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-stable/All/', @freebsd.packagesite
49
+ freebsd = Tpkg::OS::FreeBSD.new(:packagesite => 'http://example.com/freebsd/<%= os_version %>/<%= arch %>')
50
+ assert_equal 'http://example.com/freebsd/9/i386/', freebsd.packagesite
51
+ end
52
+ def test_init_links
53
+ assert_equal ['/usr/local/etc/rc.d/script'], @freebsd.init_links('/path/to/init/script', {:init => {}})
54
+ end
55
+ def test_available_native_packages
56
+ assert_equal(
57
+ [
58
+ {:metadata=>
59
+ {:name=>'curl', :version=>'7.24.0'},
60
+ :source=>:native_installed,
61
+ :prefer=>true},
62
+ ],
63
+ @freebsd.available_native_packages('curl'))
64
+ assert_equal [], @freebsd.available_native_packages('bogus')
65
+ end
66
+ def test_native_pkg_to_install_string
67
+ assert_equal 'pkg-1.0_1', @freebsd.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0', :package_version => '1'}})
68
+ assert_equal 'pkg-1.0', @freebsd.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0'}})
69
+ end
70
+ def test_install_native_package
71
+ setup_mock_os
72
+ @freebsd.expects(:system).
73
+ with('sh', '-c', "PACKAGESITE=#{@freebsd.packagesite} pkg_add -r curl-7.24.0")
74
+ @freebsd.install_native_package({:metadata => {:name => 'curl', :version => '7.24.0'}})
75
+ end
76
+ def test_upgrade_native_package
77
+ setup_mock_os
78
+ @freebsd.expects(:system).with('pkg_delete curl-7.24.0')
79
+ @freebsd.expects(:system).
80
+ with('sh', '-c', "PACKAGESITE=#{@freebsd.packagesite} pkg_add -r curl-7.24.0")
81
+ @freebsd.upgrade_native_package({:metadata => {:name => 'curl', :version => '7.24.0'}})
82
+ end
83
+ def test_os_version
84
+ fact = Facter::Util::Fact.new('operatingsystemrelease')
85
+ fact.stubs(:value).returns('9.1-RELEASE')
86
+ Facter.expects(:[]).with('operatingsystemrelease').returns(fact).at_least_once
87
+ assert_equal '9', Tpkg::OS::FreeBSD.new.os_version
88
+ end
89
+ end
@@ -0,0 +1,79 @@
1
+ #
2
+ # Tests Mac OS X OS abstraction code
3
+ #
4
+
5
+ require File.expand_path('tpkgtest', File.dirname(__FILE__))
6
+
7
+ class TpkgOSMacOSXTests < Test::Unit::TestCase
8
+ include TpkgTests
9
+
10
+ def setup
11
+ @testport = File.join(TESTCMDDIR, 'macosx/port')
12
+ @macosx = Tpkg::OS::MacOSX.new(
13
+ :portcmd => @testport,
14
+ )
15
+ end
16
+
17
+ def test_supported
18
+ fact = Facter::Util::Fact.new('operatingsystem')
19
+ Facter.expects(:[]).with('operatingsystem').returns(fact).at_least_once
20
+ fact.stubs(:value).returns('Darwin')
21
+ assert Tpkg::OS::MacOSX.supported?
22
+ fact.stubs(:value).returns('Other')
23
+ refute Tpkg::OS::MacOSX.supported?
24
+ end
25
+ def test_initialize
26
+ [:portcmd].each do |cmdvar|
27
+ macosx = Tpkg::OS::MacOSX.new(cmdvar => TESTCMD)
28
+ assert_equal TESTCMD, macosx.instance_variable_get("@#{cmdvar}")
29
+ macosx = Tpkg::OS::MacOSX.new(:testcmd => TESTCMD)
30
+ assert_equal TESTCMD, macosx.instance_variable_get("@#{cmdvar}")
31
+ end
32
+ # Test that super is called
33
+ [true, false].each do |debugval|
34
+ macosx = Tpkg::OS::MacOSX.new(:debug => debugval)
35
+ assert_equal debugval, macosx.instance_variable_get(:@debug)
36
+ end
37
+ end
38
+ def test_available_native_packages
39
+ assert_equal(
40
+ [
41
+ {:metadata=>
42
+ {:name=>'curl', :version=>'7.27.0', :package_version=>'1'},
43
+ :source=>:native_installed,
44
+ :prefer=>true},
45
+ {:metadata=>
46
+ {:name=>'curl', :version=>'7.28.1'},
47
+ :source=>:native_available},
48
+ ],
49
+ @macosx.available_native_packages('curl'))
50
+ assert_equal(
51
+ [
52
+ {:metadata=>
53
+ {:name=>'ruby186', :version=>'1.8.6-p420'},
54
+ :source=>:native_available}
55
+ ],
56
+ @macosx.available_native_packages('ruby186'))
57
+ assert_equal [], @macosx.available_native_packages('bogus')
58
+ end
59
+ def test_native_pkg_to_install_string
60
+ assert_equal 'pkg', @macosx.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0', :package_version => '1'}})
61
+ assert_equal 'pkg', @macosx.native_pkg_to_install_string({:metadata => {:name => 'pkg', :version => '1.0'}})
62
+ end
63
+ def test_install_native_package
64
+ @macosx.expects(:system).with("#{@testport} install curl")
65
+ @macosx.install_native_package(
66
+ {:metadata => {:name => 'curl', :version => '7.28.1'}})
67
+ end
68
+ def test_upgrade_native_package
69
+ @macosx.expects(:system).with("#{@testport} upgrade curl")
70
+ @macosx.upgrade_native_package(
71
+ {:metadata => {:name => 'curl', :version => '7.28.1', :package_version => '7'}})
72
+ end
73
+ def test_os_version
74
+ fact = Facter::Util::Fact.new('macosx_productversion')
75
+ Facter.expects(:[]).with('macosx_productversion').returns(fact).at_least_once
76
+ fact.stubs(:value).returns('10.8.2')
77
+ assert_equal '10.8', Tpkg::OS::MacOSX.new.os_version
78
+ end
79
+ end