def _check_existence(self, name): """ For regexp names: If only part of packages were installed during early canceling. Let's say: 1. install hbase_2_3_* 2. Only hbase_2_3_1234 is installed, but is not hbase_2_3_1234_regionserver yet. 3. We cancel the yum In that case this is bug of packages we require. And hbase_2_3_*_regionserver should be added to metainfo.xml. Checking existence should never fail in such a case for hbase_2_3_*, otherwise it gonna break things like removing packages and some others. Note: this method SHOULD NOT use yum directly (yum.rpmdb doesn't use it). Because a lot of issues we have, when customer have yum in inconsistant state (locked, used, having invalid repo). Once packages are installed we should not rely on that. """ import yum # Python Yum API is much faster then other check methods. (even then "import rpm") yb = yum.YumBase() name_regex = re.escape(name).replace("\\?", ".").replace("\\*", ".*") + '$' regex = re.compile(name_regex) with suppress_stdout(): package_list = yb.rpmdb.simplePkgList() for package in package_list: if regex.match(package[0]): return True return False
def yum_check_package_available(self, name): """ Does the same as rpm_check_package_avaiable, but faster. However need root permissions. """ import yum # Python Yum API is much faster then other check methods. (even then "import rpm") yb = yum.YumBase() name_regex = re.escape(name).replace("\\?", ".").replace("\\*", ".*") + '$' regex = re.compile(name_regex) with suppress_stdout(): package_list = yb.rpmdb.simplePkgList() for package in package_list: if regex.match(package[0]): return True return False
def yum_check_package_available(self, name): """ Does the same as rpm_check_package_avaiable, but faster. However need root permissions. """ import yum # Python Yum API is much faster then other check methods. (even then "import rpm") yb = yum.YumBase() name_regex = re.escape(name).replace("\\?", ".").replace("\\*", ".*") + '$' regex = re.compile(name_regex) with suppress_stdout(): package_list = yb.rpmdb.simplePkgList() for package in package_list: if regex.match(package[0]): return True return False