2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2007-08-08 19:33:42 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2007-08-08 19:33:42 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2007-08-08 19:33:42 +04:00
|
|
|
#include "cmCPackRPMGenerator.h"
|
|
|
|
#include "cmCPackLog.h"
|
2010-08-23 18:14:40 +04:00
|
|
|
#include "cmSystemTools.h"
|
2007-08-08 19:33:42 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
cmCPackRPMGenerator::cmCPackRPMGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
cmCPackRPMGenerator::~cmCPackRPMGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-31 15:50:17 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int cmCPackRPMGenerator::InitializeInternal()
|
|
|
|
{
|
|
|
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
2010-08-23 18:14:40 +04:00
|
|
|
if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
|
|
|
|
{
|
|
|
|
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
|
|
|
|
}
|
2007-10-31 15:50:17 +03:00
|
|
|
return this->Superclass::InitializeInternal();
|
|
|
|
}
|
|
|
|
|
2007-08-08 19:33:42 +04:00
|
|
|
//----------------------------------------------------------------------
|
2010-08-11 21:48:39 +04:00
|
|
|
int cmCPackRPMGenerator::PackageFiles()
|
2007-08-08 19:33:42 +04:00
|
|
|
{
|
2010-11-13 19:56:36 +03:00
|
|
|
int retval = 1;
|
|
|
|
/* Digest Component grouping specification */
|
|
|
|
retval = PrepareGroupingKind();
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
|
|
|
|
<< toplevel << std::endl);
|
|
|
|
|
|
|
|
/* Are we in the component packaging case */
|
2010-11-15 22:54:19 +03:00
|
|
|
if (SupportsComponentInstallation() & (!this->ComponentGroups.empty()))
|
2010-11-13 19:56:36 +03:00
|
|
|
{
|
|
|
|
/* Reset package file name list it will be populated during the
|
|
|
|
* component packaging run*/
|
|
|
|
packageFileNames.clear();
|
|
|
|
std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
|
|
|
|
/* One Package per component CASE */
|
|
|
|
/* Iterate over components */
|
|
|
|
std::map<std::string, cmCPackComponent>::iterator compIt;
|
|
|
|
for (compIt=this->Components.begin();
|
|
|
|
compIt!=this->Components.end(); ++compIt )
|
|
|
|
{
|
|
|
|
std::string localToplevel(initialTopLevel);
|
2010-11-15 22:54:19 +03:00
|
|
|
std::string packageFileName(
|
|
|
|
cmSystemTools::GetParentDirectory(toplevel.c_str())
|
|
|
|
);
|
|
|
|
std::string outputFileName(
|
|
|
|
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")
|
|
|
|
)
|
2010-11-13 19:56:36 +03:00
|
|
|
+"-"+compIt->first + this->GetOutputExtension());
|
|
|
|
|
|
|
|
localToplevel += "/"+ compIt->first;
|
|
|
|
/* replace the TEMP DIRECTORY with the component one */
|
|
|
|
this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
|
|
|
|
packageFileName += "/"+ outputFileName;
|
|
|
|
/* replace proposed CPACK_OUTPUT_FILE_NAME */
|
|
|
|
this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
|
|
|
|
/* replace the TEMPORARY package file name */
|
2010-11-15 22:54:19 +03:00
|
|
|
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
|
|
|
|
packageFileName.c_str());
|
2010-11-13 19:56:36 +03:00
|
|
|
|
|
|
|
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compIt->first.c_str());
|
|
|
|
if (!this->ReadListFile("CPackRPM.cmake"))
|
|
|
|
{
|
2010-11-15 22:54:19 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"Error while execution CPackRPM.cmake" << std::endl);
|
2010-11-13 19:56:36 +03:00
|
|
|
retval = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the generated package to package file names list
|
|
|
|
packageFileNames.push_back(packageFileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* This is the non component case */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!this->ReadListFile("CPackRPM.cmake"))
|
|
|
|
{
|
2010-11-15 22:54:19 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"Error while execution CPackRPM.cmake" << std::endl);
|
2010-11-13 19:56:36 +03:00
|
|
|
retval = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-08 19:33:42 +04:00
|
|
|
if (!this->IsSet("RPMBUILD_EXECUTABLE"))
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find rpmbuild" << std::endl);
|
2010-11-13 19:56:36 +03:00
|
|
|
retval = 0;
|
2007-08-08 19:33:42 +04:00
|
|
|
}
|
2010-11-13 19:56:36 +03:00
|
|
|
return retval;
|
2007-08-08 19:33:42 +04:00
|
|
|
}
|
|
|
|
|
2010-11-15 22:54:19 +03:00
|
|
|
bool cmCPackRPMGenerator::SupportsComponentInstallation() const
|
|
|
|
{
|
|
|
|
if (IsSet("CPACK_RPM_COMPONENT_INSTALL"))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2007-08-08 23:44:02 +04:00
|
|
|
|