Exemplo n.º 1
0
        private void CreateDiskImage(string compiledFile)
        {
            var bootImageOptions = new BootImageOptions();

            if (LauncherOptions.BootLoader == BootLoader.Syslinux_6_03)
            {
                bootImageOptions.MBRCode     = GetResource(@"syslinux\6.03", "mbr.bin");
                bootImageOptions.FatBootCode = GetResource(@"syslinux\6.03", "ldlinux.bin");

                bootImageOptions.IncludeFiles.Add(new IncludeFile("ldlinux.sys", GetResource(@"syslinux\6.03", "ldlinux.sys")));
                bootImageOptions.IncludeFiles.Add(new IncludeFile("mboot.c32", GetResource(@"syslinux\6.03", "mboot.c32")));
            }
            else if (LauncherOptions.BootLoader == BootLoader.Syslinux_3_72)
            {
                bootImageOptions.MBRCode     = GetResource(@"syslinux\3.72", "mbr.bin");
                bootImageOptions.FatBootCode = GetResource(@"syslinux\3.72", "ldlinux.bin");

                bootImageOptions.IncludeFiles.Add(new IncludeFile("ldlinux.sys", GetResource(@"syslinux\3.72", "ldlinux.sys")));
                bootImageOptions.IncludeFiles.Add(new IncludeFile("mboot.c32", GetResource(@"syslinux\3.72", "mboot.c32")));
            }

            bootImageOptions.IncludeFiles.Add(new IncludeFile("syslinux.cfg", GetResource("syslinux", "syslinux.cfg")));
            bootImageOptions.IncludeFiles.Add(new IncludeFile(compiledFile, "main.exe"));

            bootImageOptions.IncludeFiles.Add(new IncludeFile("TEST.TXT", Encoding.ASCII.GetBytes("This is a test file.")));

            foreach (var include in LauncherOptions.IncludeFiles)
            {
                bootImageOptions.IncludeFiles.Add(include);
            }

            bootImageOptions.VolumeLabel = "MOSABOOT";

            var vmext = ".img";

            switch (LauncherOptions.ImageFormat)
            {
            case ImageFormat.VHD: vmext = ".vhd"; break;

            case ImageFormat.VDI: vmext = ".vdi"; break;

            default: break;
            }

            ImageFile = Path.Combine(LauncherOptions.DestinationDirectory, Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile) + vmext);

            bootImageOptions.DiskImageFileName   = ImageFile;
            bootImageOptions.PatchSyslinuxOption = true;
            bootImageOptions.FileSystem          = LauncherOptions.FileSystem;
            bootImageOptions.ImageFormat         = LauncherOptions.ImageFormat;
            bootImageOptions.BootLoader          = LauncherOptions.BootLoader;

            Generator.Create(bootImageOptions);
        }
