// Create a Makefile for release
        public virtual StringWriter GenerateMakeFileForRelease(string srcDir)
        {
            string gccOptionForLink;
            string gccOptionForCompile;

            generateGccOptions(srcDir, false, false, out gccOptionForLink, out gccOptionForCompile);

            string codeDir = Path.Combine(srcDir, "code");
            string libDir  = Path.Combine(srcDir, "lib");

            string[] codeFiles = Directory.GetFiles(codeDir, "*.a");
            string[] libFiles  = Directory.GetFiles(libDir, "*.a");

            StringWriter sr = new StringWriter();

            sr.WriteLine("# {0}", this.TitleString);
            sr.WriteLine("# Makefile");
            sr.WriteLine("# ");

#if !BU_SOFTETHER
            sr.WriteLine("# Copyright (c) SoftEther Corporation. All Rights Reserved.");
#else
            sr.WriteLine("# Copyright (c) SoftEther VPN Project at University of Tsukuba, Japan. All Rights Reserved.");
#endif
            sr.WriteLine("# Platform: {0}", this.CrossLibName);
            sr.WriteLine();
            sr.WriteLine("CC={0}", this.Compiler);
            sr.WriteLine();
            sr.WriteLine();
            sr.WriteLine("OPTIONS={0}", gccOptionForLink);
            sr.WriteLine();
            sr.WriteLine("default:");
            sr.WriteLine("\t@./.install.sh");
            sr.WriteLine();
            sr.WriteLine("# NOTE:");
            sr.WriteLine("# You have to read and agree the license agreement at the same directory");
            sr.WriteLine("#  before using this software.");
            sr.WriteLine();
            sr.WriteLine("i_read_and_agree_the_license_agreement:");

            sr.WriteLine("\t@echo \"Preparing {0}...\"", BuildHelper.GetSoftwareTitle(this.Software));

            foreach (string filename in libFiles)
            {
                sr.WriteLine("\t-ranlib lib/{0}", Path.GetFileName(filename));
            }

            sr.WriteLine("\t-ranlib code/{0}.a", this.Software.ToString());

            sr.WriteLine("\t$(CC) code/{0}.a $(OPTIONS) -o {0}", this.Software.ToString());

            sr.WriteLine("\t-ranlib code/{0}.a", "vpncmd");

            sr.WriteLine("\t$(CC) code/{0}.a $(OPTIONS) -o {0}", "vpncmd");

            if (this.Software == Software.vpnserver_vpnbridge || this.Software == Software.vpnbridge || this.Software == Software.vpnserver)
            {
                sr.WriteLine("\t./vpncmd /tool /cmd:Check");
            }

            Language[] langs = BuildHelper.GetLanguageList();

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"--------------------------------------------------------------------\"");
            sr.WriteLine("\t@echo \"The preparation of {0} is completed !\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"*** How to switch the display language of the {0} Service ***\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo \"{0} supports the following languages:\"", BuildHelper.GetSoftwareTitle(this.Software));

            foreach (Language lang in langs)
            {
                sr.WriteLine("\t@echo \"  - {0}\"", lang.Title);
            }

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"You can choose your prefered language of {0} at any time.\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo \"To switch the current language, open and edit the 'lang.config' file.\"");

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"Note: the administrative password is not set on the VPN Server. Please set your own administrative password as soon as possible by vpncmd or the GUI manager.\"");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo \"*** How to start the {0} Service ***\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo \"Please execute './{0} start' to run the {1} Background Service.\"", this.Software.ToString(), BuildHelper.GetSoftwareTitle(this.Software));
#if !BU_SOFTETHER
            sr.WriteLine("\t@echo \"And please execute './vpncmd' to run the PacketiX VPN Command-Line Utility to configure {0}.\"", BuildHelper.GetSoftwareTitle(this.Software));
#else
            sr.WriteLine("\t@echo \"And please execute './vpncmd' to run the SoftEther VPN Command-Line Utility to configure {0}.\"", BuildHelper.GetSoftwareTitle(this.Software));
#endif
            sr.WriteLine("\t@echo");

#if !BU_SOFTETHER
            sr.WriteLine("\t@echo \"Of course, you can use the VPN Server Manager GUI Application for Windows on the other Windows PC in order to configure the {0} remotely.\"", BuildHelper.GetSoftwareTitle(this.Software));
