diff --git a/src/build_manifest.rs b/src/build_manifest.rs index 7ca3933..aba857c 100644 --- a/src/build_manifest.rs +++ b/src/build_manifest.rs @@ -37,15 +37,14 @@ impl<'a> BuildManifest<'a> { }) } - pub(crate) fn run(&self, upload_base: &str) -> Result { + pub(crate) fn run(&self, upload_base: &str, dest: &Path) -> Result { let config = &self.builder.config; // Ensure the manifest dir exists but is empty. - let manifest_dir = self.builder.manifest_dir(); - if manifest_dir.is_dir() { - std::fs::remove_dir_all(&manifest_dir)?; + if dest.is_dir() { + std::fs::remove_dir_all(&dest)?; } - std::fs::create_dir_all(&manifest_dir)?; + std::fs::create_dir_all(&dest)?; // Ensure the shipped files path does not exists if self.shipped_files_path.is_file() { @@ -57,7 +56,7 @@ impl<'a> BuildManifest<'a> { let num_threads = self.builder.config.num_threads.to_string(); let status = Command::new(self.executable.path()) .arg(self.builder.dl_dir()) - .arg(self.builder.manifest_dir()) + .arg(dest) .arg(&self.builder.date) .arg(upload_base) .arg(config.channel.to_string()) diff --git a/src/main.rs b/src/main.rs index d087434..5409cd4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -189,38 +189,42 @@ impl Context { if BuildManifest::exists(self) { let mut signer = Signer::new(&self.config)?; let build_manifest = BuildManifest::new(self)?; - let smoke_test = SmokeTester::new(&[self.manifest_dir(), self.dl_dir()])?; - - // First of all, a manifest is generated pointing to the smoke test server. This will - // produce the correct checksums and shipped files list, as the only difference from - // between the "real" execution and this one is the URLs included in the manifest. - let execution = - build_manifest.run(&format!("http://{}/dist", smoke_test.server_addr()))?; - signer.override_checksum_cache(execution.checksum_cache); + let smoke_test = SmokeTester::new(&[self.smoke_manifest_dir(), self.dl_dir()])?; + + // First of all, the real manifests are generated, pointing to the public download + // endpoint. This will also collect the list of files shipped in the release (used + // later to prune the files we're not shipping) and a cache of all the checksums + // generated by build-manifest. + let execution = build_manifest.run( + &format!("{}/{}", self.config.upload_addr, self.config.upload_dir), + &self.real_manifest_dir(), + )?; + + // Then another set of manifests is generated pointing to the smoke test server. These + // manifests will be discarded later. + build_manifest.run( + &format!("http://{}/dist", smoke_test.server_addr()), + &self.smoke_manifest_dir(), + )?; // Removes files that we are not shipping from the files we're about to upload. if let Some(shipped_files) = &execution.shipped_files { self.prune_unused_files(&shipped_files)?; } - // Sign both the downloaded artifacts and the generated manifests. The signatures of - // the downloaded files are permanent, while the signatures for the generated manifests - // will be discarded later (as the manifests point to the smoke test server). + // Sign both the downloaded artifacts and all the generated manifests. The signatures + // of the downloaded files and the real manifests are permanent, while the signatures + // for the smoke test manifests will be discarded later. + signer.override_checksum_cache(execution.checksum_cache); signer.sign_directory(&self.dl_dir())?; - signer.sign_directory(&self.manifest_dir())?; + signer.sign_directory(&self.real_manifest_dir())?; + signer.sign_directory(&self.smoke_manifest_dir())?; // Ensure the release is downloadable from rustup and can execute a basic binary. smoke_test.test(&self.config.channel)?; - // Generate the real manifests and sign them. - build_manifest.run(&format!( - "{}/{}", - self.config.upload_addr, self.config.upload_dir - ))?; - signer.sign_directory(&self.manifest_dir())?; - // Merge the generated manifests with the downloaded artifacts. - for entry in std::fs::read_dir(&self.manifest_dir())? { + for entry in std::fs::read_dir(&self.real_manifest_dir())? { let entry = entry?; if entry.file_type()?.is_file() { std::fs::rename(entry.path(), self.dl_dir().join(entry.file_name()))?; @@ -702,10 +706,14 @@ upload-addr = \"{}/{}\" self.work.join("dl") } - fn manifest_dir(&self) -> PathBuf { + fn real_manifest_dir(&self) -> PathBuf { self.work.join("manifests") } + fn smoke_manifest_dir(&self) -> PathBuf { + self.work.join("manifests-smoke") + } + fn build_dir(&self) -> PathBuf { self.work.join("build") }