Skip to content

Commit

Permalink
Fix/mac start cli packing (#2767)
Browse files Browse the repository at this point in the history
* wip

* wip: Adding more of the docker for the mac build

* fix: Running a build

* chore: Make the code a little cleaner

* optimize: reduce docker image size for mac-tar2sqfs

* feat: Update sdk-utils container usage and Dockerfile

* feat: Publish SDK Utils Container image

* clean up ...

* feat: Add manual input to control tagging Docker image as 'latest'

* fix: Update workflow input handling

* switch to different repo and clean

---------

Co-authored-by: Mariusz Kogen <[email protected]>
Co-authored-by: Aiden McClelland <[email protected]>
  • Loading branch information
3 people authored Oct 29, 2024
1 parent 1be9cda commit 8e0db27
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions core/startos/src/s9pk/v2/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ impl SqfsDir {
let guid = Guid::new();
let path = self.tmpdir.join(guid.as_ref()).with_extension("squashfs");
if self.path.extension().and_then(|s| s.to_str()) == Some("tar") {
Command::new("tar2sqfs")
.arg("-q")
.arg(&path)
tar2sqfs(&self.path)?
.input(Some(&mut open_file(&self.path).await?))
.invoke(ErrorKind::Filesystem)
.await?;
Expand Down Expand Up @@ -553,7 +551,7 @@ impl ImageSource {
Command::new(CONTAINER_TOOL)
.arg("export")
.arg(container.trim())
.pipe(Command::new("tar2sqfs").arg("-q").arg(&dest))
.pipe(&mut tar2sqfs(&dest)?)
.capture(false)
.invoke(ErrorKind::Docker)
.await?;
Expand All @@ -575,6 +573,38 @@ impl ImageSource {
}
}

fn tar2sqfs(dest: impl AsRef<Path>) -> Result<Command, Error> {
let dest = dest.as_ref();

Ok({
#[cfg(target_os = "linux")]
{
let mut command = Command::new("tar2sqfs");
command.arg(&dest);
command
}
#[cfg(target_os = "macos")]
{
let directory = dest
.parent()
.unwrap_or_else(|| Path::new("/"))
.to_path_buf();
let mut command = Command::new(CONTAINER_TOOL);
command
.arg("run")
.arg("-i")
.arg("--rm")
.arg("-v")
.arg(format!("{}:/data:rw", directory.display()))
.arg("ghcr.io/start9labs/sdk/utils:latest")
.arg("tar2sqfs")
.arg("-q")
.arg(Path::new("/data").join(&dest.file_name().unwrap_or_default()));
command
}
})
}

#[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
Expand Down

0 comments on commit 8e0db27

Please sign in to comment.