-
Notifications
You must be signed in to change notification settings - Fork 441
Buildstream #4149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Buildstream #4149
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
|
||
| from mkosi.config import Config | ||
| from mkosi.context import Context | ||
|
|
||
| from mkosi.log import die | ||
| from mkosi.config import Architecture | ||
| from mkosi.installer.bst import BST | ||
| from mkosi.distribution import ( | ||
| Distribution, | ||
| DistributionInstaller, | ||
| PackageType, | ||
| ) | ||
|
|
||
| class Installer(DistributionInstaller, distribution=Distribution.buildstream): | ||
| @classmethod | ||
| def pretty_name(cls) -> str: | ||
| return "BuildStream" | ||
|
|
||
| @classmethod | ||
| def filesystem(cls) -> str: | ||
| return "btrfs" | ||
|
|
||
| @classmethod | ||
| def package_type(cls) -> PackageType: | ||
| return PackageType.none | ||
|
|
||
| @classmethod | ||
| def default_release(cls) -> str: | ||
| return "snapshot" | ||
|
|
||
| @classmethod | ||
| def package_manager(cls, config: "Config") -> type[BST]: | ||
| return BST | ||
|
|
||
| @classmethod | ||
| def setup(cls, context: Context) -> None: | ||
| pass | ||
|
|
||
| @classmethod | ||
| def install(cls, context: Context) -> None: | ||
| pass | ||
|
|
||
| @classmethod | ||
| def architecture(cls, arch: Architecture) -> str: | ||
| a = { | ||
| Architecture.x86_64: "x86_64", | ||
| }.get(arch) # fmt: skip | ||
|
|
||
| if not a: | ||
| die(f"Architecture {a} is not supported by {cls.pretty_name()}") | ||
|
|
||
| return a | ||
|
|
||
| @classmethod | ||
| def latest_snapshot(cls, config: Config) -> str: | ||
| die(f"Latest snapshot not supported by {cls.pretty_name()}") | ||
|
|
||
| @classmethod | ||
| def is_kernel_package(cls, package: str) -> bool: | ||
| return False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
|
||
| from collections.abc import Sequence | ||
| from pathlib import Path | ||
|
|
||
| from mkosi.config import Config | ||
| from mkosi.context import Context | ||
| from mkosi.installer import PackageManager | ||
| from mkosi.run import run | ||
| from mkosi.log import die | ||
|
|
||
|
|
||
| class BST(PackageManager): | ||
| @classmethod | ||
| def executable(cls, config: Config) -> str: | ||
| return "bst" | ||
|
|
||
| @classmethod | ||
| def subdir(cls, config: Config) -> Path: | ||
| return Path("bst") | ||
|
|
||
| @classmethod | ||
| def architecture(cls, context: Context) -> str: | ||
| return context.config.distribution.installer.architecture(context.config.architecture) | ||
|
|
||
| @classmethod | ||
| def setup(cls, context: Context) -> None: | ||
| if len(context.config.packages) > 1: | ||
| die("Only a single element can be specified in Packages= when using bst") | ||
|
|
||
| @classmethod | ||
| def install( | ||
| cls, | ||
| context: Context, | ||
| packages: Sequence[str], | ||
| *, | ||
| apivfs: bool = True, | ||
| allow_downgrade: bool = False, | ||
| ) -> None: | ||
| options = [ | ||
| "--same-dir", | ||
| *context.rootoptions(), | ||
| # bst might need to lookup files/paths across the user's home directory so make sure it is | ||
| # available. | ||
| "--bind", Path.home(), Path.home(), | ||
| "--setenv", "HOME", Path.home(), | ||
| ] | ||
|
|
||
| # We don't really want to run bst as (fake) root but it uses bubblewrap which stubbornly refuses to | ||
| # run when invoked unprivileged but with capabilities. We get around this by running as fake root but | ||
| # still setting $HOME to the user's home to reuse the buildstream cache directory. | ||
| run( | ||
| ["bst", "build", *packages], | ||
| sandbox=cls.sandbox(context, apivfs=apivfs, options=options), | ||
| env=cls.finalize_environment(context), | ||
| ) | ||
| run( | ||
| ["bst", "artifact", "checkout", "--force", "--directory=/buildroot", *packages], | ||
| sandbox=cls.sandbox(context, apivfs=apivfs, options=options), | ||
| env=cls.finalize_environment(context), | ||
| ) | ||
|
|
||
| @classmethod | ||
| def remove(cls, context: Context, packages: Sequence[str]) -> None: | ||
| die("Removing packages is not supported for bst") | ||
|
|
||
| @classmethod | ||
| def sync(cls, context: Context, force: bool) -> None: | ||
| pass | ||
|
|
||
| @classmethod | ||
| def createrepo(cls, context: Context) -> None: | ||
| die("Creating package repositories is not supported for bst") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
|
||
| [Match] | ||
| Distribution=buildstream | ||
|
|
||
| [Content] | ||
| # BuildStream is a generic distribution so we don't know which package to install, hence override to the | ||
| # empty list. | ||
| Packages= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found the issue: this file gets loaded last (after (as I workaround I removed this line, and the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the suggestion from @behrmann on matrix, I made a fix Details
diff --git a/mkosi/resources/mkosi-initrd/mkosi.conf b/mkosi/resources/mkosi-initrd/mkosi.conf
index ab76f73a..ca1afddb 100644
--- a/mkosi/resources/mkosi-initrd/mkosi.conf
+++ b/mkosi/resources/mkosi-initrd/mkosi.conf
@@ -10,12 +10,6 @@ SplitArtifacts=
Bootable=no
MakeInitrd=yes
CleanPackageMetadata=yes
-Packages=
- systemd # sine qua non
- udev
- bash # for emergency logins
- less # this makes 'systemctl' much nicer to use ;)
- gzip # For compressed keymap unpacking by loadkeys
RemoveFiles=
# we don't need this after the binary catalogs have been built
diff --git a/mkosi/resources/mkosi-initrd/mkosi.conf.d/buildstream.conf b/mkosi/resources/mkosi-initrd/mkosi.conf.d/buildstream.conf
deleted file mode 100644
index 1e76355e..00000000
--- a/mkosi/resources/mkosi-initrd/mkosi.conf.d/buildstream.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Distribution=buildstream
-
-[Content]
-# BuildStream is a generic distribution so we don't know which package to install, hence override to the
-# empty list.
-Packages=
diff --git a/mkosi/resources/mkosi-initrd/mkosi.conf.d/default-packages.conf b/mkosi/resources/mkosi-initrd/mkosi.conf.d/default-packages.conf
new file mode 100644
index 00000000..5dc12408
--- /dev/null
+++ b/mkosi/resources/mkosi-initrd/mkosi.conf.d/default-packages.conf
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+# BuildStream is a generic distribution so we don't know which package to install.
+Distribution=!buildstream
+
+Packages=
+ systemd # sine qua non
+ udev
+ bash # for emergency logins
+ less # this makes 'systemctl' much nicer to use ;)
+ gzip # For compressed keymap unpacking by loadkeys
diff --git a/mkosi/resources/mkosi-tools/mkosi.conf b/mkosi/resources/mkosi-tools/mkosi.conf
index b597d0a0..5ccf8f46 100644
--- a/mkosi/resources/mkosi-tools/mkosi.conf
+++ b/mkosi/resources/mkosi-tools/mkosi.conf
@@ -2,22 +2,3 @@
[Output]
Output=mkosi.tools
-
-[Content]
-Packages=
- bash
- ca-certificates
- coreutils
- cpio
- curl
- dosfstools
- e2fsprogs
- keyutils
- kmod
- mtools
- opensc
- openssl
- systemd
- tar
- xfsprogs
- zstd
diff --git a/mkosi/resources/mkosi-tools/mkosi.conf.d/buildstream.conf b/mkosi/resources/mkosi-tools/mkosi.conf.d/buildstream.conf
deleted file mode 100644
index 1e76355e..00000000
--- a/mkosi/resources/mkosi-tools/mkosi.conf.d/buildstream.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Distribution=buildstream
-
-[Content]
-# BuildStream is a generic distribution so we don't know which package to install, hence override to the
-# empty list.
-Packages=
diff --git a/mkosi/resources/mkosi-tools/mkosi.conf.d/default-packages.conf b/mkosi/resources/mkosi-tools/mkosi.conf.d/default-packages.conf
new file mode 100644
index 00000000..e20e4bd4
--- /dev/null
+++ b/mkosi/resources/mkosi-tools/mkosi.conf.d/default-packages.conf
@@ -0,0 +1,22 @@
+[Match]
+# BuildStream is a generic distribution so we don't know which package to install.
+Distribution=!buildstream
+
+[Content]
+Packages=
+ bash
+ ca-certificates
+ coreutils
+ cpio
+ curl
+ dosfstools
+ e2fsprogs
+ keyutils
+ kmod
+ mtools
+ opensc
+ openssl
+ systemd
+ tar
+ xfsprogs
+ zstd
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If that works for you, that looks like a reasonable workaround to me, though that empty |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| [Match] | ||
| Format=uki | ||
| Distribution=!arch | ||
| Distribution=!buildstream | ||
|
|
||
| [Content] | ||
| Packages=systemd-boot | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
|
||
| [Match] | ||
| Distribution=buildstream | ||
|
|
||
| [Content] | ||
| # BuildStream is a generic distribution so we don't know which package to install, hence override to the | ||
| # empty list. | ||
| Packages= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed this to run it properly, I'm running it from distrobox and it does weird things to the home directory. Regardless, passing the directory we run it from seems sound.