#else
            sr.WriteLine("\t@echo \"Of course, you can use the VPN Server Manager GUI Application for Windows / Mac OS X on the other Windows / Mac OS X computers in order to configure the {0} remotely.\"", BuildHelper.GetSoftwareTitle(this.Software));
#endif

#if !BU_SOFTETHER
#else
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"*** For Windows users ***\"");
            sr.WriteLine("\t@echo \"You can download the SoftEther VPN Server Manager for Windows\"");
            sr.WriteLine("\t@echo \"from the http://www.softether-download.com/ web site.\"");
            sr.WriteLine("\t@echo \"This manager application helps you to completely and easily manage the VPN server services running in remote hosts.\"");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"*** For Mac OS X users ***\"");
            sr.WriteLine("\t@echo \"In April 2016 we released the SoftEther VPN Server Manager for Mac OS X.\"");
            sr.WriteLine("\t@echo \"You can download it from the http://www.softether-download.com/ web site.\"");
            sr.WriteLine("\t@echo \"VPN Server Manager for Mac OS X works perfectly as same as the traditional Windows versions. It helps you to completely and easily manage the VPN server services running in remote hosts.\"");
            sr.WriteLine("\t@echo");
#endif

            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo");
#if !BU_SOFTETHER
            sr.WriteLine("\t@echo \"*** SoftEther VPN Server HTML5 Web Administration Console (NEW) ***\"");
#else
            sr.WriteLine("\t@echo \"*** PacketiX VPN Server HTML5 Web Administration Console (NEW) ***\"");
#endif
            sr.WriteLine("\t@echo \"This VPN Server / Bridge has the built-in HTML5 Web Administration Console.\"");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"After you start the server daemon, you can open the HTML5 Web Administration Console is available at\"");
            sr.WriteLine("\t@echo");
#if !BU_SOFTETHER
            sr.WriteLine("\t@echo \"https://127.0.0.1:8888/\"");
            sr.WriteLine("\t@echo \"  or\"");
            sr.WriteLine("\t@echo \"https://*****:*****@echo \"https://127.0.0.1:5555/\"");
            sr.WriteLine("\t@echo \"or\"");
            sr.WriteLine("\t@echo \"https://*****:*****@echo");
            sr.WriteLine("\t@echo \"This HTML5 page is obviously under construction, and your HTML5 development contribution is very appreciated.\"");
            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo \"--------------------------------------------------------------------\"");
            sr.WriteLine("\t@echo");

            sr.WriteLine();

            sr.WriteLine("clean:");
            sr.WriteLine("\trm -f {0}", this.Software.ToString());
            sr.WriteLine("\trm -f {0}", "vpncmd");
            sr.WriteLine();

            return(sr);
        }
