Exemple #1
0
        void Extract(PathToPackage pathToPackage, string targetPath, IPackageExtractor customPackageExtractor)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(pathToPackage))
                {
                    log.Verbose("No package path defined. Skipping package extraction.");
                    return;
                }

                log.Verbose("Extracting package to: " + targetPath);

                var extractorToUse = customPackageExtractor ?? combinedPackageExtractor;
                var filesExtracted = extractorToUse.Extract(pathToPackage, targetPath);

                log.Verbose("Extracted " + filesExtracted + " files");

                variables.Set(KnownVariables.OriginalPackageDirectoryPath, targetPath);
                log.SetOutputVariable(PackageVariables.Output.InstallationDirectoryPath, targetPath, variables);
                log.SetOutputVariable(PackageVariables.Output.DeprecatedInstallationDirectoryPath, targetPath, variables);
                log.SetOutputVariable(PackageVariables.Output.ExtractedFileCount, filesExtracted.ToString(), variables);
            }
            catch (UnauthorizedAccessException)
            {
                LogAccessDenied();
                throw;
            }
            catch (Exception ex) when(ex.Message.ContainsIgnoreCase("Access is denied"))
            {
                LogAccessDenied();
                throw;
            }
        }
Exemple #2
0
        public void ExtractToApplicationDirectory(PathToPackage pathToPackage, IPackageExtractor customPackageExtractor = null)
        {
            var metadata   = PackageName.FromFile(pathToPackage);
            var targetPath = ApplicationDirectory.GetApplicationDirectory(metadata, variables, fileSystem);

            Extract(pathToPackage, targetPath, customPackageExtractor);
        }
Exemple #3
0
 public StageScriptPackagesConvention(string packagePathContainingScript, ICalamariFileSystem fileSystem, IPackageExtractor extractor, bool forceExtract = false)
 {
     this.packagePathContainingScript = packagePathContainingScript;
     this.fileSystem   = fileSystem;
     this.extractor    = extractor;
     this.forceExtract = forceExtract;
 }
        /// <summary>
        /// Initializes an instance of <see cref="UpdateManager"/>.
        /// </summary>
        public UpdateManager(AssemblyMetadata updatee, IPackageResolver resolver, IPackageExtractor extractor)
        {
#if NETSTANDARD2_0
            // Ensure that this is only used on Windows
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                throw new PlatformNotSupportedException("Onova only supports Windows.");
            }
#endif

            _updatee   = updatee.GuardNotNull(nameof(updatee));
            _resolver  = resolver.GuardNotNull(nameof(resolver));
            _extractor = extractor.GuardNotNull(nameof(extractor));

            // Set storage directory path
            _storageDirPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "Onova", _updatee.Name);

            // Set updater executable file path
            _updaterFilePath = Path.Combine(_storageDirPath, $"{_updatee.Name}.Updater.exe");

            // Set lock file path
            _lockFilePath = Path.Combine(_storageDirPath, "Onova.lock");
        }
Exemple #5
0
        public void ExtractToStagingDirectory(PathToPackage pathToPackage, IPackageExtractor customPackageExtractor = null)
        {
            var targetPath = Path.Combine(Environment.CurrentDirectory, "staging");

            fileSystem.EnsureDirectoryExists(targetPath);
            Extract(pathToPackage, targetPath, customPackageExtractor);
        }
 public ExtractPackageToStagingDirectoryConvention(
     IPackageExtractor extractor,
     ICalamariFileSystem fileSystem,
     String subDirectory = "staging")
     : base(extractor, fileSystem)
 {
     SubDirectory = subDirectory;
 }
        public void SetUp()
        {
            extractor = Substitute.For <IPackageExtractor>();

            fileSystem = Substitute.For <ICalamariFileSystem>();
            fileSystem.RemoveInvalidFileNameChars(Arg.Any <string>()).Returns(c => c.Arg <string>().Replace("!", ""));

            variables  = new CalamariVariableDictionary();
            convention = new ExtractPackageToApplicationDirectoryConvention(extractor, fileSystem);
        }
 public RePackArchiveConvention(
     ICalamariFileSystem fileSystem,
     ICommandOutput commandOutput,
     IPackageExtractor packageExtractor,
     ICommandLineRunner commandLineRunner)
 {
     this.fileSystem       = fileSystem;
     this.packageExtractor = packageExtractor;
     this.jarTool          = new JarTool(commandLineRunner, commandOutput, fileSystem);
 }
        public void SetUp()
        {
            extractor = Substitute.For<IPackageExtractor>();
            extractor.GetMetadata(PackageLocation).Returns(new PackageMetadata { Id = "Acme.Web", Version = "1.0.0" });

            fileSystem = Substitute.For<ICalamariFileSystem>();
            fileSystem.RemoveInvalidFileNameChars(Arg.Any<string>()).Returns(c => c.Arg<string>().Replace("!", ""));

            variables = new CalamariVariableDictionary();
            convention = new ExtractPackageToApplicationDirectoryConvention(extractor, fileSystem, new SystemSemaphore());
        }