Exemplo n.º 2
0
        private void CreateDiskImage(string imagefile)
        {
            var bootImageOptions = new BootImageOptions();

            if (LauncherSettings.ImageBootLoader == "syslinux3.72")
            {
                bootImageOptions.MBRCode     = GetResource(@"syslinux\3.72", "mbr.bin");
                bootImageOptions.FatBootCode = GetResource(@"syslinux\3.72", "ldlinux.bin");

                bootImageOptions.IncludeFiles.Add(new IncludeFile("ldlinux.sys", GetResource(@"syslinux\3.72", "ldlinux.sys")));
                bootImageOptions.IncludeFiles.Add(new IncludeFile("mboot.c32", GetResource(@"syslinux\3.72", "mboot.c32")));
                bootImageOptions.PatchSyslinuxOption = true;
            }
            else if (LauncherSettings.ImageBootLoader == "syslinux6.03")
            {
                // NOT FULLY IMPLEMENTED YET!
                bootImageOptions.MBRCode     = GetResource(@"syslinux\6.03", "mbr.bin");
                bootImageOptions.FatBootCode = GetResource(@"syslinux\6.03", "ldlinux.bin");

                bootImageOptions.IncludeFiles.Add(new IncludeFile("ldlinux.sys", GetResource(@"syslinux\6.03", "ldlinux.sys")));
                bootImageOptions.IncludeFiles.Add(new IncludeFile("mboot.c32", GetResource(@"syslinux\6.03", "mboot.c32")));
                bootImageOptions.PatchSyslinuxOption = false;
            }

            bootImageOptions.IncludeFiles.Add(new IncludeFile("syslinux.cfg", GetSyslinuxCFG()));

            bootImageOptions.IncludeFiles.Add(new IncludeFile(LauncherSettings.OutputFile, "main.exe"));

            bootImageOptions.IncludeFiles.Add(new IncludeFile("TEST.TXT", Encoding.ASCII.GetBytes("This is a test file.")));

            if (LauncherSettings.FileSystemRootInclude != null)
            {
                var dir = Path.Combine(Path.GetDirectoryName(Environment.CurrentDirectory), LauncherSettings.FileSystemRootInclude);
                foreach (var file in Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories))
                {
                    var name = Path.GetFileName(file).ToUpper();

                    Console.WriteLine("Adding file: " + name);
                    bootImageOptions.IncludeFiles.Add(new IncludeFile(name, File.ReadAllBytes(file)));
                }
            }

            bootImageOptions.VolumeLabel       = "MOSA";
            bootImageOptions.DiskImageFileName = imagefile;

            switch (LauncherSettings.ImageBootLoader)
            {
            case "syslinux3.72": bootImageOptions.BootLoader = BootLoader.Syslinux_3_72; break;

            case "syslinux6.03": bootImageOptions.BootLoader = BootLoader.Syslinux_6_03; break;

            case "grub0.97": bootImageOptions.BootLoader = BootLoader.Grub_0_97; break;

            case "grub2.00": bootImageOptions.BootLoader = BootLoader.Grub_2_00; break;

            default: break;
            }

            switch (LauncherSettings.ImageFormat)
            {
            case "img": bootImageOptions.ImageFormat = ImageFormat.IMG; break;

            case "iso": bootImageOptions.ImageFormat = ImageFormat.ISO; break;

            case "vhd": bootImageOptions.ImageFormat = ImageFormat.VHD; break;

            case "vdi": bootImageOptions.ImageFormat = ImageFormat.VDI; break;

            case "vmdk": bootImageOptions.ImageFormat = ImageFormat.VMDK; break;

            default: break;
            }

            switch (LauncherSettings.FileSystem)
            {
            case "fat12": bootImageOptions.FileSystem = BootImage.FileSystem.FAT12; break;

            case "fat16": bootImageOptions.FileSystem = BootImage.FileSystem.FAT16; break;

            case "fat32": bootImageOptions.FileSystem = BootImage.FileSystem.FAT32; break;

            default: throw new NotImplementCompilerException("unknown file system");
            }

            Generator.Create(bootImageOptions);
        }
Exemplo n.º 3
0
 public Options()
 {
     options = new BootImageOptions();
 }
