diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e48ff31..c584d87b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -79,7 +79,7 @@ jobs: - name: Install test dependencies run: | sudo apt update - sudo apt install -y python3-pytest python3-paramiko python3-boto3 flake8 qemu-system-x86 qemu-efi-aarch64 qemu-system-arm qemu-user-static pylint libosinfo-bin + sudo apt install -y python3-pytest python3-paramiko python3-boto3 flake8 pylint libosinfo-bin - name: Diskspace (before) run: | df -h @@ -90,6 +90,18 @@ jobs: sudo rm -rf /var/lib/containers/storage sudo mkdir -p /etc/containers echo -e "[storage]\ndriver = \"overlay\"\nrunroot = \"/run/containers/storage\"\ngraphroot = \"/var/lib/containers/storage\"" | sudo tee /etc/containers/storage.conf + - name: Updating qemu-user + run: | + # get qemu-9 with openat2 patches via qemu-user-static, that + # has no dependencies so just install. + # XXX: remove once ubuntu ships qemu-9.1 + sudo apt install -y software-properties-common + sudo apt-add-repository -y ppa:mvo/qemu + sudo apt install --no-install-recommends -y qemu-user-static + # Now remove ppa again, the metadata confuses apt. Then install + # qemu-system-* from the regular repo again. + sudo apt-add-repository --remove -y ppa:mvo/qemu + sudo apt install -y qemu-system-arm qemu-system-x86 qemu-efi-aarch64 - name: Install python test deps run: | # make sure test deps are available for root diff --git a/Containerfile b/Containerfile index 8e0d35c8..26bd03fd 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,4 @@ -FROM registry.fedoraproject.org/fedora:40 AS builder +FROM registry.fedoraproject.org/fedora:41 AS builder RUN dnf install -y git-core golang gpgme-devel libassuan-devel && mkdir -p /build/bib COPY bib/go.mod bib/go.sum /build/bib/ ARG GOPROXY=https://proxy.golang.org,direct @@ -10,7 +10,7 @@ COPY . /build WORKDIR /build RUN ./build.sh -FROM registry.fedoraproject.org/fedora:40 +FROM registry.fedoraproject.org/fedora:41 # Fast-track osbuild so we don't depend on the "slow" Fedora release process to implement new features in bib COPY ./group_osbuild-osbuild-fedora.repo /etc/yum.repos.d/ COPY ./package-requires.txt . diff --git a/bib/cmd/bootc-image-builder/image.go b/bib/cmd/bootc-image-builder/image.go index d4091448..c16fe245 100644 --- a/bib/cmd/bootc-image-builder/image.go +++ b/bib/cmd/bootc-image-builder/image.go @@ -388,19 +388,11 @@ func manifestForDiskImage(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest mf.Distro = manifest.DISTRO_FEDORA runner := &runner.Linux{} - // Remove the "NewBootcLegacyDiskImage" if part below and - // *only* use the "else" part of the code once either of the - // following is available in centos/rhel - // https://github.com/containers/bootc/pull/462 - // https://www.mail-archive.com/qemu-devel@nongnu.org/msg1034508.html - if c.Architecture != arch.Current() { - legacyImg := image.NewBootcLegacyDiskImage(img) - err = legacyImg.InstantiateManifestFromContainers(&mf, []container.SourceSpec{containerSource}, runner, rng) - } else { - err = img.InstantiateManifestFromContainers(&mf, []container.SourceSpec{containerSource}, runner, rng) + if err := img.InstantiateManifestFromContainers(&mf, []container.SourceSpec{containerSource}, runner, rng); err != nil { + return nil, err } - return &mf, err + return &mf, nil } func labelForISO(os *source.OSRelease, arch *arch.Arch) string { diff --git a/bib/cmd/bootc-image-builder/main.go b/bib/cmd/bootc-image-builder/main.go index e3bc59c0..2a998860 100644 --- a/bib/cmd/bootc-image-builder/main.go +++ b/bib/cmd/bootc-image-builder/main.go @@ -561,35 +561,69 @@ func rootPreRunE(cmd *cobra.Command, _ []string) error { return nil } -// TODO: provide more version info (like actual version number) once we -// release a real version -func cmdVersion(_ *cobra.Command, _ []string) error { +func cmdVersion() (string, error) { info, ok := debug.ReadBuildInfo() if !ok { - return fmt.Errorf("cannot read build info") + return "", fmt.Errorf("cannot read build info") } var gitRev string + var buildTime string + var buildTainted bool + ret := []string{} for _, bs := range info.Settings { if bs.Key == "vcs.revision" { gitRev = bs.Value - break + continue + } + if bs.Key == "vcs.time" { + buildTime = bs.Value + continue + } + if bs.Key == "vcs.modified" { + bT, err := strconv.ParseBool(bs.Value) + if err != nil { + logrus.Errorf("Error parsing 'vcs.modified': %v", err) + bT = true + } + + buildTainted = bT + continue } } if gitRev != "" { - fmt.Printf("revision: %s\n", gitRev[:7]) + ret = append(ret, fmt.Sprintf("build_revision: %s", gitRev[:7])) } else { - fmt.Printf("revision: unknown\n") + ret = append(ret, "build_revision: unknown") } - return nil + if buildTime != "" { + ret = append(ret, fmt.Sprintf("build_time: %s", buildTime)) + } + if buildTainted { + ret = append(ret, "build_status: tainted") + } else { + ret = append(ret, "build_status: ok") + } + + // append final newline + ret = append(ret, "") + + return strings.Join(ret, "\n"), nil } func buildCobraCmdline() (*cobra.Command, error) { + version, err := cmdVersion() + if err != nil { + return nil, err + } + rootCmd := &cobra.Command{ Use: "bootc-image-builder", Long: "Create a bootable image from an ostree native container", PersistentPreRunE: rootPreRunE, SilenceErrors: true, + Version: version, } + rootCmd.SetVersionTemplate(version) rootCmd.PersistentFlags().StringVar(&rootLogLevel, "log-level", "", "logging level (debug, info, error); default error") @@ -605,7 +639,10 @@ func buildCobraCmdline() (*cobra.Command, error) { SilenceUsage: true, Example: rootCmd.Use + " build quay.io/centos-bootc/centos-bootc:stream9\n" + rootCmd.Use + " quay.io/centos-bootc/centos-bootc:stream9\n", + Version: rootCmd.Version, } + buildCmd.SetVersionTemplate(version) + rootCmd.AddCommand(buildCmd) manifestCmd := &cobra.Command{ Use: "manifest", @@ -614,13 +651,21 @@ func buildCobraCmdline() (*cobra.Command, error) { DisableFlagsInUseLine: true, RunE: cmdManifest, SilenceUsage: true, + Version: rootCmd.Version, } + manifestCmd.SetVersionTemplate(version) + versionCmd := &cobra.Command{ Use: "version", + Short: "Show the version and quit", SilenceUsage: true, - Hidden: true, - RunE: cmdVersion, + RunE: func(cmd *cobra.Command, args []string) error { + root := cmd.Root() + root.SetArgs([]string{"--version"}) + return root.Execute() + }, } + rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(manifestCmd) @@ -687,6 +732,7 @@ func run() error { if err != nil { return err } + return rootCmd.Execute() } diff --git a/bib/data/defs/almalinux-10.yaml b/bib/data/defs/almalinux-10.yaml new file mode 120000 index 00000000..31ce3eb1 --- /dev/null +++ b/bib/data/defs/almalinux-10.yaml @@ -0,0 +1 @@ +centos-10.yaml \ No newline at end of file diff --git a/bib/data/defs/almalinux-9.yaml b/bib/data/defs/almalinux-9.yaml new file mode 120000 index 00000000..f09a8726 --- /dev/null +++ b/bib/data/defs/almalinux-9.yaml @@ -0,0 +1 @@ +centos-9.yaml \ No newline at end of file diff --git a/bib/go.mod b/bib/go.mod index 7d20a565..edc49a5b 100644 --- a/bib/go.mod +++ b/bib/go.mod @@ -8,13 +8,14 @@ require ( github.com/cheggaaa/pb/v3 v3.1.5 github.com/google/uuid v1.6.0 github.com/hashicorp/go-version v1.7.0 - github.com/osbuild/images v0.106.0 + github.com/mattn/go-isatty v0.0.20 + github.com/osbuild/images v0.107.0 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.10.0 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 - golang.org/x/sys v0.28.0 + golang.org/x/sys v0.29.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -75,7 +76,6 @@ require ( github.com/letsencrypt/boulder v0.0.0-20240418210053-89b07f4543e0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect diff --git a/bib/go.sum b/bib/go.sum index 9bef71af..bea79ecd 100644 --- a/bib/go.sum +++ b/bib/go.sum @@ -188,8 +188,6 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= @@ -227,8 +225,8 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU= github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec= -github.com/osbuild/images v0.106.0 h1:9vDLkSporWPNT4ltFy236/ONver5u7MqIgIutwECev0= -github.com/osbuild/images v0.106.0/go.mod h1:4bNmMQOVadIKVC1q8zsLO8tdEQFH90zIp+MQBQUnCiE= +github.com/osbuild/images v0.107.0 h1:lSH4Wkizm+7ZSzo0xYGs4vNpjmV8JaYZg6GczK/dCfo= +github.com/osbuild/images v0.107.0/go.mod h1:4bNmMQOVadIKVC1q8zsLO8tdEQFH90zIp+MQBQUnCiE= github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f h1:/UDgs8FGMqwnHagNDPGOlts35QkhAZ8by3DR7nMih7M= github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f/go.mod h1:J6OG6YJVEWopen4avK3VNQSnALmmjvniMmni/YFYAwc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -368,8 +366,8 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/test/test_opts.py b/test/test_opts.py index 188b4f1f..afb3d096 100644 --- a/test/test_opts.py +++ b/test/test_opts.py @@ -148,7 +148,8 @@ def test_bib_errors_only_once(tmp_path, container_storage, build_fake_container) assert res.stderr.count(needle) == 1 -def test_bib_version(tmp_path, container_storage, build_fake_container): +@pytest.mark.parametrize("version_argument", ["version", "--version", "-v"]) +def test_bib_version(tmp_path, container_storage, build_fake_container, version_argument): output_path = tmp_path / "output" output_path.mkdir(exist_ok=True) @@ -159,7 +160,7 @@ def test_bib_version(tmp_path, container_storage, build_fake_container): "-v", f"{container_storage}:/var/lib/containers/storage", "-v", f"{output_path}:/output", build_fake_container, - "version", + version_argument, ], check=True, capture_output=True, text=True) expected_rev = "unknown" diff --git a/test/testcases.py b/test/testcases.py index 78d8e926..4cf76751 100644 --- a/test/testcases.py +++ b/test/testcases.py @@ -87,7 +87,9 @@ def gen_testcases(what): # pylint: disable=too-many-return-statements return [TestCaseC9S(image="ami"), TestCaseFedora(image="ami")] if what == "anaconda-iso": return [ - TestCaseFedora(image="anaconda-iso", sign=True), + # 2024-12-19: disabled for now until the mirror situation becomes + # a bit more stable + # TestCaseFedora(image="anaconda-iso", sign=True), TestCaseC9S(image="anaconda-iso"), TestCaseC10S(image="anaconda-iso"), ] @@ -102,12 +104,8 @@ def gen_testcases(what): # pylint: disable=too-many-return-statements ] # do a cross arch test too if platform.machine() == "x86_64": - # TODO: re-enable once - # https://github.com/osbuild/bootc-image-builder/issues/619 - # is resolved - # test_cases.append( - # TestCaseC9S(image="raw", target_arch="arm64")) - pass + test_cases.append( + TestCaseC9S(image="raw", target_arch="arm64")) elif platform.machine() == "arm64": # TODO: add arm64->x86_64 cross build test too pass