1 module gccbuild.extract; 2 3 import scriptlike, gccbuild; 4 5 void extractSources() 6 { 7 startSection("Extracting files"); 8 extractDir.tryMkdirRecurse(); 9 chdir(extractDir); 10 11 foreach (name, component; build.configuredComponents) 12 { 13 extractComponent(component); 14 } 15 16 if (build.glibc.isInConfig && build.glibcPorts) 17 { 18 extractComponent(build.glibcPorts); 19 runCollectLog( 20 "mv " ~ build.glibcPorts.sourceFolder.toString() ~ " " ~ ( 21 build.glibc.sourceFolder ~ "ports").toString()); 22 } 23 24 endSection(); 25 } 26 27 void extractComponent(Component component) 28 { 29 switch (component.file.extension) 30 { 31 case ".gz": 32 case ".bz2": 33 case ".xz": 34 failEnforcec(component.file.stripExt.extension == ".tar", 35 "Unknown archive format: ", component.file); 36 37 if (component.sourceFolder.exists && !forceExtract) 38 { 39 writeBulletPoint(component.file ~ " (cached)"); 40 } 41 else 42 { 43 string forced = component.sourceFolder.exists ? " (forced)" : ""; 44 writeBulletPoint(component.file ~ forced ~ "..."); 45 component.sourceFolder.tryRmdirRecurse(); 46 try 47 runCollectLog(mixin(interp!"tar xf ${component.localFile}")); 48 catch (Exception e) 49 failc("Couldn't extract ", component.file, ": ", e); 50 component.wasExtracted = true; 51 endBulletPoint(); 52 } 53 break; 54 default: 55 failc("Unknown archive format: ", component.file); 56 } 57 }