Пример #2
0
        // Create a Makefile for release
        public virtual StringWriter GenerateMakeFileForRelease(string srcDir)
        {
            string gccOptionForLink;
            string gccOptionForCompile;

            generateGccOptions(srcDir, false, false, out gccOptionForLink, out gccOptionForCompile);

            string codeDir = Path.Combine(srcDir, "code");
            string libDir  = Path.Combine(srcDir, "lib");

            string[] codeFiles = Directory.GetFiles(codeDir, "*.a");
            string[] libFiles  = Directory.GetFiles(libDir, "*.a");

            StringWriter sr = new StringWriter();

            sr.WriteLine("# {0}", this.TitleString);
            sr.WriteLine("# Makefile");
            sr.WriteLine("# ");

#if !BU_SOFTETHER
            sr.WriteLine("# Copyright (c) SoftEther Corporation. All Rights Reserved.");
#else
            sr.WriteLine("# Copyright (c) SoftEther VPN Project at University of Tsukuba, Japan. All Rights Reserved.");
#endif
            sr.WriteLine("# Platform: {0}", this.CrossLibName);
            sr.WriteLine();
            sr.WriteLine("CC={0}", this.Compiler);
            sr.WriteLine("OPTIONS={0}", gccOptionForLink);
            sr.WriteLine();
            sr.WriteLine("default:");
            sr.WriteLine("\t@./.install.sh");
            sr.WriteLine();
            sr.WriteLine("# NOTE:");
            sr.WriteLine("# You have to read and agree the license agreement at the same directory");
            sr.WriteLine("#  before using this software.");
            sr.WriteLine();
            sr.WriteLine("i_read_and_agree_the_license_agreement:");

            sr.WriteLine("\t@echo \"Preparing {0}...\"", BuildHelper.GetSoftwareTitle(this.Software));

            foreach (string filename in libFiles)
            {
                sr.WriteLine("\t-ranlib lib/{0}", Path.GetFileName(filename));
            }

            sr.WriteLine("\t-ranlib code/{0}.a", this.Software.ToString());
            sr.WriteLine("\t$(CC) code/{0}.a $(OPTIONS) -o {0}", this.Software.ToString());

            sr.WriteLine("\t-ranlib code/{0}.a", "vpncmd");
            sr.WriteLine("\t$(CC) code/{0}.a $(OPTIONS) -o {0}", "vpncmd");

            if (this.Software == Software.vpnserver_vpnbridge || this.Software == Software.vpnbridge || this.Software == Software.vpnserver)
            {
                sr.WriteLine("\t./vpncmd /tool /cmd:Check");
            }

            Language[] langs = BuildHelper.GetLanguageList();

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"--------------------------------------------------------------------\"");
            sr.WriteLine("\t@echo \"The preparation of {0} is completed !\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"*** How to switch the display language of the {0} Service ***\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo \"{0} supports the following languages:\"", BuildHelper.GetSoftwareTitle(this.Software));

            foreach (Language lang in langs)
            {
                sr.WriteLine("\t@echo \"  - {0}\"", lang.Title);
            }

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"You can choose your prefered language of {0} at any time.\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo \"To switch the current language, open and edit the 'lang.config' file.\"");

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo \"*** How to start the {0} Service ***\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo \"Please execute './{0} start' to run the {1} Background Service.\"", this.Software.ToString(), BuildHelper.GetSoftwareTitle(this.Software));
#if !BU_SOFTETHER
            sr.WriteLine("\t@echo \"And please execute './vpncmd' to run the PacketiX VPN Command-Line Utility to configure {0}.\"", BuildHelper.GetSoftwareTitle(this.Software));
#else
            sr.WriteLine("\t@echo \"And please execute './vpncmd' to run the SoftEther VPN Command-Line Utility to configure {0}.\"", BuildHelper.GetSoftwareTitle(this.Software));
#endif
            sr.WriteLine("\t@echo \"Of course, you can use the VPN Server Manager GUI Application for Windows on the other Windows PC in order to configure the {0} remotely.\"", BuildHelper.GetSoftwareTitle(this.Software));

            sr.WriteLine("\t@echo \"--------------------------------------------------------------------\"");
            sr.WriteLine("\t@echo");

            sr.WriteLine();

            sr.WriteLine("clean:");
            sr.WriteLine("\trm -f {0}", this.Software.ToString());
            sr.WriteLine("\trm -f {0}", "vpncmd");
            sr.WriteLine();

            return(sr);
        }
