X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=Source%2FCPack%2FcmCPackPackageMakerGenerator.cxx;h=c617a3e32d4f247c97b93dabdbb4d5d5d1bc91be;hb=297c63fa65327491a2b50e521b661c5835a19fe4;hp=edbe8380d6d86d9166c0f2a301525d8f7b29c26b;hpb=ef8aa19c33e83ff019595fd7f8fdc29c35c336a3;p=platform%2Fupstream%2Fcmake.git 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 << "" << std::endl; + } choiceOut << "" << 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