dpkginv 0.1.0.pre.1 → 0.1.3

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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dpkginv (0.1.2)
5
+ json
6
+ ohai
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ ipaddress (0.8.0)
12
+ json (1.7.5)
13
+ mixlib-cli (1.2.2)
14
+ mixlib-config (1.1.2)
15
+ mixlib-log (1.4.1)
16
+ ohai (6.14.0)
17
+ ipaddress
18
+ mixlib-cli
19
+ mixlib-config
20
+ mixlib-log
21
+ systemu
22
+ yajl-ruby
23
+ systemu (2.5.2)
24
+ yajl-ruby (1.1.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ dpkginv!
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Dave Coyle <http://coyled.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ dpkginv
2
+ =======
3
+
4
+ Query installed packages on Debian/Ubuntu-based systems and emit
5
+ inventory as JSON
6
+
7
+ Usage:
8
+
9
+ $ gem install dpkginv
10
+ $ dpkginv
11
+
12
+
13
+ If you want to include a per-host unique identifier to avoid relying
14
+ on FQDN, create a file `/etc/dpkginv.conf` containing:
15
+
16
+ system_id: <some_id_for_this_host>
17
+
18
+ You could, for example, set this to the value of
19
+ `/sys/class/dmi/id/product_uuid`
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/dpkginv CHANGED
@@ -1,34 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/setup'
4
- require 'ohai'
5
- require 'json'
6
- require 'open4'
3
+ require 'dpkginv'
7
4
 
8
- Ohai::Config[:plugin_path] << File.dirname(__FILE__) + '/../plugins/ohai'
9
- o = Ohai::System.new
10
-
11
- # ohai has dozens of plugins; let's only load the ones we need...
12
- o.require_plugin('linux/lsb')
13
- o.require_plugin('linux/hostname')
14
- o.require_plugin('os')
15
- o.require_plugin('platform')
16
- o.require_plugin('kernel')
17
- o.require_plugin('dpkg')
18
-
19
- distro = o[:platform]
20
-
21
- json = {
22
- :fqdn => o[:fqdn],
23
- :os => {
24
- :distro => distro,
25
- :codename => o[:lsb][:codename]
26
- },
27
- :kernel => {
28
- :release => o[:kernel][:release],
29
- :machine => o[:kernel][:machine]
30
- },
31
- :dpkg => o[:dpkg]
32
- }
33
-
34
- puts JSON.pretty_generate(json)
5
+ DpkgInv.run
data/dpkginv.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ require 'rake'
2
+ Gem::Specification.new do |s|
3
+ s.name = 'dpkginv'
4
+ s.version = '0.1.3'
5
+ s.summary = 'Debian/Ubuntu package inventory tools'
6
+ s.description = 'Read Debian/Ubuntu package inventory, emit as JSON'
7
+ s.authors = ['Dave Coyle']
8
+ s.email = 'hello@coyled.com'
9
+ s.homepage = 'https://github.com/coyled/dpkginv'
10
+ s.license = 'MIT'
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- test/*`.split("\n")
13
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
14
+
15
+ s.add_runtime_dependency 'ohai'
16
+ s.add_runtime_dependency 'json'
17
+ end
@@ -0,0 +1,54 @@
1
+ require 'ohai'
2
+ require 'json'
3
+ require 'yaml'
4
+ require 'time'
5
+
6
+ Ohai::Config[:plugin_path] << File.dirname(__FILE__) + '/ohai/plugins'
7
+
8
+ module DpkgInv
9
+
10
+ def self.run
11
+ puts JSON.pretty_generate(inventory)
12
+ end
13
+
14
+ def self.inventory
15
+ o = Ohai::System.new
16
+
17
+ # ohai has dozens of plugins; let's only load the ones we need...
18
+ o.require_plugin('linux/lsb')
19
+ o.require_plugin('linux/hostname')
20
+ o.require_plugin('kernel')
21
+ o.require_plugin('dpkg')
22
+
23
+ json = {
24
+ :fqdn => o[:fqdn],
25
+ :lsb => {
26
+ :id => o[:lsb][:id],
27
+ :release => o[:lsb][:release],
28
+ :codename => o[:lsb][:codename],
29
+ :description => o[:lsb][:description]
30
+ },
31
+ :kernel => {
32
+ :release => o[:kernel][:release],
33
+ :machine => o[:kernel][:machine]
34
+ },
35
+ :dpkg => o[:dpkg],
36
+ :created_at => Time.now.iso8601
37
+ }
38
+
39
+ #
40
+ # load system_id from external file, but it's not required if you
41
+ # just want a JSON representation of your packages. it can be set by
42
+ # config management, etc.
43
+ #
44
+ config_file = '/etc/dpkginv.conf'
45
+ if File.exists?(config_file)
46
+ config = YAML.load_file(config_file)
47
+ unless config == false || config['system_id'].nil?
48
+ json[:system_id] = config['system_id']
49
+ end
50
+ end
51
+
52
+ return json
53
+ end
54
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Debian/Ubuntu dpkg plugin for Chef's Ohai
3
+ #
4
+
5
+ provides "dpkg"
6
+
7
+ dpkg Mash.new
8
+
9
+ popen4("dpkg-query -W -f '${Status}|${Package}|${Version}|${Architecture}\n'") do |pid, stdin, stdout, stderr|
10
+ stdout.each do |line|
11
+ #
12
+ # example dpkg output:
13
+ # install ok installed|manpages|3.35-0.1ubuntu1|all
14
+ #
15
+
16
+ line.chomp
17
+ selection_status, null, install_status, name, version, arch = line.split(%r{\||\s})
18
+
19
+ dpkg[name] = Mash.new
20
+ dpkg[name][:selection_status] = selection_status
21
+ dpkg[name][:install_status] = install_status
22
+ dpkg[name][:version] = version.to_s
23
+ dpkg[name][:arch] = arch
24
+ end
25
+ end
data/lib/dpkginv.rb ADDED
@@ -0,0 +1 @@
1
+ require 'dpkginv/base'
metadata CHANGED
@@ -1,37 +1,67 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpkginv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.1
5
- prerelease: 6
4
+ version: 0.1.3
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dave Coyle
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-25 00:00:00.000000000Z
12
+ date: 2012-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ohai
16
- requirement: &82387010 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0.6'
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *82387010
25
- description: Pre-release; don't use this yet.
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Read Debian/Ubuntu package inventory, emit as JSON
26
47
  email: hello@coyled.com
27
48
  executables:
28
49
  - dpkginv
29
50
  extensions: []
30
51
  extra_rdoc_files: []
31
52
  files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
32
59
  - bin/dpkginv
33
- - plugins/ohai/dpkg.rb
34
- homepage: http://coyled.com/dpkginv
60
+ - dpkginv.gemspec
61
+ - lib/dpkginv.rb
62
+ - lib/dpkginv/base.rb
63
+ - lib/dpkginv/ohai/plugins/dpkg.rb
64
+ homepage: https://github.com/coyled/dpkginv
35
65
  licenses:
36
66
  - MIT
37
67
  post_install_message:
@@ -47,12 +77,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
77
  required_rubygems_version: !ruby/object:Gem::Requirement
48
78
  none: false
49
79
  requirements:
50
- - - ! '>'
80
+ - - ! '>='
51
81
  - !ruby/object:Gem::Version
52
- version: 1.3.1
82
+ version: '0'
53
83
  requirements: []
54
84
  rubyforge_project:
55
- rubygems_version: 1.8.11
85
+ rubygems_version: 1.8.23
56
86
  signing_key:
57
87
  specification_version: 3
58
88
  summary: Debian/Ubuntu package inventory tools
data/plugins/ohai/dpkg.rb DELETED
@@ -1,18 +0,0 @@
1
- #
2
- # Debian/Ubuntu dpkg plugin for Chef's Ohai
3
- #
4
-
5
- provides "dpkg"
6
-
7
- dpkg Mash.new
8
-
9
- popen4("dpkg-query -W -f '${Status}|${Package}|${Version}|${Architecture}\n'") do |pid, stdin, stdout, stderr|
10
- stdout.each do |line|
11
- output = line.split('|')
12
- name = output[1]
13
- dpkg[name] = Mash.new
14
- dpkg[name][:selection_status], null, dpkg[name][:install_status] = output[0].split
15
- dpkg[name][:version] = output[2].to_s
16
- dpkg[name][:arch] = output[3].chomp
17
- end
18
- end