allow ability to catalog packages from /var/lib/dpkg/status.d/

Some debian-based variants (such as Google's Distroless images)
don't write a single file to `/var/lib/dpkg/status`, but rather write
a file per package to `/var/lib/dpkg/status.d/`

related to #44

Signed-off-by: Weston Steimel <weston.steimel@gmail.com>
This commit is contained in:
Weston Steimel 2021-02-21 01:45:10 +00:00
parent 40e9c4b146
commit b963be219b
No known key found for this signature in database
GPG Key ID: 61849329106F14D6
2 changed files with 5 additions and 2 deletions

View File

@ -38,6 +38,7 @@ func (c *Cataloger) Catalog(resolver source.Resolver) ([]pkg.Package, error) {
return nil, fmt.Errorf("failed to find dpkg status files's by glob: %w", err) return nil, fmt.Errorf("failed to find dpkg status files's by glob: %w", err)
} }
var results []pkg.Package
var pkgs []pkg.Package var pkgs []pkg.Package
for _, dbLocation := range dbFileMatches { for _, dbLocation := range dbFileMatches {
dbContents, err := resolver.FileContentsByLocation(dbLocation) dbContents, err := resolver.FileContentsByLocation(dbLocation)
@ -94,8 +95,10 @@ func (c *Cataloger) Catalog(resolver source.Resolver) ([]pkg.Package, error) {
} }
} }
} }
results = append(results, pkgs...)
} }
return pkgs, nil return results, nil
} }
func fetchMd5Contents(resolver source.Resolver, dbLocation source.Location, pkgs []pkg.Package) (map[string]io.Reader, map[string]source.Location, error) { func fetchMd5Contents(resolver source.Resolver, dbLocation source.Location, pkgs []pkg.Package) (map[string]io.Reader, map[string]source.Location, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/scylladb/go-set/strset" "github.com/scylladb/go-set/strset"
) )
const DpkgDbGlob = "**/var/lib/dpkg/status" const DpkgDbGlob = "**/var/lib/dpkg/{status,status.d/**}"
var _ fileOwner = (*DpkgMetadata)(nil) var _ fileOwner = (*DpkgMetadata)(nil)