Пример #1
0
        public override void Start(HttpListenerContext context)
        {
            XmlDocument options = context.GetRequestDataAsXml();

            string pkgxml = options.DocumentElement["executable"].InnerText;

            PackageProperties properties = PackageProperties.Deserialize(Path.Combine(RemotePath, pkgxml));

            if (properties.AutoGenerateRelease)
            {
                properties.Release = DateTime.Now.ToString("yyyyMMdd.HHmmss");
            }

            PackageBuilder builder = new PackageBuilder(properties);

            builder.Root = RemotePath;

            bool result = builder.Build();

            if (result)
            {
                // Build was successful
                string rpm = String.Format("{0}-{1}-{2}.noarch.rpm", properties.ShortName, properties.Version, properties.Release);
                rpm_file = String.Format("{0}/{1}", RemotePath, rpm);

                // See if we are supposed to leave a copy on the server
                if (properties.LeavePackageOnServer)
                {
                    try {
                        if (!Directory.Exists(properties.ServerLocation))
                        {
                            Directory.CreateDirectory(properties.ServerLocation);
                        }

                        File.Copy(rpm_file, Path.Combine(properties.ServerLocation, rpm), true);
                    } catch (Exception ex) {
                        copy_exception = ex;
                    }
                }
            }
            else
            {
                build_exception = new Exception(builder.Errors[0].ErrorText);
            }

            HasTerminated = true;
            context.WriteString(ToXml());
        }