Пример #3
0
        static int ReleaseWin32(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[id]"),
                new ConsoleParam("IGNOREERROR"),
                new ConsoleParam("SERIAL"),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            bool     serial = vl["SERIAL"].BoolValue;
            int      version, build;
            string   name;
            DateTime date;

            Win32BuildUtil.ReadBuildInfoFromTextFile(out build, out version, out name, out date);
            BuildSoftware[] softs = BuildSoftwareList.List;

            if (Str.IsEmptyStr(vl.DefaultParam.StrValue))
            {
                Con.WriteLine("IDs:");
                foreach (BuildSoftware soft in softs)
                {
                    if (soft.Os.IsWindows)
                    {
                        soft.SetBuildNumberVersionName(build, version, name, date);
                        Con.WriteLine("  {0}", soft.IDString);
                        Con.WriteLine("    - \"{0}\"", soft.OutputFileName);
                    }
                }
            }
            else
            {
                string key = vl.DefaultParam.StrValue;
                bool   all = false;

                if ("all".StartsWith(key, StringComparison.InvariantCultureIgnoreCase))
                {
                    all = true;
                }

                if ("clean".StartsWith(key, StringComparison.InvariantCultureIgnoreCase))
                {
                    // Delete the release directory
                    Paths.DeleteAllReleaseExe();
                    Con.WriteLine("Clean completed.");
                    return(0);
                }

                List <BuildSoftware> o = new List <BuildSoftware>();

                foreach (BuildSoftware soft in softs)
                {
                    soft.SetBuildNumberVersionName(build, version, name, date);

                    if (soft.Os.IsWindows)
                    {
                        if (all || soft.IDString.IndexOf(key, StringComparison.InvariantCultureIgnoreCase) != -1)
                        {
                            o.Add(soft);
                        }
                    }
                }

                if (o.Count == 0)
                {
                    throw new ApplicationException(string.Format("Software ID '{0}' not found.", key));
                }
                else
                {
                    if (all)
                    {
                        // Delete the release directory
                        Paths.DeleteAllReleaseExe();
                    }
                    else
                    {
                        IO.MakeDir(Paths.ReleaseDir);
                    }

                    if (serial)
                    {
                        // Build in series
                        int i;
                        for (i = 0; i < o.Count; i++)
                        {
                            Con.WriteLine("{0} / {1}: Executing for '{2}'...",
                                          i + 1, o.Count, o[i].IDString);

                            BuildHelper.BuildMain(o[i], false);
                        }
                    }
                    else if (o.Count == 1)
                    {
                        // To build
                        BuildHelper.BuildMain(o[0], false);
                    }
                    else
                    {
                        // Make a child process build
                        Process[] procs = new Process[o.Count];

                        int i;

                        for (i = 0; i < o.Count; i++)
                        {
                            Con.WriteLine("{0} / {1}: Executing for '{2}'...",
                                          i + 1, o.Count, o[i].IDString);

                            procs[i] = Kernel.Run(Env.ExeFileName,
                                                  string.Format("/PAUSEIFERROR:{1} /CMD:ReleaseWin32 {0}",
                                                                o[i].IDString, vl["IGNOREERROR"].BoolValue ? "no" : "yes"));
                        }

                        Con.WriteLine("Waiting child processes...");

                        int numError = 0;

                        for (i = 0; i < o.Count; i++)
                        {
                            procs[i].WaitForExit();

                            bool ok = procs[i].ExitCode == 0;

                            if (ok == false)
                            {
                                numError++;
                            }

                            Con.WriteLine("{0} / {1} ({2}):", i + 1, o.Count, o[i].IDString);
                            Con.WriteLine("       {0}", ok ? "Success" : "* Error *");
                        }

                        Con.WriteLine();
                        if (numError != 0)
                        {
                            throw new ApplicationException(string.Format("{0} Errors.", numError));
                        }
                        Con.WriteLine("No Errors.");
                    }
                }
            }

            return(0);
        }
Пример #4
0
        // Create a Makefile for release
        public virtual StringWriter GenerateMakeFileForRelease(string srcDir)
        {
            string gccOptionForLink;
            string gccOptionForCompile;

            bool try_no_pie = false;

            if (this.Os == OSList.Linux)
            {
                try_no_pie = true;
            }

            generateGccOptions(srcDir, false, false, out gccOptionForLink, out gccOptionForCompile);

            string codeDir = Path.Combine(srcDir, "code");
            string libDir  = Path.Combine(srcDir, "lib");

            string[] codeFiles = Directory.GetFiles(codeDir, "*.a");
            string[] libFiles  = Directory.GetFiles(libDir, "*.a");

            StringWriter sr = new StringWriter();

            sr.WriteLine("# {0}", this.TitleString);
            sr.WriteLine("# Makefile");
            sr.WriteLine("# ");

#if !BU_SOFTETHER
            sr.WriteLine("# Copyright (c) SoftEther Corporation. All Rights Reserved.");
#else
            sr.WriteLine("# Copyright (c) SoftEther VPN Project at University of Tsukuba, Japan. All Rights Reserved.");
#endif
            sr.WriteLine("# Platform: {0}", this.CrossLibName);
            sr.WriteLine();
            sr.WriteLine("CC={0}", this.Compiler);
            sr.WriteLine();
            if (try_no_pie)
            {
                sr.WriteLine("#For Ubuntu 18.04 or later we must add -no-pie option for gcc if supported");
                sr.WriteLine("RET_NO_PIE_CHECK := $(shell $(CC) -no-pie 2>&1 | grep no-pie | wc -w)");
                sr.WriteLine("ifeq ($(RET_NO_PIE_CHECK),0)");
                sr.WriteLine("\tNO_PIE_OPTION=-no-pie");
                sr.WriteLine("else");
                sr.WriteLine("\tNO_PIE_OPTION=");
                sr.WriteLine("endif");
            }
            else
            {
                sr.WriteLine("NO_PIE_OPTION=");
            }
            sr.WriteLine();
            sr.WriteLine("OPTIONS=$(NO_PIE_OPTION) {0}", gccOptionForLink);
            sr.WriteLine();
            sr.WriteLine("default:");
            sr.WriteLine("\t@./.install.sh");
            sr.WriteLine();
            sr.WriteLine("# NOTE:");
            sr.WriteLine("# You have to read and agree the license agreement at the same directory");
            sr.WriteLine("#  before using this software.");
            sr.WriteLine();
            sr.WriteLine("i_read_and_agree_the_license_agreement:");

            sr.WriteLine("\t@echo \"Preparing {0}...\"", BuildHelper.GetSoftwareTitle(this.Software));

            foreach (string filename in libFiles)
            {
                sr.WriteLine("\t-ranlib lib/{0}", Path.GetFileName(filename));
            }

            sr.WriteLine("\t-ranlib code/{0}.a", this.Software.ToString());

            sr.WriteLine("\t$(CC) code/{0}.a $(OPTIONS) -o {0}", this.Software.ToString());

            sr.WriteLine("\t-ranlib code/{0}.a", "vpncmd");

            sr.WriteLine("\t$(CC) code/{0}.a $(OPTIONS) -o {0}", "vpncmd");

            if (this.Software == Software.vpnserver_vpnbridge || this.Software == Software.vpnbridge || this.Software == Software.vpnserver)
            {
                sr.WriteLine("\t./vpncmd /tool /cmd:Check");
            }

            Language[] langs = BuildHelper.GetLanguageList();

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"--------------------------------------------------------------------\"");
            sr.WriteLine("\t@echo \"The preparation of {0} is completed !\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"*** How to switch the display language of the {0} Service ***\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo \"{0} supports the following languages:\"", BuildHelper.GetSoftwareTitle(this.Software));

            foreach (Language lang in langs)
            {
                sr.WriteLine("\t@echo \"  - {0}\"", lang.Title);
            }

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"You can choose your prefered language of {0} at any time.\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo \"To switch the current language, open and edit the 'lang.config' file.\"");

            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo \"*** How to start the {0} Service ***\"", BuildHelper.GetSoftwareTitle(this.Software));
            sr.WriteLine("\t@echo");

            sr.WriteLine("\t@echo \"Please execute './{0} start' to run the {1} Background Service.\"", this.Software.ToString(), BuildHelper.GetSoftwareTitle(this.Software));
