public override bool Execute()
        {
            this.Log.LogMessage(
                MessageImportance.High,
                "Creating DEB package '{0}' from folder '{1}'",
                this.DebPath,
                this.PublishDir);

            using (var targetStream = File.Open(this.DebPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                using (var tarStream = File.Open(this.DebTarPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    ArchiveBuilder archiveBuilder = new ArchiveBuilder()
                    {
                        Log = this.Log,
                    };

                    var archiveEntries = archiveBuilder.FromDirectory(
                        this.PublishDir,
                        this.AppHost,
                        this.Prefix,
                        this.Content);

                    archiveEntries.AddRange(archiveBuilder.FromLinuxFolders(this.LinuxFolders));
                    EnsureDirectories(archiveEntries);

                    archiveEntries = archiveEntries
                                     .OrderBy(e => e.TargetPathWithFinalSlash, StringComparer.Ordinal)
                                     .ToList();

                    TarFileCreator.FromArchiveEntries(archiveEntries, tarStream);
                    tarStream.Position = 0;

                    // Prepare the list of dependencies
                    List <string> dependencies = new List <string>();

                    if (this.DebDependencies != null)
                    {
                        var debDependencies = this.DebDependencies.Select(d => d.ItemSpec).ToArray();

                        dependencies.AddRange(debDependencies);
                    }

                    if (this.DebDotNetDependencies != null)
                    {
                        var debDotNetDependencies = this.DebDotNetDependencies.Select(d => d.ItemSpec).ToArray();

                        dependencies.AddRange(debDotNetDependencies);
                    }

                    // Prepare the list of recommended dependencies
                    List <string> recommends = new List <string>();

                    if (this.DebRecommends != null)
                    {
                        recommends.AddRange(this.DebRecommends.Select(d => d.ItemSpec));
                    }

                    // XZOutputStream class has low quality (doesn't even know it's current position,
                    // needs to be disposed to finish compression, etc),
                    // So we are doing compression in a separate step
                    using (var tarXzStream = File.Open(this.DebTarXzPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                        using (var xzStream = new XZOutputStream(tarXzStream))
                        {
                            tarStream.CopyTo(xzStream);
                        }

                    using (var tarXzStream = File.Open(this.DebTarXzPath, FileMode.Open, FileAccess.Read, FileShare.None))
                    {
                        var pkg = DebPackageCreator.BuildDebPackage(
                            archiveEntries,
                            this.PackageName,
                            this.Description,
                            this.Maintainer,
                            this.Version,
                            !string.IsNullOrWhiteSpace(this.DebPackageArchitecture) ? this.DebPackageArchitecture : GetPackageArchitecture(this.RuntimeIdentifier),
                            this.CreateUser,
                            this.UserName,
                            this.InstallService,
                            this.ServiceName,
                            this.Prefix,
                            this.Section,
                            this.Priority,
                            this.Homepage,
                            this.PreInstallScript,
                            this.PostInstallScript,
                            this.PreRemoveScript,
                            this.PostRemoveScript,
                            dependencies,
                            recommends,
                            null);

                        DebPackageCreator.WriteDebPackage(
                            archiveEntries,
                            tarXzStream,
                            targetStream,
                            pkg);
                    }

                    this.Log.LogMessage(
                        MessageImportance.High,
                        "Created DEB package '{0}' from folder '{1}'",
                        this.DebPath,
                        this.PublishDir);

                    return(true);
                }
        }
Esempio n. 2
0
        public override bool Execute()
        {
            this.Log.LogMessage(MessageImportance.Normal, "Creating RPM package '{0}' from folder '{1}'", this.RpmPath, this.PublishDir);

            var krgen         = PgpSigner.GenerateKeyRingGenerator("dotnet", "dotnet");
            var secretKeyRing = krgen.GenerateSecretKeyRing();
            var privateKey    = secretKeyRing.GetSecretKey().ExtractPrivateKey("dotnet".ToCharArray());
            var publicKey     = secretKeyRing.GetPublicKey();

            using (var targetStream = File.Open(this.RpmPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                using (var cpioStream = File.Open(this.CpioPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    ArchiveBuilder archiveBuilder = new ArchiveBuilder()
                    {
                        Log = this.Log,
                    };

                    var archiveEntries = archiveBuilder.FromDirectory(
                        this.PublishDir,
                        this.AppHost,
                        this.Prefix,
                        this.Content);

                    archiveEntries.AddRange(archiveBuilder.FromLinuxFolders(this.LinuxFolders));

                    archiveEntries = archiveEntries
                                     .OrderBy(e => e.TargetPathWithFinalSlash, StringComparer.Ordinal)
                                     .ToList();

                    CpioFileCreator cpioCreator = new CpioFileCreator();
                    cpioCreator.FromArchiveEntries(
                        archiveEntries,
                        cpioStream);
                    cpioStream.Position = 0;

                    // Prepare the list of dependencies
                    List <PackageDependency> dependencies = new List <PackageDependency>();

                    if (this.RpmDotNetDependencies != null)
                    {
                        dependencies.AddRange(
                            this.RpmDotNetDependencies.Select(
                                d => GetPackageDependency(d)));
                    }

                    if (this.RpmDependencies != null)
                    {
                        dependencies.AddRange(
                            this.RpmDependencies.Select(
                                d => GetPackageDependency(d)));
                    }

                    RpmPackageCreator rpmCreator = new RpmPackageCreator();
                    rpmCreator.CreatePackage(
                        archiveEntries,
                        cpioStream,
                        this.PackageName,
                        this.Version,
                        !string.IsNullOrEmpty(this.RpmPackageArchitecture) ? this.RpmPackageArchitecture : GetPackageArchitecture(this.RuntimeIdentifier),
                        this.Release,
                        this.CreateUser,
                        this.UserName,
                        this.InstallService,
                        this.ServiceName,
                        this.Vendor,
                        this.Description,
                        this.Url,
                        this.Prefix,
                        this.PreInstallScript,
                        this.PostInstallScript,
                        this.PreRemoveScript,
                        this.PostRemoveScript,
                        dependencies,
                        null,
                        privateKey,
                        targetStream);
                }

            this.Log.LogMessage(MessageImportance.Normal, "Created RPM package '{0}' from folder '{1}'", this.RpmPath, this.PublishDir);
            return(true);
        }
        public override bool Execute()
        {
            this.Log.LogMessage(MessageImportance.Normal, "Creating RPM package '{0}' from folder '{1}'", this.RpmPath, this.PublishDir);

            var krgen         = PgpSigner.GenerateKeyRingGenerator("dotnet", "dotnet");
            var secretKeyRing = krgen.GenerateSecretKeyRing();
            var privateKey    = secretKeyRing.GetSecretKey().ExtractPrivateKey("dotnet".ToCharArray());
            var publicKey     = secretKeyRing.GetPublicKey();

            using (var targetStream = File.Open(this.RpmPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                using (var cpioStream = File.Open(this.CpioPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    ArchiveBuilder archiveBuilder = new ArchiveBuilder();
                    var            archiveEntries = archiveBuilder.FromDirectory(
                        this.PublishDir,
                        this.Prefix,
                        this.Content);

                    archiveEntries.AddRange(archiveBuilder.FromLinuxFolders(this.LinuxFolders));
                    archiveEntries = archiveEntries
                                     .OrderBy(e => e.TargetPathWithFinalSlash, StringComparer.Ordinal)
                                     .ToList();

                    CpioFileCreator cpioCreator = new CpioFileCreator();
                    cpioCreator.FromArchiveEntries(
                        archiveEntries,
                        cpioStream);
                    cpioStream.Position = 0;

                    // Prepare the list of dependencies
                    PackageDependency[] dependencies = Array.Empty <PackageDependency>();

                    if (this.RpmDependencies != null)
                    {
                        dependencies = this.RpmDependencies.Select(
                            d => new PackageDependency(
                                d.ItemSpec,
                                RpmSense.RPMSENSE_EQUAL | RpmSense.RPMSENSE_GREATER,
                                d.GetVersion()))
                                       .ToArray();
                    }

                    RpmPackageCreator rpmCreator = new RpmPackageCreator();
                    rpmCreator.CreatePackage(
                        archiveEntries,
                        cpioStream,
                        this.PackageName,
                        this.Version,
                        "x86_64",
                        this.Release,
                        this.CreateUser,
                        this.UserName,
                        this.InstallService,
                        this.ServiceName,
                        this.Prefix,
                        dependencies,
                        null,
                        privateKey,
                        targetStream);
                }

            this.Log.LogMessage(MessageImportance.Normal, "Created RPM package '{0}' from folder '{1}'", this.RpmPath, this.PublishDir);
            return(true);
        }
Esempio n. 4
0
        public override bool Execute()
        {
            this.Log.LogMessage(
                MessageImportance.High,
                "Creating DEB package '{0}' from folder '{1}'",
                this.DebPath,
                this.PublishDir);

            using (var targetStream = File.Open(this.DebPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                using (var tarStream = File.Open(this.DebTarPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    ArchiveBuilder archiveBuilder = new ArchiveBuilder();
                    var            archiveEntries = archiveBuilder.FromDirectory(
                        this.PublishDir,
                        this.Prefix,
                        this.Content);

                    archiveEntries.AddRange(archiveBuilder.FromLinuxFolders(this.LinuxFolders));
                    this.EnsureDirectories(archiveEntries);

                    archiveEntries = archiveEntries
                                     .OrderBy(e => e.TargetPathWithFinalSlash, StringComparer.Ordinal)
                                     .ToList();

                    TarFileCreator.FromArchiveEntries(archiveEntries, tarStream);
                    tarStream.Position = 0;

                    // Prepare the list of dependencies
                    PackageDependency[] dependencies = Array.Empty <PackageDependency>();

                    if (this.DebDependencies != null)
                    {
                        dependencies = this.DebDependencies.Select(
                            d => new PackageDependency
                        {
                            Name    = d.ItemSpec,
                            Version = d.GetVersion()
                        }).ToArray();
                    }

                    // XZOutputStream class has low quality (doesn't even know it's current position,
                    // needs to be disposed to finish compression, etc),
                    // So we are doing compression in a separate step
                    using (var tarXzStream = File.Open(this.DebTarXzPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                        using (var xzStream = new XZOutputStream(tarXzStream))
                        {
                            tarStream.CopyTo(xzStream);
                        }

                    using (var tarXzStream = File.Open(this.DebTarXzPath, FileMode.Open, FileAccess.Read, FileShare.None))
                    {
                        DebPackageCreator.BuildDebPackage(
                            archiveEntries,
                            tarXzStream,
                            this.PackageName,
                            this.Description,
                            this.Maintainer,
                            this.Version,
                            "amd64",
                            this.CreateUser,
                            this.UserName,
                            this.InstallService,
                            this.ServiceName,
                            this.Prefix,
                            dependencies,
                            null,
                            targetStream);
                    }

                    this.Log.LogMessage(
                        MessageImportance.High,
                        "Created DEB package '{0}' from folder '{1}'",
                        this.DebPath,
                        this.PublishDir);

                    return(true);
                }
        }