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 */
|
|
|
|
if (!this->ComponentGroups.empty())
|
|
|
|
{
|
|
|
|
/* 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);
|
|
|
|
std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel.c_str()));
|
|
|
|
std::string outputFileName(std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
|
|
|
|
+"-"+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 */
|
|
|
|
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",packageFileName.c_str());
|
|
|
|
|
|
|
|
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compIt->first.c_str());
|
|
|
|
if (!this->ReadListFile("CPackRPM.cmake"))
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake" << std::endl);
|
|
|
|
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"))
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake" << std::endl);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-08-08 23:44:02 +04:00
|
|
|
|