예제 #1
0
        public static void HandlerItem(bool dev, PublishDirInfo item)
        {
            var rpmPath = GetPackPath(dev, item, FileEx.RPM);

            //var cpioPath = GetPackPath(item, FileEx.CPIO);

            using var targetStream = File.Open(rpmPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
            //using var cpioStream = File.Open(cpioPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
            using var cpioStream = new MemoryStream();

            ArchiveBuilder2 archiveBuilder2 = new()
            {
                Log = TaskLoggingHelper.Instance,
            };
            ArchiveBuilder archiveBuilder = archiveBuilder2;

            var archiveEntries = archiveBuilder.FromDirectory(
                item.Path,
                Constants.HARDCODED_APP_NAME,
                LinuxPackConstants.Prefix,
                Array.Empty <ITaskItem>());

            LinuxPackConstants.AddFileNameDesktop(archiveBuilder2, archiveEntries);

            //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 (item.DeploymentMode == DeploymentMode.FDE)
            {
                dependencies.Add(new PackageDependency {
                    Name = LinuxPackConstants.aspnetcore_runtime_6_0
                });
            }

            //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,
                LinuxPackConstants.PackageName,
                Utils.GetVersion(dev),
                RpmTask.GetPackageArchitecture(item.Name),
                LinuxPackConstants.Release,
                LinuxPackConstants.CreateUser,
                LinuxPackConstants.UserName,
                LinuxPackConstants.InstallService,
                LinuxPackConstants.ServiceName,
                LinuxPackConstants.RpmVendor,
                LinuxPackConstants.Description,
                LinuxPackConstants.Url,
                LinuxPackConstants.Prefix,
                LinuxPackConstants.PreInstallScript,
                LinuxPackConstants.PostInstallScript,
                LinuxPackConstants.PreRemoveScript,
                LinuxPackConstants.PostRemoveScript,
                dependencies,
                null !,
                privateKey !,
                targetStream);
        }
        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);
        }
예제 #3
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);
        }