Skip to content

Commit

Permalink
more host clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Oct 14, 2024
1 parent 7e9a701 commit b5bd189
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/render/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use rattler_conda_types::{Channel, MatchSpec, Platform, PrefixRecord, RepoDataRe
use rattler_solve::{resolvo::Solver, ChannelPriority, SolveStrategy, SolverImpl, SolverTask};
use url::Url;

use crate::{metadata::PlatformWithVirtualPackages, tool_configuration};
use crate::{
metadata::PlatformWithVirtualPackages, packaging::Files, recipe::parser::GlobVec,
tool_configuration,
};

fn print_as_table(packages: &[RepoDataRecord]) {
let mut table = Table::new();
Expand Down Expand Up @@ -311,6 +314,21 @@ pub async fn install_packages(

let installed_packages = PrefixRecord::collect_from_prefix(target_prefix)?;

if !installed_packages.is_empty() && name.starts_with("host") {
// we have to clean up extra files in the prefix
let extra_files =
Files::from_prefix(target_prefix, &GlobVec::default(), &GlobVec::default())?;
tracing::info!(
"Cleaning up {} files in the prefix from a previous build.",
extra_files.new_files.len()
);
for f in extra_files.new_files {
if !f.is_dir() {
fs_err::remove_file(target_prefix.join(f))?;
}
}
}

tracing::info!("\nInstalling {name} environment\n");
Installer::new()
.with_download_client(tool_configuration.client.clone())
Expand Down
5 changes: 5 additions & 0 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ impl Output {
let span = tracing::info_span!("Fetching source code");
let _enter = span.enter();

// if the work directory already exists, we should remove it
if self.build_configuration.directories.work_dir.exists() {
fs::remove_dir_all(&self.build_configuration.directories.work_dir)?;
}

if let Some(finalized_sources) = &self.finalized_sources {
fetch_sources(
finalized_sources,
Expand Down

0 comments on commit b5bd189

Please sign in to comment.