Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Logger.Log("Package Manager Start");

            PackageData packageData = new PackageData();

            packageData.InputInstallFormsFolder     = CreateFolder(CurrentFolder + Path.DirectorySeparatorChar, "install-forms");
            packageData.InputInstallFirmwareFolder  = CreateFolder(CurrentFolder + Path.DirectorySeparatorChar, "install-firmware");
            packageData.InputRollbackFormsFolder    = CreateFolder(CurrentFolder + Path.DirectorySeparatorChar, "rollback-forms");
            packageData.InputRollbackFirmwareFolder = CreateFolder(CurrentFolder + Path.DirectorySeparatorChar, "rollback-firmware");

            if (args.Length != 1)
            {
                ShowUsage();
                CreateSampleInputFile();
                FatalError("This program requires a json file passed as it's only argument. An example input file has been provided in the " +
                           "same directory from whence you ran the executable. Please try again");
            }

            string inputFile            = args[0];
            bool   inputFileIsValid     = ValidateInputFile(inputFile, ".json");
            bool   inputFoldersAreValid = ValidateInputFolders(packageData);

            if (!inputFileIsValid || !inputFoldersAreValid)
            {
                ShowUsage();
                CreateSampleInputFile();
                FatalError("The input file or input folders were not in a valid state. An example input file has been provided in the" +
                           "same directory from whence you ran the executable. Please try again.");
            }

            ReadInputFileData(inputFile, packageData);
            SetPackageContentBooleans(packageData);
            CreatePackageFolders(packageData);

            FileBuilder fileBuilder = new FileBuilder(packageData);

            BuildPackageFiles(fileBuilder, packageData);

            if (packageData.HasRollback)
            {
                HandleRollbackItems(packageData, fileBuilder);
            }

            ManifestPackage(packageData);
            CleanExecutableDirectory(packageData);

            Logger.Log("Package Manager End");
            Logger.Dispose();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Build all of the various files associated with a package.
        /// </summary>
        /// <param name="fileBuilder"> The file builder object, which contains methods for building each file type. </param>
        /// <param name="packageData"> The data object for the package </param>
        private static void BuildPackageFiles(FileBuilder fileBuilder, PackageData packageData)
        {
            string rootReadMe    = CreateFile(packageData.RootPackageFolder, "readme.md");
            string changeLogFile = CreateFile(packageData.RootPackageFolder, "changelog.txt");
            string verifyReadMe  = CreateFile(packageData.VerifyFolder, "readme.md");
            string touchScript   = CreateFile(packageData.ScriptsFolder, "touch.cmd");
            string installReadMe = CreateFile(packageData.InstallFolder, "readme.md");
            string installScript = CreateFile(packageData.InstallFolder, "install.cmd");

            fileBuilder.BuildRootReadMe(rootReadMe);
            fileBuilder.BuildChangeLog(changeLogFile);
            fileBuilder.BuildVerifyReadMe(verifyReadMe);
            fileBuilder.BuildTouchScript(touchScript);
            fileBuilder.BuildInstallReadMe(installReadMe);
            fileBuilder.BuildInstallScript(installScript);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles all items related to a rollback, if the package has one.
        /// </summary>
        /// <param name="packageData"> The data object for the package </param>
        /// <param name="fileBuilder"> The file building object, containing methods to build each file type for the package </param>
        private static void HandleRollbackItems(PackageData packageData, FileBuilder fileBuilder)
        {
            packageData.RollbackFolder = CreateFolder(packageData.RootPackageFolder, "rollback");
            string rollbackReadMe = CreateFile(packageData.RollbackFolder, "readme.md");
            string rollbackScript = CreateFile(packageData.RollbackFolder, "rollback.cmd");

            if (packageData.HasFormsRollback)
            {
                packageData.RollbackForms            = GetFolderFiles(packageData.InputRollbackFormsFolder);
                packageData.FinalRollbackFormsFolder = packageData.RollbackFolder + "\\Forms";
                Directory.Move(packageData.InputRollbackFormsFolder, packageData.FinalRollbackFormsFolder);
            }

            if (packageData.HasFirmwareRollback)
            {
                packageData.RollbackFirmware            = GetFolderFiles(packageData.InputRollbackFirmwareFolder);
                packageData.FinalRollbackFirmwareFolder = packageData.RollbackFolder + "\\Firmware";
                Directory.Move(packageData.InputRollbackFirmwareFolder, packageData.FinalRollbackFirmwareFolder);
            }

            fileBuilder.BuildRollbackReadMe(rollbackReadMe);
            fileBuilder.BuildRollbackScript(rollbackScript);
        }