diff --git a/testdata/arch/arch.tar.gz b/testdata/arch/arch.tar.gz new file mode 100644 index 00000000..fb9ca46c Binary files /dev/null and b/testdata/arch/arch.tar.gz differ diff --git a/testdata/arch/arch2.tar.gz b/testdata/arch/arch2.tar.gz new file mode 100644 index 00000000..f715bb8b Binary files /dev/null and b/testdata/arch/arch2.tar.gz differ diff --git a/testdata/arch/arch3.tar.gz b/testdata/arch/arch3.tar.gz new file mode 100644 index 00000000..5570b144 Binary files /dev/null and b/testdata/arch/arch3.tar.gz differ diff --git a/testdata/arch/blank.tar.gz b/testdata/arch/blank.tar.gz new file mode 100644 index 00000000..231a8d13 Binary files /dev/null and b/testdata/arch/blank.tar.gz differ diff --git a/worker.go b/worker.go index a9c82762..ae00a167 100644 --- a/worker.go +++ b/worker.go @@ -510,6 +510,15 @@ func computeAncestryFeatures(ancestryLayers []database.LayerWithContent) ([]data // all detectable features removed is to pass in the file status. for vf, mapF := range currentFeatures { features[vf] = mapF + /* + // FIXME: Arch Linux installed packages are a list of directories + if len(features[vf]) == 0 { + features[vf] = make(map[string]database.NamespacedFeature) + } + for k, f := range mapF { + features[vf][k] = f + } + */ } } diff --git a/worker_test.go b/worker_test.go index 5f6e0ff4..b0e0bbeb 100644 --- a/worker_test.go +++ b/worker_test.go @@ -30,6 +30,7 @@ import ( "github.com/coreos/clair/pkg/strutil" // Register the required detectors. + _ "github.com/coreos/clair/ext/featurefmt/alpm" _ "github.com/coreos/clair/ext/featurefmt/dpkg" _ "github.com/coreos/clair/ext/featurefmt/rpm" _ "github.com/coreos/clair/ext/featurens/aptsources" @@ -337,7 +338,7 @@ func TestProcessAncestryWithDistUpgrade(t *testing.T) { nonUpgradedMap := map[database.Feature]struct{}{} for _, f := range nonUpgradedFeatures { - f.VersionFormat = "dpkg" + f.VersionFormat = dpkg.ParserName nonUpgradedMap[f] = struct{}{} } @@ -435,6 +436,36 @@ func TestProcessLayers(t *testing.T) { } } +func TestProcessArchLayers(t *testing.T) { + _, f, _, _ := runtime.Caller(0) + testDataPath := filepath.Join(filepath.Dir(f)) + "/testdata/arch/" + + datastore := newMockDatastore() + + // suppose there are multiple arch layers + layers := []LayerRequest{ + {Hash: "blank", Path: testDataPath + "blank.tar.gz"}, + {Hash: "arch", Path: testDataPath + "arch.tar.gz"}, + {Hash: "arch2", Path: testDataPath + "arch2.tar.gz"}, + {Hash: "arch3", Path: testDataPath + "arch3.tar.gz"}, + } + + Processors = database.Processors{ + Detectors: []string{"os-release"}, + Listers: []string{"alpm"}, + } + + assert.Nil(t, ProcessAncestry(datastore, "Docker", "Mock", layers)) + assert.Len(t, datastore.ancestry["Mock"].Features, 6) + + // check the namespaces are correct + for _, f := range datastore.ancestry["Mock"].Features { + if !assert.NotEqual(t, database.Namespace{}, f.Namespace) { + assert.Fail(t, "Every feature should have a namespace attached") + } + } +} + // TestUpgradeClair checks if a clair is upgraded and certain ancestry's // features should not change. We assume that Clair should only upgrade func TestClairUpgrade(t *testing.T) {