mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
Bugfix/mac build (#2726)
* fix mac build * additional fixes * handle arm64 from uname -m * handle arm64 from uname -m in all builds * gracefully handle rootless docker * use cross-platform method of determining file uid
This commit is contained in:
@@ -21,7 +21,7 @@ pub struct Manifest {
|
||||
#[serde(default)]
|
||||
pub git_hash: Option<GitHash>,
|
||||
pub title: String,
|
||||
pub version: exver::emver::Version,
|
||||
pub version: String,
|
||||
pub description: Description,
|
||||
#[serde(default)]
|
||||
pub assets: Assets,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use exver::{ExtendedVersion, VersionRange};
|
||||
@@ -44,9 +45,9 @@ impl S9pk<TmpSource<PackSource>> {
|
||||
// manifest.json
|
||||
let manifest_raw = reader.manifest().await?;
|
||||
let manifest = from_value::<ManifestV1>(manifest_raw.clone())?;
|
||||
let mut new_manifest = Manifest::from(manifest.clone());
|
||||
let mut new_manifest = Manifest::try_from(manifest.clone())?;
|
||||
|
||||
let images: BTreeMap<ImageId, bool> = manifest
|
||||
let images: BTreeSet<(ImageId, bool)> = manifest
|
||||
.package_procedures()
|
||||
.filter_map(|p| {
|
||||
if let PackageProcedure::Docker(p) = p {
|
||||
@@ -89,8 +90,6 @@ impl S9pk<TmpSource<PackSource>> {
|
||||
|
||||
// images
|
||||
for arch in reader.docker_arches().await? {
|
||||
let images_dir = tmp_dir.join("images").join(&arch);
|
||||
tokio::fs::create_dir_all(&images_dir).await?;
|
||||
Command::new(CONTAINER_TOOL)
|
||||
.arg("load")
|
||||
.input(Some(&mut reader.docker_images(&arch).await?))
|
||||
@@ -194,13 +193,18 @@ impl S9pk<TmpSource<PackSource>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ManifestV1> for Manifest {
|
||||
fn from(value: ManifestV1) -> Self {
|
||||
impl TryFrom<ManifestV1> for Manifest {
|
||||
type Error = Error;
|
||||
fn try_from(value: ManifestV1) -> Result<Self, Self::Error> {
|
||||
let default_url = value.upstream_repo.clone();
|
||||
Self {
|
||||
Ok(Self {
|
||||
id: value.id,
|
||||
title: value.title.into(),
|
||||
version: ExtendedVersion::from(value.version).into(),
|
||||
version: ExtendedVersion::from(
|
||||
exver::emver::Version::from_str(&value.version)
|
||||
.with_kind(ErrorKind::Deserialization)?,
|
||||
)
|
||||
.into(),
|
||||
satisfies: BTreeSet::new(),
|
||||
release_notes: value.release_notes,
|
||||
can_migrate_from: VersionRange::any(),
|
||||
@@ -246,6 +250,6 @@ impl From<ManifestV1> for Manifest {
|
||||
git_hash: value.git_hash,
|
||||
os_version: value.eos_version,
|
||||
has_config: value.config.is_some(),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,20 +109,16 @@ pub fn handler<C: Context>() -> ParentHandler<C> {
|
||||
ParentHandler::<C>::new()
|
||||
.subcommand(
|
||||
"launch",
|
||||
from_fn_blocking(subcontainer::launch::<ContainerCliContext>).no_display(),
|
||||
from_fn_blocking(subcontainer::launch).no_display(),
|
||||
)
|
||||
.subcommand(
|
||||
"launch-init",
|
||||
from_fn_blocking(subcontainer::launch_init::<ContainerCliContext>).no_display(),
|
||||
)
|
||||
.subcommand(
|
||||
"exec",
|
||||
from_fn_blocking(subcontainer::exec::<ContainerCliContext>).no_display(),
|
||||
from_fn_blocking(subcontainer::launch_init).no_display(),
|
||||
)
|
||||
.subcommand("exec", from_fn_blocking(subcontainer::exec).no_display())
|
||||
.subcommand(
|
||||
"exec-command",
|
||||
from_fn_blocking(subcontainer::exec_command::<ContainerCliContext>)
|
||||
.no_display(),
|
||||
from_fn_blocking(subcontainer::exec_command).no_display(),
|
||||
)
|
||||
.subcommand(
|
||||
"create-fs",
|
||||
|
||||
@@ -8,9 +8,15 @@ use crate::rpc_continuations::Guid;
|
||||
use crate::service::effects::prelude::*;
|
||||
use crate::util::Invoke;
|
||||
|
||||
#[cfg(feature = "container-runtime")]
|
||||
mod sync;
|
||||
|
||||
#[cfg(not(feature = "container-runtime"))]
|
||||
mod sync_dummy;
|
||||
|
||||
pub use sync::*;
|
||||
#[cfg(not(feature = "container-runtime"))]
|
||||
use sync_dummy as sync;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
@@ -14,6 +14,7 @@ use tokio::sync::oneshot;
|
||||
use unshare::Command as NSCommand;
|
||||
|
||||
use crate::service::effects::prelude::*;
|
||||
use crate::service::effects::ContainerCliContext;
|
||||
|
||||
const FWD_SIGNALS: &[c_int] = &[
|
||||
SIGABRT, SIGALRM, SIGCONT, SIGHUP, SIGINT, SIGIO, SIGPIPE, SIGPROF, SIGQUIT, SIGTERM, SIGTRAP,
|
||||
@@ -130,8 +131,8 @@ impl ExecParams {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn launch<C: Context>(
|
||||
_: C,
|
||||
pub fn launch(
|
||||
_: ContainerCliContext,
|
||||
ExecParams {
|
||||
env,
|
||||
workdir,
|
||||
@@ -141,6 +142,8 @@ pub fn launch<C: Context>(
|
||||
}: ExecParams,
|
||||
) -> Result<(), Error> {
|
||||
use unshare::{Namespace, Stdio};
|
||||
|
||||
use crate::service::cli::ContainerCliContext;
|
||||
let mut sig = signal_hook::iterator::Signals::new(FWD_SIGNALS)?;
|
||||
let mut cmd = NSCommand::new("/usr/bin/start-cli");
|
||||
cmd.arg("subcontainer").arg("launch-init");
|
||||
@@ -262,7 +265,7 @@ pub fn launch<C: Context>(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn launch_init<C: Context>(_: C, params: ExecParams) -> Result<(), Error> {
|
||||
pub fn launch_init(_: ContainerCliContext, params: ExecParams) -> Result<(), Error> {
|
||||
nix::mount::mount(
|
||||
Some("proc"),
|
||||
¶ms.chroot.join("proc"),
|
||||
@@ -281,8 +284,8 @@ pub fn launch_init<C: Context>(_: C, params: ExecParams) -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exec<C: Context>(
|
||||
_: C,
|
||||
pub fn exec(
|
||||
_: ContainerCliContext,
|
||||
ExecParams {
|
||||
env,
|
||||
workdir,
|
||||
@@ -384,6 +387,6 @@ pub fn exec<C: Context>(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exec_command<C: Context>(_: C, params: ExecParams) -> Result<(), Error> {
|
||||
pub fn exec_command(_: ContainerCliContext, params: ExecParams) -> Result<(), Error> {
|
||||
params.exec()
|
||||
}
|
||||
|
||||
30
core/startos/src/service/effects/subcontainer/sync_dummy.rs
Normal file
30
core/startos/src/service/effects/subcontainer/sync_dummy.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use crate::service::effects::prelude::*;
|
||||
use crate::service::effects::ContainerCliContext;
|
||||
|
||||
pub fn launch(_: ContainerCliContext) -> Result<(), Error> {
|
||||
Err(Error::new(
|
||||
eyre!("requires feature container-runtime"),
|
||||
ErrorKind::InvalidRequest,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn launch_init(_: ContainerCliContext) -> Result<(), Error> {
|
||||
Err(Error::new(
|
||||
eyre!("requires feature container-runtime"),
|
||||
ErrorKind::InvalidRequest,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn exec(_: ContainerCliContext) -> Result<(), Error> {
|
||||
Err(Error::new(
|
||||
eyre!("requires feature container-runtime"),
|
||||
ErrorKind::InvalidRequest,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn exec_command(_: ContainerCliContext) -> Result<(), Error> {
|
||||
Err(Error::new(
|
||||
eyre!("requires feature container-runtime"),
|
||||
ErrorKind::InvalidRequest,
|
||||
))
|
||||
}
|
||||
Reference in New Issue
Block a user