Created
December 5, 2014 09:52
-
-
Save rottenbytes/263d945e9c2c8c1984f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ohai.plugin(:PackagesList) do | |
provides "packages/list" | |
depends "platform" | |
collect_data(:linux) do | |
if platform == "debian" | |
packages Mash.new | |
# Desired=Unknown/Install/Remove/Purge/Hold | |
#| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend | |
#|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) | |
#||/ Name Version Architecture Description | |
#+++-==================================-==========================-============-========================================================================== | |
#ii acpi 1.6-1 amd64 displays information on ACPI devices | |
#ii acpi-support-base 0.140-5 all scripts for handling base ACPI events such as the power button | |
#ii acpid 1:2.0.16-1+deb7u1 amd64 Advanced Configuration and Power Interface event daemon | |
#ii adduser 3.113+nmu3 all add and remove users and groups | |
re = /([a-z][a-z])\s+(\S+)\s+(\S+)\s+.*/ | |
list = Hash.new | |
shell_out("/usr/bin/dpkg -l").stdout.lines do |l| | |
m = re.match(l.chomp) | |
if m | |
if m[1] == "ii" | |
list[m[2]] = m[3] | |
end | |
end | |
end | |
packages[:list] = list | |
end | |
end | |
collect_data(:freebsd) do | |
packages Mash.new unless packages | |
# $ pkg info | |
#xextproto-7.2.0 XExt extension headers | |
#xf86miscproto-0.9.3 XFree86-Misc extension headers | |
#xf86vidmodeproto-2.3.1 XFree86-VidModeExtension extension headers | |
#xineramaproto-1.2.1 Xinerama extension headers | |
#xkbcomp-1.2.3 Compile XKB keyboard description | |
#xkeyboard-config-2.5.1 X Keyboard Configuration Database | |
#xorg-fonts-truetype-7.5.1 X.Org TrueType fonts | |
#xorg-server-1.7.7_6,1 X.Org X server and related programs | |
#xproto-7.0.22 X11 protocol headers | |
#yajl-2.0.4_1 A Portable JSON parsing and serialization library in ANSI C | |
#zsh-5.0.2 The Z shell | |
list = Hash.new | |
shell_out('pkg query -a "%n %v"').stdout.lines do |l| | |
name, version = l.split(" ") | |
list[name] = version | |
end | |
packages[:list] = list | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment