2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2007-02-01 00:50:24 +03: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-02-01 00:50:24 +03: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-02-01 00:50:24 +03:00
|
|
|
|
|
|
|
#include "cmCPackCygwinSourceGenerator.h"
|
|
|
|
|
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmCPackLog.h"
|
|
|
|
|
|
|
|
#include <cmsys/SystemTools.hxx>
|
|
|
|
|
|
|
|
// Includes needed for implementation of RenameFile. This is not in
|
|
|
|
// system tools because it is not implemented robustly enough to move
|
|
|
|
// files across directories.
|
|
|
|
#ifdef _WIN32
|
|
|
|
# include <windows.h>
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
cmCPackCygwinSourceGenerator::~cmCPackCygwinSourceGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int cmCPackCygwinSourceGenerator::InitializeInternal()
|
|
|
|
{
|
|
|
|
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
|
|
|
|
return this->Superclass::InitializeInternal();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2010-08-11 21:48:39 +04:00
|
|
|
int cmCPackCygwinSourceGenerator::PackageFiles()
|
2007-02-01 00:50:24 +03:00
|
|
|
{
|
2007-02-02 22:40:26 +03:00
|
|
|
// Create a tar file of the sources
|
2007-02-01 00:50:24 +03:00
|
|
|
std::string packageDirFileName
|
|
|
|
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
2009-11-03 17:40:57 +03:00
|
|
|
packageDirFileName += ".tar.bz2";
|
2010-08-11 21:48:39 +04:00
|
|
|
packageFileNames[0] = packageDirFileName;
|
2007-02-01 00:50:24 +03:00
|
|
|
std::string output;
|
2009-11-03 17:40:57 +03:00
|
|
|
// skip one parent up to the cmCPackTarBZip2Generator
|
|
|
|
// to create tar.bz2 file with the list of source
|
|
|
|
// files
|
2010-08-25 13:04:49 +04:00
|
|
|
this->Compress = cmArchiveWrite::CompressBZip2;
|
2010-08-11 21:48:39 +04:00
|
|
|
if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
|
2007-02-01 00:50:24 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-02 22:40:26 +03:00
|
|
|
// Now create a tar file that contains the above .tar.bz2 file
|
|
|
|
// and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY
|
|
|
|
// files
|
2009-11-03 17:40:57 +03:00
|
|
|
std::string compressOutFile = packageDirFileName;
|
2012-08-13 21:42:58 +04:00
|
|
|
// at this point compressOutFile is the full path to
|
2007-02-01 00:50:24 +03:00
|
|
|
// _CPack_Package/.../package-2.5.0.tar.bz2
|
|
|
|
// we want to create a tar _CPack_Package/.../package-2.5.0-1-src.tar.bz2
|
2012-08-13 21:42:58 +04:00
|
|
|
// with these
|
|
|
|
// _CPack_Package/.../package-2.5.0-1.patch
|
2007-02-01 00:50:24 +03:00
|
|
|
// _CPack_Package/.../package-2.5.0-1.sh
|
|
|
|
// _CPack_Package/.../package-2.5.0.tar.bz2
|
|
|
|
// the -1 is CPACK_CYGWIN_PATCH_NUMBER
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2009-11-03 17:40:57 +03:00
|
|
|
// first copy the patch file and the .sh file
|
|
|
|
// to the toplevel cpack temp dir
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2007-02-02 22:40:26 +03:00
|
|
|
// copy the patch file into place
|
2009-11-03 17:40:57 +03:00
|
|
|
if(!this->GetOption("CPACK_CYGWIN_PATCH_FILE"))
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"No patch file specified for cygwin sources.");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-02 22:40:26 +03:00
|
|
|
if(!cmSystemTools::CopyFileAlways(
|
2007-02-01 00:50:24 +03:00
|
|
|
this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
|
|
|
|
this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: ["
|
|
|
|
<< this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
|
|
|
|
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2009-11-03 17:40:57 +03:00
|
|
|
if(!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"))
|
|
|
|
{
|
2012-08-13 21:42:58 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2009-11-03 17:40:57 +03:00
|
|
|
"No build script specified for cygwin sources.");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-02 22:40:26 +03:00
|
|
|
// copy the build script into place
|
|
|
|
if(!cmSystemTools::CopyFileAlways(
|
2007-02-01 00:50:24 +03:00
|
|
|
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
|
|
|
|
this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: "
|
|
|
|
<< this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
|
|
|
|
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
std::string outerTarFile
|
|
|
|
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
|
|
|
outerTarFile += "-";
|
2008-03-13 04:54:27 +03:00
|
|
|
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
|
|
|
|
if(!patch)
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
|
|
|
|
<< " not specified, defaulting to 1\n");
|
|
|
|
patch = "1";
|
|
|
|
}
|
|
|
|
outerTarFile += patch;
|
2009-11-03 17:40:57 +03:00
|
|
|
outerTarFile += "-src.tar.bz2";
|
|
|
|
std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
std::string buildScript = tmpDir;
|
|
|
|
buildScript += "/";
|
|
|
|
buildScript += cmSystemTools::GetFilenameName(
|
2007-02-01 00:50:24 +03:00
|
|
|
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
|
2009-11-03 17:40:57 +03:00
|
|
|
std::string patchFile = tmpDir;
|
|
|
|
patchFile += "/";
|
|
|
|
patchFile += cmSystemTools::GetFilenameName(
|
2007-02-01 00:50:24 +03:00
|
|
|
this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
|
2010-08-11 21:48:39 +04:00
|
|
|
|
2007-02-01 00:50:24 +03:00
|
|
|
std::string file = cmSystemTools::GetFilenameName(compressOutFile);
|
2009-11-03 17:40:57 +03:00
|
|
|
std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
|
|
|
|
sourceTar += "/";
|
|
|
|
sourceTar += file;
|
2010-08-11 21:48:39 +04:00
|
|
|
/* reset list of file to be packaged */
|
|
|
|
files.clear();
|
2007-02-01 00:50:24 +03:00
|
|
|
// a source release in cygwin should have the build script used
|
|
|
|
// to build the package, the patch file that is different from the
|
|
|
|
// regular upstream version of the sources, and a bziped tar file
|
|
|
|
// of the original sources
|
2010-08-11 21:48:39 +04:00
|
|
|
files.push_back(buildScript);
|
|
|
|
files.push_back(patchFile);
|
|
|
|
files.push_back(sourceTar);
|
|
|
|
/* update the name of the produced package */
|
|
|
|
packageFileNames[0] = outerTarFile;
|
|
|
|
/* update the toplevel dir */
|
|
|
|
toplevel = tmpDir;
|
|
|
|
if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
|
2007-02-01 00:50:24 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-31 15:50:17 +03:00
|
|
|
const char* cmCPackCygwinSourceGenerator::GetPackagingInstallPrefix()
|
2007-02-01 00:50:24 +03:00
|
|
|
{
|
|
|
|
this->InstallPrefix = "/";
|
|
|
|
this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME");
|
|
|
|
return this->InstallPrefix.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
|
|
|
|
{
|
|
|
|
this->OutputExtension = "-";
|
2012-08-13 21:42:58 +04:00
|
|
|
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
|
2008-03-13 04:54:27 +03:00
|
|
|
if(!patch)
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
|
|
|
|
<< " not specified, defaulting to 1\n");
|
|
|
|
patch = "1";
|
|
|
|
}
|
|
|
|
this->OutputExtension += patch;
|
2007-02-01 00:50:24 +03:00
|
|
|
this->OutputExtension += "-src.tar.bz2";
|
|
|
|
return this->OutputExtension.c_str();
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|