forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 571aadf.
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Cosmos.Build.Common | ||
{ | ||
public class IsoMaker | ||
{ | ||
static public string Generate(string imageFile, string isoFilename) | ||
{ | ||
var destinationDirectory = Path.GetDirectoryName(imageFile); | ||
|
||
string isoDirectory = Path.Combine(destinationDirectory, "iso"); | ||
|
||
if (Directory.Exists(isoDirectory)) | ||
{ | ||
Directory.Delete(isoDirectory, true); | ||
} | ||
|
||
Directory.CreateDirectory(isoDirectory); | ||
|
||
var buildISO = Path.Combine(CosmosPaths.Build, "ISO"); | ||
|
||
File.Copy(Path.Combine(buildISO, "isolinux.bin"), Path.Combine(isoDirectory, "isolinux.bin")); | ||
File.Copy(Path.Combine(buildISO, "mboot.c32"), Path.Combine(isoDirectory, "mboot.c32")); | ||
File.Copy(Path.Combine(buildISO, "syslinux.cfg"), Path.Combine(isoDirectory, "syslinux.cfg")); | ||
File.Copy(Path.Combine(buildISO, "ldlinux.c32"), Path.Combine(isoDirectory, "ldlinux.c32")); | ||
File.Copy(Path.Combine(buildISO, "libcom32.c32"), Path.Combine(isoDirectory, "libcom32.c32")); | ||
File.Copy(imageFile, Path.Combine(isoDirectory, "Cosmos.bin")); | ||
|
||
string arg = | ||
"-relaxed-filenames" + | ||
" -J -R" + | ||
" -o " + Quote(isoFilename) + | ||
" -b isolinux.bin" + | ||
" -no-emul-boot" + | ||
" -boot-load-size 4" + | ||
" -boot-info-table " + | ||
Quote(isoDirectory); | ||
|
||
var output = ProcessExtension.LaunchApplication( | ||
Path.Combine(Path.Combine(CosmosPaths.Tools, "mkisofs"), "mkisofs.exe"), | ||
arg, | ||
true | ||
); | ||
|
||
return output; | ||
} | ||
|
||
protected static string Quote(string location) | ||
{ | ||
return '"' + location + '"'; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Cosmos.Build.Common | ||
{ | ||
public static class ProcessExtension | ||
{ | ||
public static string LaunchApplication(string app, string args, bool waitForExit) | ||
{ | ||
var start = new ProcessStartInfo(); | ||
start.FileName = app; | ||
start.Arguments = args; | ||
start.UseShellExecute = false; | ||
start.CreateNoWindow = true; | ||
start.RedirectStandardOutput = true; | ||
start.RedirectStandardError = true; | ||
|
||
var process = Process.Start(start); | ||
|
||
if (waitForExit) | ||
{ | ||
var output = process.StandardOutput.ReadToEnd(); | ||
|
||
process.WaitForExit(); | ||
|
||
var error = process.StandardError.ReadToEnd(); | ||
return output + error; | ||
} | ||
|
||
return string.Empty; | ||
} | ||
} | ||
} |