[Piuparts-commits] [piuparts] 01/02: p: add is_installed() method

Holger Levsen holger at moszumanska.debian.org
Sun Feb 9 18:20:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit f24fce58064757ea30d7e717b7d54e0fa283ef6d
Author: Andreas Beckmann <anbe at debian.org>
Date:   Thu Jan 30 18:58:03 2014 +0100

    p: add is_installed() method
    
    check whether package(s) is/are installed in the chroot
    
    based on an initial patch from Julien Cristau
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 piuparts.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/piuparts.py b/piuparts.py
index 8cc813a..ff94957 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -1049,6 +1049,19 @@ class Chroot:
         else:
             logging.debug("The package did not modify any file.\n")
 
+    def is_installed(self, packages):
+        if not packages:
+            return True
+        retcode, output = self.run(["dpkg-query", "-f", "${Package} ${Status}\n", "-W"] + packages, ignore_errors=True)
+        if retcode != 0:
+            return False
+        installed = True
+        for line in output.splitlines():
+            pkg, desired, whatever, status = line.split()
+            if status != 'installed':
+                logging.error("Installation of %s failed", pkg)
+                installed = False
+        return installed
 
     def install_packages(self, package_files, packages, with_scripts=True):
         if package_files:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list