Exemplo n.º 1
0
        private static void generateManifests(Metabank mb, bool silent)
        {
            mb.fsAccess("amm.GenerateManifest()", Metabank.BIN_CATALOG,
                        (session, dir) =>
            {
                foreach (var sdn in dir.SubDirectoryNames)
                {
                    using (var sdir = dir.GetSubDirectory(sdn))
                    {
                        var computed        = ManifestUtils.GeneratePackagingManifest(sdir);
                        var computedContent = computed.Configuration.ToLaconicString();

                        if (!silent)
                        {
                            ConsoleUtils.WriteMarkupContent(
                                "<push><f color=gray>Pckg: <f color=white>{0,-42}<f color=gray>  Mnfst.Sz: <f color=yellow>{1}<pop>\n".Args("'{0}'".Args(sdn), computedContent.Length));
                        }

                        using (var file = sdir.CreateFile(ManifestUtils.MANIFEST_FILE_NAME))
                        {
                            file.WriteAllText(computedContent);
                        }
                    }
                }

                return(true);
            }
                        );
        }
Exemplo n.º 2
0
        public void DeepCopy_1()
        {
            var p1 = ManifestUtilsTests.Get_TEZT_PATH();
            var p2 = p1 + "_2";

            IOMiscUtils.EnsureDirectoryDeleted(p2);
            Directory.CreateDirectory(p2);

            using (var fs = new LocalFileSystem("L1"))
            {
                using (var session = fs.StartSession())
                {
                    var fromDir   = session[p1] as FileSystemDirectory;
                    var manifest1 = ManifestUtils.GeneratePackagingManifest(fromDir);

                    var toDir = session[p2] as FileSystemDirectory;

                    fromDir.DeepCopyTo(toDir, FileSystemDirectory.DirCopyFlags.Directories | FileSystemDirectory.DirCopyFlags.Files);
                    var manifest2 = ManifestUtils.GeneratePackagingManifest(toDir);


                    Console.WriteLine(manifest1.Configuration.ContentView);

                    Assert.IsTrue(ManifestUtils.HasTheSameContent(manifest1, manifest2));
                }
            }
        }
Exemplo n.º 3
0
        public void Install_1()
        {
            var source = ManifestUtilsTests.Get_TEZT_PATH();
            var target = source + "_INSTALLED";

            using (var fs = new LocalFileSystem("L1"))
            {
                var session   = fs.StartSession();
                var sourceDir = session[source] as FileSystemDirectory;

                var manifest = ManifestUtils.GeneratePackagingManifest(sourceDir, packageName: "Package1");
                var fn       = Path.Combine(source, ManifestUtils.MANIFEST_FILE_NAME);
                try
                {
                    manifest.Configuration.ToLaconicFile(fn);


                    var set = new List <LocalInstallation.PackageInfo>
                    {
                        new LocalInstallation.PackageInfo("Package1", sourceDir, null)//no relative path
                    };


                    using (var install = new LocalInstallation(target))
                    {
                        Console.WriteLine("Installed anew: " + install.CheckLocalAndInstallIfNeeded(set));
                    }
                }
                finally
                {
                    IOMiscUtils.EnsureFileEventuallyDeleted(fn);
                }
            }
        }
Exemplo n.º 4
0
                                  public override void Validate(ValidationContext ctx)
                                  {
                                      var output = ctx.Output;

                                      try
                                      {
                                          var packages = Packages;
                                      }
                                      catch (Exception error)
                                      {
                                          output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, error.ToMessageWithType(), error));
                                          return;
                                      }

                                      try
                                      {
                                          Metabank.fsAccess("BinCatalog.Validate", BIN_CATALOG,
                                                            (session, dir) =>
                    {
                        foreach (var sdn in dir.SubDirectoryNames)
                        {
                            using (var sdir = dir.GetSubDirectory(sdn))
                                using (var mf = sdir.GetFile(ManifestUtils.MANIFEST_FILE_NAME))
                                {
                                    if (mf == null)
                                    {
                                        output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null,
                                                                             StringConsts.METABASE_BIN_PACKAGE_MISSING_MANIFEST_ERROR
                                                                             .Args(sdn, ManifestUtils.MANIFEST_FILE_NAME), null)
                                                   );
                                        continue;
                                    }

                                    var manifest = LaconicConfiguration.CreateFromString(mf.ReadAllText()).Root;
                                    var computed = ManifestUtils.GeneratePackagingManifest(sdir);

                                    if (!ManifestUtils.HasTheSameContent(manifest, computed, oneWay: false))
                                    {
                                        output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null,
                                                                             StringConsts.METABASE_BIN_PACKAGE_OUTDATED_MANIFEST_ERROR
                                                                             .Args(sdn, ManifestUtils.MANIFEST_FILE_NAME), null)
                                                   );
                                    }
                                }
                        }

                        return(true);
                    }
                                                            );
                                      }
                                      catch (Exception error)
                                      {
                                          output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, error.ToMessageWithType(), error));
                                          return;
                                      }
                                  }
