Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions local/README.md

This file was deleted.

18 changes: 0 additions & 18 deletions local/alpha-sdk.Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions local/alpha-sdk.Dockerfile.dockerignore

This file was deleted.

187 changes: 0 additions & 187 deletions local/alpha-sdk.sh

This file was deleted.

42 changes: 1 addition & 41 deletions twoliter/src/cmd/build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
use super::build_clean::BuildClean;
use crate::cargo_make::CargoMake;
use crate::common::fs;
use crate::docker::DockerContainer;
use crate::lock::Lock;
use crate::project;
use crate::tools::install_tools;
use anyhow::{Context, Result};
use clap::Parser;
use log::debug;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use tempfile::TempDir;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -114,51 +111,15 @@ pub(crate) struct BuildVariant {
impl BuildVariant {
pub(super) async fn run(&self) -> Result<()> {
let project = project::load_or_find_project(self.project_path.clone()).await?;
let token = project.token();
let toolsdir = project.project_dir().join("build/tools");
install_tools(&toolsdir).await?;
let makefile_path = toolsdir.join("Makefile.toml");
let lock_file = Lock::load(&project).await?;
// A temporary directory in the `build` directory
let build_temp_dir = TempDir::new_in(project.project_dir())
.context("Unable to create a tempdir for Twoliter's build")?;
let packages_dir = build_temp_dir.path().join("sdk_rpms");
fs::create_dir_all(&packages_dir).await?;

let sdk_container =
DockerContainer::new(format!("sdk-{}", token), lock_file.sdk.source).await?;
sdk_container
.cp_out(Path::new("twoliter/alpha/build/rpms"), &packages_dir)
.await?;

let rpms_dir = project.project_dir().join("build").join("rpms");
fs::create_dir_all(&rpms_dir).await?;
debug!("Moving rpms to build dir");
let rpms = packages_dir.join("rpms");
let mut read_dir = tokio::fs::read_dir(&rpms)
.await
.context(format!("Unable to read dir '{}'", rpms.display()))?;
while let Some(entry) = read_dir.next_entry().await.context(format!(
"Error while reading entries in dir '{}'",
rpms.display()
))? {
debug!("Moving '{}'", entry.path().display());
fs::rename(entry.path(), rpms_dir.join(entry.file_name())).await?;
}

let sbkeys_dir = project.project_dir().join("sbkeys");
if !sbkeys_dir.is_dir() {
// Create a sbkeys directory in the main project
debug!("sbkeys dir not found. Creating a temporary directory");
fs::create_dir_all(&sbkeys_dir).await?;
sdk_container
.cp_out(
Path::new("twoliter/alpha/sbkeys/generate-local-sbkeys"),
&sbkeys_dir,
)
.await?;
};

let mut optional_envs = Vec::new();

if let Some(lookaside_cache) = &self.lookaside_cache {
Expand All @@ -176,7 +137,6 @@ impl BuildVariant {
.env("TWOLITER_TOOLS_DIR", toolsdir.display().to_string())
.env("BUILDSYS_ARCH", &self.arch)
.env("BUILDSYS_VARIANT", &self.variant)
.env("BUILDSYS_SBKEYS_DIR", sbkeys_dir.display().to_string())
.env("BUILDSYS_VERSION_IMAGE", project.release_version())
.env("GO_MODULES", project.find_go_modules().await?.join(" "))
.env(
Expand Down
75 changes: 0 additions & 75 deletions twoliter/src/docker/container.rs

This file was deleted.

2 changes: 0 additions & 2 deletions twoliter/src/docker/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
mod commands;
mod container;
mod image;

pub(crate) use self::container::DockerContainer;
pub(crate) use self::image::ImageUri;
9 changes: 1 addition & 8 deletions twoliter/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use log::{debug, info, trace, warn};
use semver::Version;
use serde::de::Error;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use sha2::{Digest, Sha256, Sha512};
use sha2::{Digest, Sha256};
use std::collections::BTreeMap;
use std::ffi::OsStr;
use std::fmt::{Display, Formatter};
Expand Down Expand Up @@ -169,13 +169,6 @@ impl Project {
}
}

pub(crate) fn token(&self) -> String {
let mut d = Sha512::new();
d.update(self.filepath().display().to_string());
let digest = hex::encode(d.finalize());
(digest[..12]).to_string()
}

/// Returns a list of the names of Go modules by searching the `sources` directory for `go.mod`
/// files.
pub(crate) async fn find_go_modules(&self) -> Result<Vec<String>> {
Expand Down