#if !BU_SOFTETHER
            sr.WriteLine("\t@echo \"And please execute './vpncmd' to run the PacketiX VPN Command-Line Utility to configure {0}.\"", BuildHelper.GetSoftwareTitle(this.Software));
#else
            sr.WriteLine("\t@echo \"And please execute './vpncmd' to run the SoftEther VPN Command-Line Utility to configure {0}.\"", BuildHelper.GetSoftwareTitle(this.Software));
#endif
            sr.WriteLine("\t@echo");
#if !BU_SOFTETHER
            sr.WriteLine("\t@echo \"Of course, you can use the VPN Server Manager GUI Application for Windows on the other Windows PC in order to configure the {0} remotely.\"", BuildHelper.GetSoftwareTitle(this.Software));
#else
            sr.WriteLine("\t@echo \"Of course, you can use the VPN Server Manager GUI Application for Windows / Mac OS X on the other Windows / Mac OS X computers in order to configure the {0} remotely.\"", BuildHelper.GetSoftwareTitle(this.Software));
#endif

#if !BU_SOFTETHER
#else
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"*** For Windows users ***\"");
            sr.WriteLine("\t@echo \"You can download the SoftEther VPN Server Manager for Windows\"");
            sr.WriteLine("\t@echo \"from the http://www.softether-download.com/ web site.\"");
            sr.WriteLine("\t@echo \"This manager application helps you to completely and easily manage the VPN server services running in remote hosts.\"");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo");
            sr.WriteLine("\t@echo \"*** For Mac OS X users ***\"");
            sr.WriteLine("\t@echo \"In April 2016 we released the SoftEther VPN Server Manager for Mac OS X.\"");
            sr.WriteLine("\t@echo \"You can download it from the http://www.softether-download.com/ web site.\"");
            sr.WriteLine("\t@echo \"VPN Server Manager for Mac OS X works perfectly as same as the traditional Windows versions. It helps you to completely and easily manage the VPN server services running in remote hosts.\"");
            sr.WriteLine("\t@echo");
