tpkg 2.3.3 → 2.3.4

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 (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,173 @@
1
+ # tpkg package management system
2
+ # License: MIT (http://www.opensource.org/licenses/mit-license.php)
3
+
4
+ class Tpkg::OS::RedHat < Tpkg::OS
5
+ def self.supported?
6
+ Facter.loadfacts
7
+ ['RedHat', 'CentOS', 'Fedora'].include?(Facter['operatingsystem'].value)
8
+ end
9
+ register_implementation(self)
10
+
11
+ def initialize(options={})
12
+ @yumcmd = options[:yumcmd] || options[:testcmd] || 'yum'
13
+ @rpmcmd = options[:rpmcmd] || options[:testcmd] || 'rpm'
14
+ @rpmbuildcmd = options[:rpmbuildcmd] || options[:testcmd] || 'rpmbuild'
15
+ # This is primarily used by the unit tests
16
+ @quiet = options[:quiet]
17
+ super
18
+ end
19
+
20
+ def init_links(installed_path, tpkgfile)
21
+ sys_v_init_links(installed_path, tpkgfile, ['2', '3', '4', '5'], '/etc/rc.d')
22
+ end
23
+ def cron_dot_d_directory
24
+ '/etc/cron.d'
25
+ end
26
+ def available_native_packages(pkgname)
27
+ native_packages = []
28
+ [ {:arg => 'installed', :header => 'Installed', :source => :native_installed},
29
+ {:arg => 'available', :header => 'Available', :source => :native_available} ].each do |yum|
30
+ cmd = "#{@yumcmd} info #{yum[:arg]} #{pkgname}"
31
+ puts "available_native_packages running '#{cmd}'" if @debug
32
+ stderr_first_line = nil
33
+ Open3.popen3(cmd) do |stdin, stdout, stderr|
34
+ stdin.close
35
+ read_packages = false
36
+ name = version = package_version = nil
37
+ stdout.each_line do |line|
38
+ if line =~ /#{yum[:header]} Packages/
39
+ # Skip the header lines until we get to this line
40
+ read_packages = true
41
+ elsif read_packages
42
+ if line =~ /^Name\s*:\s*(.+)/
43
+ name = $1.strip
44
+ elsif line =~ /^Arch\s*:\s*(.+)/
45
+ arch = $1.strip
46
+ elsif line =~ /^Version\s*:\s*(.+)/
47
+ version = $1.strip.to_s
48
+ elsif line =~ /^Release\s*:\s*(.+)/
49
+ package_version = $1.strip.to_s
50
+ elsif line =~ /^Repo\s*:\s*(.+)/
51
+ repo = $1.strip
52
+ elsif line =~ /^\s*$/
53
+ pkg = Tpkg.pkg_for_native_package(name, version, package_version, yum[:source])
54
+ native_packages << pkg
55
+ name = version = package_version = nil
56
+ end
57
+ # In the end we ignore the architecture. Anything that
58
+ # shows up in yum should be installable on this box, and
59
+ # the chance of a mismatch between facter's idea of the
60
+ # architecture and RPM's idea is high. I.e. i386 vs i686
61
+ # or i32e vs x86_64 or whatever.
62
+ end
63
+ end
64
+ stderr_first_line = stderr.gets
65
+ end
66
+ # FIXME: popen3 doesn't set $?
67
+ if !$?.success?
68
+ # Ignore 'no matching packages', raise anything else
69
+ if stderr_first_line != "Error: No matching Packages to list\n"
70
+ raise "available_native_packages error running yum"
71
+ end
72
+ end
73
+ end
74
+ native_packages
75
+ end
76
+ def install_native_package(pkg)
77
+ pkgname = native_pkg_to_install_string(pkg)
78
+ cmd = "#{@yumcmd} -y install #{pkgname}"
79
+ puts "Running '#{cmd}' to install native package" if @debug
80
+ system(cmd)
81
+ end
82
+ def upgrade_native_package(pkg)
83
+ pkgname = native_pkg_to_install_string(pkg)
84
+ cmd = "#{@yumcmd} -y install #{pkgname}"
85
+ puts "Running '#{cmd}' to upgrade native package" if @debug
86
+ system(cmd)
87
+ end
88
+ def stub_native_pkg(pkg)
89
+ native_deps = pkg[:metadata].get_native_deps
90
+ return if native_deps.empty?
91
+
92
+ rpm = create_rpm("stub_for_#{pkg[:metadata][:name]}", native_deps)
93
+ return if rpm.nil?
94
+
95
+ cmd = "#{@rpmcmd} -i #{rpm}"
96
+ puts "Running '#{cmd} to install native dependency stub" if @debug
97
+ system(cmd)
98
+ if !$?.success?
99
+ warn "Warning: Failed to install native stub package for #{pkg[:metadata][:name]}" unless @quiet
100
+ end
101
+ end
102
+ def remove_native_stub_pkg(pkg)
103
+ native_deps = pkg[:metadata].get_native_deps
104
+ return if native_deps.empty?
105
+
106
+ stub_pkg_name = "stub_for_#{pkg[:metadata][:name]}"
107
+ cmd = "#{@yumcmd} -y remove #{stub_pkg_name}"
108
+ puts "Running '#{cmd} to remove native dependency stub" if @debug
109
+ puts cmd if @debug
110
+ system(cmd)
111
+ if !$?.success?
112
+ warn "Warning: Failed to remove native stub package for #{pkg[:metadata][:name]}" unless @quiet
113
+ end
114
+ end
115
+
116
+ def os_version
117
+ if !@os_version
118
+ if Facter['lsbmajdistrelease'] &&
119
+ Facter['lsbmajdistrelease'].value &&
120
+ !Facter['lsbmajdistrelease'].value.empty?
121
+ @os_version = Facter['lsbmajdistrelease'].value
122
+ end
123
+ end
124
+ super
125
+ end
126
+
127
+ private
128
+ def create_rpm(name, deps=[])
129
+ topdir = Tpkg::tempdir('rpmbuild')
130
+ %w[BUILD RPMS SOURCES SPECS SRPMS].each do |dir|
131
+ FileUtils.mkdir_p(File.join(topdir, dir))
132
+ end
133
+
134
+ dep_list = deps.collect{|dep|dep[:name]}.join(",")
135
+
136
+ spec = <<-EOS.gsub(/^\s+/, "")
137
+ Name: #{name}
138
+ Summary: stub pkg created by tpkg
139
+ Version: 1
140
+ Release: 1
141
+ buildarch: noarch
142
+ Requires: #{dep_list}
143
+ Group: Applications/System
144
+ License: MIT
145
+ BuildRoot: %{_builddir}/%{name}-buildroot
146
+ %description
147
+ stub pkg created by tpkg for the following dependencies: #{dep_list}
148
+ %files
149
+ EOS
150
+ spec_file = File.join(topdir, 'SPECS', 'pkg.spec')
151
+ File.open(spec_file, 'w') do |file|
152
+ file.puts(spec)
153
+ end
154
+
155
+ system("#{@rpmbuildcmd} -bb --define '_topdir #{topdir}' #{spec_file}")
156
+ if !$?.success?
157
+ warn "Warning: Failed to create native stub package for #{name}" unless @quiet
158
+ return nil
159
+ end
160
+ result = File.join(topdir, 'RPMS', 'noarch', "#{name}-1-1.noarch.rpm")
161
+ if !File.exists?(result)
162
+ warn "Warning: rpmbuild failed to produce a native stub package for #{name}" unless @quiet
163
+ return nil
164
+ end
165
+ tmpfile = Tempfile.new(File.basename(result))
166
+ FileUtils.cp(result, tmpfile.path)
167
+ rpm = tmpfile.path
168
+ FileUtils.rm_rf(topdir)
169
+
170
+ return rpm
171
+ end
172
+
173
+ end
@@ -0,0 +1,101 @@
1
+ # tpkg package management system
2
+ # License: MIT (http://www.opensource.org/licenses/mit-license.php)
3
+
4
+ class Tpkg::OS::Solaris < Tpkg::OS
5
+ def self.supported?
6
+ Facter.loadfacts
7
+ Facter['operatingsystem'].value == 'Solaris'
8
+ end
9
+ register_implementation(self)
10
+
11
+ def initialize(options={})
12
+ @pkginfocmd = options[:pkginfocmd] || options[:testcmd] || 'pkginfo'
13
+ @pkgutilcmd = options[:pkgutilcmd] || options[:testcmd] || '/opt/csw/bin/pkgutil'
14
+ super
15
+ end
16
+
17
+ def init_links(installed_path, tpkgfile)
18
+ sys_v_init_links(installed_path, tpkgfile, ['2', '3'], '/etc')
19
+ end
20
+ def available_native_packages(pkgname)
21
+ native_packages = []
22
+ # Example of pkginfo -x output:
23
+ # SUNWzfsu ZFS (Usr)
24
+ # (i386) 11.10.0,REV=2006.05.18.01.46
25
+ cmd = "#{@pkginfocmd} -x #{pkgname}"
26
+ puts "available_native_packages running '#{cmd}'" if @debug
27
+ IO.popen(cmd) do |pipe|
28
+ name = nil
29
+ pipe.each_line do |line|
30
+ if line =~ /^\w/
31
+ name = line.split(' ').first
32
+ else
33
+ arch, solversion = line.split(' ')
34
+ # Lots of Sun and some third party packages (including CSW)
35
+ # seem to use this REV= convention in the version. I've
36
+ # never seen it documented, but since it seems to be a
37
+ # widely used convention we'll go with it.
38
+ version, package_version = solversion.split(',REV=')
39
+ native_packages <<
40
+ Tpkg.pkg_for_native_package(
41
+ name, version, package_version, :native_installed)
42
+ name = nil
43
+ end
44
+ end
45
+ end
46
+ if !$?.success?
47
+ raise "available_native_packages error running pkginfo"
48
+ end
49
+ if File.exist?(@pkgutilcmd)
50
+ cmd = "#{@pkgutilcmd} -a --parse #{pkgname}"
51
+ puts "available_native_packages running '#{cmd}'" if @debug
52
+ IO.popen(cmd) do |pipe|
53
+ pipe.each_line do |line|
54
+ shortname, name, solversion, size = line.chomp.split("\t")
55
+ # pkgutil treats the specified name as a regular expression, so we
56
+ # have filter for the ones that are an exact match
57
+ next if name != pkgname
58
+ # Lots of Sun and some third party packages (including CSW)
59
+ # seem to use this REV= convention in the version. I've
60
+ # never seen it documented, but since it seems to be a
61
+ # widely used convention we'll go with it.
62
+ version, package_version = solversion.split(',REV=')
63
+ native_packages <<
64
+ Tpkg.pkg_for_native_package(
65
+ name, version, package_version, :native_available)
66
+ end
67
+ end
68
+ end
69
+ native_packages
70
+ end
71
+ def native_pkg_to_install_string(pkg)
72
+ name = pkg[:metadata][:name]
73
+ version = pkg[:metadata][:version]
74
+ package_version = pkg[:metadata][:package_version]
75
+ pkgname = "#{name}-#{version}"
76
+ if package_version
77
+ pkgname << ",REV=#{package_version}"
78
+ end
79
+ pkgname
80
+ end
81
+ def install_native_package(pkg)
82
+ pkgname = native_pkg_to_install_string(pkg)
83
+ if File.exist?(@pkgutilcmd)
84
+ cmd = "#{@pkgutilcmd} -y -i #{pkgname}"
85
+ puts "Running '#{cmd}' to install native package" if @debug
86
+ system(cmd)
87
+ else
88
+ raise "No supported native package tool available on #{os}"
89
+ end
90
+ end
91
+ def upgrade_native_package(pkg)
92
+ pkgname = native_pkg_to_install_string(pkg)
93
+ if File.exist?(@pkgutilcmd)
94
+ cmd = "#{@pkgutilcmd} -y -u #{pkgname}"
95
+ puts "Running '#{cmd}' to upgrade native package" if @debug
96
+ system(cmd)
97
+ else
98
+ raise "No supported native package tool available on #{os}"
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,26 @@
1
+ # tpkg package management system
2
+ # License: MIT (http://www.opensource.org/licenses/mit-license.php)
3
+
4
+ class Tpkg::OS::Windows < Tpkg::OS
5
+ def self.supported?
6
+ Facter.loadfacts
7
+ Facter['operatingsystem'].value == 'windows'
8
+ end
9
+ register_implementation(self)
10
+
11
+ def os_version
12
+ if !@os_version
13
+ # Extract 6.1 from 6.1.7601, for example
14
+ # That seems like the right level to split at
15
+ # based on http://en.wikipedia.org/wiki/Ver_(command)
16
+ winver = Facter['operatingsystemrelease'].value
17
+ @os_version = winver.split('.')[0,2].join('.')
18
+ end
19
+ super
20
+ end
21
+
22
+ def sudo_default?
23
+ # Neither of the common Windows environments for running Ruby have sudo
24
+ return false
25
+ end
26
+ end
@@ -0,0 +1,67 @@
1
+ ###
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2006 kuwata-lab.com all rights reserved.
5
+ ###
6
+
7
+
8
+ module Kwalify
9
+
10
+ RELEASE = ("$Release: 0.7.2 $" =~ /[.\d]+/) && $&
11
+
12
+ end
13
+
14
+ require 'kwalify/types'
15
+ require 'kwalify/messages'
16
+ require 'kwalify/errors'
17
+ require 'kwalify/rule'
18
+ require 'kwalify/validator'
19
+ require 'kwalify/meta-validator'
20
+ require 'kwalify/yaml-parser'
21
+ #require 'kwalify/parser/base'
22
+ #require 'kwalify/parser/yaml'
23
+
24
+
25
+ module Kwalify
26
+
27
+ module Util
28
+
29
+ autoload :HashLike, 'kwalify/util/hashlike'
30
+
31
+ end
32
+
33
+ module Yaml
34
+
35
+ autoload :Parser, 'kwalify/parser/yaml'
36
+
37
+ ## read yaml_str, parse it, and return yaml document.
38
+ ##
39
+ ## opts:
40
+ ## ::validator: Kwalify::Validator object
41
+ ## ::preceding_aliass: allow preceding alias if true
42
+ ## ::data_binding: enable data binding if true
43
+ ## ::untabify: expand tab chars if true
44
+ ## ::filename: filename
45
+ def self.load(yaml_str, opts={})
46
+ #require 'kwalify/parser/yaml'
47
+ parser = Kwalify::Yaml::Parser.new(opts[:validator])
48
+ parser.preceding_alias = true if opts[:preceding_alias]
49
+ parser.data_binding = true if opts[:data_binding]
50
+ yaml_str = Kwalify::Util.untabify(yaml_str) if opts[:untabify]
51
+ ydoc = parser.parse(yaml_str, :filename=>opts[:filename])
52
+ return ydoc
53
+ end
54
+
55
+ ## read file, parse it, and return yaml document.
56
+ ## see Kwalify::Yaml::Parser.load()
57
+ def self.load_file(filename, opts={})
58
+ opts[:filename] = filename
59
+ return self.load(File.read(filename), opts)
60
+ end
61
+
62
+ end
63
+
64
+ module Json
65
+ end
66
+
67
+ end
@@ -0,0 +1,127 @@
1
+ ###
2
+ ### $Rev$
3
+ ### $Release: 0.7.2 $
4
+ ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
+ ###
6
+
7
+ require 'kwalify/messages'
8
+
9
+ module Kwalify
10
+
11
+ class KwalifyError < StandardError
12
+ end
13
+
14
+
15
+ class AssertionError < KwalifyError
16
+ def initialize(msg)
17
+ super("*** assertion error: " + msg)
18
+ end
19
+ end
20
+
21
+
22
+ class BaseError < KwalifyError
23
+ def initialize(message="", path=nil, value=nil, rule=nil, error_symbol=nil)
24
+ super(message)
25
+ @path = path.is_a?(Array) ? '/'+path.join('/') : path
26
+ @rule = rule
27
+ @value = value
28
+ @error_symbol = error_symbol
29
+ end
30
+ attr_accessor :error_symbol, :rule, :path, :value
31
+ attr_accessor :filename, :linenum, :column
32
+
33
+ def path
34
+ return @path == '' ? "/" : @path
35
+ end
36
+
37
+ alias _to_s to_s
38
+ alias message to_s
39
+
40
+ def to_s
41
+ s = ''
42
+ s << @filename << ":" if @filename
43
+ s << "#{@linenum}:#{@column} " if @linenum
44
+ s << "[#{path()}] " if @path
45
+ s << _to_s()
46
+ return s
47
+ end
48
+
49
+ def <=>(ex)
50
+ #return @linenum <=> ex.linenum
51
+ v = 0
52
+ v = @linenum <=> ex.linenum if @linenum && ex.linenum
53
+ v = @column <=> ex.column if v == 0 && @column && ex.column
54
+ v = @path <=> ex.path if v == 0
55
+ return v
56
+ end
57
+ end
58
+
59
+
60
+ class SchemaError < BaseError
61
+ def initialize(message="", path=nil, rule=nil, value=nil, error_symbol=nil)
62
+ super(message, path, rule, value, error_symbol)
63
+ end
64
+ end
65
+
66
+
67
+ class ValidationError < BaseError
68
+ def initialize(message="", path=nil, rule=nil, value=nil, error_symbol=nil)
69
+ super(message, path, rule, value, error_symbol)
70
+ end
71
+ end
72
+
73
+
74
+ ## syntax error for YAML and JSON
75
+ class SyntaxError < BaseError #KwalifyError
76
+ def initialize(msg, linenum=nil, error_symbol=nil)
77
+ super(linenum ? "line #{linenum}: #{msg}" : msg)
78
+ @linenum = linenum
79
+ @error_symbol = error_symbol
80
+ end
81
+ #attr_accessor :linenum, :error_symbol
82
+ def message
83
+ "file: #{@filename}, line #{@linenum}: #{super}"
84
+ end
85
+ end
86
+
87
+
88
+ ## (obsolete) use Kwalify::SyntaxError instead
89
+ class YamlSyntaxError < SyntaxError
90
+ end
91
+
92
+
93
+ module ErrorHelper
94
+
95
+ #module_function
96
+
97
+ def assert_error(message="")
98
+ raise AssertionError.new(message)
99
+ end
100
+
101
+ def validate_error(error_symbol, rule, path, val, args=nil)
102
+ msg = _build_message(error_symbol, val, args);
103
+ path = '/'+path.join('/') if path.is_a?(Array)
104
+ return ValidationError.new(msg, path, val, rule, error_symbol)
105
+ end
106
+ module_function :validate_error
107
+
108
+ def schema_error(error_symbol, rule, path, val, args=nil)
109
+ msg = _build_message(error_symbol, val, args);
110
+ path = '/'+path.join('/') if path.is_a?(Array)
111
+ return SchemaError.new(msg, path, val, rule, error_symbol)
112
+ end
113
+
114
+ def _build_message(message_key, val, args)
115
+ msg = Kwalify.msg(message_key)
116
+ assert_error("message_key=#{message_key.inspect}") unless msg
117
+ msg = msg % args if args
118
+ msg = "'#{val.to_s.gsub(/\n/, '\n')}': #{msg}" if !val.nil? && Types.scalar?(val)
119
+ return msg;
120
+ end
121
+ module_function :_build_message
122
+
123
+ end
124
+
125
+ extend ErrorHelper
126
+
127
+ end