Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
1c49ed7
feat: support multiple archives with "priority" field
May 13, 2024
fc45267
feat: support "pro" keyword in archives
May 28, 2024
0099462
feat: support fetching packages from Pro archives
May 29, 2024
cfe740b
Merge "feat/multiple-archives" into this branch
Aug 6, 2024
7b0e273
Merge remote-tracking branch 'upstream/main'
Aug 6, 2024
d1bafd9
fix: export ProValue and errors on invalid pro values
Aug 7, 2024
6479279
fix: remove redundant type, map and function
Aug 7, 2024
cd3dd75
doc: update comment for archiveURL
Aug 7, 2024
f23cca6
fix: warn on invalid archive pro value, no errors
Aug 8, 2024
5c676fc
refactor: archive baseURL selection
Aug 8, 2024
025acda
fix: log pro value with archive label
Aug 8, 2024
706941e
fix: remove ProNone value, use ""
Aug 8, 2024
6d15dd1
fix: do not fetch index if arch is unsupported
Aug 8, 2024
6031926
fix: add warnings when ignoring archive suite/component
Aug 9, 2024
a0948d0
test(spread): add test for pro archives
Aug 9, 2024
c2753a5
test: refactor real archive tests
Aug 13, 2024
c1f44d9
feat: add gpg keys for fips, esm-apps, esm-infra
Aug 13, 2024
f84e257
test: real archive tests for Ubuntu Pro archives
Aug 13, 2024
64d1e74
feat: support multiple archives with "priority" field (#12)
Oct 3, 2024
82587f6
Merge branch 'main' into multiple-archive-support
letFunny Oct 7, 2024
74c5851
Merge branch 'multiple-archive-support' into feat/pro-archives
Oct 8, 2024
3af0bf1
refactor(archive): minor changes, add (real-archive) tests
Oct 9, 2024
7b7bc28
refactor: move "empty archives list" check to slicer
Oct 9, 2024
ec16375
test(archive): use proper pkg in real archive test
Oct 9, 2024
a4d9407
test(archive): add more real pro archives test
Oct 9, 2024
49b84a0
ci: add workflow job to run pro archive tests
Oct 9, 2024
80ea7b2
ci: fix permissions to run the real archive tests
Oct 9, 2024
39c3023
Merge branch 'main' into multiple-archive-support
letFunny Oct 14, 2024
a19c876
more descriptive variable name
letFunny Oct 14, 2024
bb18527
pkgToArchive -> pkgArchive
letFunny Oct 14, 2024
e634cff
doc: add proper comments about arch support of ports
Oct 15, 2024
374acb2
test: user gocheck idiomatically
Oct 15, 2024
3289ac7
doc: nitpick: use spaces instead of tabs in comments
Oct 15, 2024
607d097
test(archive): s/binPath/path
Oct 15, 2024
6cb7775
fix: use quotes to log invalid pro value
Oct 15, 2024
69ebee4
test(setup): edit test summary
Oct 15, 2024
3ba9566
test(setup): rename ignored archive to "ignored"
Oct 15, 2024
abbd9d8
Merge remote-tracking branch 'letfunny/multiple-archive-support'
Oct 15, 2024
dd75c92
refactor: move logic up in archive
Oct 15, 2024
a8cdd86
respect default archive if priorities not being used
letFunny Oct 15, 2024
40d0867
simplify for loop, unnecessary variable
letFunny Oct 15, 2024
2315cf7
Merge remote branch 'letfunny/multiple-archive-support'
Oct 15, 2024
1928bd8
test(archive): no copyright check in real archive tests
Oct 15, 2024
9c22dfd
test(archive): use table tests in TestArchiveLabels
Oct 15, 2024
49e1abf
test: add fips real archive test
Oct 15, 2024
fdf812a
chore: use focal to run real archive tests
Oct 15, 2024
5a260b3
chore: use sudo to write to apt creds file
Oct 15, 2024
7d1e3f0
remove unnecessary bool flag
letFunny Oct 16, 2024
1183226
make tests deterministic
letFunny Oct 16, 2024
bb5f58b
make more tests deterministic
letFunny Oct 16, 2024
44dcaaa
doc: use spaces to align in comments
Oct 16, 2024
94e7fe5
doc: add notes in README about the support of Pro
Oct 16, 2024
2554170
test(archive): add a Pro archive test with bad creds
Oct 16, 2024
3ff090d
snap: add pro credentials access plug
Oct 16, 2024
68206e5
fix(archive): change error message for 401 response
Oct 16, 2024
0ee1deb
doc: update README text per suggestion
Oct 16, 2024
7ff02ac
test(archive): remove useless test
Oct 16, 2024
47c92d9
fix: use archive name in error messages instead of URL
Oct 16, 2024
ebb60d1
Merge remote-tracking branch 'letfunny/multiple-archive-support'
Oct 17, 2024
db539fd
fix(slicer): keep uniform error msg for no valid archives
Oct 17, 2024
334d55a
fix(archive): update 401 response error message
Oct 17, 2024
2608ee3
fix(archive): validate pro value when opening archive
Oct 17, 2024
15d0805
fix(archive): tweak the invalid pro value error msg
Oct 17, 2024
39fd79d
Revert "fix(archive): tweak the invalid pro value error msg"
Oct 17, 2024
6e14e4e
snap: keep using go 1.21 to build chisel
Oct 17, 2024
2471a67
fix: address Alberto's comments
Oct 17, 2024
2188322
docs: remove double space
Oct 18, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
go-version: '>=1.17.0'

- name: Build and run spread
env:
PRO_TOKEN: ${{ secrets.PRO_TOKEN }}
run: |
(cd _spread/cmd/spread && go build)
_spread/cmd/spread/spread -v focal jammy mantic noble
43 changes: 43 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,46 @@ jobs:
with:
name: chisel-test-coverage.html
path: ./*.html

real-archive-tests:
# Do not change to newer releases as "fips" may not be available there.
runs-on: ubuntu-20.04
name: Real Archive Tests
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'

- name: Run real archive tests
env:
PRO_TOKEN: ${{ secrets.PRO_TOKEN }}
run: |
set -ex

detach() {
sudo pro detach --assume-yes || true
sudo rm -f /etc/apt/auth.conf.d/90ubuntu-advantage
}
trap detach EXIT

# Attach pro token and enable services
sudo pro attach ${PRO_TOKEN} --no-auto-enable

# Cannot enable fips and fips-updates at the same time.
# Hack: enable fips, copy the credentials and then after enabling
# other services, add the credentials back.
sudo pro enable fips --assume-yes
sudo cp /etc/apt/auth.conf.d/90ubuntu-advantage /etc/apt/auth.conf.d/90ubuntu-advantage.fips-creds
# This will disable the fips service.
sudo pro enable fips-updates esm-apps esm-infra --assume-yes
# Add the fips credentials back.
sudo sh -c 'cat /etc/apt/auth.conf.d/90ubuntu-advantage.fips-creds >> /etc/apt/auth.conf.d/90ubuntu-advantage'
sudo rm /etc/apt/auth.conf.d/90ubuntu-advantage.fips-creds

# Make apt credentials accessible to USER.
sudo setfacl -m u:$USER:r /etc/apt/auth.conf.d/90ubuntu-advantage

# Run tests on Pro and non-Pro real archives.
go test ./internal/archive/ -v --real-archive --real-pro-archive
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,48 @@ provided packages and install only the desired slices into the *myrootfs*
folder, according to the slice definitions available in the
["ubuntu-22.04" chisel-releases branch](<https://github.com/canonical/chisel-releases/tree/ubuntu-22.04>).

## Chisel support for Pro archives

Chisel can also fetch and install packages from Ubuntu Pro archives. For this,
the archive has to be defined with the `archives.<archive>.pro` field in
chisel.yaml and its credentials have to be made available to Chisel.


```yaml
# chisel.yaml
format: v1
archives:
<archive-name>:
pro: <value>
...
...
```

Chisel currently supports the following Pro archives:

| `pro` value | Archive URL | Related Ubuntu Pro service |
| - | - | - |
| fips | https://esm.ubuntu.com/fips/ubuntu | fips |
| fips-updates | https://esm.ubuntu.com/fips-updates/ubuntu | fips-updates |
| apps | https://esm.ubuntu.com/apps/ubuntu | esm-apps |
| infra | https://esm.ubuntu.com/infra/ubuntu | esm-infra |

Authentication to Pro archives requires that the host is Pro or it is equipped
with the Pro credentials. By default, Chisel will support using credentials
from the `/etc/apt/auth.conf.d/` directory, but this location can be configured
using the environment variable `CHISEL_AUTH_DIR`. Note that Chisel must have
read permission for the necessary credentials files.

The format of the files is documented in the
[apt_auth.conf(5)](https://manpages.debian.org/testing/apt/apt_auth.conf.5.en.html)
man page. Below is a snippet of the `/etc/apt/auth.conf.d/90ubuntu-advantage`
file from a host with the `fips-updates` and `infra` archives enabled:

```
machine esm.ubuntu.com/infra/ubuntu/ login bearer password <infra-token>
machine esm.ubuntu.com/fips-updates/ubuntu/ login bearer password <fips-updates-token>
```

## Reference

### Chisel releases
Expand Down
5 changes: 5 additions & 0 deletions cmd/chisel/cmd_cut.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ func (cmd *cmdCut) Execute(args []string) error {
Arch: cmd.Arch,
Suites: archiveInfo.Suites,
Components: archiveInfo.Components,
Pro: archiveInfo.Pro,
CacheDir: cache.DefaultDir("chisel"),
PubKeys: archiveInfo.PubKeys,
})
if err != nil {
if err == archive.ErrCredentialsNotFound {
logf("Ignoring archive %q (credentials not found)...", archiveName)
continue
}
return err
}
archives[archiveName] = openArchive
Expand Down
2 changes: 0 additions & 2 deletions cmd/chisel/cmd_find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ func makeSamplePackage(pkg string, slices []string) *setup.Package {
}

var sampleRelease = &setup.Release{
DefaultArchive: "ubuntu",

Archives: map[string]*setup.Archive{
"ubuntu": {
Name: "ubuntu",
Expand Down
8 changes: 0 additions & 8 deletions cmd/chisel/cmd_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var infoTests = []infoTest{{
query: []string{"mypkg1_myslice1"},
stdout: `
package: mypkg1
archive: ubuntu
slices:
myslice1:
contents:
Expand All @@ -37,7 +36,6 @@ var infoTests = []infoTest{{
query: []string{"mypkg2"},
stdout: `
package: mypkg2
archive: ubuntu
slices:
myslice:
contents:
Expand All @@ -49,7 +47,6 @@ var infoTests = []infoTest{{
query: []string{"mypkg1_myslice2", "mypkg1_myslice1"},
stdout: `
package: mypkg1
archive: ubuntu
slices:
myslice1:
contents:
Expand All @@ -65,7 +62,6 @@ var infoTests = []infoTest{{
query: []string{"mypkg1_myslice1", "mypkg2", "mypkg1_myslice2"},
stdout: `
package: mypkg1
archive: ubuntu
slices:
myslice1:
contents:
Expand All @@ -76,7 +72,6 @@ var infoTests = []infoTest{{
- mypkg2_myslice
---
package: mypkg2
archive: ubuntu
slices:
myslice:
contents:
Expand All @@ -88,7 +83,6 @@ var infoTests = []infoTest{{
query: []string{"mypkg1_myslice1", "mypkg1"},
stdout: `
package: mypkg1
archive: ubuntu
slices:
myslice1:
contents:
Expand All @@ -104,7 +98,6 @@ var infoTests = []infoTest{{
query: []string{"mypkg1_myslice1", "mypkg1_myslice1", "mypkg1_myslice1"},
stdout: `
package: mypkg1
archive: ubuntu
slices:
myslice1:
contents:
Expand All @@ -121,7 +114,6 @@ var infoTests = []infoTest{{
query: []string{"foo", "mypkg1_myslice1", "bar_foo"},
stdout: `
package: mypkg1
archive: ubuntu
slices:
myslice1:
contents:
Expand Down
1 change: 1 addition & 0 deletions cmd/chisel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ func run() error {
deb.SetLogger(log.Default())
setup.SetLogger(log.Default())
slicer.SetLogger(log.Default())
SetLogger(log.Default())

parser := Parser()
xtra, err := parser.Parse()
Expand Down
Loading