From a96ab00afcc1f40c3da89b46121caa4b218bea86 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 7 Mar 2014 18:13:48 +0400 Subject: [PATCH] Verify dependencies with progress. --- cmd/snapshot_pull.go | 2 +- cmd/snapshot_verify.go | 4 +++- debian/list.go | 16 ++++++++++++++-- debian/list_test.go | 14 +++++++------- system/t05_snapshot/VerifySnapshot10Test_gold | 1 + system/t05_snapshot/VerifySnapshot1Test_gold | 1 + system/t05_snapshot/VerifySnapshot3Test_gold | 1 + system/t05_snapshot/VerifySnapshot4Test_gold | 1 + system/t05_snapshot/VerifySnapshot5Test_gold | 1 + system/t05_snapshot/VerifySnapshot6Test_gold | 1 + system/t05_snapshot/VerifySnapshot7Test_gold | 1 + system/t05_snapshot/VerifySnapshot8Test_gold | 1 + system/t05_snapshot/VerifySnapshot9Test_gold | 1 + 13 files changed, 34 insertions(+), 11 deletions(-) diff --git a/cmd/snapshot_pull.go b/cmd/snapshot_pull.go index 30534515..99c42492 100644 --- a/cmd/snapshot_pull.go +++ b/cmd/snapshot_pull.go @@ -127,7 +127,7 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error { pL := debian.NewPackageList() pL.Add(pkg) - missing, err := pL.VerifyDependencies(context.dependencyOptions, []string{arch}, packageList) + missing, err := pL.VerifyDependencies(context.dependencyOptions, []string{arch}, packageList, nil) if err != nil { context.progress.ColoredPrintf("@y[!]@| @!Error while verifying dependencies for pkg %s: %s@|", pkg, err) } diff --git a/cmd/snapshot_verify.go b/cmd/snapshot_verify.go index 773a4be4..a819e654 100644 --- a/cmd/snapshot_verify.go +++ b/cmd/snapshot_verify.go @@ -70,7 +70,9 @@ func aptlySnapshotVerify(cmd *commander.Command, args []string) error { return fmt.Errorf("unable to determine list of architectures, please specify explicitly") } - missing, err := packageList.VerifyDependencies(context.dependencyOptions, architecturesList, sourcePackageList) + context.progress.Printf("Verifying...\n") + + missing, err := packageList.VerifyDependencies(context.dependencyOptions, architecturesList, sourcePackageList, context.progress) if err != nil { return fmt.Errorf("unable to verify dependencies: %s", err) } diff --git a/debian/list.go b/debian/list.go index 2c4fd97c..9d1549ec 100644 --- a/debian/list.go +++ b/debian/list.go @@ -219,13 +219,21 @@ func depSliceDeduplicate(s []Dependency) []Dependency { // VerifyDependencies looks for missing dependencies in package list. // // Analysis would be peformed for each architecture, in specified sources -func (l *PackageList) VerifyDependencies(options int, architectures []string, sources *PackageList) ([]Dependency, error) { +func (l *PackageList) VerifyDependencies(options int, architectures []string, sources *PackageList, progress aptly.Progress) ([]Dependency, error) { missing := make([]Dependency, 0, 128) + if progress != nil { + progress.InitBar(int64(l.Len())*int64(len(architectures)), false) + } + for _, arch := range architectures { cache := make(map[string]bool, 2048) for _, p := range l.packages { + if progress != nil { + progress.AddBar(1) + } + if !p.MatchesArchitecture(arch) { continue } @@ -280,6 +288,10 @@ func (l *PackageList) VerifyDependencies(options int, architectures []string, so } } + if progress != nil { + progress.ShutdownBar() + } + return missing, nil } @@ -404,7 +416,7 @@ func (l *PackageList) Filter(queries []string, withDependencies bool, source *Pa added = 0 // find missing dependencies - missing, err := result.VerifyDependencies(dependencyOptions, architecturesList, dependencySource) + missing, err := result.VerifyDependencies(dependencyOptions, architecturesList, dependencySource, nil) if err != nil { return nil, err } diff --git a/debian/list_test.go b/debian/list_test.go index eab60bc9..c57d8d6d 100644 --- a/debian/list_test.go +++ b/debian/list_test.go @@ -259,19 +259,19 @@ func (s *PackageListSuite) TestFilter(c *C) { } func (s *PackageListSuite) TestVerifyDependencies(c *C) { - missing, err := s.il.VerifyDependencies(0, []string{"i386"}, s.il) + missing, err := s.il.VerifyDependencies(0, []string{"i386"}, s.il, nil) c.Check(err, IsNil) c.Check(missing, DeepEquals, []Dependency{}) - missing, err = s.il.VerifyDependencies(0, []string{"i386", "amd64"}, s.il) + missing, err = s.il.VerifyDependencies(0, []string{"i386", "amd64"}, s.il, nil) c.Check(err, IsNil) c.Check(missing, DeepEquals, []Dependency{Dependency{Pkg: "lib", Relation: VersionGreater, Version: "0.9", Architecture: "amd64"}}) - missing, err = s.il.VerifyDependencies(0, []string{"arm"}, s.il) + missing, err = s.il.VerifyDependencies(0, []string{"arm"}, s.il, nil) c.Check(err, IsNil) c.Check(missing, DeepEquals, []Dependency{}) - missing, err = s.il.VerifyDependencies(DepFollowAllVariants, []string{"arm"}, s.il) + missing, err = s.il.VerifyDependencies(DepFollowAllVariants, []string{"arm"}, s.il, nil) c.Check(err, IsNil) c.Check(missing, DeepEquals, []Dependency{Dependency{Pkg: "lib", Relation: VersionGreater, Version: "0.9", Architecture: "arm"}, Dependency{Pkg: "mail-agent", Relation: VersionDontCare, Version: "", Architecture: "arm"}}) @@ -280,15 +280,15 @@ func (s *PackageListSuite) TestVerifyDependencies(c *C) { s.il.Add(p) } - missing, err = s.il.VerifyDependencies(DepFollowSource, []string{"i386", "amd64"}, s.il) + missing, err = s.il.VerifyDependencies(DepFollowSource, []string{"i386", "amd64"}, s.il, nil) c.Check(err, IsNil) c.Check(missing, DeepEquals, []Dependency{Dependency{Pkg: "lib", Relation: VersionGreater, Version: "0.9", Architecture: "amd64"}}) - missing, err = s.il.VerifyDependencies(DepFollowSource, []string{"arm"}, s.il) + missing, err = s.il.VerifyDependencies(DepFollowSource, []string{"arm"}, s.il, nil) c.Check(err, IsNil) c.Check(missing, DeepEquals, []Dependency{Dependency{Pkg: "libx", Relation: VersionEqual, Version: "1.5", Architecture: "source"}}) - _, err = s.il.VerifyDependencies(0, []string{"i386", "amd64", "s390"}, s.il) + _, err = s.il.VerifyDependencies(0, []string{"i386", "amd64", "s390"}, s.il, nil) c.Check(err, ErrorMatches, "unable to process package app_1.0_s390:.*") } diff --git a/system/t05_snapshot/VerifySnapshot10Test_gold b/system/t05_snapshot/VerifySnapshot10Test_gold index 1cc4a811..711b7254 100644 --- a/system/t05_snapshot/VerifySnapshot10Test_gold +++ b/system/t05_snapshot/VerifySnapshot10Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (11): fenix [amd64] fenix-plugins-system [amd64] diff --git a/system/t05_snapshot/VerifySnapshot1Test_gold b/system/t05_snapshot/VerifySnapshot1Test_gold index 1cc4a811..711b7254 100644 --- a/system/t05_snapshot/VerifySnapshot1Test_gold +++ b/system/t05_snapshot/VerifySnapshot1Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (11): fenix [amd64] fenix-plugins-system [amd64] diff --git a/system/t05_snapshot/VerifySnapshot3Test_gold b/system/t05_snapshot/VerifySnapshot3Test_gold index dd0ababd..1e01856f 100644 --- a/system/t05_snapshot/VerifySnapshot3Test_gold +++ b/system/t05_snapshot/VerifySnapshot3Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (2): kbdcontrol [i386] vidcontrol [i386] diff --git a/system/t05_snapshot/VerifySnapshot4Test_gold b/system/t05_snapshot/VerifySnapshot4Test_gold index 271a4994..620ccc19 100644 --- a/system/t05_snapshot/VerifySnapshot4Test_gold +++ b/system/t05_snapshot/VerifySnapshot4Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (1742): 915resolution [i386] 9fonts [i386] diff --git a/system/t05_snapshot/VerifySnapshot5Test_gold b/system/t05_snapshot/VerifySnapshot5Test_gold index d4d89bd3..6f4c5393 100644 --- a/system/t05_snapshot/VerifySnapshot5Test_gold +++ b/system/t05_snapshot/VerifySnapshot5Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (1622): 915resolution [i386] 9fonts [i386] diff --git a/system/t05_snapshot/VerifySnapshot6Test_gold b/system/t05_snapshot/VerifySnapshot6Test_gold index 9dc6b800..0cd55905 100644 --- a/system/t05_snapshot/VerifySnapshot6Test_gold +++ b/system/t05_snapshot/VerifySnapshot6Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (3797): 915resolution [amd64] 915resolution [i386] diff --git a/system/t05_snapshot/VerifySnapshot7Test_gold b/system/t05_snapshot/VerifySnapshot7Test_gold index b8a91254..350f583f 100644 --- a/system/t05_snapshot/VerifySnapshot7Test_gold +++ b/system/t05_snapshot/VerifySnapshot7Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (673): abrowser [amd64] abrowser [i386] diff --git a/system/t05_snapshot/VerifySnapshot8Test_gold b/system/t05_snapshot/VerifySnapshot8Test_gold index 1c4a2835..16c7c3a4 100644 --- a/system/t05_snapshot/VerifySnapshot8Test_gold +++ b/system/t05_snapshot/VerifySnapshot8Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (32): dpkg (>= 1.15.4) [amd64] dpkg (>= 1.15.4) [i386] diff --git a/system/t05_snapshot/VerifySnapshot9Test_gold b/system/t05_snapshot/VerifySnapshot9Test_gold index f3cac258..6bccc866 100644 --- a/system/t05_snapshot/VerifySnapshot9Test_gold +++ b/system/t05_snapshot/VerifySnapshot9Test_gold @@ -1,4 +1,5 @@ Loading packages... +Verifying... Missing dependencies (30): dpkg (>= 1.15.4) [amd64] dpkg (>= 1.15.4) [i386]