Exemplo n.º 5
0
        public void Compare_2()
        {
            using (var fs = new LocalFileSystem("L1"))
            {
                var session   = fs.StartSession();
                var dir       = session[Get_TEZT_PATH()] as FileSystemDirectory;
                var manifest1 = ManifestUtils.GeneratePackagingManifest(dir);
                var manifest2 = NFX.Environment.LaconicConfiguration.CreateFromString(EXPECTED).Root;

                Assert.IsTrue(manifest1.HasTheSameContent(manifest2));
            }
        }
Exemplo n.º 6
0
        public void Compare_1()
        {
            using (var fs = new LocalFileSystem("L1"))
            {
                var session   = fs.StartSession();
                var dir       = session[Get_TEZT_PATH()] as FileSystemDirectory;
                var manifest1 = ManifestUtils.GeneratePackagingManifest(dir);
                var manifest2 = ManifestUtils.GeneratePackagingManifest(dir);

                Assert.IsTrue(manifest1.HasTheSameContent(manifest2));
            }
        }
Exemplo n.º 7
0
        public void Compare_2()
        {
            using (var fs = new LocalFileSystem(NOPApplication.Instance))
            {
                var session   = fs.StartSession();
                var dir       = session[Get_TEZT_PATH()] as FileSystemDirectory;
                var manifest1 = ManifestUtils.GeneratePackagingManifest(dir);
                var manifest2 = Azos.Conf.LaconicConfiguration.CreateFromString(EXPECTED).Root;

                Aver.IsTrue(manifest1.HasTheSameContent(manifest2));
            }
        }
Exemplo n.º 8
0
        public void Compare_3()
        {
            using (var fs = new LocalFileSystem("L1"))
            {
                var session   = fs.StartSession();
                var dir       = session[Get_TEZT_PATH()] as FileSystemDirectory;
                var manifest1 = ManifestUtils.GeneratePackagingManifest(dir);
                var manifest2 = ManifestUtils.GeneratePackagingManifest(dir);

                manifest2[0].Children.First(c => c.IsSameNameAttr("Some Text File With Spaces.txt")).AttrByName(ManifestUtils.CONFIG_SIZE_ATTR).Value = "123";

                Assert.IsFalse(manifest1.HasTheSameContent(manifest2));
            }
        }
Exemplo n.º 9
0
        public void Compare_4()
        {
            using (var fs = new LocalFileSystem(NOPApplication.Instance))
            {
                var session   = fs.StartSession();
                var dir       = session[Get_TEZT_PATH()] as FileSystemDirectory;
                var manifest1 = ManifestUtils.GeneratePackagingManifest(dir);
                var manifest2 = ManifestUtils.GeneratePackagingManifest(dir);

                manifest2[2].Delete();

                Aver.IsFalse(manifest1.HasTheSameContent(manifest2));
            }
        }
Exemplo n.º 10
0
        public void Generate_1()
        {
            using (var fs = new LocalFileSystem("L1"))
            {
                var session  = fs.StartSession();
                var dir      = session[Get_TEZT_PATH()] as FileSystemDirectory;
                var manifest = ManifestUtils.GeneratePackagingManifest(dir);

                Console.WriteLine(manifest.Configuration.ContentView);

                Assert.AreEqual("SubDir1", manifest[0].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value);
                Assert.AreEqual("SubDir2", manifest[1].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value);
                Assert.AreEqual("Gagarin.txt", manifest[2].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value);
                Assert.AreEqual("TextFile1.txt", manifest[3].AttrByName(ManifestUtils.CONFIG_NAME_ATTR).Value);

                Assert.AreEqual(500066, manifest[0].Children.First(c => c.IsSameNameAttr("Bitmap1.bmp")).AttrByName(ManifestUtils.CONFIG_SIZE_ATTR).ValueAsInt());
                Assert.AreEqual(1248671023, manifest[0].Children.First(c => c.IsSameNameAttr("Bitmap1.bmp")).AttrByName(ManifestUtils.CONFIG_CSUM_ATTR).ValueAsInt());

                Assert.AreEqual(105, manifest[0].Children.First(c => c.IsSameNameAttr("Some Text File With Spaces.txt")).AttrByName(ManifestUtils.CONFIG_SIZE_ATTR).ValueAsInt());
                Assert.AreEqual(1399856254, manifest[0].Children.First(c => c.IsSameNameAttr("Some Text File With Spaces.txt")).AttrByName(ManifestUtils.CONFIG_CSUM_ATTR).ValueAsInt());
            }
        }