Exemplo n.º 4
0
        private void CreateDiskImage(string imagefile)
        {
            var bootImageOptions = new BootImageOptions();

            if (LauncherSettings.ImageBootLoader == "syslinux3.72")
            {
                bootImageOptions.MBRCode     = GetResource(@"syslinux\3.72", "mbr.bin");
                bootImageOptions.FatBootCode = GetResource(@"syslinux\3.72", "ldlinux.bin");

                bootImageOptions.IncludeFiles.Add(new IncludeFile("ldlinux.sys", GetResource(@"syslinux\3.72", "ldlinux.sys")));
                bootImageOptions.IncludeFiles.Add(new IncludeFile("mboot.c32", GetResource(@"syslinux\3.72", "mboot.c32")));
                bootImageOptions.PatchSyslinuxOption = true;
            }
            else if (LauncherSettings.ImageBootLoader == "syslinux6.03")
            {
                // NOT FULLY IMPLEMENTED YET!
                bootImageOptions.MBRCode     = GetResource(@"syslinux\6.03", "mbr.bin");
                bootImageOptions.FatBootCode = GetResource(@"syslinux\6.03", "ldlinux.bin");

                bootImageOptions.IncludeFiles.Add(new IncludeFile("ldlinux.sys", GetResource(@"syslinux\6.03", "ldlinux.sys")));
                bootImageOptions.IncludeFiles.Add(new IncludeFile("mboot.c32", GetResource(@"syslinux\6.03", "mboot.c32")));
                bootImageOptions.PatchSyslinuxOption = false;
            }

            bootImageOptions.IncludeFiles.Add(new IncludeFile("syslinux.cfg", GetResource("syslinux", "syslinux.cfg")));
            bootImageOptions.IncludeFiles.Add(new IncludeFile(LauncherSettings.OutputFile, "main.exe"));

            bootImageOptions.IncludeFiles.Add(new IncludeFile("TEST.TXT", Encoding.ASCII.GetBytes("This is a test file.")));

            bootImageOptions.VolumeLabel       = "MOSA";
            bootImageOptions.DiskImageFileName = imagefile;

            switch (LauncherSettings.ImageBootLoader)
            {
            case "syslinux3.72": bootImageOptions.BootLoader = BootLoader.Syslinux_3_72; break;

            case "syslinux6.03": bootImageOptions.BootLoader = BootLoader.Syslinux_6_03; break;

            case "grub0.97": bootImageOptions.BootLoader = BootLoader.Grub_0_97; break;

            case "grub2.00": bootImageOptions.BootLoader = BootLoader.Grub_2_00; break;

            default: break;
            }

            switch (LauncherSettings.ImageFormat)
            {
            case "img": bootImageOptions.ImageFormat = ImageFormat.IMG; break;

            case "iso": bootImageOptions.ImageFormat = ImageFormat.ISO; break;

            case "vhd": bootImageOptions.ImageFormat = ImageFormat.VHD; break;

            case "vdi": bootImageOptions.ImageFormat = ImageFormat.VDI; break;

            case "vmdk": bootImageOptions.ImageFormat = ImageFormat.VMDK; break;

            default: break;
            }

            switch (LauncherSettings.FileSystem)
            {
            case "fat12": bootImageOptions.FileSystem = BootImage.FileSystem.FAT12; break;

            case "fat16": bootImageOptions.FileSystem = BootImage.FileSystem.FAT16; break;

            case "fat32": bootImageOptions.FileSystem = BootImage.FileSystem.FAT32; break;

            default: throw new NotImplementCompilerException("unknown file system");
            }

            Generator.Create(bootImageOptions);
        }
Exemplo n.º 5
0
        public static BootImageOptions Parse(string filename)
        {
            var options = new BootImageOptions();

            var reader = File.OpenText(filename);

            while (true)
            {
                string line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                string[] parts = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                switch (parts[0].Trim())
                {
                case "-mbr": options.MBROption = true; options.MBRCode = (parts.Length > 1) ? File.ReadAllBytes(parts[1]) : null; break;

                case "-boot": options.FatBootCode = (parts.Length > 1) ? File.ReadAllBytes(parts[1]) : null; break;

                case "-vhd": options.ImageFormat = ImageFormat.VHD; break;

                case "-img": options.ImageFormat = ImageFormat.IMG; break;

                case "-vdi": options.ImageFormat = ImageFormat.VDI; break;

                case "-syslinux": options.PatchSyslinuxOption = true; break;

                case "-guid": if (parts.Length > 1)
                    {
                        options.MediaGuid = new Guid(parts[1]);
                    }
                    break;

                case "-snapguid": if (parts.Length > 1)
                    {
                        options.MediaLastSnapGuid = new Guid(parts[1]);
                    }
                    break;

                case "-fat12": options.FileSystem = FileSystem.FAT12; break;

                case "-fat16": options.FileSystem = FileSystem.FAT16; break;

                case "-fat32": options.FileSystem = FileSystem.FAT32; break;

                case "-file":
                    if (parts.Length > 2)
                    {
                        options.IncludeFiles.Add(new IncludeFile(parts[1], parts[2]));
                    }
                    else
                    {
                        options.IncludeFiles.Add(new IncludeFile(parts[1]));
                    } break;

                case "-blocks": options.BlockCount = Convert.ToUInt32(parts[1]); break;

                case "-volume": options.VolumeLabel = parts[1]; break;

                default: break;
                }
            }

            reader.Close();

            return(options);
        }