def already_installed(self, pkg): """ Decide if a package is installed and the right version """ retval, stdout = run2( ["dpkg-query", "-W", "-f=${Status} ${Version}\\n", pkg["name"]], show_command=True) if retval: # Assume it's not installed return False lines = stdout.splitlines() if len(lines) == 0: return False words = lines[0].split() if not (len(words) == 4 and words[2] == 'installed'): return False vsn_text = words[3] vsn = split_debian_version(words[3]) if ("exact-version" in pkg): r = (debian_version_is(vsn, split_debian_version(pkg['exact-version']))) if (r != 0): print " %s=%s is not required version %s" % ( pkg['name'], vsn_text, pkg['exact-version']) return False else: return True if ("min-version" in pkg): r = debian_version_is(vsn, split_debian_version(pkg['min-version'])) if (r < 0): print " %s=%s is too old (require %s)" % ( pkg['name'], vsn_text, pkg['min-version']) return False else: return True if ("max-version" in pkg): r = (debian_version_is(vsn, split_debian_version( pkg['max-version'])) < 1) if (r > 0): print " %s=%s is too new (require <= %s)" % ( pkg['name'], vsn_text, pkg['min-version']) return False else: return True # If no-one cares about the version, then .. return True
def already_installed(self, pkg): """ Decide if a package is installed and the right version """ retval, stdout = run2([ "dpkg-query", "-W", "-f=${Status} ${Version}\\n", pkg["name"] ], show_command=True) if retval: # Assume it's not installed return False lines = stdout.splitlines() if len(lines) == 0: return False words = lines[0].split() if not (len(words) == 4 and words[2] == 'installed'): return False vsn_text = words[3] vsn = split_debian_version(words[3]) if ("exact-version" in pkg): r = (debian_version_is(vsn, split_debian_version(pkg['exact-version']))) if (r != 0): print " %s=%s is not required version %s"%(pkg['name'], vsn_text, pkg['exact-version']) return False else: return True if ("min-version" in pkg): r = debian_version_is(vsn, split_debian_version(pkg['min-version'])) if (r < 0): print " %s=%s is too old (require %s)"%(pkg['name'], vsn_text, pkg['min-version']) return False else: return True if ("max-version" in pkg): r = (debian_version_is(vsn, split_debian_version(pkg['max-version'])) < 1) if (r > 0): print " %s=%s is too new (require <= %s)"%(pkg['name'], vsn_text, pkg['min-version']) return False else: return True # If no-one cares about the version, then .. return True
def current_version(self, pkg): retval, stdout = run2([ "dpkg-query", "-W", "-f=${Status} ${Version}\\n", pkg["name"] ], show_command=True) if retval: # Assume it's not installed return None lines = stdout.splitlines() if len(lines) == 0: return None words = lines[0].split() if not (len(words) == 4 and words[2] == 'installed'): return None vsn_text = words[3] vsn = split_debian_version(words[3]) return vsn
def current_version(self, pkg): retval, stdout = run2( ["dpkg-query", "-W", "-f=${Status} ${Version}\\n", pkg["name"]], show_command=True) if retval: # Assume it's not installed return None lines = stdout.splitlines() if len(lines) == 0: return None words = lines[0].split() if not (len(words) == 4 and words[2] == 'installed'): return None vsn_text = words[3] vsn = split_debian_version(words[3]) return vsn