Beispiel #1
0
        public override int Run(string[] remainingArguments)
        {
            _path = remainingArguments[0];

            try
            {
                using (RpmReader reader = new RpmReader(_path))
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append($"Name: {reader.Name}\n");
                    builder.Append($"Version: {reader.Version}\n");
                    builder.Append($"Release: {reader.Release}\n");
                    builder.Append($"Architecture: {reader.Arch}\n");
                    builder.Append($"Size: {reader.Size}\n");
                    builder.Append($"License: {reader.License}\n");
                    builder.Append($"Source RPM: {reader.SourceRpm}\n");
                    builder.Append($"BuildTime: {reader.BuildTime}\n");
                    builder.Append($"BuildHost: {reader.BuildHost}\n");
                    builder.Append($"Summary: {reader.Summary}\n");
                    builder.Append($"Description: {reader.Description}\n");
                    Console.WriteLine(builder.ToString());
                }
                return 0;
            }
            catch (System.IO.FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return 1;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return 1;
            }
        }
 public override int Run(string[] remainingArguments)
 {
     try
     {
         using (RpmReader reader = new RpmReader(remainingArguments.Last()))
         {
             StringBuilder builder = new StringBuilder();
             if (_printAllScripts || (!_printPreinScript && !_printPostinScript && !_printPreunScript && !_printPostunScript))
             {
                 PrintPreinScript(builder, reader);
                 PrintPostinScript(builder, reader);
                 PrintPreunScript(builder, reader);
                 PrintPostunScript(builder, reader);
                 Console.WriteLine(builder.ToString());
                 return 0;
             }
             if (_printPreinScript)
             {
                 PrintPreinScript(builder, reader);
             }
             if (_printPostinScript)
             {
                 PrintPostinScript(builder, reader);
             }
             if (_printPreunScript)
             {
                 PrintPreunScript(builder, reader);
             }
             if (_printPostunScript)
             {
                 PrintPostunScript(builder, reader);
             }
             Console.WriteLine(builder.ToString());
             return 0;
         }
     }
     catch (System.IO.FileNotFoundException ex)
     {
         Console.WriteLine(ex.Message);
         return 1;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return 1;
     }
 }
 public override int Run(string[] remainingArguments)
 {
     try
     {
         using (RpmReader reader = new RpmReader(remainingArguments.Last()))
         {
             Console.WriteLine(reader.Changelog);
         }
         return 0;
     }
     catch (System.IO.FileNotFoundException ex)
     {
         Console.WriteLine(ex.Message);
         return 1;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return 1;
     }
 }
Beispiel #4
0
        public void ValidateFile()
        {
            using (RpmReader reader = new RpmReader("vlc.rpm"))
            {
                // проверяем общие свойства
                Assert.IsTrue(reader.IsValidate);
                Assert.AreEqual(reader.Name, "vlc");
                Assert.AreEqual(reader.Version, "3.0.0");
                Assert.AreEqual(reader.Release, "7.20160608gitbb83680.fc24");
                Assert.AreEqual(reader.Arch, "x86_64");
                Assert.AreEqual(reader.License, "GPLv2+");
                Assert.AreEqual(reader.BuildHost, "copr-builder-856817140.novalocal");
                Assert.AreEqual(reader.Summary, "The cross-platform open-source multimedia framework, player and server");
                Assert.AreEqual(reader.Vendor, "Fedora Project COPR (paulcarroty/test-3.0.2)");
                Assert.AreEqual(reader.SourceRpm, null);               
                Assert.AreEqual(reader.Description, "VLC media player is a highly portable multimedia player and multimedia framework\ncapable of reading most audio and video formats as well as DVDs, Audio CDs VCDs,\nand various streaming protocols.\nIt can also be used as a media converter or a server to stream in uni-cast or\nmulti-cast in IPv4 or IPv6 on networks.");
                uint expectedSize = 34215049;
                Assert.AreEqual(reader.Size, expectedSize);
                Assert.AreEqual(reader.BuildTime, new DateTime(2016, 06, 26, 20, 15, 29));

                Assert.IsFalse(reader.Changelog == null);

                string[] files = reader.ListFiles;
                Assert.IsTrue(files.Count() == 3, "Не совпадает количество файлов, которое находиться в архиве");
                Assert.IsTrue(files.FirstOrDefault(g => g == "vlc-3.0.0-20160608-bb83680.tar.xz") != null);
                Assert.IsTrue(files.FirstOrDefault(g => g == "vlc-snapshot.sh") != null);
                Assert.IsTrue(files.FirstOrDefault(g => g == "vlc.spec") != null);

                // check scripts(in this package they are not)
                Assert.IsTrue(reader.PreinScript == null);
                Assert.IsTrue(reader.PostinScript == null);
                Assert.IsTrue(reader.PostunScript == null);
                Assert.IsTrue(reader.PreunScript == null);

                         
            }
        }
 public override int Run(string[] remainingArguments)
 {
     try
     {
         using (RpmReader reader = new RpmReader(remainingArguments.Last()))
         {
  
             StringBuilder builder = new StringBuilder("Filelist: \n");
             builder.Append(reader.ListFiles.Select(g => g + "\n"));
             Console.WriteLine(builder.ToString());
         }
         return 0;
     }
     catch (System.IO.FileNotFoundException ex)
     {
         Console.WriteLine(ex.Message);
         return 1;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return 1;
     }
 }
 private void PrintPostunScript(StringBuilder builder, RpmReader reader)
 {
     builder.Append("The Postuninstall scripts content:\n");
     builder.Append(reader.PostunScript + "\n");
     PrintSeparator(builder);
 }