mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 04:13:34 +00:00
Publish ISOs via FTP
svn path=/trunk/; revision=19523
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="publishPath" value="c:\iso" />
|
||||
<add key="publishPath" value="c:\iso" /> <!-- c:\iso or ftp://ftp.server.com/iso -->
|
||||
<add key="smtpServer" value="localhost" />
|
||||
<add key="errorEmail" value="mailbox@somewhere-on-the-net" />
|
||||
<add key="makeParameters" value="" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,17 @@ namespace ReactOS.CustomRevisionAction
|
||||
/// </summary>
|
||||
private static string publishPath;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to publish ISOs to a remote destination via FTP.
|
||||
/// </summary>
|
||||
private static bool PublishToRemoteFtpLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return publishPath.StartsWith("ftp://");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the application.
|
||||
/// </summary>
|
||||
@@ -138,6 +149,82 @@ namespace ReactOS.CustomRevisionAction
|
||||
revision);
|
||||
}
|
||||
|
||||
private static void SplitRemotePublishPath(string publishPath,
|
||||
out string server,
|
||||
out string directory)
|
||||
{
|
||||
string searchString = "://";
|
||||
int index = publishPath.IndexOf(searchString);
|
||||
if (index == -1)
|
||||
throw new InvalidOperationException();
|
||||
int endOfProtocolIndex = index + searchString.Length;
|
||||
string withoutProtocol = publishPath.Remove(0, endOfProtocolIndex);
|
||||
index = withoutProtocol.IndexOf("/");
|
||||
if (index == -1)
|
||||
{
|
||||
server = withoutProtocol;
|
||||
directory = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
server = withoutProtocol.Substring(0, index);
|
||||
directory = withoutProtocol.Remove(0, index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy ISO to the (remote) destination.
|
||||
/// </summary>
|
||||
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
|
||||
/// <param name="branch">Branch.</param>
|
||||
/// <param name="revision">Revision.</param>
|
||||
/// <remarks>
|
||||
/// Structure is ftp://ftp.server.com/whereever/<branch>/ReactOS-<branch>-r<revision>.iso.
|
||||
/// </remarks>
|
||||
private static void CopyISOToRemoteFtpDestination(string sourceFilename,
|
||||
string branch,
|
||||
int revision)
|
||||
{
|
||||
string server;
|
||||
string directory;
|
||||
SplitRemotePublishPath(publishPath, out server, out directory);
|
||||
FtpClient ftpClient = new FtpClient(server, "anonymous", "[email protected]");
|
||||
ftpClient.Login();
|
||||
if (directory != "")
|
||||
ftpClient.ChangeDir(directory);
|
||||
/* Create destination directory if it does not already exist */
|
||||
if (ftpClient.GetFileList(branch).Length < 1)
|
||||
ftpClient.MakeDir(branch);
|
||||
ftpClient.ChangeDir(branch);
|
||||
ftpClient.Upload(sourceFilename);
|
||||
ftpClient.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy ISO to the (local) destination.
|
||||
/// </summary>
|
||||
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
|
||||
/// <param name="branch">Branch.</param>
|
||||
/// <param name="revision">Revision.</param>
|
||||
/// <remarks>
|
||||
/// Structure is <branch>\ReactOS-<branch>-r<revision>.iso.
|
||||
/// </remarks>
|
||||
private static void CopyISOToLocalDestination(string sourceFilename,
|
||||
string branch,
|
||||
int revision)
|
||||
{
|
||||
string distributionFilename = GetDistributionFilename(branch,
|
||||
revision);
|
||||
string destinationDirectory = Path.Combine(publishPath,
|
||||
branch);
|
||||
string destinationFilename = Path.Combine(destinationDirectory,
|
||||
distributionFilename);
|
||||
if (!Directory.Exists(destinationDirectory))
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
File.Copy(sourceFilename,
|
||||
destinationFilename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy ISO to the destination.
|
||||
/// </summary>
|
||||
@@ -151,16 +238,10 @@ namespace ReactOS.CustomRevisionAction
|
||||
string branch,
|
||||
int revision)
|
||||
{
|
||||
string distributionFilename = GetDistributionFilename(branch,
|
||||
revision);
|
||||
string destinationDirectory = Path.Combine(publishPath,
|
||||
branch);
|
||||
string destinationFilename = Path.Combine(destinationDirectory,
|
||||
distributionFilename);
|
||||
if (!Directory.Exists(destinationDirectory))
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
File.Copy(sourceFilename,
|
||||
destinationFilename);
|
||||
if (PublishToRemoteFtpLocation)
|
||||
CopyISOToRemoteFtpDestination(sourceFilename, branch, revision);
|
||||
else
|
||||
CopyISOToLocalDestination(sourceFilename, branch, revision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user