Thursday Sep 03, 2009

dmidecode in /contrib IPS Repository

After a few false starts getting dmidecode promoted to the /contrib repo, yesterday's refresh finally pulled the package in. I talked about my reasons for porting this utility in my prior blog on dmidecode.

So fire up package-manager and install it - or use the groovy install link from the repo directly.


Tuesday Aug 04, 2009

%attr boy

A few weeks ago, I blogged about my initial port of dmidecode into the SourceJuicer (SJ). Since then, I've been working on getting the package "promoted" to the /contrib repository. While doing this, I learned a bit about the %attr directives.

One of the comments I'd gotten was to tighten up the permissions on the binaries and man pages. In the initial port, the spec file did this for the packaging:

%files %defattr (-, root, bin) %doc AUTHORS CHANGELOG README %dir %attr(0755, root, bin) %{_sbindir} %{_sbindir}/\* %dir %attr(0755, root, bin) %{_mandir} %{_mandir}/\*/\*

While the directory attributes were explicitly set, the file attributes weren't. So I tried this:

%files %defattr (-, root, bin) %doc AUTHORS CHANGELOG README %dir %attr(0755, root, bin) %{_sbindir} %attr(0555, root, bin) %{_sbindir}/\* %{_sbindir}/\* %dir %attr(0755, root, bin) %{_mandir} %attr(0444, root, bin) %{_mandir}/\*/\* %{_mandir}/\*/\*

Wonderful. Now the permissions are tighter on the binaries and man pages. However, the SJ build was quite unhappy.

pkgbuild: Creating packages... pkgbuild: pkgbuild: File listed twice: usr/sbin/biosdecode pkgbuild: pkgbuild: File listed twice: usr/sbin/dmidecode pkgbuild: pkgbuild: File listed twice: usr/sbin/ownership pkgbuild: pkgbuild: File listed twice: usr/sbin/vpddecode pkgbuild: pkgbuild: File listed twice: usr/share/man/man8/biosdecode.8 pkgbuild: pkgbuild: File listed twice: usr/share/man/man8/dmidecode.8 pkgbuild: pkgbuild: File listed twice: usr/share/man/man8/ownership.8 pkgbuild: pkgbuild: File listed twice: usr/share/man/man8/vpddecode.8

After quite a bit of trial and error, I realized that when the %attr directive is used for a file or set of files, the files the directive references are included in the package. So the final %files section is:

%files %defattr (-, root, bin) %doc AUTHORS CHANGELOG README %dir %attr(0755, root, bin) %{_sbindir} %attr(0555, root, bin) %{_sbindir}/\* %dir %attr(0755, root, bin) %{_mandir} %attr(0444, root, bin) %{_mandir}/man8/\*

The moral of the story is that when using %attr you don't need (and don't want :) individual lines listing the sames files for inclusion in the package.


Monday Jul 06, 2009

OpenSolaris dmidecode IPS

I've talked about the SourceJuicer before. If you often grab source tarballs and compile them on Solaris, check it out. And better yet - contribute. It's really not very involved. Today I put the dmidecode utility into the juicer.

Part of the x86gentopo project is adding OEM-specific SMBIOS structures. In searching around to find out if the structure types we were proposing would conflict with already existing OEM extensions, I stumbled upon dmidecode. Quite a nice utility. The /usr/sbin/smbios CLI is the Solaris equivalent. A minor annoyance with dmidecode is that it must be run as root since it directly reads the /dev/xsvc device, whereas smbios uses the /dev/smbios device. But execution aside, both report the same basic information:

# dmidecode -t baseboard # dmidecode 2.10 SMBIOS 2.5 present. Handle 0x0002, DMI type 2, 15 bytes Base Board Information Manufacturer: Sun Microsystems Product Name: Ultra 24 Version: 50 Serial Number: 3K01V3 Asset Tag: Null Features: Board is a hosting board Board is replaceable Location In Chassis: Null Chassis Handle: 0x0003 Type: Motherboard Contained Object Handles: 0 $ smbios -t 2 ID SIZE TYPE 2 60 SMB_TYPE_BASEBOARD (base board) Manufacturer: Sun Microsystems Product: Ultra 24 Version: 50 Serial Number: 3K01V3 Asset Tag: Null Location Tag: Null Chassis: 3 Flags: 0x9 SMB_BBFL_MOTHERBOARD (board is a motherboard) SMB_BBFL_REPLACABLE (board is field-replacable) Board Type: 0xa (motherboard)

Some slight field label differences, but the set of information one would expect. And, the listing of contained object handles from dmidecode is something missing from /usr/sbin/smbios. That's an enhancement the x86gentopo project is working on.

Although, dmidecode has some nice additions that make scripting simpler. For example, to fetch the system serial number (residing in the Type 1 SMBIOS strucure):

# dmidecode -s system-serial-number 0909FMB010

The keyword strings are a nice touch. Compare this with:

$ smbios -i `smbios -s |grep SMB_TYPE_SYSTEM | awk '{print $1}'` \\ | grep Serial | awk '{print $3}' 0909FMB010

While one gets the same result, it's obvious which approach is simpler and more maintainable in a script. And that's the primary reason it prompted me to port the utility. I'd suspect that many administrators have built scripts around dmidecode for basic system inventories. If moving to Solaris, having dmidecode around means one less script to port.

It's available in the /pending repository. /pending is an unstable repository, although dmidecode is about as benign as things get, so there's little risk in using it. It's behaved fine on my two systems running OpenSolaris b117 (one Sun system, one Toshiba laptop). If you do download it and use it, I'd really appreciate it if you let me know how it's working. I want to get the package moved to the more stable /contrib repository, and any reports of dmidecode working "in the wild" would certainly help.





« July 2016