Skip to content

Commit e997d4f

Browse files
authored
feat(erofs): initial commit for erofs support (#626)
* feat: add support for erofs layers - atomfs has added support for additional filesystem types such as erofs. * fix: use atomfs v1.2.0 * ci: use our own cached images instead of upstream Signed-off-by: Ramkumar Chinchani <[email protected]>
1 parent c34ba3a commit e997d4f

File tree

16 files changed

+236
-48
lines changed

16 files changed

+236
-48
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
echo "running kernel is: $(uname -a)"
7171
- name: docker-clone
7272
run: |
73-
make docker-clone "STACKER_DOCKER_BASE=docker://" CLONE_D="$PWD/.build/oci-clone"
73+
make docker-clone "STACKER_DOCKER_BASE=docker://ghcr.io/project-stacker/" CLONE_D="$PWD/.build/oci-clone"
7474
- name: Go-download
7575
run: |
7676
make go-download

.github/workflows/coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ on:
3232

3333
jobs:
3434
build:
35-
runs-on: ubuntu-22.04
35+
runs-on: ubuntu-24.04
3636
services:
3737
registry:
3838
image: ghcr.io/project-stacker/registry:2
@@ -71,7 +71,7 @@ jobs:
7171
echo "running kernel is: $(uname -a)"
7272
- name: docker-clone
7373
run: |
74-
make docker-clone "STACKER_DOCKER_BASE=docker://" CLONE_D="$PWD/.build/oci-clone"
74+
make docker-clone "STACKER_DOCKER_BASE=docker://ghcr.io/project-stacker/" CLONE_D="$PWD/.build/oci-clone"
7575
- name: Go-download
7676
run: |
7777
make go-download

cmd/stacker/build.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55

66
cli "github.com/urfave/cli/v2"
7-
"machinerun.io/atomfs/squashfs"
7+
"machinerun.io/atomfs/pkg/verity"
88
"stackerbuild.io/stacker/pkg/stacker"
99
"stackerbuild.io/stacker/pkg/types"
1010
)
@@ -52,12 +52,13 @@ func initCommonBuildFlags() []cli.Flag {
5252
},
5353
&cli.StringSliceFlag{
5454
Name: "layer-type",
55-
Usage: "set the output layer type (supported values: tar, squashfs); can be supplied multiple times",
55+
Usage: "set the output layer type (supported values: tar, squashfs, erofs); can be supplied multiple times",
5656
Value: cli.NewStringSlice("tar"),
5757
},
5858
&cli.BoolFlag{
59-
Name: "no-squashfs-verity",
60-
Usage: "do not append dm-verity data to squashfs archives",
59+
Name: "no-verity",
60+
Usage: "do not append dm-verity data to fs archives",
61+
Aliases: []string{"no-squashfs-verity"},
6162
},
6263
&cli.BoolFlag{
6364
Name: "require-hash",
@@ -103,7 +104,7 @@ func newBuildArgs(ctx *cli.Context) (stacker.BuildArgs, error) {
103104
AnnotationsNamespace: ctx.String("annotations-namespace"),
104105
}
105106
var err error
106-
verity := squashfs.VerityMetadata(!ctx.Bool("no-squashfs-verity"))
107+
verity := verity.VerityMetadata(!ctx.Bool("no-verity"))
107108
args.LayerTypes, err = types.NewLayerTypes(ctx.StringSlice("layer-type"), verity)
108109
return args, err
109110
}

cmd/stacker/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/opencontainers/umoci/oci/casext"
1212
"github.com/pkg/errors"
1313
cli "github.com/urfave/cli/v2"
14-
stackeroci "machinerun.io/atomfs/oci"
14+
stackeroci "machinerun.io/atomfs/pkg/oci"
1515
)
1616

