mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
parent
571aadfd63
commit
d5352d12e2
2 changed files with 88 additions and 0 deletions
56
source/Cosmos.Build.Common/IsoMaker.cs
Normal file
56
source/Cosmos.Build.Common/IsoMaker.cs
Normal file
|
|
@ -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 + '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
32
source/Cosmos.Build.Common/ProcessExtension.cs
Normal file
32
source/Cosmos.Build.Common/ProcessExtension.cs
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue