@@ -102,6 +102,7 @@ pub(crate) struct Tarball<'a> {
102102
103103 include_target_in_component_name : bool ,
104104 is_preview : bool ,
105+ permit_symlinks : bool ,
105106}
106107
107108impl < ' a > Tarball < ' a > {
@@ -141,6 +142,7 @@ impl<'a> Tarball<'a> {
141142
142143 include_target_in_component_name : false ,
143144 is_preview : false ,
145+ permit_symlinks : false ,
144146 }
145147 }
146148
@@ -160,6 +162,10 @@ impl<'a> Tarball<'a> {
160162 self . is_preview = is;
161163 }
162164
165+ pub ( crate ) fn permit_symlinks ( & mut self , flag : bool ) {
166+ self . permit_symlinks = flag;
167+ }
168+
163169 pub ( crate ) fn image_dir ( & self ) -> & Path {
164170 t ! ( std:: fs:: create_dir_all( & self . image_dir) ) ;
165171 & self . image_dir
@@ -316,6 +322,18 @@ impl<'a> Tarball<'a> {
316322 }
317323 self . builder . run ( & mut cmd) ;
318324
325+ // Ensure there are no symbolic links in the tarball. In particular,
326+ // rustup-toolchain-install-master and most versions of Windows can't handle symbolic links.
327+ let decompressed_output = self . temp_dir . join ( & package_name) ;
328+ if !self . builder . config . dry_run && !self . permit_symlinks {
329+ for entry in walkdir:: WalkDir :: new ( & decompressed_output) {
330+ let entry = t ! ( entry) ;
331+ if entry. path_is_symlink ( ) {
332+ panic ! ( "generated a symlink in a tarball: {}" , entry. path( ) . display( ) ) ;
333+ }
334+ }
335+ }
336+
319337 // Use either the first compression format defined, or "gz" as the default.
320338 let ext = self
321339 . builder
@@ -328,7 +346,7 @@ impl<'a> Tarball<'a> {
328346
329347 GeneratedTarball {
330348 path : crate :: dist:: distdir ( self . builder ) . join ( format ! ( "{}.tar.{}" , package_name, ext) ) ,
331- decompressed_output : self . temp_dir . join ( package_name ) ,
349+ decompressed_output,
332350 work : self . temp_dir ,
333351 }
334352 }
0 commit comments