#endif


            sr.WriteLine("\t@echo \"--------------------------------------------------------------------\"");
            sr.WriteLine("\t@echo");

            sr.WriteLine();

            sr.WriteLine("clean:");
            sr.WriteLine("\trm -f {0}", this.Software.ToString());
            sr.WriteLine("\trm -f {0}", "vpncmd");
            sr.WriteLine();

            return(sr);
        }
Пример #5
0
        static int CopyRelease(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            int      build, version;
            string   name;
            DateTime date;

            Win32BuildUtil.ReadBuildInfoFromTextFile(out build, out version, out name, out date);

            string baseName = string.Format("v{0}-{1}-{2}-{3:D4}.{4:D2}.{5:D2}",
                                            BuildHelper.VersionIntToString(version),
                                            build,
                                            name,
                                            date.Year, date.Month, date.Day);

#if !BU_OSS
            string destDirName = Path.Combine(Paths.ReleaseDestDir,
                                              string.Format(@"{0}-{1}-{2}-{3}",
                                                            Str.DateToStrShort(BuildSoftwareList.ListCreatedDateTime),
                                                            baseName,
                                                            Env.MachineName, Env.UserName));
#else   // !BU_OSS
            string destDirName = Path.Combine(Paths.ReleaseDestDir,
                                              string.Format(@"{1}",
                                                            Str.DateToStrShort(BuildSoftwareList.ListCreatedDateTime),
                                                            baseName,
                                                            Env.MachineName, Env.UserName));
#endif

#if !BU_OSS
            string publicDir = Path.Combine(destDirName, "Public");
#else   // !BU_OSS
            string publicDir = destDirName;
#endif

#if !BU_OSS
            string filesReleaseDir = Path.Combine(publicDir, baseName);
#else   // !BU_OSS
            string filesReleaseDir = publicDir;
#endif

            string autorunReleaseSrcDir = Path.Combine(publicDir, "autorun");

            IO.CopyDir(Paths.ReleaseDir, filesReleaseDir, null, false, true);

#if !BU_OSS
            IO.CopyDir(Paths.ReleaseSrckitDir, Path.Combine(destDirName, "Private"), null, false, true);
            IO.CopyDir(Path.Combine(Paths.BaseDirName, @"tmp\lib"), Path.Combine(destDirName, @"Private\lib"), null, false, true);
#endif

            //IO.MakeDir(autorunReleaseSrcDir);

            /*
             * File.Copy(Path.Combine(Paths.AutorunSrcDir, "Project1.exe"),
             *      Path.Combine(autorunReleaseSrcDir, "autorun.exe"), true);
             *
             * File.Copy(Path.Combine(Paths.AutorunSrcDir, "autorun.inf"),
             *      Path.Combine(autorunReleaseSrcDir, "autorun.inf"), true);
             *
             * File.Copy(Path.Combine(Paths.AutorunSrcDir, "packetix.ico"),
             *      Path.Combine(autorunReleaseSrcDir, "autorun.ico"), true);*/

            // Create a batch file
            string batchFileName = Path.Combine(publicDir, "MakeCD.cmd");
#if !BU_OSS
            StreamWriter w = new StreamWriter(batchFileName);
#else   // !BU_OSS
            StringWriter w = new StringWriter();
#endif
            w.WriteLine(@"SETLOCAL");
            w.WriteLine(@"SET BATCH_FILE_NAME=%0");
            w.WriteLine(@"SET BATCH_DIR_NAME=%0\..");
            w.WriteLine(@"SET NOW_TMP=%time:~0,2%");
            w.WriteLine(@"SET NOW=%date:~0,4%%date:~5,2%%date:~8,2%_%NOW_TMP: =0%%time:~3,2%%time:~6,2%");
            w.WriteLine();
            w.WriteLine();

            string[] files = Directory.GetFiles(filesReleaseDir, "*", SearchOption.AllDirectories);

            string cddir = "CD";

            /*string.Format("CD-v{0}.{1}-{2}-{3}-{4:D4}.{5:D2}.{6:D2}",
             * version / 100, version % 100, build, name,
             * date.Year, date.Month, date.Day);*/

            StringWriter txt = new StringWriter();

            foreach (string filename in files)
            {
                string file = filename;

                BuildSoftware s = new BuildSoftware(file);

                // Software\Windows\PacketiX VPN Server 4.0\32bit (Intel x86)\filename.exe
                string cpustr  = string.Format("{0} - {1}", CPUBitsUtil.CPUBitsToString(s.Cpu.Bits), s.Cpu.Title).Replace("/", "or");
                string cpustr2 = cpustr;

                if (s.Cpu == CpuList.intel)
                {
                    cpustr2 = "";
                    cpustr  = "Intel";
                }

                string tmp = string.Format(@"{1}\{2}\{3}\{5}{4}",
                                           0,
                                           s.Os.Title,
                                           BuildHelper.GetSoftwareTitle(s.Software),
                                           cpustr2,
                                           Path.GetFileName(file),
                                           ""
                                           );

                tmp = Str.ReplaceStr(tmp, "\\\\", "\\");

                w.WriteLine("mkdir \"{1}\\{0}\"", Path.GetDirectoryName(tmp), cddir);
                w.WriteLine("copy /b /y \"{2}\\{0}\" \"{3}\\{1}\"", IO.GetRelativeFileName(file, filesReleaseDir), tmp, baseName, cddir);
                w.WriteLine();

                string txt_filename = tmp;
                txt_filename = Str.ReplaceStr(txt_filename, "\\", "/");

                string txt_description = BuildHelper.GetSoftwareTitle(s.Software);

                string txt_products = BuildHelper.GetSoftwareProductList(s.Software);

                string txt_os = s.Os.Title;

                string txt_cpu = s.Cpu.Title;
                if (s.Cpu.Bits != CPUBits.Both)
                {
                    txt_cpu += " (" + CPUBitsUtil.CPUBitsToString(s.Cpu.Bits) + ")";
                }
                else
                {
                    txt_cpu += " (x86 and x64)";
                }

                string txt_version = BuildHelper.VersionIntToString(version);

                string txt_build = build.ToString();

                string txt_verstr = name;

                string txt_date = Str.DateTimeToStrShortWithMilliSecs(date);

                string txt_lang = "English, Japanese, Simplified Chinese";

                string txt_category = "PacketiX VPN (Commercial)";

#if BU_SOFTETHER
                txt_category = "SoftEther VPN (Freeware)";
#endif

                txt.WriteLine("FILENAME\t" + txt_filename);
                txt.WriteLine("DESCRIPTION\t" + txt_description);
                txt.WriteLine("CATEGORY\t" + txt_category);
                txt.WriteLine("PRODUCT\t" + txt_products);
                txt.WriteLine("OS\t" + txt_os);
                txt.WriteLine("OSLIST\t" + s.Os.OSSimpleList);
                txt.WriteLine("CPU\t" + txt_cpu);
                txt.WriteLine("VERSION\t" + txt_version);
                txt.WriteLine("BUILD\t" + txt_build);
                txt.WriteLine("VERSTR\t" + txt_verstr);
                txt.WriteLine("DATE\t" + txt_date);
                txt.WriteLine("LANGUAGE\t" + txt_lang);
                txt.WriteLine("*");
                txt.WriteLine();
            }

#if BU_OSS
            Con.WriteLine("Installer packages are built on '{0}'. Enjoy it !!", publicDir);

            return(0);
#endif  // BU_OSS

            /*
             * w.WriteLine("mkdir \"{0}\\autorun\"", cddir);
             * w.WriteLine("copy /b /y autorun\\autorun.ico \"{0}\\autorun\"", cddir);
             * w.WriteLine("copy /b /y autorun\\autorun.exe \"{0}\\autorun\"", cddir);
             * w.WriteLine("copy /b /y autorun\\autorun.inf \"{0}\\autorun.inf\"", cddir);
             * */

            string zipFileName = string.Format("VPN-CD-v{0}.{1:D2}-{2}-{3}-{4:D4}.{5:D2}.{6:D2}.zip",
                                               version / 100, version % 100, build, name,
                                               date.Year, date.Month, date.Day);
            w.WriteLine("del {0}", zipFileName);
            w.WriteLine("CD {0}", cddir);
            w.WriteLine("zip -r -0 ../{0} *", zipFileName);
            w.WriteLine("cd ..");
            w.WriteLine("move {0} CD\\", zipFileName);
            w.WriteLine("rename CD {0}-tree", baseName);
            w.WriteLine();

            w.Close();

            // Copy of fastcopy
            string fastcopy_dest = Path.Combine(destDirName, @"Private\fastcopy_bin");
            IO.MakeDirIfNotExists(fastcopy_dest);
            File.Copy(Path.Combine(Paths.UtilityDirName, "FastCopy.exe"), Path.Combine(fastcopy_dest, "FastCopy.exe"), true);
            File.Copy(Path.Combine(Paths.UtilityDirName, "FastEx64.dll"), Path.Combine(fastcopy_dest, "FastEx64.dll"), true);
            File.Copy(Path.Combine(Paths.UtilityDirName, "FastExt1.dll"), Path.Combine(fastcopy_dest, "FastExt1.dll"), true);

            string fastcopy_exe = @"..\Private\fastcopy_bin\FastCopy.exe";

            // Create a upload batch
            string uploadBatchFileName = Path.Combine(publicDir, "UploadNow.cmd");
#if !BU_OSS
            w = new StreamWriter(uploadBatchFileName);
#endif  // !BU_OSS

            string folder_name = "packetix";
#if BU_SOFTETHER
            folder_name = "softether";
#endif
            w.WriteLine(@"mkdir \\download\FILES\{1}\{0}-tree", baseName, folder_name);
            w.WriteLine(@"{0} /cmd=force_copy /exclude={3} /auto_close /force_start /estimate /open_window /error_stop=TRUE /bufsize=128 /disk_mode=diff /speed=full /verify {1}-tree /to=\\download\FILES\{2}\{1}-tree", fastcopy_exe, baseName, folder_name,
                        "\"*files.txt*\"");

            w.WriteLine();

            /*
             * w.WriteLine(@"mkdir \\downloadjp\FILES\{1}\{0}-tree", baseName, folder_name);
             * w.WriteLine(@"{0} /cmd=force_copy /exclude={3} /auto_close /force_start /estimate /open_window /error_stop=TRUE /bufsize=128 /disk_mode=diff /speed=full /verify {1}-tree /to=\\downloadjp\FILES\{2}\{1}-tree", fastcopy_exe, baseName, folder_name,
             *      "\"*files.txt*\"");
             *
             * w.WriteLine();*/

            w.WriteLine(@"copy /y /b {0}-tree\files.txt \\download\FILES\{1}\{0}-tree\files.txt", baseName, folder_name);
            //w.WriteLine(@"copy /y /b {0}-tree\files.txt \\downloadjp\FILES\{1}\{0}-tree\files.txt", baseName, folder_name);


            w.WriteLine();
            w.WriteLine(@"pause");
            w.WriteLine();

            w.Close();


            txt.WriteLine("FILENAME\t" + zipFileName);
#if BU_SOFTETHER
            txt.WriteLine("DESCRIPTION\t" + "ZIP CD-ROM Image Package of SoftEther VPN (for Admins)");
            txt.WriteLine("CATEGORY\t" + "SoftEther VPN (Freeware)");
            txt.WriteLine("PRODUCT\t" + "ZIP CD-ROM Image Package of SoftEther VPN");
#else   // BU_SOFTETHER
            txt.WriteLine("DESCRIPTION\t" + "ZIP CD-ROM Image Package of PacketiX VPN (for Admins)");
            txt.WriteLine("CATEGORY\t" + "PacketiX VPN (Commercial)");
            txt.WriteLine("PRODUCT\t" + "ZIP CD-ROM Image Package of PacketiX VPN");
#endif  // BU_SOFTETHER
            txt.WriteLine("OS\t" + "Any");
            txt.WriteLine("OSLIST\t" + "Any");
            txt.WriteLine("CPU\t" + "CD-ROM");
            txt.WriteLine("VERSION\t" + BuildHelper.VersionIntToString(version));
            txt.WriteLine("BUILD\t" + build.ToString());
            txt.WriteLine("VERSTR\t" + name);
            txt.WriteLine("DATE\t" + Str.DateTimeToStrShortWithMilliSecs(date));
            txt.WriteLine("LANGUAGE\t" + "English, Japanese, Simplified Chinese");
            txt.WriteLine("*");
            txt.WriteLine();

            IO.MakeDirIfNotExists(Path.Combine(publicDir, cddir));
            File.WriteAllText(Path.Combine(Path.Combine(publicDir, cddir), "files.txt"), txt.ToString(), Str.Utf8Encoding);

            // Execution of batch file
            string old_cd = Environment.CurrentDirectory;

            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(batchFileName);
            }
            catch
            {
            }

            Win32BuildUtil.ExecCommand(Paths.CmdFileName, string.Format("/C \"{0}\"", batchFileName));

            try
            {
                Environment.CurrentDirectory = old_cd;
            }
            catch
            {
            }

            Con.WriteLine();
            Con.WriteLine("'{0}' に出力されました。", destDirName);

            return(0);
        }