1717
var inspectCmd = cli.Command{

cmd/stacker/internal_go.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/pkg/errors"
1010
cli "github.com/urfave/cli/v2"
1111
"golang.org/x/sys/unix"
12-
"machinerun.io/atomfs"
12+
"machinerun.io/atomfs/pkg/molecule"
1313
"stackerbuild.io/stacker/pkg/lib"
1414
"stackerbuild.io/stacker/pkg/log"
1515
"stackerbuild.io/stacker/pkg/overlay"
@@ -176,14 +176,14 @@ func doAtomfsMount(ctx *cli.Context) error {
176176
tag := ctx.Args().Get(0)
177177
mountpoint := ctx.Args().Get(1)
178178

179-
opts := atomfs.MountOCIOpts{
179+
opts := molecule.MountOCIOpts{
180180
OCIDir: config.OCIDir,
181181
Tag: tag,
182182
Target: mountpoint,
183183
AllowMissingVerityData: true,
184184
}
185185

186-
mol, err := atomfs.BuildMoleculeFromOCI(opts)
186+
mol, err := molecule.BuildMoleculeFromOCI(opts)
187187
if err != nil {
188188
return err
189189
}
@@ -199,5 +199,5 @@ func doAtomfsUmount(ctx *cli.Context) error {
199199
}
200200

201201
mountpoint := ctx.Args().Get(0)
202-
return atomfs.Umount(mountpoint)
202+
return molecule.Umount(mountpoint)
203203
}

cmd/stacker/publish.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"github.com/pkg/errors"
55
cli "github.com/urfave/cli/v2"
6-
"machinerun.io/atomfs/squashfs"
6+
"machinerun.io/atomfs/pkg/verity"
77
"stackerbuild.io/stacker/pkg/lib"
88
"stackerbuild.io/stacker/pkg/stacker"
99
"stackerbuild.io/stacker/pkg/types"
@@ -69,7 +69,7 @@ var publishCmd = cli.Command{
6969
},
7070
&cli.StringSliceFlag{
7171
Name: "layer-type",
72-
Usage: "set the output layer type (supported values: tar, squashfs); can be supplied multiple times",
72+
Usage: "set the output layer type (supported values: tar, squashfs, erofs); can be supplied multiple times",
7373
Value: cli.NewStringSlice("tar"),
7474
},
7575
&cli.StringSliceFlag{
@@ -108,7 +108,7 @@ func beforePublish(ctx *cli.Context) error {
108108
}
109109

110110
func doPublish(ctx *cli.Context) error {
111-
verity := squashfs.VerityMetadata(!ctx.Bool("no-squashfs-verity"))
111+
verity := verity.VerityMetadata(!ctx.Bool("no-verity"))
112112
layerTypes, err := types.NewLayerTypes(ctx.StringSlice("layer-type"), verity)
113113
if err != nil {
114114
return err

cmd/stacker/validate.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func validateLayerTypeFlags(ctx *cli.Context) error {
5050
break
5151
case "squashfs":
5252
break
53+
case "erofs":
54+
break
5355
default:
5456
return errors.Errorf("unknown layer type: %s", layerType)
5557
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/mitchellh/hashstructure v1.1.0
2020
github.com/moby/buildkit v0.11.4
2121
github.com/opencontainers/go-digest v1.0.0
22-
github.com/opencontainers/image-spec v1.1.0-rc4
22+
github.com/opencontainers/image-spec v1.1.0
2323
github.com/opencontainers/umoci v0.4.8-0.20220412065115-12453f247749
2424
github.com/pkg/errors v0.9.1
2525
github.com/pkg/xattr v0.4.9
@@ -278,7 +278,7 @@ require (
278278
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
279279
gopkg.in/warnings.v0 v0.1.2 // indirect
280280
gopkg.in/yaml.v3 v3.0.1 // indirect
281-
machinerun.io/atomfs v1.1.3
281+
machinerun.io/atomfs v1.2.0
282282
modernc.org/libc v1.37.6 // indirect
283283
modernc.org/mathutil v1.6.0 // indirect
284284
modernc.org/memory v1.7.2 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3ev
754754
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
755755
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
756756
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
757-
github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0=
758-
github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
757+
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
758+
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
759759
github.com/opencontainers/runc v1.2.3 h1:fxE7amCzfZflJO2lHXf4y/y8M1BoAqp+FVmG19oYB80=
760760
github.com/opencontainers/runc v1.2.3/go.mod h1:nSxcWUydXrsBZVYNSkTjoQ/N6rcyTtn+1SD5D4+kRIM=
761761
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
@@ -1598,8 +1598,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
15981598
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
15991599
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
16001600
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
1601-
machinerun.io/atomfs v1.1.3 h1:oV1SH7VI2MqAks7FlirhLLKvyVcJkMB0NFevXF8EJaU=
1602-
machinerun.io/atomfs v1.1.3/go.mod h1:qXz4epm3/7vEpEyf9YaTCafp3CwbUeDa1XrYyx7qbPc=
1601+
machinerun.io/atomfs v1.2.0 h1:w2YtDncppFjOKWGeK0yfgCYcB5dJIZSngVHb6UWljv0=
1602+
machinerun.io/atomfs v1.2.0/go.mod h1:jrGbuGXiCPi4LFoMvcPRnqPGlxe3pW8UtLEnhUcGRmI=
16031603
modernc.org/libc v1.37.6 h1:orZH3c5wmhIQFTXF+Nt+eeauyd+ZIt2BX6ARe+kD+aw=
16041604
modernc.org/libc v1.37.6/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
16051605
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=

install-build-deps.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ installdeps_ubuntu() {
4444
squashfuse
4545
libarchive-tools
4646
shellcheck
47+
erofs-utils
48+
erofsfuse
4749
)
4850

4951
case "$VERSION_ID" in
@@ -86,6 +88,11 @@ installdeps_ubuntu() {
8688
sudo apt -yy install golang-go
8789
go version
8890
fi
91+
92+
# cloud kernels, like linux-azure, don't include erofs in the linux-modules package and instead put it linux-modules-extra
93+
if ! modinfo erofs &>/dev/null; then
94+
sudo apt -yy install linux-modules-extra-$(uname -r)
95+
fi
8996
}
9097

9198
enable_userns() {

0 commit comments

Comments
 (0)