Example #1
0
        private void ExecuteUninstallation(string packagePath, IPackageInfo packageInfo, PackageFileList fileList)
        {
            PackageLoader loader = new PackageLoader();

            loader.LoadPackage(packagePath);
            loader.Package.Initialize(this);
            PackageUninstaller uninstaller = new PackageUninstaller(packageInfo, fileList);

            // Start installing the package
            loader.Package.Uninstall(uninstaller);
            // Uninstallation complete! Add this package to the installed packages list
            int removalCount = MarkPackageUninstalled(uninstaller.Package.FullID);

            if (removalCount > 0)
            {
                SaveInstalledPackageList();
            }
            loader.Unload();
        }
Example #2
0
        private void InstallDownloadedPackage(IUpdateCheckResult result, int currentPackage, string packagePath)
        {
            string tempFolder = packagePath + ".extracted/";
            if (Directory.Exists(tempFolder)) {
                Directory.Delete(tempFolder, true);
            }
            using (ZipFile zip = new ZipFile(packagePath)) {
                foreach (ZipEntry entry in zip) {
                    if (!entry.FileName.Contains("/")) {
                        entry.Extract(tempFolder, ExtractExistingFileAction.OverwriteSilently);
                    }
                }
            }
            string uninstallPackagePath = this.packageListDirectory + "UpdaterCache/" + result.PackagesToUpdate[currentPackage].FullID + ".udruninsta_";
            if (System.IO.File.Exists(uninstallPackagePath)) {
                // An uninstall package exists!
                // Try to uninstall it
                UninstallPackage(result.PackagesToUpdate[currentPackage], uninstallPackagePath);
            }
            PackageLoader loader = new PackageLoader();
            loader.LoadPackage(tempFolder + result.PackagesToUpdate[currentPackage].FullID + ".dll");
            loader.Package.Initialize(this);
            PackageInstaller installer = new PackageInstaller(packagePath, tempFolder, this.packageListDirectory, result.PackagesToUpdate[currentPackage], loader);
            // Start installing the package
            loader.Package.Install(installer);
            // Installation complete! Add this package to the installed packages list
            MarkPackageInstalled(installer.Package.FullID, installer.Package.Version);
            SaveInstalledPackageList();
            // Close all resources used by the package installer
            installer.Close();
            loader.Unload();

            if (Directory.Exists(System.IO.Path.GetDirectoryName(uninstallPackagePath)) == false) {
                Directory.CreateDirectory(Path.GetDirectoryName(uninstallPackagePath));
            }
            using (ZipFile zip = new ZipFile()) {
                zip.AddFile(tempFolder + "FileList.xml", "\\");
                zip.AddFile(tempFolder + result.PackagesToUpdate[currentPackage].FullID + ".dll", "\\");
                zip.AddFile(tempFolder + "Updater.Linker.dll", "\\");

                zip.Save(uninstallPackagePath);
            }

            // Delete the temporary files
            if (Directory.Exists(tempFolder)) {
                Directory.Delete(tempFolder, true);
            }
            if (File.Exists(packagePath)) {
                File.Delete(packagePath);
            }
            OnPackageInstallationComplete(result, currentPackage);
        }
Example #3
0
        private void InstallDownloadedPackage(IUpdateCheckResult result, int currentPackage, string packagePath)
        {
            string tempFolder = packagePath + ".extracted/";

            if (Directory.Exists(tempFolder))
            {
                Directory.Delete(tempFolder, true);
            }
            using (ZipFile zip = new ZipFile(packagePath)) {
                foreach (ZipEntry entry in zip)
                {
                    if (!entry.FileName.Contains("/"))
                    {
                        entry.Extract(tempFolder, ExtractExistingFileAction.OverwriteSilently);
                    }
                }
            }
            string uninstallPackagePath = this.packageListDirectory + "UpdaterCache/" + result.PackagesToUpdate[currentPackage].FullID + ".udruninsta_";

            if (System.IO.File.Exists(uninstallPackagePath))
            {
                // An uninstall package exists!
                // Try to uninstall it
                UninstallPackage(result.PackagesToUpdate[currentPackage], uninstallPackagePath);
            }
            PackageLoader loader = new PackageLoader();

            loader.LoadPackage(tempFolder + result.PackagesToUpdate[currentPackage].FullID + ".dll");
            loader.Package.Initialize(this);
            PackageInstaller installer = new PackageInstaller(packagePath, tempFolder, this.packageListDirectory, result.PackagesToUpdate[currentPackage], loader);

            // Start installing the package
            loader.Package.Install(installer);
            // Installation complete! Add this package to the installed packages list
            MarkPackageInstalled(installer.Package.FullID, installer.Package.Version);
            SaveInstalledPackageList();
            // Close all resources used by the package installer
            installer.Close();
            loader.Unload();

            if (Directory.Exists(System.IO.Path.GetDirectoryName(uninstallPackagePath)) == false)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(uninstallPackagePath));
            }
            using (ZipFile zip = new ZipFile()) {
                zip.AddFile(tempFolder + "FileList.xml", "\\");
                zip.AddFile(tempFolder + result.PackagesToUpdate[currentPackage].FullID + ".dll", "\\");
                zip.AddFile(tempFolder + "Updater.Linker.dll", "\\");

                zip.Save(uninstallPackagePath);
            }

            // Delete the temporary files
            if (Directory.Exists(tempFolder))
            {
                Directory.Delete(tempFolder, true);
            }
            if (File.Exists(packagePath))
            {
                File.Delete(packagePath);
            }
            OnPackageInstallationComplete(result, currentPackage);
        }
Example #4
0
 private void ExecuteUninstallation(string packagePath, IPackageInfo packageInfo, PackageFileList fileList)
 {
     PackageLoader loader = new PackageLoader();
     loader.LoadPackage(packagePath);
     loader.Package.Initialize(this);
     PackageUninstaller uninstaller = new PackageUninstaller(packageInfo, fileList);
     // Start installing the package
     loader.Package.Uninstall(uninstaller);
     // Uninstallation complete! Add this package to the installed packages list
     int removalCount = MarkPackageUninstalled(uninstaller.Package.FullID);
     if (removalCount > 0) {
         SaveInstalledPackageList();
     }
     loader.Unload();
 }