Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package_ensure() doesn't work on Ubuntu 10.04 #4

Closed
akostyuk opened this issue Jun 9, 2011 · 4 comments
Closed

package_ensure() doesn't work on Ubuntu 10.04 #4

akostyuk opened this issue Jun 9, 2011 · 4 comments
Assignees

Comments

@akostyuk
Copy link
Contributor

akostyuk commented Jun 9, 2011

Hi!
Seems package_ensure(package_name) doesn't work on Ubuntu 10.04:
Code:

from cuisine.cuisine import *
def setup():
    package_ensure('nginx')

Output:

unit@unit:~/PROJECTS/test$ fab -H 10.7.1.5 --user=unit setup
[10.7.1.5] Executing task 'setup'
[10.7.1.5] run: dpkg -s nginx | grep 'Status: install ok installed' ; true
[10.7.1.5] Passphrase for private key: 
[10.7.1.5] Login password: 
[10.7.1.5] out: Package `nginx' is not installed and no info is available.
[10.7.1.5] out: Use dpkg --info (= dpkg-deb --info) to examine archive files,
[10.7.1.5] out: and dpkg --contents (= dpkg-deb --contents) to list their contents.
[10.7.1.5] out: 

Done.
Disconnecting from 10.7.1.5... done.
@ghost ghost assigned sebastien Jun 9, 2011
@sebastien
Copy link
Owner

Hi!

This output doesn't mean that nginx is not installed, it's just the standard output from dpkg -s (package status) when the package is not found. Did you run it again to check if the output was different?

@akostyuk
Copy link
Contributor Author

akostyuk commented Jun 9, 2011

Hello Sébastien!
I tried again using your last changes, but it did not work. I think it should be like this:

diff --git a/cuisine/cuisine.py b/cuisine/cuisine.py
index b9d6f98..05cd3dd 100644
--- a/cuisine/cuisine.py
+++ b/cuisine/cuisine.py
@@ -218,7 +218,7 @@ def package_install( package, update=False ):
 def package_ensure( package ):
        """Tests if the given package is installed, and installes it in case it's not
        already there."""
-       if run("dpkg -s %s | grep 'Status:' ; true" % package).find("installed") == -1:
+       if run("dpkg-query -W -f='${Status}' %s ; true" % package).find("installed") == -1:
                package_install(package)

 def command_ensure( command, package=None ):

@sebastien
Copy link
Owner

Thanks a lot, I updated with you changes and pushed it. Let me know if this works.

@akostyuk
Copy link
Contributor Author

yeah, thanks!
now this works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants