diff options
author | David Cole <david.cole@kitware.com> | 2012-10-31 20:35:05 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-10-31 20:35:05 (GMT) |
commit | e2006ce5a9a0e8d914cd2930618d587b5bf1a30b (patch) | |
tree | 12f358eb9f6e41b088b4a81192cf233dbce06aea /Source | |
parent | e7af22f6c3f7441dd528c1b0e89c3aee041e07c4 (diff) | |
parent | 4374441f3fa162931d7d59d2e18a7e0bd14de505 (diff) | |
download | CMake-e2006ce5a9a0e8d914cd2930618d587b5bf1a30b.zip CMake-e2006ce5a9a0e8d914cd2930618d587b5bf1a30b.tar.gz CMake-e2006ce5a9a0e8d914cd2930618d587b5bf1a30b.tar.bz2 |
Merge topic 'packagemaker-component-postflight'
4374441 PackageMaker: Enable postflight script in component mode (#12375)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/cmCPackComponentGroup.h | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.cxx | 126 | ||||
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.h | 3 |
3 files changed, 97 insertions, 36 deletions
diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index 48d935c..abae372 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -42,7 +42,9 @@ public: class cmCPackComponent { public: - cmCPackComponent() : Group(0), TotalSize(0) { } + cmCPackComponent() : Group(0), IsRequired(true), IsHidden(false), + IsDisabledByDefault(false), IsDownloaded(false), + TotalSize(0) { } /// The name of the component (used to reference the component). std::string Name; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index edbe838..c617a3e 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -106,56 +106,101 @@ int cmCPackPackageMakerGenerator::PackageFiles() resDir += "/en.lproj"; } - - // Create directory structure - std::string preflightDirName = resDir + "/PreFlight"; - std::string postflightDirName = resDir + "/PostFlight"; const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT"); const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT"); const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT"); - // if preflight or postflight scripts not there create directories - // of the same name, I think this makes it work - if(!preflight) + + if(this->Components.empty()) { - if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) + // Create directory structure + std::string preflightDirName = resDir + "/PreFlight"; + std::string postflightDirName = resDir + "/PostFlight"; + // if preflight or postflight scripts not there create directories + // of the same name, I think this makes it work + if(!preflight) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem creating installer directory: " - << preflightDirName.c_str() << std::endl); - return 0; + if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating installer directory: " + << preflightDirName.c_str() << std::endl); + return 0; + } + } + if(!postflight) + { + if ( !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating installer directory: " + << postflightDirName.c_str() << std::endl); + return 0; + } + } + // if preflight, postflight, or postupgrade are set + // then copy them into the resource directory and make + // them executable + if(preflight) + { + this->CopyInstallScript(resDir.c_str(), + preflight, + "preflight"); + } + if(postflight) + { + this->CopyInstallScript(resDir.c_str(), + postflight, + "postflight"); + } + if(postupgrade) + { + this->CopyInstallScript(resDir.c_str(), + postupgrade, + "postupgrade"); } } - if(!postflight) + else if(postflight) { - if ( !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) + // create a postflight component to house the script + this->PostFlightComponent.Name = "PostFlight"; + this->PostFlightComponent.DisplayName = "PostFlight"; + this->PostFlightComponent.Description = "PostFlight"; + this->PostFlightComponent.IsHidden = true; + + // empty directory for pkg contents + std::string packageDir = toplevel + "/" + PostFlightComponent.Name; + if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem creating installer directory: " - << postflightDirName.c_str() << std::endl); + "Problem creating component packages directory: " + << packageDir.c_str() << std::endl); return 0; } - } - // if preflight, postflight, or postupgrade are set - // then copy them into the resource directory and make - // them executable - if(preflight) - { - this->CopyInstallScript(resDir.c_str(), - preflight, - "preflight"); - } - if(postflight) - { - this->CopyInstallScript(resDir.c_str(), + + // create package + std::string packageFileDir = packageDirFileName + "/Contents/Packages/"; + if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating component PostFlight Packages directory: " + << packageFileDir.c_str() << std::endl); + return 0; + } + std::string packageFile = packageFileDir + + this->GetPackageName(PostFlightComponent); + if (!this->GenerateComponentPackage(packageFile.c_str(), + packageDir.c_str(), + PostFlightComponent)) + { + return 0; + } + + // copy postflight script into resource directory of .pkg + std::string resourceDir = packageFile + "/Contents/Resources"; + this->CopyInstallScript(resourceDir.c_str(), postflight, "postflight"); } - if(postupgrade) - { - this->CopyInstallScript(resDir.c_str(), - postupgrade, - "postupgrade"); - } if (!this->Components.empty()) { @@ -778,6 +823,11 @@ WriteDistributionFile(const char* metapackageFile) << std::endl; } } + if(!this->PostFlightComponent.Name.empty()) + { + choiceOut << "<line choice=\"" << PostFlightComponent.Name + << "Choice\"></line>" << std::endl; + } choiceOut << "</choices-outline>" << std::endl; // Create the actual choices @@ -792,6 +842,12 @@ WriteDistributionFile(const char* metapackageFile) { CreateChoice(compIt->second, choiceOut); } + + if(!this->PostFlightComponent.Name.empty()) + { + CreateChoice(PostFlightComponent, choiceOut); + } + this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str()); // Create the distribution.dist file in the metapackage to turn it diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 101813f..ba3d968 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -112,6 +112,9 @@ protected: // value. std::string EscapeForXML(std::string str); + // The PostFlight component when creating a metapackage + cmCPackComponent PostFlightComponent; + double PackageMakerVersion; double PackageCompatibilityVersion; }; |