Exemple #10
0
        /// <summary>
        /// Initializes an instance of <see cref="UpdateManager"/>.
        /// </summary>
        public UpdateManager(AssemblyMetadata updatee, IPackageResolver resolver, IPackageExtractor extractor)
        {
            _updatee   = updatee.GuardNotNull(nameof(updatee));
            _resolver  = resolver.GuardNotNull(nameof(resolver));
            _extractor = extractor.GuardNotNull(nameof(extractor));

            _storageDirPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "Onova",
                _updatee.Name);
        }
        public void SetUp()
        {
            extractor = Substitute.For <IPackageExtractor>();
            extractor.GetMetadata(PackageLocation).Returns(new PackageMetadata {
                Id = "Acme.Web", Version = "1.0.0"
            });

            fileSystem = Substitute.For <ICalamariFileSystem>();
            fileSystem.RemoveInvalidFileNameChars(Arg.Any <string>()).Returns(c => c.Arg <string>().Replace("!", ""));

            variables  = new CalamariVariableDictionary();
            convention = new ExtractPackageToApplicationDirectoryConvention(extractor, fileSystem, new SystemSemaphore());
        }
Exemple #12
0
        public void SetUp()
        {
            extractor = Substitute.For <IPackageExtractor>();
            extractor.GetMetadata("C:\\Package.nupkg").Returns(new PackageMetadata {
                Id = "Acme.Web", Version = "1.0.0"
            });

            fileSystem = Substitute.For <ICalamariFileSystem>();
            fileSystem.RemoveInvalidFileNameChars(Arg.Any <string>()).Returns(c => new CalamariPhysicalFileSystem().RemoveInvalidFileNameChars(c.Arg <string>()));

            variables = new VariableDictionary();
            variables.Set("env:SystemDrive", "C:");

            convention = new ExtractPackageToApplicationDirectoryConvention(extractor, fileSystem, new SystemSemaphore());
        }
Exemple #13
0
        /// <summary>
        /// Initializes an instance of <see cref="UpdateManager"/>.
        /// </summary>
        public UpdateManager(AssemblyMetadata updatee, IPackageResolver resolver, IPackageExtractor extractor)
        {
            _updatee   = updatee.GuardNotNull(nameof(updatee));
            _resolver  = resolver.GuardNotNull(nameof(resolver));
            _extractor = extractor.GuardNotNull(nameof(extractor));

            // Set storage directory path
            _storageDirPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "Onova", _updatee.Name);

            // Set updater executable file path
            _updaterFilePath = Path.Combine(_storageDirPath, $"{_updatee.Name}.Updater.dll");

            _runtimeconfigFilePath = Path.Combine(_storageDirPath, $"{_updatee.Name}.Updater.runtimeconfig.json");

            // Set lock file path
            _lockFilePath = Path.Combine(_storageDirPath, "Onova.lock");
        }
Exemple #14
0
        /// <summary>
        /// Initializes an instance of <see cref="UpdateManager"/>.
        /// </summary>
        public UpdateManager(AssemblyMetadata updatee, IPackageResolver resolver, IPackageExtractor extractor)
        {
            Platform.EnsureWindows();

            Updatee    = updatee;
            _resolver  = resolver;
            _extractor = extractor;

            // Set storage directory path
            _storageDirPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "Onova", updatee.Name);

            // Set updater executable file path
            _updaterFilePath = Path.Combine(_storageDirPath, $"{updatee.Name}.Updater.exe");

            // Set lock file path
            _lockFilePath = Path.Combine(_storageDirPath, "Onova.lock");
        }
