mizzy/serverspec — pull request #138 by ryotarai (2013-06-07 14:44:06+00:00)
Title: Fix a bug of check_installed on Debian squeeze.

On debian squeeze, `dpkg -s ` returns 0 as exit code.

For example:
```bash
vagrant@debian-squeeze:~$ cat /etc/debian_version
6.0.7
vagrant@debian-squeeze:~$ dpkg -s git
Package `git' is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
vagrant@debian-squeeze:~$ echo $?
1
vagrant@debian-squeeze:~$ sudo apt-get install git
# abbr.
vagrant@debian-squeeze:~$ dpkg -s git
# abbr.
vagrant@debian-squeeze:~$ echo $?
0
vagrant@debian-squeeze:~$ sudo apt-get purge git
# abbr.
vagrant@debian-squeeze:~$ dpkg -s git
Package: git
Status: unknown ok not-installed
Priority: optional
Section: vcs
vagrant@debian-squeeze:~$ echo $?
0
```

Because of this problem, I use `dpkg -s && ! dpkg -s | grep -E '^Status: .+ not-installed$'` instead of `dpkg -s `

I tested this command on Ubuntu (Precise) and Debian (Squeeze).
Test log is here: https://gist.github.com/ryotarai/5729755