Skip to content

Commit

Permalink
- Use mkisofs to create ISO file
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Dec 7, 2014
1 parent 0cf75a8 commit ca7b9aa
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 29 deletions.
Binary file removed Build/Tools/mkisofs.exe
Binary file not shown.
Binary file added Build/Tools/mkisofs/mkisofs.exe
Binary file not shown.
6 changes: 6 additions & 0 deletions Build/Tools/mkisofs/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

mkisofs
- GPLv2
- http://code.google.com/p/mkisofs-md5/
- Version: 2.01

1 change: 1 addition & 0 deletions Setup/Cosmos.iss
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Source: ".\Resources\Dependencies\cecil\Mono.Cecil.Pdb.pdb"; DestDir: "{app}\Bui
Source: ".\Build\Tools\*.exe"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
Source: ".\Build\Tools\NAsm\*.exe"; DestDir: "{app}\Build\Tools\NAsm"; Flags: ignoreversion uninsremovereadonly
Source: ".\Build\Tools\Cygwin\*"; DestDir: "{app}\Build\Tools\cygwin"; Flags: ignoreversion uninsremovereadonly overwritereadonly
Source: ".\Build\Tools\mkisofs\*"; DestDir: "{app}\Build\Tools\mkisofs"; Flags: ignoreversion uninsremovereadonly overwritereadonly
;
Source: ".\Build\VSIP\Cosmos.Deploy.USB.exe"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
Source: ".\Build\VSIP\Cosmos.Build.Common.dll"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
Expand Down
1 change: 1 addition & 0 deletions source/Cosmos.Build.Common/Cosmos.Build.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<Compile Include="Enums.cs" />
<Compile Include="EnumValue.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="ProcessExtension.cs" />
<Compile Include="IsoMaker.cs" />
<Compile Include="PropertiesBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
78 changes: 51 additions & 27 deletions source/Cosmos.Build.Common/IsoMaker.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace Cosmos.Build.Common {
public class IsoMaker {

static public void Generate(string aBuildPath, string xInputPathname, string aIsoPathname) {
string xPath = Path.Combine(aBuildPath, @"ISO");
if (File.Exists(aIsoPathname)) {
File.Delete(aIsoPathname);
}

string xIsoLinux = Path.Combine(xPath, "isolinux.bin");
File.SetAttributes(xIsoLinux, FileAttributes.Normal);

var xPSI = new ProcessStartInfo(
Path.Combine(CosmosPaths.Tools, "mkisofs.exe"),
String.Format("-R -b \"{0}\" -no-emul-boot -boot-load-size 4 -boot-info-table -o \"{1}\" \"{2}\"",
xIsoLinux, aIsoPathname, xPath)
);
xPSI.UseShellExecute = false;
xPSI.CreateNoWindow = true;
Process.Start(xPSI);
using System.Text;

namespace Cosmos.Build.Common
{
public class IsoMaker
{
static public void 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(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
);

File.WriteAllText(Path.ChangeExtension(isoFilename, ".log"), output);
}

protected static string Quote(string location)
{
return '"' + location + '"';
}

}
}
}
}
32 changes: 32 additions & 0 deletions source/Cosmos.Build.Common/ProcessExtension.cs
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;
}
}
}
2 changes: 1 addition & 1 deletion source/Cosmos.Build.MSBuild/MakeISO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public string CosmosBuildDir {
#endregion

public override bool Execute() {
IsoMaker.Generate(CosmosBuildDir, InputFile, OutputFile);
IsoMaker.Generate(InputFile, OutputFile);
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.VS.Package/VsProjectConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override int DebugLaunch(uint aLaunch) {
string xBinFile = Path.ChangeExtension(xOutputAsm, ".bin");

if (xDeployment == DeploymentType.ISO) {
IsoMaker.Generate(CosmosPaths.Build, xBinFile, xIsoFile);
IsoMaker.Generate(xBinFile, xIsoFile);

} else if (xDeployment == DeploymentType.USB) {
Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.USB.exe"), "\"" + xBinFile + "\"");
Expand Down

0 comments on commit ca7b9aa

Please sign in to comment.