Exemple #15
0
 public PackageStore(IPackageExtractor packageExtractorFactory)
 {
     this.packageExtractorFactory = packageExtractorFactory;
 }
Exemple #16
0
 /// <summary>
 /// Initializes an instance of <see cref="UpdateManager"/> on the entry assembly.
 /// </summary>
 public UpdateManager(IPackageResolver resolver, IPackageExtractor extractor)
     : this(new AssemblyMetadata(Assembly.GetEntryAssembly()), resolver, extractor)
 {
 }
Exemple #17
0
 protected ExtractPackageConvention(IPackageExtractor extractor, ICalamariFileSystem fileSystem)
 {
     this.extractor  = extractor;
     this.fileSystem = fileSystem;
 }
 public ExtractPackageToApplicationDirectoryConvention(IPackageExtractor extractor, ICalamariFileSystem fileSystem, ISemaphore semaphore) : base(extractor, fileSystem)
 {
     this.semaphore = semaphore;
 }
Exemple #19
0
        protected internal virtual void TransformInternal(bool cleanup, string destination, IEnumerable <string> fileToTransformPatterns, IPackageExtractor packageExtractor, IPackageWriter packageWriter, IEnumerable <string> pathToDeletePatterns, string source, IEnumerable <string> transformationNames)
        {
            if (packageExtractor == null)
            {
                throw new ArgumentNullException(nameof(packageExtractor));
            }

            if (packageWriter == null)
            {
                throw new ArgumentNullException(nameof(packageWriter));
            }

            var temporaryDirectoryPath = this.FileSystem.Path.Combine(this.FileSystem.Path.GetTempPath(), Guid.NewGuid().ToString());

            try
            {
                var temporaryOriginalDirectoryPath = this.FileSystem.Path.Combine(temporaryDirectoryPath, "Original");

                packageExtractor.Extract(temporaryOriginalDirectoryPath, source);

                var temporaryTransformDirectoryPath = this.FileSystem.Path.Combine(temporaryDirectoryPath, "Transform");

                this.FileSystem.CopyDirectory(temporaryTransformDirectoryPath, temporaryOriginalDirectoryPath);

                this.Transform(temporaryTransformDirectoryPath, fileToTransformPatterns, transformationNames);

                this.DeleteItems(temporaryTransformDirectoryPath, pathToDeletePatterns);

                packageWriter.Write(destination, temporaryTransformDirectoryPath);
            }
            finally
            {
                if (cleanup && this.FileSystem.Directory.Exists(temporaryDirectoryPath))
                {
                    this.FileSystem.Directory.Delete(temporaryDirectoryPath, true);
                }
            }
        }
Exemple #20
0
 /// <summary>
 /// A proxy package extractor what wraps an external extractor.
 /// </summary>
 public ProxyPackageExtractor(IPackageExtractor extractor) => Extractor = extractor;
 public ExtractPackageToStagingDirectoryConvention(IPackageExtractor extractor, ICalamariFileSystem fileSystem) 
     : base(extractor, fileSystem)
 {
 }
 public ExtractPackageToApplicationDirectoryConvention(IPackageExtractor extractor, ICalamariFileSystem fileSystem, ISemaphore semaphore)
 {
     this.extractor  = extractor;
     this.fileSystem = fileSystem;
     this.semaphore  = semaphore;
 }
 /// <summary>
 /// Initializes an instance of <see cref="UpdateManager"/> on the entry assembly.
 /// </summary>
 public UpdateManager(IPackageResolver resolver, IPackageExtractor extractor)
     : this(AssemblyMetadata.FromEntryAssembly(), resolver, extractor)
 {
 }
 public ExtractPackageToApplicationDirectoryConvention(IPackageExtractor extractor, ICalamariFileSystem fileSystem)
     : base(extractor, fileSystem)
 {
 }
Exemple #25
0
 public ExtractPackageToApplicationDirectoryConvention(IPackageExtractor extractor, ICalamariFileSystem fileSystem, ISemaphore semaphore) : base(extractor, fileSystem)
 {
     this.semaphore = semaphore;
 }