433
433
"It is expected to be a tuple containing only another "
434
434
"tuple with 3 elements (name, version, relation)."
435
435
% (token, self.title, self.id, self.dependencies))
436
# Map relations to the canonical form used in control files.
439
elif relation == '>':
441
436
return (name, version, relation)
443
438
def _checkDependencyVersion(self, available, required, relation):
444
439
"""Return True if the available version satisfies the context."""
445
440
# This dict maps the package version relationship syntax in lambda
446
441
# functions which returns boolean according the results of
447
# apt_pkg.version_compare function (see the order above).
442
# apt_pkg.VersionCompare function (see the order above).
448
443
# For further information about pkg relationship syntax see:
450
445
# http://www.debian.org/doc/debian-policy/ch-relationships.html
468
463
# it behaves similar to cmp, i.e. returns negative
469
464
# if first < second, zero if first == second and
470
465
# positive if first > second.
471
dep_result = apt_pkg.version_compare(available, required)
466
dep_result = apt_pkg.VersionCompare(available, required)
473
468
return version_relation_map[relation](dep_result)
505
500
def updateDependencies(self):
506
501
"""See `IBuild`."""
508
# apt_pkg requires init_system to get version_compare working
510
apt_pkg.init_system()
503
# apt_pkg requires InitSystem to get VersionCompare working properly.
512
506
# Check package build dependencies using apt_pkg
514
parsed_deps = apt_pkg.parse_depends(self.dependencies)
508
parsed_deps = apt_pkg.ParseDepends(self.dependencies)
515
509
except (ValueError, TypeError):
516
510
raise UnparsableDependencies(
517
511
"Build dependencies for %s (%s) could not be parsed: '%s'\n"
872
866
return resulting_tuple[0]
874
def preloadBuildsData(self, builds):
876
from lp.soyuz.model.distroarchseries import (
879
from lp.registry.model.distroseries import (
882
from lp.registry.model.distribution import (
885
from lp.soyuz.model.archive import Archive
886
from lp.registry.model.person import Person
887
self._prefetchBuildData(builds)
888
distro_arch_series = load_related(
889
DistroArchSeries, builds, ['distro_arch_series_id'])
890
package_builds = load_related(
891
PackageBuild, builds, ['package_build_id'])
892
archives = load_related(Archive, package_builds, ['archive_id'])
893
load_related(Person, archives, ['ownerID'])
894
distroseries = load_related(
895
DistroSeries, distro_arch_series, ['distroseriesID'])
897
Distribution, distroseries, ['distributionID'])
899
868
def getByBuildFarmJobs(self, build_farm_jobs):
900
869
"""See `ISpecificBuildFarmJobSource`."""
901
870
if len(build_farm_jobs) == 0:
904
873
build_farm_job_ids = [
905
874
build_farm_job.id for build_farm_job in build_farm_jobs]
876
def eager_load(rows):
878
from lp.soyuz.model.distroarchseries import (
881
from lp.registry.model.distroseries import (
884
from lp.registry.model.distribution import (
887
from lp.soyuz.model.archive import Archive
888
from lp.registry.model.person import Person
889
self._prefetchBuildData(rows)
890
distro_arch_series = load_related(
891
DistroArchSeries, rows, ['distro_arch_series_id'])
892
package_builds = load_related(
893
PackageBuild, rows, ['package_build_id'])
894
archives = load_related(Archive, package_builds, ['archive_id'])
895
load_related(Person, archives, ['ownerID'])
896
distroseries = load_related(
897
DistroSeries, distro_arch_series, ['distroseriesID'])
899
Distribution, distroseries, ['distributionID'])
907
900
resultset = Store.of(build_farm_jobs[0]).using(*clause_tables).find(
908
901
BinaryPackageBuild,
909
902
BinaryPackageBuild.package_build == PackageBuild.id,
910
903
PackageBuild.build_farm_job == BuildFarmJob.id,
911
904
BuildFarmJob.id.is_in(build_farm_job_ids))
912
return DecoratedResultSet(
913
resultset, pre_iter_hook=self.preloadBuildsData)
905
return DecoratedResultSet(resultset, pre_iter_hook=eager_load)
915
907
def getPendingBuildsForArchSet(self, archseries):
916
908
"""See `IBinaryPackageBuildSet`."""