diff --git a/config.star b/config.star
index 40093b3..b7594f0 100644
--- a/config.star
+++ b/config.star
@@ -6,6 +6,7 @@ signing_key = "build/keys/distro.rsa"
signing_pubkey = "build/keys/distro.rsa.pub"
target_arch = "x86_64"
+libc = "musl"
host_cflags = "-O2 -pipe"
host_cxxflags = ""
@@ -22,8 +23,8 @@ if target_arch == "x86_64":
target_ldflags += " -Wl,-z,pack-relative-relocs"
options = {
- "libc": "musl",
- "target_triple": "x86_64-linux-musl",
+ "libc": libc,
+ "target_triple": target_arch + "-linux-" + libc,
"host_cflags": host_cflags,
"host_cxxflags": host_cxxflags,
"host_ldflags": host_ldflags,
diff --git a/host-recipes/binutils/recipe.star b/host-recipes/binutils/recipe.star
index 2268936..4775011 100644
--- a/host-recipes/binutils/recipe.star
+++ b/host-recipes/binutils/recipe.star
@@ -13,12 +13,11 @@ source = {
host_deps = []
def configure(ctx):
- triple = ctx.options["target_triple"]
ctx.run([
ctx.source_dir + "/configure",
"--prefix=" + ctx.prefix,
- "--target=" + triple,
- "--with-sysroot=" + ctx.prefix + "/" + triple,
+ "--target=" + OPTIONS.target_triple,
+ "--with-sysroot=" + ctx.prefix + "/" + OPTIONS.target_triple,
"--disable-nls",
"--disable-werror",
"--enable-deterministic-archives",
@@ -29,9 +28,9 @@ def configure(ctx):
# gprofng's libcollector does not build against musl/recent gcc.
"--disable-gprofng",
], env = {
- "CFLAGS": ctx.options["host_cflags"],
- "CXXFLAGS": ctx.options["host_cxxflags"],
- "LDFLAGS": ctx.options["host_ldflags"],
+ "CFLAGS": OPTIONS.host_cflags,
+ "CXXFLAGS": OPTIONS.host_cxxflags,
+ "LDFLAGS": OPTIONS.host_ldflags,
})
def build(ctx):
diff --git a/host-recipes/gcc/recipe.star b/host-recipes/gcc/recipe.star
index 36d2063..57b00f7 100644
--- a/host-recipes/gcc/recipe.star
+++ b/host-recipes/gcc/recipe.star
@@ -13,12 +13,11 @@ source = {
host_deps = ["binutils"]
def configure(ctx):
- triple = ctx.options["target_triple"]
ctx.run([
ctx.source_dir + "/configure",
"--prefix=" + ctx.prefix,
- "--target=" + triple,
- "--with-sysroot=" + ctx.prefix + "/" + triple,
+ "--target=" + OPTIONS.target_triple,
+ "--with-sysroot=" + ctx.prefix + "/" + OPTIONS.target_triple,
"--without-headers",
"--with-newlib",
"--enable-languages=c,c++",
@@ -34,9 +33,9 @@ def configure(ctx):
"--disable-libvtv",
"--disable-multilib",
], env = {
- "CFLAGS": ctx.options["host_cflags"],
- "CXXFLAGS": ctx.options["host_cxxflags"],
- "LDFLAGS": ctx.options["host_ldflags"],
+ "CFLAGS": OPTIONS.host_cflags,
+ "CXXFLAGS": OPTIONS.host_cxxflags,
+ "LDFLAGS": OPTIONS.host_ldflags,
})
def build(ctx):
diff --git a/lib/common.star b/lib/common.star
index 7882cac..86b94d4 100644
--- a/lib/common.star
+++ b/lib/common.star
@@ -1,14 +1,35 @@
# Commonly used helpers, auto-loaded into every recipe.
-def autotools_configure(ctx, extra_args = []):
+def _toolchain_env(ctx):
+ sysroot_flag = " --sysroot=" + ctx.sysroot
+ return {
+ "CFLAGS": OPTIONS.cflags + sysroot_flag,
+ "CXXFLAGS": OPTIONS.cxxflags + sysroot_flag,
+ "LDFLAGS": OPTIONS.ldflags + sysroot_flag,
+ }
+
+# Autotools
+
+def autotools_configure(ctx, extra_args = [], extra_env = {}):
args = [
ctx.source_dir + "/configure",
"--prefix=" + ctx.prefix,
"--sysconfdir=/etc",
"--localstatedir=/var",
+ "--bindir=" + ctx.prefix + "/bin",
+ "--sbindir=" + ctx.prefix + "/bin",
+ "--libdir=" + ctx.prefix + "/lib",
+ "--with-sysroot=" + ctx.sysroot,
+ "--disable-static",
+ "--enable-shared",
]
+ args.append("--host=" + OPTIONS.target_triple)
args.extend(extra_args)
- ctx.run(args, env = _toolchain_env(ctx))
+
+ envs = _toolchain_env(ctx)
+ envs.update(extra_env)
+
+ ctx.run(args, env = envs)
def autotools_build(ctx, extra_args = []):
args = ["make", "-j" + str(ctx.jobs)]
@@ -25,15 +46,17 @@ def autotools_install(ctx, pkg, extra_args = []):
args.extend(extra_args)
ctx.run(args)
-def autotools(configure_args = [], build_args = [], install_args = []):
+def autotools(configure_args = [], configure_env = [], build_args = [], install_args = []):
def _configure(ctx):
- autotools_configure(ctx, extra_args = configure_args)
+ autotools_configure(ctx, extra_args = configure_args, extra_env = configure_env)
def _build(ctx):
autotools_build(ctx, extra_args = build_args)
def _install(ctx, pkg):
autotools_install(ctx, pkg, extra_args = install_args)
return _configure, _build, _install
+# Meson
+
def meson_configure(ctx, extra_args = []):
args = [
"meson",
@@ -51,7 +74,6 @@ def meson_build(ctx):
def meson_install(ctx, pkg):
ctx.run(["meson", "install", "-C", ctx.build_dir, "--destdir", pkg.destdir])
-
def meson(configure_args = [], build_args = [], install_args = []):
def _configure(ctx):
meson_configure(ctx, extra_args = configure_args)
@@ -61,6 +83,8 @@ def meson(configure_args = [], build_args = [], install_args = []):
meson_install(ctx, pkg, extra_args = install_args)
return _configure, _build, _install
+# Make
+
def make(ctx, target = None, extra_args = []):
args = ["make", "-C", ctx.source_dir, "O=" + ctx.build_dir,
"-j" + str(ctx.jobs)]
@@ -73,10 +97,3 @@ def make_install(ctx, pkg, extra_args = []):
args = ["make", "-C", ctx.build_dir, "DESTDIR=" + pkg.destdir, "install"]
args.extend(extra_args)
ctx.run(args)
-
-def _toolchain_env(ctx):
- env = {}
- for key, var in [("cflags", "CFLAGS"), ("cxxflags", "CXXFLAGS"), ("ldflags", "LDFLAGS")]:
- if key in ctx.options:
- env[var] = ctx.options[key]
- return env
diff --git a/recipes/limine/recipe.star b/recipes/limine/recipe.star
new file mode 100644
index 0000000..41c40e7
--- /dev/null
+++ b/recipes/limine/recipe.star
@@ -0,0 +1,25 @@
+name = "limine"
+version = "12.2.0"
+revision = 1
+description = "Modern, secure, portable, multiprotocol bootloader and boot manager"
+license = "BSD-2-Clause"
+
+source = {
+ "url": f"https://github.com/Limine-Bootloader/Limine/releases/download/v{version}/limine-{version}.tar.gz",
+ "sha256": "db8a119878cfeead63c0a78236c577c40539c5759496950ea0ed32a6cf567865",
+ "strip_components": 1,
+}
+
+host_deps = ["binutils", "gcc"]
+deps = [OPTIONS.libc]
+
+def configure(ctx):
+ toolchain = OPTIONS.target_triple + "-"
+ autotools_configure(ctx, extra_env = {
+ "TOOLCHAIN_FOR_TARGET": toolchain,
+ "LD_FOR_TARGET": toolchain + "ld",
+ "OBJCOPY_FOR_TARGET": toolchain + "objcopy",
+ "OBJDUMP_FOR_TARGET": toolchain + "objdump",
+ })
+
+_, build, install = autotools()
diff --git a/recipes/linux/recipe.star b/recipes/linux/recipe.star
index 6ead550..f1c3758 100644
--- a/recipes/linux/recipe.star
+++ b/recipes/linux/recipe.star
@@ -13,13 +13,12 @@ source = {
host_deps = ["binutils", "gcc"]
def _make_args(ctx, *args):
- triple = ctx.options["target_triple"]
result = [
"make",
"-C", ctx.source_dir,
"O=" + ctx.build_dir,
"ARCH=x86_64",
- f"CROSS_COMPILE={triple}-",
+ "CROSS_COMPILE=" + OPTIONS.target_triple + "-",
"-j" + str(ctx.jobs),
]
result.extend(args)
diff --git a/recipes/musl/recipe.star b/recipes/musl/recipe.star
index 477e13c..e013188 100644
--- a/recipes/musl/recipe.star
+++ b/recipes/musl/recipe.star
@@ -13,18 +13,17 @@ source = {
host_deps = ["binutils", "gcc"]
def configure(ctx):
- triple = ctx.options["target_triple"]
ctx.run(
[
ctx.source_dir + "/configure",
"--prefix=/usr",
"--syslibdir=/lib",
- "--target=" + triple,
+ "--target=" + OPTIONS.target_triple,
],
env = {
- "CC": triple + "-gcc",
- "CFLAGS": ctx.options["cflags"],
- "LDFLAGS": ctx.options["ldflags"],
+ "CC": OPTIONS.target_triple + "-gcc",
+ "CFLAGS": OPTIONS.cflags,
+ "LDFLAGS": OPTIONS.ldflags,
},
)
diff --git a/src/apk.rs b/src/apk.rs
index 976c80d..07d8144 100644
--- a/src/apk.rs
+++ b/src/apk.rs
@@ -38,7 +38,7 @@ pub fn mkpkg_plan(
"--info".to_owned(),
format!("origin:{}", package.recipe),
];
- for dep in &package.run_deps {
+ for dep in &package.deps {
args.push("--info".to_owned());
args.push(format!("depends:{dep}"));
}
diff --git a/src/build.rs b/src/build.rs
index 476910d..b31254d 100644
--- a/src/build.rs
+++ b/src/build.rs
@@ -112,6 +112,16 @@ impl Builder {
self.preflight_container()?;
let repo = self.pkgs_dir();
fs::create_dir_all(&repo)?;
+ // Nothing to index yet — leave it alone so callers don't trip on a
+ // failing `*.apk` glob.
+ let has_apks = fs::read_dir(&repo)?.any(|e| {
+ e.ok()
+ .and_then(|e| e.path().extension().map(|x| x == "apk"))
+ .unwrap_or(false)
+ });
+ if !has_apks {
+ return Ok(());
+ }
log::step(
"index",
&format!("signing repository at {}", repo.display()),
@@ -121,14 +131,14 @@ impl Builder {
if !key.exists() || !pubkey.exists() {
bail!("signing key is not configured or missing; run `distro init-key` first");
}
- let index_name = "APKINDEX.adb";
+ let index_name = "APKINDEX.tar.gz";
let status = Command::new(&self.config.container_runtime)
.arg("run")
.arg("--rm")
.arg("-v")
.arg(format!("{}:/repo", repo.display()))
.arg("-v")
- .arg(format!("{}:/keys/private.rsa:ro", key.display()))
+ .arg(format!("{}:/keys/distro.rsa:ro", key.display()))
.arg("-v")
.arg(format!(
"{}:/etc/apk/keys/distro.rsa.pub:ro",
@@ -138,7 +148,7 @@ impl Builder {
.arg("/bin/sh")
.arg("-lc")
.arg(format!(
- "cd /repo && apk --sign-key /keys/private.rsa mkndx -o {index_name} *.apk"
+ "cd /repo && apk --sign-key /keys/distro.rsa mkndx -o {index_name} *.apk"
))
.status()
.context("failed to run repository index command")?;
@@ -207,7 +217,7 @@ impl Builder {
.arg("-v")
.arg(format!("{}:/rootfs", root.display()))
.arg("-v")
- .arg(format!("{}:/repo:ro", self.pkgs_dir().display()))
+ .arg(format!("{}:/repo:ro", self.pkgs_root().display()))
.arg("-v")
.arg(format!(
"{}:/etc/apk/keys/distro.rsa.pub:ro",
@@ -217,8 +227,11 @@ impl Builder {
.arg("apk")
.arg("--root")
.arg("/rootfs")
+ .arg("--keys-dir")
+ .arg("/etc/apk/keys")
+ .arg("--initdb")
.arg("--repository")
- .arg("/repo/APKINDEX.adb")
+ .arg("/repo")
.arg("add")
.args(packages)
.status()
@@ -315,7 +328,7 @@ impl Builder {
&source_dir,
&build_dir,
dest_dir,
- sysroot.as_deref(),
+ sysroot.as_ref().map(|s| s.path()),
)?;
self.apk_mkpkg(output, dest_dir)?;
@@ -466,11 +479,11 @@ impl Builder {
.arg("-v")
.arg(format!("{}:/out", repo.display()))
.arg("-v")
- .arg(format!("{}:/keys/private.rsa:ro", signing_key.display()))
+ .arg(format!("{}:/keys/distro.rsa:ro", signing_key.display()))
.arg(&self.config.container_image)
.arg("apk")
.arg("--sign-key")
- .arg("/keys/private.rsa")
+ .arg("/keys/distro.rsa")
.args(plan.args)
.status()
.context("failed to run apk mkpkg command")?;
@@ -627,11 +640,11 @@ impl Builder {
Ok(Some(sandbox))
}
- fn materialize_sysroot(&self, recipe: &Recipe) -> Result