def is_correct_pigz_version(): ver = System.execute('pigz --version')[0][5:] logger.debug('Detected pigz version: %s' % (ver, )) versionMatches = compareVersions(ver, '>=', '2.2.3') logger.debug('pigz version is compatible? %s' % (versionMatches)) return versionMatches
def checkDependencies(self, productPackageFile): for dependency in productPackageFile.packageControlFile.getPackageDependencies( ): productOnDepots = self._depotBackend._context.productOnDepot_getObjects( depotId=self._depotBackend._depotId, productId=dependency['package']) if not productOnDepots: raise BackendUnaccomplishableError( u"Dependent package '%s' not installed" % dependency['package']) if not dependency['version']: logger.info(u"Fulfilled product dependency '%s'" % dependency) continue productOnDepot = productOnDepots[0] availableVersion = productOnDepot.getProductVersion( ) + u'-' + productOnDepot.getPackageVersion() if compareVersions(availableVersion, dependency['condition'], dependency['version']): logger.info( u"Fulfilled package dependency %s (available version: %s)" % (dependency, availableVersion)) else: raise BackendUnaccomplishableError( u"Unfulfilled package dependency %s (available version: %s)" % (dependency, availableVersion))
def getUpdatablePackages(updater): """ Returns information about updatable packages from the given `updater`. :raises NoActiveRepositoryError: If not active repositories are found. :param updater: The update to use. :type updater: OpsiPackageUpdater :returns: A dict containing the productId as key and the value is \ another dict with the keys _productId_, _newVersion_, _oldVersion_ and \ _repository_. :rtype: {str: {} """ if not any(updater.getActiveRepositories()): raise NoActiveRepositoryError("No active repository configured.") updates = {} try: installedProducts = updater.getInstalledProducts() downloadablePackages = updater.getDownloadablePackages() downloadablePackages = updater.onlyNewestPackages(downloadablePackages) downloadablePackages = updater._filterProducts(downloadablePackages) for availablePackage in downloadablePackages: productId = availablePackage['productId'] for product in installedProducts: if product['productId'] == productId: logger.debug(u"Product '%s' is installed" % productId) logger.debug( u"Available product version is '%s', installed product version is '%s-%s'" % (availablePackage['version'], product['productVersion'], product['packageVersion'])) updateAvailable = compareVersions( availablePackage['version'], '>', '%s-%s' % (product['productVersion'], product['packageVersion'])) if updateAvailable: updates[productId] = { "productId": productId, "newVersion": "{version}".format(**availablePackage), "oldVersion": "{productVersion}-{packageVersion}".format( **product), "repository": availablePackage['repository'].name } break except Exception as error: raise error return updates
def testPackageVersionsAreComparedAswell(v1, operator, v2): assert compareVersions(v1, operator, v2)
def testComparisonsWithDifferntDepthsAreMadeTheSameDepth(v1, operator, v2): assert compareVersions(v1, operator, v2)
def testComparingWorksWithLettersInVersionString(v1, operator, v2): assert compareVersions(v1, operator, v2)
def testUsingInvalidVersionStringsFails(v1, operator, v2): with pytest.raises(ValueError): compareVersions(v1, operator, v2)
def testIgnoringVersionsWithWaveInThem(v1, operator, v2): assert compareVersions(v1, operator, v2)
def testUsingUnknownOperatorFails(operator): with pytest.raises(ValueError): compareVersions('1', operator, '2')
def testComparingWithOnlyOneEqualitySign(): assert compareVersions('1.0', '=', '1.0')
def testComparingWithoutGivingOperatorDefaultsToEqual(v1, operator, v2): assert compareVersions(v1, operator, v2)
def testComparingVersionsOfSameSize(first, operator, second): assert compareVersions(first, operator, second)