Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
df532f7
feat: support bin packages parsing
upils May 27, 2026
f3a58a6
fix: correct style fix
upils May 27, 2026
daf5a71
fix: lint
upils May 27, 2026
633b0e1
ci: rerun
upils May 28, 2026
6fd3d1c
fix: fully qualified slice names
upils May 29, 2026
b68da53
style: rename to avoid confusion
upils Jun 1, 2026
8494876
fix: start renaming to realname
upils Jun 2, 2026
510d4cd
fix: more renaming/refactoring
upils Jun 2, 2026
2eb88e0
fix: more renaming
upils Jun 2, 2026
74ee585
fix: improve name displayed
upils Jun 2, 2026
3cab6a3
fix: refine naming
upils Jun 2, 2026
d86b9f9
fix: add missing check on format
upils Jun 2, 2026
1cda0ff
fix: remove pkgDefaultPrefix
upils Jun 2, 2026
267c6a3
fix: consistent use of pkg.RealName
upils Jun 2, 2026
619e0ec
fix: more name tweaking
upils Jun 2, 2026
952e929
fix: correct involontary lint fixes
upils Jun 2, 2026
fb4d6e5
fix: revert accidental linting fixes
upils Jun 15, 2026
ffc5aaf
style: harmonize names
upils Jun 15, 2026
d214000
feat: revert approach
upils Jun 16, 2026
8e8aef0
refactor: more cleaning
upils Jun 16, 2026
e7357d3
fix: review
upils Jun 16, 2026
27e2709
fix: ensure store is defined when parsing
upils Jun 17, 2026
6d19749
fix: properly fill returned pkgs when searching
upils Jun 17, 2026
824c002
style: lint
upils Jun 17, 2026
7358c94
fix: filter store pkgs out of the selection for now
upils Jun 17, 2026
be67dbd
fix: check store kind is known
upils Jun 17, 2026
22050d4
fix: use bin value for kind in tests
upils Jun 17, 2026
2e69156
style: add missing period
upils Jun 17, 2026
ed9e923
fix: review
upils Jun 19, 2026
65771cb
tests: integrate v3 tests to common table
upils Jun 19, 2026
d929e92
fix: check store kind when slices used
upils Jun 19, 2026
867fcff
docs: clarify reason for temp arch filling
upils Jun 19, 2026
33fc4ca
fix: apply review comments
upils Jun 22, 2026
c2be41a
fx: clearly fail if store packages are found for now
upils Jun 22, 2026
a816047
fix: remove wrong field
upils Jun 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cmd/chisel/cmd_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ func selectPackageSlices(release *setup.Release, queries []string) (packages []*
} else {
releasePkg := release.Packages[pkgName]
pkg = &setup.Package{
Name: releasePkg.Name,
Archive: releasePkg.Archive,
Slices: make(map[string]*setup.Slice),
Name: releasePkg.Name,
RealName: releasePkg.RealName,
Archive: releasePkg.Archive,
Store: releasePkg.Store,
DefaultTrack: releasePkg.DefaultTrack,
Slices: make(map[string]*setup.Slice),
}
for _, sliceName := range pkgSlices[pkgName] {
pkg.Slices[sliceName] = releasePkg.Slices[sliceName]
Expand Down
46 changes: 38 additions & 8 deletions internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ import (
"github.com/canonical/chisel/internal/strdist"
)

// Store is the location from which packages are obtained via a store API.
type Store struct {
Name string
Kind string
Version string
DefaultPrefix string
}

// Release is a collection of package slices targeting a particular
// distribution version.
type Release struct {
Format string
Path string
Packages map[string]*Package
Archives map[string]*Archive
Stores map[string]*Store
Maintenance *Maintenance
}

Expand Down Expand Up @@ -51,10 +60,16 @@ type Archive struct {

// Package holds a collection of slices that represent parts of themselves.
type Package struct {
Name string
Path string
Archive string
Slices map[string]*Slice
// Name is the unique package identifier (e.g. "bin-curl" for store packages,
// "curl" for archive packages).
Name string
// RealName is the bare name visible in the Debian archive (e.g. "curl").
RealName string
Path string
Archive string
Store string
DefaultTrack string
Slices map[string]*Slice
}

// Slice holds the details about a package slice.
Expand Down Expand Up @@ -441,20 +456,20 @@ func readSlices(release *Release, baseDir, dirName string) error {

pkgName := match[1]
pkgPath := filepath.Join(dirName, entry.Name())
if pkg, ok := release.Packages[pkgName]; ok {
return fmt.Errorf("package %q slices defined more than once: %s and %s", pkgName, pkg.Path, stripBase(baseDir, pkgPath))
}
data, err := os.ReadFile(pkgPath)
if err != nil {
// Errors from package os generally include the path.
return fmt.Errorf("cannot read slice definition file: %v", err)
}

pkg, err := parsePackage(release.Format, pkgName, stripBase(baseDir, pkgPath), data)
pkg, err := parsePackage(release, pkgName, stripBase(baseDir, pkgPath), data)
if err != nil {
return err
}

if existing, ok := release.Packages[pkg.Name]; ok {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Note to reviewer]: Before the package parsing we only have the real name. So this check can now only be done after the package parsing because we need the package name.

return fmt.Errorf("package %q slices defined more than once: %s and %s", pkg.Name, existing.Path, stripBase(baseDir, pkgPath))
}
release.Packages[pkg.Name] = pkg
}
return nil
Expand Down Expand Up @@ -502,6 +517,21 @@ func Select(release *Release, slices []SliceKey, arch string) (*Selection, error
new, newPath, newInfo.Generate)
}
}
// An invalid store kind should only throw an error if a slice references it.
// Hence, the check is here.
pkg := release.Packages[new.Package]
if pkg.Store == "" {
continue
}
store, ok := selection.Release.Stores[pkg.Store]
if !ok {
return nil, fmt.Errorf("internal error: slice %s refers to missing store %q", new, pkg.Store)
}
switch store.Kind {
case "bin":
default:
return nil, fmt.Errorf("slice %s refers to store %q with unknown kind %q", new, pkg.Store, store.Kind)
}
}

return selection, nil
Expand Down
Loading
Loading